Module does not supporting QueueWorker plugin derivatives because of the way how CronJobDiscovery class processing queue worker plugin id:
$job_id = str_replace(':', '__', CronJobInterface::QUEUE_ID_PREFIX . $id);
Then in ultimate_cron module QueueWorker reverse id transformation happens only partially:
$queue_name = str_replace(CronJobInterface::QUEUE_ID_PREFIX, '', $job->id());
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 3094120-5.patch | 1.69 KB | dench0 |
Issue fork ultimate_cron-3094120
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
dench0Attached patch.
I'm suggesting to change replacement string for colon from '__' to '--' and then make reverse transformation. Now Drupal does not has any limitation to the plugin id and, of course, possible situation when queue worker plugin will have double hyphens in his id, but I don't know any contrib module with that id.
Comment #3
dench0Little bit changed previous patch, because it have issue with cron job edit form. In new path I'm suggesting to add one more constant to the
CronJobInterfaceconst QUEUE_DERIVATIVE_ID_DELIMITER = '__derivative_id__';.Comment #4
lisa.rae commentedMarking Needs Work, patch failed to apply
Comment #5
dench0Comment #6
jdleonardThis appears to be a duplicate of #3001044: Drupal\Component\Plugin\Exception\PluginNotFoundException: The "feeds_feed_refresh__test_node". Closing this issue in favor of the older issue, which has a similar patch. If this patch is superior in some way, I'd suggest adding it to the other issue.
Comment #7
joseph.olstadThe other issue not a duplicate
Comment #8
joseph.olstadHmm, neither patch seems to help in my case, I'm trying to get node_revision_delete 2.0.x cron to get recognized, maybe another issue involved.
The 2.0.x version of node_revision_delete does NOT have a hook_cron implementation. Perhaps there's some new way to invoke cron?
Comment #9
berdirAre you using the option to expose single queues as their own job?
Either way, node_revision_delete uses a single, regular queue. Without that option, you won't see anything, but it should just work, it will always call all queues that have any data in them. Check with drush queue:list or manually in the queue table if there's any data to process.
If you do use the option (which I don't recommend), you should see the queue job show up when you rebuild jobs, and then same.
Comment #10
joseph.olstadnode_revision_delete version 2.0.x does not have a hook_cron, it has an QueueWorker class
with that said, node_revision_delete 1.x has a hook_cron, this works with Ultimate Cron, but not 2.0.x version of nrd
I'm not sure if I understood your suggestion. Maybe you're not aware of the differences between node_revision_delete 1.x and 2.x
This is the first time I've seen a QueueWorker class. I'd have to look this up to understand when it came in and what it's about.
Comment #11
joseph.olstad#3401632: Support for Ultimate Cron
Comment #12
joseph.olstadComment #13
berdirYou don't need a Job for queues, they run every time cron runs.
Comment #14
joseph.olstadok so is there a way to say, "QueueWorker for nrd, run only between 04:00 AM and 05:00 AM"?
how do we set up an Ultimate Cron functionality with a QueueWorker?
Comment #15
berdir> This is the first time I've seen a QueueWorker class. I'd have to look this up to understand when it came in and what it's about.
The queue system has existed for a very long time and you *very* likely relied on them before without knowing it. media_entity in core uses queues conditionally, entity_reference_revisions uses queues for for orphan cleanup, drush queue:list probably shows a bunch of them on your project.
A queue will only process stuff if something has explicitly added items to the queue. For node_delete_revisions, that happens when nodes are updated, then they will be checked on the next cron run. This is completely different to how 1.x worked, which had expensive queries that did run on every cron execution. Queues typically also have a fixed time limit per cron run per queue, so they run at most 30s or 60s or something like that.
in my experience, you very rarely need to control when they run. You can do that, with the mentioned setting that will expose each queue as its own job. Then you could set them up to either not run at all and set up separate queue processing with drush queue:run or run them at specific times. But that causes risks
The other thing you can do is alter their definition and lower their execution limit, so that they run only 10s for each cron run or so.
This issue is a about a very specific edge case with queue workers created as derivatives, which causes invalid job names combined with that optional setting.
Comment #16
johan den hollander commentedSo how would this then delete revisions older then x months form a node that has not been touched recently?
Comment #17
berdirI don't know and was wondering about that too, but that is an issue with node_delete_revisions, not this module. I guess at the moment the answer is "not" ;)
Comment #19
berdirCommitted this, prefer the changed separator over keeping __ of the other issue.
This does mean that existing jobs will be duplicated, but they weren't working before, so that's fine by me.
Comment #21
berdirThis breaks the updated tests which now use such a queue plugin in the edit test. This also means that we should able to test this pretty easily.
Comment #25
man-1982 commentedAdded backwards compatibility fallback for legacy __ delimiter format with deprecation notice, post_update migration hook, and kernel tests for derivative discovery/migration.
Comment #27
berdir__derivative_id__ is quite long. config entity ids can be up to 166 characters, see \Drupal\Core\Config\Entity\ConfigEntityStorage::MAX_ID_LENGTH. "ultimate_cron_queue___derivative_id__" is 38 characters, which still leaves 128 characters for the plugin id and derivate id. That's *probably* ok, but would it make sense to add something to handle that?
On the post update, config entities support renames, although there are some edge cases with that still (registering of uuid in key lookups) and our references won't support that, so it probably doesn't make a difference.