MinnPost / object-sync-for-salesforce

WordPress plugin that maps and syncs data between Salesforce objects and WordPress objects.
https://wordpress.org/plugins/object-sync-for-salesforce/
GNU General Public License v2.0
93 stars 48 forks source link

PHP Fatal Error: #504

Closed phillamb168 closed 1 year ago

phillamb168 commented 1 year ago

Describe the bug When using Salesforce scheduler setting, I get PHP Fatal Error: Uncaught TypeError: DateTime::__construct() - wants string instead of array.

To Reproduce Steps to reproduce the behavior:

  1. Go to the scheduling tab for the plugin
  2. Under 'Pull from Salesforce', choose any values and click submit
  3. See error

Expected behavior Scheduler should run, but errors out.

full log dump { "installName": "myinstall", "environment": "DEV", "type": "error", "date": "2022-11-04T20:57:49.000Z", "severity": "error", "client": "99.57.241.201:0", "message": "PHP Fatal error: Uncaught TypeError: DateTime::__construct(): Argument #1 ($datetime) must be of type string, array given in /nas/content/live/{sitename}/wp-content/plugins/object-sync-for-salesforce/vendor/woocommerce/action-scheduler/functions.php:336\\nStack trace:\\n#0 /nas/content/live/{sitename}/wp-content/plugins/object-sync-for-salesforce/vendor/woocommerce/action-scheduler/functions.php(336): DateTime->__construct(Array, Object(DateTimeZone))\\n#1 /nas/content/live/{sitename}/wp-content/plugins/object-sync-for-salesforce/vendor/woocommerce/action-scheduler/classes/ActionScheduler_ActionFactory.php(114): as_get_datetime_object(Array)\\n#2 /nas/content/live/{sitename}/wp-content/plugins/object-sync-for-salesforce/vendor/woocommerce/action-scheduler/classes/ActionScheduler_ActionFactory.php(149): ActionScheduler_ActionFactory->single_unique('object_sync_for...', false, Array, 1667595469, 'salesforce_pull...')\\n#3 /nas/content/live/{sitename}/wp-content/plugins/object-sync-for-salesforce/vendor/woocommerce/action-scheduler/functions.php(59): ActionScheduler_ActionFactory->recurring_unique('object_sync_for...', Array, 1667595469, 0, 'salesforce_pull...', false)\\n#4 /nas/content/live/{sitename}/wp-content/plugins/object-sync-for-salesforce/classes/class-object-sync-sf-queue.php(215): as_schedule_recurring_action(1667595469, 0, 'object_sync_for...', Array, 'salesforce_pull...')\\n#5 /nas/content/live/{sitename}/wp-content/plugins/object-sync-for-salesforce/classes/class-object-sync-sf-admin.php(446): Object_Sync_Sf_Queue->schedule_recurring(1667595469, 0, 'object_sync_for...', Array, 'salesforce_pull...')\\n#6 /nas/content/live/{sitename}/wp-content/plugins/object-sync-for-salesforce/classes/class-object-sync-sf-admin.php(399): Object_Sync_Sf_Admin->set_action_schedule('salesforce_pull', 'salesforce_pull...')\\n#7 /nas/content/live/{sitename}/wp-includes/class-wp-hook.php(307): Object_Sync_Sf_Admin->initial_action_schedule('1', false, 'object_sync_for...')\\n#8 /nas/content/live/{sitename}/wp-includes/plugin.php(191): WP_Hook->apply_filters('1', Array)\\n#9 /nas/content/live/{sitename}/wp-includes/option.php(439): apply_filters('pre_update_opti...', '1', false, 'object_sync_for...')\\n#10 /nas/content/live/{sitename}/wp-admin/options.php(322): update_option('object_sync_for...', '1')\\n#11 {main}\\n thrown in /nas/content/live/{sitename}/wp-content/plugins/object-sync-for-salesforce/vendor/woocommerce/action-scheduler/functions.php on line 336, referer: https://{sitename}.wpengine.com/wp-admin/options-general.php?page=object-sync-salesforce-admin&tab=schedule", "uuid": "bac204ca-8b5a-468c-979d-1b847bd97c1c" } Environment (please complete the following information):

jonathanstegall commented 1 year ago

I've heard some people are seeing this. I haven't been able to reproduce it, but I do believe it's a bug in Action Scheduler. I've reported it and submitted a fix for review. If/when it is accepted, I'll update the plugin as soon as possible. https://github.com/woocommerce/action-scheduler/issues/881

If I can reproduce it I could add it as a temporary fix until they update, but I can't tell why it only occurs for some users.

phillamb168 commented 1 year ago

Thanks @jonathanstegall - looks like this patch fixes it: https://github.com/woocommerce/action-scheduler/pull/883/files

jonathanstegall commented 1 year ago

Didn't realize that previous merge would close this issue. To be clear, Action Scheduler 3.5.3 was irrelevant to this issue, and they still haven't merged or addressed the pull request I submitted to them.

MannyAdumbire commented 1 year ago

I'm getting this error as well. in my case this error happens either when:

a. The plugin has just been activated for the first time and there is no Time Unit defined in options table. b. I set "Run Schedule Every" to "0" or revert "Time Unit" to "- Select one -" and Save settings.

image

Interestingly, Negative numbers work, though zero doesn't 🤯

image

Is this a unrelated issue? I can open in separate ticket if so!

jonathanstegall commented 1 year ago

@MannyAdumbire have you tried the patch to see if it fixes the issue for you? I'm still waiting for the Action Scheduler maintainers to accept it, but it would be good to know if it is a fix for you. If it is, maybe you can comment on the issue in their repository to that effect.

MannyAdumbire commented 1 year ago

@jonathanstegall Yup I just confirmed the patch prevents an Exception both when "0" in my case, commenting there. Thanks!!

jonathanstegall commented 1 year ago

Noting here that Action Scheduler merged in the patch mentioned in this issue, which was already included in v2.2.6 of this plugin. I'm going to close this issue since the patch is already included in this plugin and presumably will be released in the next version of Action Scheduler.