EDIT: The below only worked for one upgrade now regardless, I am experiencing this error with the self updater.
I’m aware that Invoice Ninja hasn’t officially been updated for PHP8.1 but I just wanted to report that if PHP8.1 is set as the default for CLI (which will happen if PHP8.1 gets installed on a server) then the built in updater will fail with FormatException: SyntaxError: Unexpected end of JSON Input.
This probably makes sense since there would be syntax changes in PHP8.1 compared to previous versions but the reason for this error could be confusing if someone encounters it.
To resolve this and get the built in updater working again, I simply changed the PHP CLI version back to 7.4 by using sudo update-alternatives --set php /usr/bin/php7.4
PHP 8.0 would probably also work.
After setting this, the built in InvoiceNinja updater is working correctly for now.
Personally I think a message should be thrown to the user if InvoiceNinja detects PHP8.1 being used for InvoiceNinja at this stage as I’ve experienced multiple incompatibilities with it and InvoiceNinja. Is there an ETA for PHP8.1 support?
We can tighten the system requirement for the PHP version in the composer.json file. I haven’t looked into the exact issue with 8.1 yet. Most likely we’ll look into this with when we upgrade to Laravel 9 LTS.
I’m getting this error trying to go from .83 to .84 now, despite what I reported above…I’ll manually update and see if the improvements on the self updater help for any updates after that.
I get this error regardless of the PHP version now actually. Trying to update 5.3.84 to 5.3.85 and the self updater just gives me this syntax error. Permissions are all correct. @david any ideas?
No difference in result even when clearing out the bootstrap cache folder.
Trying to update 5.3.84 to 5.3.85. As nickkilla said in the other thread on this forum, the last few updates I’ve had to do by uploading the zip manually. It was a few versions back that the self updater appeared to break due to this error and all my usual troubleshooting hasn’t gotten it working.
For those with this issue, I found that it was due to PHP’s memory limit being set to low. In my case, it was set to 128M while the invoiceninja self updater wants to use more than 128M for updating. This was causing the script to reach the limit and halt.
I found this by checking my apache error logs located at “/var/log/virtualmin/mydomain.com_error_log”
and saw the line “Got error 'PHP message: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes)”.
To solve this issue, increase the PHP memory limit to something greater. I changed mine to 512M.
I’m using php7.4 with invoiceninja, so the below steps should be adjusted for whichever version you are using:
Edit /etc/php/7.4/fpm/php.ini and change the line “memory_limit” to 512M instead of 128M or whatever it currently is. I use nano to edit it so it was nano /etc/php/7.4/fpm/php.ini. Save that file.
Run sudo systemctl restart php7.4-fpm.service.
Try the self updater again. Worked for me, no more issues with the built in updater.
So It seems I had that already changed. I went ahead and increased max timeout also. The update occurred but still got the error at the end and checking the logs I see
For version 5.5.9 to 5.5.17, the update of memory in php.ini from 128M to 512M worked after I had received the FormatException: Unexpected end of JSON Input error.
I did have to cycle through the update twice, first it showed completed but the version had not updated, but it did complete successfully on second time around.
Another afternoon where I almost gave up on this thing, but after 90 min of searching found this answer. Self-Hosted maintenance is not for the meek.
Tip: I run this in an Ubuntu Virtualbox, and save snapshots before every upgrade of either OS or InvoiceNinja.