Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error opening/editing forms: Argument #4 ($properties) must be of type array, null given #13652

Open
1 task done
pjrobertson opened this issue Apr 15, 2024 · 4 comments
Open
1 task done
Labels
bug Issues or PR's relating to bugs pending-feedback PR's and issues that are awaiting feedback from the author

Comments

@pjrobertson
Copy link

pjrobertson commented Apr 15, 2024

Mautic Version

5.0.x series

Way of installing

I downloaded a release from https://www.mautic.org/mautic-releases

PHP version

8.0.30

What browsers are you seeing the problem on?

Not relevant

What happened?

Upgraded from 4.x to 5.0.4. Tried to open up an existing form and also tried creating a new form. A 500 error occurred, with the following info in the console:

[2024-04-15T15:27:43.858030+00:00] mautic.CRITICAL: Uncaught PHP Exception TypeError:
 "Mautic\FormBundle\Crate\FieldCrate::__construct(): Argument #4 ($properties) must be of type array, null given, 
called in /mautic/public/app/bundles/LeadBundle/EventListener/FormSubscriber.php on line 133" at
 /mautic/public/app/bundles/FormBundle/Crate/FieldCrate.php line 14 {"exception":"[object] (TypeError(code: 0): 
Mautic\\FormBundle\\Crate\\FieldCrate::__construct(): Argument #4 ($properties) must be of type array, 
null given, called in /mautic/public/app/bundles/LeadBundle/EventListener/FormSubscriber.php on line 133 at
 /mautic/public/app/bundles/FormBundle/Crate/FieldCrate.php:14)"} {"hostname":"example.com","pid":802}

How can we reproduce this issue?

Step 1: Upgrade to 5.0.4
Step 2: Open up an existing form OR create a new form then go to the 'fields' tab and try to add a new field (e.g. 'email)
Step 3: Note the 500 error in the console, go to the backend and see the logs as above.

NOTE: I managed to 'fix' this problem by modifying public/app/bundles/LeadBundle/EventListener/FormSubscriber.php:L133 as follows:

$field->getProperties() === null ? [] $field->getProperties()

I don't know if this is a 'good' way of fixing the issue.

Code of Conduct

  • I confirm that I have read and agree to follow this project's Code of Conduct
@pjrobertson pjrobertson added bug Issues or PR's relating to bugs needs-triage For new issues/PRs that need to be triaged labels Apr 15, 2024
@dsp76
Copy link

dsp76 commented Apr 20, 2024

@pjrobertson it looks like the update and/or migration had an error. Forms editing works usually fine in 5.0.4. Could you please try to see in the Mautic forum, if other users had the same experience when updating? Please then also add details on how you upgraded in the forum post, e.g. with Mautic CLI commands or via composer...

Please also try to do a "console mautic:assets:generate" and refresh the cache.

@dsp76 dsp76 added pending-feedback PR's and issues that are awaiting feedback from the author and removed needs-triage For new issues/PRs that need to be triaged labels Apr 20, 2024
@pjrobertson
Copy link
Author

  1. Nothing in the forum/other GH issues regarding this, I previously checked but have just checked again.
    I did have a problem during the update, which was the same as this issue - I followed the steps there and ran the following SQL on my database: update emails set headers='[]' where headers=''; - but this table is completely unrelated to the forms

  2. I updated using the CLI console mautic:update:apply and console mautic:update:apply --finish - when the error above ocurred I had to rerun the --finish command

  3. Regenerating assets and clearing cache did nothing.

I suggest integrating my above fix, the worst case it takes another milisecond in script execution when editing a form. Best case is it fixes a bug. I agree that the right way to solve this would be to find the table in the DB where the properties=null and change to properties=[] but this fix is easier.

@RCheesley
Copy link
Sponsor Member

@pjrobertson in the upgrade process, did you run the database migrations at all?

@pjrobertson
Copy link
Author

When I faced the issue above see here I did try to run the migrations manually, which subsequently failed. I then fixed the issue manually as explained above with update emails set headers='[]' where headers='';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues or PR's relating to bugs pending-feedback PR's and issues that are awaiting feedback from the author
Projects
None yet
Development

No branches or pull requests

3 participants