Upgrade cakephp 3.10 to cakephp 4 throws Hash::insert() error

Following all the migration steps from the CakePHP manual, I end up with a error 500 on all pages. The log tells me this:

> [Wed Jul 19 11:56:02.566953 2023] [proxy_fcgi:error] [pid 12776]
> [client] AH01071: Got error 'PHP message: PHP
> Fatal error:  Uncaught TypeError: Argument 2 passed to
> Cake\\Utility\\Hash::insert() must be of the type string, int given,
> called in
> /var/www/clients/client0/web4/web/ID/vendor/cakephp/cakephp/src/Core/Configure.php
> on line 92 and defined in
> /var/www/clients/client0/web4/web/ID/vendor/cakephp/cakephp/src/Utility/Hash.php:316\nStack
> trace:\n#0
> /var/www/clients/client0/web4/web/ID/vendor/cakephp/cakephp/src/Core/Configure.php(92):
> Cake\\Utility\\Hash::insert()\n#1
> /var/www/clients/client0/web4/web/ID/vendor/cakephp/cakephp/src/Core/Configure.php(339):
> Cake\\Core\\Configure::write()\n#2
> /var/www/clients/client0/web4/web/ID/config/bootstrap.php(74):
> Cake\\Core\\Configure::load()\n#3
> /var/www/clients/client0/web4/web/ID/vendor/cakephp/cakephp/src/Http/BaseApplication.php(161):
> require_once('/var/www/client...')\n#4
> /var/www/clients/client0/web4/web/ID/src/Application.php(41):
> Cake\\Http\\BaseApplication->bootstrap()\n#5
> /var/www/clients/client0/web4/web/ID/vendor/cakephp/cakephp/src/Http/Server.php(10...'

Since I don’t know - or cannot see - where the hash is called in Application.php or bootstrap.php, I’m not sure how to debug this.

You have something in your config/bootstrap.php Line 74 which seems to not be valid.

I would recommend you look at https://github.com/cakephp/app/blob/4.0.4/config/bootstrap.php and compare it to yours to be up2date.

If you are not on CakePHP 4.0 but maybe another minor version please change the tag version to use the correct version you need.

Thank you for your answer.
That’s what I thought in the first place. But it is the loading of the app.php file

try {
    Configure::config('default', new PhpConfig());
    Configure::load('app', 'default', false); // line 74
} catch (\Exception $e) {
    exit($e->getMessage() . "\n");
if (file_exists(CONFIG . 'app_local.php')) {
    Configure::load('app_local', 'default');

I looked into that and the only hashing value there is the salt-value (and that one a string)


the error was caused by some defines for external API’s, I don’t understand why they are used by the hash utility. (below are not the real tokens)

    define('WS_GRAPH_VERSION', "v15.0"),
    define('WS_PHONE_NUMBER_ID', "44444444444"),
    define('WS_ACCESS_TOKEN', "sngsnfgndgndstrjklu7sp"),
    define('OAI_TOKEN', "454k-545yeunntytyjtyjtyjtjueneuetueutuetySh"),
    define('CLAR_TOKEN01', "45565u6et5Y3"),
    define('CLAR_TOKEN02', "u4zru4ntru4r6+"),

Then your config/app.php contains code which uses those constants.