`->pivot->save()` - possible infinite loop after upgrade to OctoberCMS 3

Hi,

We are upgraded from OctoberCMS 2 to OctoberCMS 3 and we ran into the following issue: Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of ‘1000’ frames.

$legal_relationship = $association->legal_relationships->where('id', $some_id)->first();
        if (isset($legal_relationship)) {
            $legal_relationship->pivot->membership_fee = 80;
            $legal_relationship->pivot->save();
        }

The above code works fine with OctoberCMS 2, but the following error occurs with version 3:

I’m not sure if the code is incorrect or this is a bug.

Any help is appreciated.

A solution to the problem:

$association->legal_relationships()->updateExistingPivot($legal_relationship, ['membership_fee' => 50]);
1 Like

Hi and welcome @zssso

We’ve added this to our internal tracker to take a look soon. We will test and confirm, infinite loops can happen via model event logic, although if it was working in v2, then this is probably related to the different internals in the latest Laravel version.

Hi,

Thank you for your answer.

I have an other issue I forgot to mention: After licensing the container the update process always fails with: “Update Failed - General Error. Status code: 500”. Then nothin works, no error, just a blank page. The workaround find if to delete the composer.lock file then run composer update.