When trying to add a NEW email conditional action on a failed renewal I get the following error:
Fatal error: Unsupported operand types in modules/uc_recurring/uc_recurring.ca.inc on line 391
Conditionally combining the arrays if $settings is not empty seems to have fixed the problem, but there is probably a more finessed way to do it and I have no idea if this will cause problems down the road.
Thanks for your great work!
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | uc_recurring-unsupported_operand_types-1011728-12.patch | 712 bytes | agileware |
| #10 | uc_recurring-new_action_mail_form_settings-1011728-10.patch | 1.47 KB | miche |
| #6 | uc_recurring-new_action_mail_form_settings-miche.patch | 1.15 KB | miche |
Comments
Comment #1
micheExperienced same issue in alpha6. Still investigating.
Comment #2
univate commented#1054110: When running cron: Fatal error: Unsupported operand types
Comment #3
micheReopening. I do not think this is a duplicate. Although the same fatal error happens, a very different line of code is the culprit.
To replicate error:
/admin/store/ca/uc_recurring_renewal_email_failed/edit/actions
in "Available Actions" select box, choose "Send an order email regarding order renewal"
click "Add Action"
I propose changing
to
This will insure that if there is existing content in the form fields, it gets preserved on save and also prefill the fields when creating a new action.
Additionally, we can complete remove the following lines because ca_build_email_form() has been moved out of uc_roles.ca as of the dev release.
Comment #4
univate commentedThe operand + on arrays is a union, so those two blocks of code do completely different things.
Comment #5
micheIn my testing, when editing and saving an existing action, you don't need to specify what the settings are so that it pulls in what has already been saved. However, when adding a new one, you need to specify what to prefil the form elements with.
To accomplish this testing:
If I completely remove the code about the settings array
--If I change an existing action, everything is saved as expected.
--If I add a new one, it loads as empty without the tokens.
If I change the += to just =
--If I change an existing one, nothing saves and it uses the content from the settings array in code.
--If I add a new one, it loads as expected with filled fields from the settings array.
This has led me to believe that we need a conditional statement.
- If editing/saving an existing, don't do anything.
- If creating a new one, define the contents for the fields.
Comment #6
micheI have attached a patch with my proposed code. I would appreciate if someone could test if the logic change works as desired. Thanks!
Comment #7
tinker commented@miche - Your patch has incorrect logic and does not match the original operation of the code. You could try something like:
This is not tested, I have not looked at the code, just suggesting different logic. Really we should know why $settings is not an array.
Comment #8
univate commentedWhat tinker has posted is what we will need to do, we can't just ignore the $settings when something is passed to this function as it may not include all required variables.
I am also interest in understanding why $settings is not an array?, if nothing is passed is should be an empty array, if something is passed then by definition it should be array(). Where in ubercart is it try to pass something other then an array.
Comment #9
univate commentedComment #10
micheThank you for the code snippet. I have tested this locally and confirmed that a fatal error no longer happens, existing/modified emails are preserved, new ones are prefilled with the template.
Comment #11
agileware commentedThe patch in #10 fixes the error for me.
Comment #12
agileware commentedThis patch also fixes it a different way - I forgot I had seen this before :(.
The issue is that when you add the action through the UI, the ca_actions_form() function passes in the actions, which are NULL.
I would expect this NULL is the only case where you won't have an array because the settings have not yet been saved.
Other modules that provide actions like uc_order do not do this same sort of array merging so don't run into the problem.
Comment #13
mattcasey commented#12 works for me, I am using the previous dev and the error goes away
Comment #14
westwesterson commentedTested the fix in 12. This works for me too!
Comment #15
daveparrish commented#12 also worked for me. I am using version 6.x-2.0-alpha6.
Comment #16
univate commentedcommitted #12