Skip to content
Snippets Groups Projects

Issue #3383487: Replace hook_cron() with a more modern approach

Issue #3383487: Replace hook_cron() with a more modern approach

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
85 86 }
86 87 }
87 88
89 /**
90 * {@inheritdoc}
91 */
92 public function run() {
93 $this->garbageCollection();
94 return TRUE;
95 }
  • Comment on lines +92 to +95

    Quite a few services using this exact code, worth a CronGarbageCollectionTrait?

  • 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.

  • Please register or sign in to reply
  • 83 85 return $this->container->get($service_name)->get($bin);
    84 86 }
    85 87
    88 /**
    89 * {@inheritdoc}
    90 */
    91 public function run() {
  • Looking good

    The issue summary talks about stuff like more advanced scheduling etc (e.g. only running every N cron runs etc)

    Are we still planning to add something like that?

  • 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

    Compare with previous version

  • added 1 commit

    • f60af6c5 - Fix SecurityAdvisoriesFetcher

    Compare with previous version

  • added 1 commit

    • 1c4a43a2 - Fix and rename addCronService to addCronSubscriber

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • 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;
  • 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 }
  • 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 }
  • added 1 commit

    • c8695d32 - Fix service collector method name

    Compare with previous version

  • added 1 commit

    • cf50b7c2 - Update cron logging test, add missing service tags

    Compare with previous version

  • added 100 commits

    Compare with previous version

  • Derek Wright added 254 commits

    added 254 commits

    Compare with previous version

  • Derek Wright added 1 commit

    added 1 commit

    Compare with previous version

  • added 255 commits

    Compare with previous version

  • added 42 commits

    Compare with previous version

  • added 1 commit

    • 6dcb744c - Move CronSubscriberService, rename to onCron, add autoconfiguration

    Compare with previous version

  • added 1 commit

    • 37c9a812 - also remove tag from kernel class

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • added 73 commits

    Compare with previous version

  • added 362 commits

    Compare with previous version

  • Please register or sign in to reply
    Loading