Update to 5.5.2 and PHP 8.1

I am hosting InvoiceNinja on Siteground and I got into trouble after update to 5.5.2 and php 8.1 (from 7.4). I changed PHP to 8.1 and inside Health Check I see two PHP versions: web 8.1 and cli 7.4. If I try to upgrade, I get two errors:

FormatException: SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data

and later

500: <br /> <b>Fatal error</b>: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0". You are running 7.4.30. in <b>/home/customer/www/X/public_html/vendor/composer/platform_check.php</b> on line <b>24</b><br />

I found somewhere that this can be solved editing .htaccess but I can’t find what to change. Can someone help where to go from here?

Hi,

I believe you need to upgrade the PHP CLI version to 8.1

Sure, that’s obvious, but how?

It would depend on your server, I suggest reaching out to your webhost to ask.

1 Like

So, I talked to SIteground support and they used

which php81
alias php81='/usr/local/php81/bin/php-cli'

After that php -v showed php 8.1 version, but System Chek in IN was still reporting that cli php version is 7.4.30.
After that they cleared all levels of server-side cache and now I am stuck at login screen with 500: Server Error

In logs I have this error:

[2022-07-29 09:47:47] production.ERROR: Declaration of Egulias\EmailValidator\Validation\MessageIDValidation::isValid(string $email, Egulias\EmailValidator\EmailLexer $emailLexer): bool must be compatible with Egulias\EmailValidator\Validation\EmailValidation::isValid($email, Egulias\EmailValidator\EmailLexer $emailLexer) {"userId":1,"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Declaration of Egulias\\EmailValidator\\Validation\\MessageIDValidation::isValid(string $email, Egulias\\EmailValidator\\EmailLexer $emailLexer): bool must be compatible with Egulias\\EmailValidator\\Validation\\EmailValidation::isValid($email, Egulias\\EmailValidator\\EmailLexer $emailLexer) at /home/customer/www/X/public_html/vendor/egulias/email-validator/src/Validation/MessageIDValidation.php:23)
[stacktrace]
#0 {main}
"}

@david any thoughts?

If it helps: I also restored yesterday’s version from backup, but it doesn’t solve this 500: Server error

It may help to run php artisan clear-compiled

Already tried, no change.

Now I did two new test installations in subfolder and:

  • 5.5.3 returned error when I tried to run setup
    Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0". You are running 7.4.30. in /home/customer/www/X/public_html/test1/vendor/composer/platform_check.php on line 24
    It looks like InvoiceNinja still sees php 7.4.

  • 5.4.12 opened setup page but just returns 500: Server error
    Screenshot-2022-07-29-at-14-23-31-Server-Error — ImgBB

What do you see if you run php -v

PHP 8.1.8 (cli) (built: Jul 6 2022 11:02:41) (ZTS)
Copyright (c) The PHP Group
Zend Engine v4.1.8-dev, Copyright (c) Zend Technologies
with Zend OPcache v8.1.8, Copyright (c), by Zend Technologies

Ok, I think we’ll need to wait for @david

I reversed php settings back to 7.4 and I can login now, but only on another computer, on first one I am still getting 500 error, even if I completely clear cache.

I also find out that fresh instalation (IN 5.4) works if I add /public/setup instead of just /setup.

Question is still, how to do an upgrade to 5.5. Unfortunatelly I am on shared hosting so I am a bit limited on what I can do. It seems like composer only sees original php version and what was tried so far doesn’t change that.

In the browser try running /update?secret=secret

Hey!
I did exactly the same as @provy, as I’m also on a shared hosting:

$ php='/usr/bin/php81'
$ php -v
PHP 8.1.5 (cli) (built: Apr 15 2022 08:28:55) (NTS)
$ php artisan clear-compiled
Compiled services and packages files removed!

but running /update?secret=secret still returns an error 500.
Were you able to fix it, @provy?

@lucaw

after running /update are there any errors in the logs for hints?

Thanks, @david.

My shared hoster is asking for more details on how InvoiceNinja is using CLI. I can manually choose the CLI PHP version by executing php81 [command], but not set PHP 8.1 as standard, as this would affect all their other customers too. Can you give us some more hints on that? I assume that many IN users are on a shared hosting.

There are errors in laravel.log, but not after running /update:

[2022-08-10 12:02:30] production.ERROR: Facade does not implement getFacadeAccessor method. {"exception":"[object] (RuntimeException(code: 0): Facade does not implement getFacadeAccessor method. at /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:178)
[stacktrace]
#0 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(166): Illuminate\\Support\\Facades\\Facade::getFacadeAccessor()
#1 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(255): Illuminate\\Support\\Facades\\Facade::getFacadeRoot()
#2 /home/sites/4a/0/02ec6ee49d/public_html/in5test/config/app.php(218): Illuminate\\Support\\Facades\\Facade::__callStatic('defaultAliases', Array)
#3 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php(72): require('/home/sites/4a/...')
#4 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php(39): Illuminate\\Foundation\\Bootstrap\\LoadConfiguration->loadConfigurationFiles(Object(Illuminate\\Foundation\\Application), Object(Illuminate\\Config\\Repository))
#5 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(237): Illuminate\\Foundation\\Bootstrap\\LoadConfiguration->bootstrap(Object(Illuminate\\Foundation\\Application))
#6 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(310): Illuminate\\Foundation\\Application->bootstrapWith(Array)
#7 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigCacheCommand.php(88): Illuminate\\Foundation\\Console\\Kernel->bootstrap()
#8 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigCacheCommand.php(58): Illuminate\\Foundation\\Console\\ConfigCacheCommand->getFreshConfiguration()
#9 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\\Foundation\\Console\\ConfigCacheCommand->handle()
#10 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#11 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure))
#12 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#13 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Container/Container.php(653): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#14 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\\Container\\Container->call(Array)
#15 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/symfony/console/Command/Command.php(298): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArrayInput), Object(Illuminate\\Console\\OutputStyle))
#16 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArrayInput), Object(Illuminate\\Console\\OutputStyle))
#17 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php(68): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArrayInput), Object(Illuminate\\Console\\OutputStyle))
#18 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php(28): Illuminate\\Console\\Command->runCommand('config:cache', Array, Object(Illuminate\\Console\\OutputStyle))
#19 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Foundation/Console/OptimizeCommand.php(30): Illuminate\\Console\\Command->call('config:cache')
#20 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\\Foundation\\Console\\OptimizeCommand->handle()
#21 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#22 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure))
#23 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#24 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Container/Container.php(653): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#25 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\\Container\\Container->call(Array)
#26 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/symfony/console/Command/Command.php(298): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#27 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#28 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/symfony/console/Application.php(1024): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#29 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/symfony/console/Application.php(299): Symfony\\Component\\Console\\Application->doRunCommand(Object(Illuminate\\Foundation\\Console\\OptimizeCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#30 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/symfony/console/Application.php(171): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#31 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Console/Application.php(94): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#32 /home/sites/4a/0/02ec6ee49d/public_html/in5test/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#33 /home/sites/4a/0/02ec6ee49d/public_html/in5test/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#34 {main}
"}

@lucaw

We don’t actually use the CLI at all except in one place where we report the version of the CLI the system sees. In shared hosting this may well give a false positive.

As long as your cron executes the correct version of PHP (in this case 8.1 for v5.5) then you can ignore what is being reported in the health check.

The error above does looks strange. In this particular case, i would suggest downloading the latest release and overwriting your existing files and then try to load again.

No, I am still having problems, but I don’t have much time lately. Hopefully I’ll try again tomorrow.

I tried /update link, but nothing changed (I didn’t check logs) and the weird part is, that IN is working fine on home computer (meaning I can login and use it) but not on computer on which I first tried to do update, this is where I get error 500 when trying to login. Tried on three browsers (FF, Chrome, Edge).
This goes only for logging in, so far I haven’t tried to update again, because I still see php-cli version 7.4, even if I use alias command and point it to 8.1.