Skip to content

Instantly share code, notes, and snippets.

@fbrnc
Last active March 11, 2018 07:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fbrnc/a758315e2d9af024ab0f to your computer and use it in GitHub Desktop.
Save fbrnc/a758315e2d9af024ab0f to your computer and use it in GitHub Desktop.
What's wrong with Catalogrule's cron job?

catalogrule/observer::dailyCatalogUpdate called by the catalogrule_apply_all cron job will delete block caches every night:

https://github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/core/Mage/CatalogRule/Model/Rule.php#L319

What's wrong with this?

  1. It shouldn't do this if there are no catalog rules in the first place.
  2. Even if there are catalog rules it should check if the current execution time is close to any job's start or stop date and only flush caches then.
  3. The configuration (https://github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/core/Mage/CatalogRule/etc/config.xml#L102-104) basically only allows adding caches, but not removing any caches.
  4. Cleaning caches - if actually required - should happen after reindexing. It's not safe to assume that noone will hit any affected page after it was cleaned and before the indexers are done.
  5. How will full page cache implementations and other proxies (e.g Varnish) be able to update/purge their caches? I guess a separate event should be dispatched here...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment