Issue #3383487: Replace hook_cron() with a more modern approach
Merge request reports
Activity
added 1 commit
- e64d8145 - Replace system_cron() calls, fix missing and incorect cron service tags
added 221 commits
-
d4ee89da...aa3ecb2c - 215 commits from branch
project:11.x
- 34002f18 - Add cron service tag, implement some examples
- e891a696 - remove system_cron()
- a36c5d04 - Replace system_cron() calls, fix missing and incorect cron service tags
- 9002c565 - fix cache factory tags
- 9ff83901 - add logging to cron services
- 8e632367 - Catch cron service exceptions
Toggle commit list-
d4ee89da...aa3ecb2c - 215 commits from branch
added 69 commits
-
e38b8280...ad2eff55 - 61 commits from branch
project:11.x
- a7af712e - Add cron service tag, implement some examples
- c22e3dad - remove system_cron()
- 6f4dab6c - Replace system_cron() calls, fix missing and incorect cron service tags
- 778825b1 - fix cache factory tags
- 9dfea3d1 - add logging to cron services
- 646056a0 - Catch cron service exceptions
- e3f43199 - Convert a few more examples
- 057ce745 - fix flood test and coding standard issues
Toggle commit list-
e38b8280...ad2eff55 - 61 commits from branch
85 86 } 86 87 } 87 88 89 /** 90 * {@inheritdoc} 91 */ 92 public function run() { 93 $this->garbageCollection(); 94 return TRUE; 95 } the new method won't have a return value making a single-line function, and for some of them, the public garbageCollection method might go away completely as it won't need that anymore. For example a redis based expirable storage won't need garbage collection, so we can remove that from the public interface and implementations that have it can just let themself be called as a cron thing.
83 85 return $this->container->get($service_name)->get($bin); 84 86 } 85 87 88 /** 89 * {@inheritdoc} 90 */ 91 public function run() { I realise we're re-using CronInterface here, but I think there's a very real chance of a method naming collision here.
e.g. a service with a run method also wants to buy into cron.
Is it worth adding a new interface with e.g. a runCron method name?
I see @berdir said the same thing in comment 8 on the issue
changed this line in version 8 of the diff
added 322 commits
-
057ce745...b0243326 - 313 commits from branch
project:11.x
- efaf6209 - Add cron service tag, implement some examples
- b9ec1a12 - remove system_cron()
- bfe335ad - Replace system_cron() calls, fix missing and incorect cron service tags
- f33e7b5f - fix cache factory tags
- 7ceda083 - add logging to cron services
- 0e3db231 - Catch cron service exceptions
- f47690c3 - Convert a few more examples
- 62cd00f0 - fix flood test and coding standard issues
- 7917c968 - Add CronSubscriberInterface
Toggle commit list-
057ce745...b0243326 - 313 commits from branch
added 1 commit
- 1c4a43a2 - Fix and rename addCronService to addCronSubscriber
2 3 namespace Drupal\Core; 4 5 /** 6 * Allows to delegate cron tasks to services. 7 * 8 * Use the tag cron on the service that implements this interface. 9 * 10 * @see hook_cron() 11 */ 12 interface CronSubscriberInterface { 13 14 /** 15 * Executes a cron task. 16 */ 17 public function runCron(): void; changed this line in version 19 of the diff
429 431 class: Drupal\Core\Cron 430 432 arguments: ['@module_handler', '@lock', '@queue', '@state', '@account_switcher', '@logger.channel.cron', '@plugin.manager.queue_worker', '@datetime.time', '%queue.config%'] 431 433 lazy: true 434 tags: 435 - { name: service_collector, call: addCronService, tag: cron } We should be auto-configuring tags based on the interface. https://symfony.com/doc/current/service_container/tags.html#autoconfiguring-tags
We have done this already with
LoggerAwareInterface
. See https://www.drupal.org/node/3395436changed this line in version 12 of the diff
429 431 class: Drupal\Core\Cron 430 432 arguments: ['@module_handler', '@lock', '@queue', '@state', '@account_switcher', '@logger.channel.cron', '@plugin.manager.queue_worker', '@datetime.time', '%queue.config%'] 431 433 lazy: true 434 tags: 435 - { name: service_collector, call: addCronService, tag: cron } It would be nice if we could use
!tagged_iterator
notation here, but I don't think our YAML parser supports it yet. See https://www.drupal.org/project/drupal/issues/2961380#comment-15388091changed this line in version 12 of the diff
added 1 commit
- cf50b7c2 - Update cron logging test, add missing service tags
added 100 commits
-
cf50b7c2...945ff69c - 86 commits from branch
project:11.x
- 945ff69c...fbe31fe9 - 4 earlier commits
- ff10e3dd - add logging to cron services
- d2041818 - Catch cron service exceptions
- 2cb00bd7 - Convert a few more examples
- 4ce971bd - fix flood test and coding standard issues
- d8bd15d3 - Add CronSubscriberInterface
- e0a1504c - Fix SecurityAdvisoriesFetcher
- de7c1820 - Fix and rename addCronService to addCronSubscriber
- b84d0565 - the cron subscriber
- 8ee2fb75 - Fix service collector method name
- 3280f806 - Update cron logging test, add missing service tags
Toggle commit list-
cf50b7c2...945ff69c - 86 commits from branch
added 254 commits
-
3280f806...5c30729a - 240 commits from branch
project:11.x
- 5c30729a...7a3d35b0 - 4 earlier commits
- 83a4f8bb - add logging to cron services
- b9682240 - Catch cron service exceptions
- b2810620 - Convert a few more examples
- 4b0fb0a8 - fix flood test and coding standard issues
- e647cfb8 - Add CronSubscriberInterface
- 553a7c5b - Fix SecurityAdvisoriesFetcher
- a26a9293 - Fix and rename addCronService to addCronSubscriber
- 4d25c9d5 - the cron subscriber
- 49a35583 - Fix service collector method name
- 1f91c2a0 - Update cron logging test, add missing service tags
Toggle commit list-
3280f806...5c30729a - 240 commits from branch
added 1 commit
added 255 commits
-
2665b390...ad606a8f - 240 commits from branch
project:11.x
- ad606a8f...d6a7f33b - 5 earlier commits
- a4a01cd5 - Catch cron service exceptions
- 4fb92d34 - Convert a few more examples
- b5c24b79 - fix flood test and coding standard issues
- fb0ce166 - Add CronSubscriberInterface
- 869c1d0c - Fix SecurityAdvisoriesFetcher
- e648dd25 - Fix and rename addCronService to addCronSubscriber
- 188273ea - the cron subscriber
- 577783a3 - Fix service collector method name
- 7cf7c2d2 - Update cron logging test, add missing service tags
- d5b6d0d8 - task #3383487: Remove unused use from merge conflict resolution
Toggle commit list-
2665b390...ad606a8f - 240 commits from branch
added 42 commits
-
d5b6d0d8...4add05d0 - 26 commits from branch
project:11.x
- 4add05d0...9d8a9f72 - 6 earlier commits
- e367c20a - Convert a few more examples
- 987ebe58 - fix flood test and coding standard issues
- da1c5683 - Add CronSubscriberInterface
- cc68a8c4 - Fix SecurityAdvisoriesFetcher
- 1eb889d2 - Fix and rename addCronService to addCronSubscriber
- 6d90543b - the cron subscriber
- 43d44614 - Fix service collector method name
- 01e72b5a - Update cron logging test, add missing service tags
- 234e89e4 - task #3383487: Remove unused use from merge conflict resolution
- 04bcaddc - fix incorrect changes during rebase
Toggle commit list-
d5b6d0d8...4add05d0 - 26 commits from branch
added 1 commit
- 6dcb744c - Move CronSubscriberService, rename to onCron, add autoconfiguration
added 73 commits
-
6f1df7dd...3d3b2c1d - 54 commits from branch
project:11.x
- 3d3b2c1d...79db46e6 - 9 earlier commits
- c7e49418 - Fix SecurityAdvisoriesFetcher
- 3ddec98d - Fix and rename addCronService to addCronSubscriber
- 5d290165 - the cron subscriber
- eca7df16 - Fix service collector method name
- f068732d - Update cron logging test, add missing service tags
- 4cdd5cab - task #3383487: Remove unused use from merge conflict resolution
- 295ace19 - fix incorrect changes during rebase
- 5c4630b6 - Move CronSubscriberService, rename to onCron, add autoconfiguration
- 677b0a33 - also remove tag from kernel class
- 202966f8 - revert autoconfiguration
Toggle commit list-
6f1df7dd...3d3b2c1d - 54 commits from branch
added 362 commits
-
202966f8...dd84445a - 343 commits from branch
project:11.x
- dd84445a...0a4ec958 - 9 earlier commits
- 2cd7fb2c - Fix SecurityAdvisoriesFetcher
- ca02f01f - Fix and rename addCronService to addCronSubscriber
- ef05c78c - the cron subscriber
- 13c14e84 - Fix service collector method name
- 9a9e6de9 - Update cron logging test, add missing service tags
- f028c828 - task #3383487: Remove unused use from merge conflict resolution
- 244d771f - fix incorrect changes during rebase
- b8794533 - Move CronSubscriberService, rename to onCron, add autoconfiguration
- d97b858c - also remove tag from kernel class
- c2f1bde3 - revert autoconfiguration
Toggle commit list-
202966f8...dd84445a - 343 commits from branch