[Solved] Attempting to upgrade from v4.5.50 to v5.3.84-C78

Howdy all,
I am trying upgrade from v4.5.50 to v5.3.84-C78

I don’t see any other errors except:

Trying to get property ‘client_id’ of non-object

I have no issues with v4. I have been using it since v3 and have upgraded it many times. I upgraded from v4.5.19 before the upgrade. Version 5 was a new install and I don’t seem to have any issues with it.

I have never purged my system in the past as far as I remember. What can I do to get the migration to work. I only see one other case where someone had the same issue: https://github.com/invoiceninja/invoiceninja/issues/4989 , but it seems it was a bug and a patch was issued. Am I dealing with another bug that was introduced with these new versions?

Hi,

@david any thoughts to debug this?

@sarsenal

The error indicates it is trying to access a property which doesn’t exist. Without inspecting the data closely, it’ll be impossible to work out the issue.

If you want to DM the file located in (storage/migrations/) we can take a look.

There are no files in the storage/migration folder. I have never seen it create any files. I don’t think it even gets to that point. It stops almost immediately with the error.

@sarsenal

The file may be in public/storage/migrations/

It sounds like v4 is generating the file, but it isn’t being processed successfully in v5. Please note, you need to check v4 for this file.

@david
I don’t have a public/storage/migrations folder on v4. I don’t even have public/storage on v4. I have it on v5. I have nothing in the storage/migrations folder on v4. I don’t see any files being built. It seems to just say getting and then exits with the error.

I’ve just doubled checked, in v4 the file should be located in storage/app/migrations.

I checked. I only have storage/migration. I don’t have storage/app/migration. and no files in the migration folder.
@david any other ideas?

@sarsenal

Sorry, are you sure you are checking in v4 for this folder? the v4 app creates a directory in storage/app/migrations for the migration file.

@david
Yes, I am very sure. I checked both v4 and v5 and listed above what I saw. Is there a deeper debug mode or something we can run during the migration to see what is going on?

@david ny ideas what I should try?

So the key here is to find the .zip file that is created in v4 if we can get this file we can move forward.

You may want to run

sudo find ./ -name *.zip

from within both your v4 and v5 directories to find the migration file.

@david
I just did a new install of v4.5.50 and installed just the database to verify nothing was wrong with the system. Of course v4.5.50 works just fine. I don’t understand what is wrong with the database that it doesn’t like. I have migrated this database from 2018 and has been upgraded from v3 to v4 and now trying upgrade from v5. I have had whitelabel since 2018 (might have been earlier). I might have even been around since v2. I have been using Invoice Ninja for a very long time.

The only migration.zip file is on v5 and in: /usr/share/nginx/invoiceninja/tests/Unit/Migration/migration.zip

This looks like a test migration file, it is not my data. As I said after I select a company to migration It returns immediately with the error: Trying to get property ‘client_id’ of non-object
So I don’t think it ever even gets to the point of building anything.

@sarsenal

Can you advise the full output of the error? in particular i need the line number where this is failing…

@david
I have no errors in the logs. I don’t know what line number it errors on. It just stops at the last line in the laravel-info.log. I checked again and no zip file was created on either v4 or v5.

I only have this in: laravel-info.log

[2022-05-09T23:11:03.177096+00:00] production.INFO: get get company gateways => 2 [] []
[2022-05-09T23:11:03.177195+00:00] production.INFO: translating gateway ID = 23 [] []
[2022-05-09T23:11:03.208642+00:00] production.INFO: translating gateway ID = 23 [] []
[2022-05-09T23:11:03.208901+00:00] production.INFO: get transform fees and limits [] []
[2022-05-09T23:11:03.215644+00:00] production.INFO: get transform fees and limits [] []
[2022-05-09T23:11:03.217088+00:00] production.INFO: translating gateway ID = 17 [] []
[2022-05-09T23:11:03.222411+00:00] production.INFO: translating gateway ID = 17 [] []
[2022-05-09T23:11:03.222643+00:00] production.INFO: get transform fees and limits [] []
[2022-05-09T23:11:03.240744+00:00] production.INFO: get client gateway tokens => 28 [] []
[2022-05-09T23:11:03.263526+00:00] production.INFO: Trying to get property ‘client_id’ of non-object [] []

@sarsenal

So it looks like client gateway token is corrupt and is not returning the contact.

If you open the file:

App\Traits\GenerateMigrationResources.php

On line 1745 if you change

if(!$contact && !$agt)

to

if(!$contact || !$agt)

this should skip the corrupt record and complete build the remaining data.

Perfect that worked! Is there any issues or data this change would impact?

@sarsenal

The record it was trying to import - a client gateway payment token, would be skipped.

Thanks again for your help