Can't Save Invoices nor Migrate to v5 on Self Hosted

Recently I moved to a new host, and since the move I am unable to save invoices, even with a fresh install of v4.5.50 using Softaculous. When I click the Save Draft button, inspector reports two errors:

500 for jquery.js (and lists the script as being located in the public folder and no such file exists in CP’s File Manager)

and

Uncaught TypeError for script.js (also appears to be looking for it in the public folder)

and the InvoiceNinja debugger says:
“[18:24:30] LOG.error: Uncaught TypeError: Cannot read properties of undefined (reading ‘errors’)
{“context”:“JavaScript”,“user_id”:7,“account_id”:“7”,“user_name”:“My Name”,“method”:“GET”,“user_agent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.60 Safari/537.36”,“locale”:“en”,“ip”:“0.0.0.0”,“count”:4,“is_console”:“no”,“is_api”:“no”,“db_server”:“mysql”,“url”:“log_error”}”

It should be noted that these errors go away and I am able to save invoices if I disable ModSecurity for this subdomain. But is that really a good idea security wise?

I figured not so I tried migrating to v5.3.76. But then I get this error (and nothing is moved over):

Server error: POST https://invoice-ninja-number-5.mydomain.com/api/v1/migration/start resulted in a 500 Internal Server Error response: { “message”: “Server Error” }

I contacted the host for support, and they are just asking for specific server requirements for this application. So any help with either getting v4 to work safely, or better yet migrating to v5 successfully would be much appreciated.

Thank you!

Hi,

Are there any details about the v5 500 error in storage/logs?

Hi Hillel,

The laravel-error log reports this:

[2022-04-01T17:39:34.393736+00:00] production.ERROR: Uncaught TypeError: Unable to process binding “foreach: function(){return $root.time_log }” Message: Unable to process binding “dateTimePicker: function(){return startTime.pretty }” Message: $(…).datetimepicker is not a function {“context”:“JavaScript”,“user_id”:1,“account_id”:“1”,“user_name”:“My Name”,“method”:“GET”,“user_agent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.60 Safari/537.36”,“locale”:“en”,“ip”:“00.00.00.00”,“count”:1,“is_console”:“no”,“is_api”:“no”,“db_server”:“mysql”,“url”:“log_error”} []
[2022-04-01T17:41:05.593959+00:00] production.ERROR: Uncaught TypeError: Cannot read properties of undefined (reading ‘errors’) {“context”:“JavaScript”,“user_id”:1,“account_id”:“1”,“user_name”:“My Name”,“method”:“GET”,“user_agent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.60 Safari/537.36”,“locale”:“en”,“ip”:“00.00.00.00”,“count”:2,“is_console”:“no”,“is_api”:“no”,“db_server”:“mysql”,“url”:“log_error”} []
[2022-04-01T17:44:15.341203+00:00] production.ERROR: Uncaught TypeError: Cannot read properties of undefined (reading ‘errors’) {“context”:“JavaScript”,“user_id”:1,“account_id”:“1”,“user_name”:“My Name”,“method”:“GET”,“user_agent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.60 Safari/537.36”,“locale”:“en”,“ip”:“00.00.00.00”,“count”:3,“is_console”:“no”,“is_api”:“no”,“db_server”:“mysql”,“url”:“log_error”} []
[2022-04-01T18:24:30.498859+00:00] production.ERROR: Uncaught TypeError: Cannot read properties of undefined (reading ‘errors’) {“context”:“JavaScript”,“user_id”:1,“account_id”:“1”,“user_name”:“My Name”,“method”:“GET”,“user_agent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.60 Safari/537.36”,“locale”:“en”,“ip”:“00.00.00.00”,“count”:4,“is_console”:“no”,“is_api”:“no”,“db_server”:“mysql”,“url”:“log_error”} []

Also, I’m confused by what is in the regular laravel log for v4.5.50 whenever I create a fresh install:

“[2022-03-20 06:46:53] laravel.EMERGENCY: Unable to create configured logger. Using emergency logger. {“exception”:”[object] (Error(code: 0): Class “Illuminate\Support\Collection” not found at /home/david/…" followed by many lines under “stacktrace” that start with “/home/david/…”.

I know that “home/david” is not a directory within my hosting account.

Also, the laravel log from the version 5 build starts with:

[2022-04-01 17:47:36] production.INFO: Importing account
[2022-04-01 17:47:36] production.INFO: Importing company
[2022-04-01 17:47:36] production.INFO: Serialization of ‘Closure’ is not allowed…

Those look like v4 logs, are there any v5 error logs related to the migration 500 error?

@david do you have any suggestions?

Well, the last section of my previous post is from the laravel log of v5.3.76 build. The next line from there has this error:

[2022-04-01 17:47:36] production.ERROR: Serialization of ‘Closure’ is not allowed {“userId”:1,“exception”:"[object] (Exception(code: 0): Serialization of ‘Closure’ is not allowed at /home/mycpanelname/invoice-ninja-5.mydomain.com/public/vendor/laravel/framework/src/Illuminate/Queue/Queue.php:158)

There is no laravel-error.log or laravel-info.log in storage/logs for v5.3.76.

Thanks, I think we’ll need to wait for David

Found this which may help, maybe v5 is pointing to the v4 database?

I’m fine with waiting. The host says it’s ok for me to disable ModSecurity in order to get invoice saving to work in Version 4. However, I don’t see how fresh installs of version 4 and 5 using Softaculous could result in 5 pointing to the wrong database. Where would I look to check for that (what DB entry)?

You can check the database credentials in the .env files

I don’t think we ever got to understand why some platforms throw this particular error:

Serialization of ‘Closure’ is not allowed

It may help to understand more about the hosting platform you are on, if you are using Softaculous, I am assuming shared hosting.

Yes, this is shared hosting on NameHero. Please let me know if there are other specifics you would like to know about this hosting platform. I’m going to take a look at the env files shortly.

It does look like each install is pointing to the correct database in the env files. At least Softaculous is matching the install version to the database assigned. Is there a way to look at the SQL and confirm that the database is the correct version (ie: tell DBs apart by differences in format or a DB entry that lists the version)?

Just following up. I have been asked a couple of questions above, and have answered, but am still hoping to get help and guidance if possible, when possible. The problem of not being able to migrate my data to version 5 remains and issue. And I’ve just had to re-open the ticket with the host, as they seem to think I should know how to solve the problem, then let them know what changes they should make. Oh brother, I wish!