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

PHP Fatal error: Uncaught RuntimeException: Error saving action: ActionScheduler_Action::$args too long #851

Open
saad-siddique opened this issue Sep 12, 2022 · 5 comments · May be fixed by #855
Labels
priority: normal The issue/PR is normal priority—not many people are affected or there’s a workaround, etc. type: enhancement The issue is a request for an enhancement.

Comments

@saad-siddique
Copy link

Hey,

A few of our plugin users (Pro version of the Automator plugin) have reported this issue. We are using v3.4.0 of the Action Scheduler library in our plugin. Has anyone else reported the problem?

"require": {
    "woocommerce/action-scheduler": "^3.4.0"
  },

Can this hardcoded extended_args varchar(8000) limit be changed to longext instead?

extended_args varchar(8000) DEFAULT NULL,

[02-Sep-2022 08:54:31 UTC] PHP Fatal error: Uncaught RuntimeException: Error saving action: ActionScheduler_Action::$args too long. To ensure the args column can be indexed, action args should not be more than 8000 characters when encoded as JSON. in /wp-content/plugins/xxxxxx/vendor/woocommerce/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php:86

Stack trace:

#0 /wp-content/plugins/xxxxxx/vendor/woocommerce/action-scheduler/classes/ActionScheduler_ActionFactory.php(177): ActionScheduler_DBStore->save_action(Object(ActionScheduler_Action))

#1 /wp-content/plugins/xxxxxx/vendor/woocommerce/action-scheduler/classes/ActionScheduler_ActionFactory.php(84): ActionScheduler_ActionFactory->store(Object(ActionScheduler_Action))

#2 /wp-content/plugins/xxxxxx/vendor/woocommerce/action-scheduler/functions.php(36): ActionScheduler_ in /wp-content/plugins/xxxxxx/vendor/woocommerce/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php on line 86
@bugnumber9
Copy link

This really needs to be fixed. Not necessarily by changing the column type, another option would be to implement a separate meta table for scheduler actions, and that does look reasonable enough to me.
I've seen the discussion in #418, including using postmeta for long actions.
As a heavy user of Uncanny Automator plugin, I can confirm that this limit is a problem. Besides that, the error says that the 8k chars limit is there to ensure indexing, but it's args column that is indexed, not extended_args which isn't indexed, see below.
tbl_struct

@jorgeatorres jorgeatorres added the type: enhancement The issue is a request for an enhancement. label Sep 15, 2022
@jorgeatorres
Copy link
Member

jorgeatorres commented Sep 15, 2022

Hi @saad-siddique @bugnumber9,

Thanks for taking the time to file this issue.

Changing the size of the column is probably not the best way to go, and the alternatives are not so trivial to implement, as described in #418, which basically dealt with this same problem.

I understand the workarounds or suggestions in #418 might not be universally applicable, so I'm filing this issue as an enhancement request in the hopes we can get to it soon.
In the mean time, if anyone is interested in submitting a PR to address this, we'd be more than happy to take a look.

Thanks again!

saad-siddique added a commit to saad-siddique/action-scheduler that referenced this issue Sep 15, 2022
Closes woocommerce#851

PHP Fatal error: Uncaught RuntimeException: Error saving action: ActionScheduler_Action::$args too long
@saad-siddique
Copy link
Author

@jorgeatorres, Thank you for taking the time to reply to this issue. I've created a PR to address this issue here: https://github.com/woocommerce/action-scheduler/pull/855/files. It's a straightforward change, and I don't think extended_args references in the code need other modifications. It should work as is if you merge it. But of course, I'll leave it up to you to decide.

@bugnumber9
Copy link

As far as I've been looking into this, there's more - there's at least protected static $max_args_length = 8000; in /classes/data-stores/ActionScheduler_DBStore.php unless I've missed something else.

@Konamiman Konamiman added the priority: normal The issue/PR is normal priority—not many people are affected or there’s a workaround, etc. label Sep 1, 2023
@vedanshujain
Copy link
Contributor

As a workaround, it might be beneficial to store large data in a different table and then have an ID as part of the argument. You can then fetch this data from the action itself. If we change the type from varchar to text, then it won't be indexable anymore (which seems like some shops do use).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: normal The issue/PR is normal priority—not many people are affected or there’s a workaround, etc. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants