Closed (fixed)
Project:
Backport
Version:
7.x-4.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
10 Mar 2018 at 08:30 UTC
Updated:
28 Mar 2018 at 16:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jose reyero commentedSimilar to drush cr for D8, this rebuilds the container and clears all caches.
Comment #3
markhalliwellI would actually prefer that we hook into D7's existing caching API rather than introducing a separate Drush command.
Comment #4
markhalliwellActually,
hook_flush_caches()is a no-go since it's invoked during cron runs.Comment #6
markhalliwellComment #7
jose reyero commentedIn the meanwhile I was working on that flush_caches... :-)
I prefer a specific drush command too, but since I had the patch already done, here you are just in case you change your mind or it is some use in the future.
Comment #8
markhalliwellAh, sorry. Figured I could sneak this in given your timezone :D Should have assigned to myself.
No,
hook_flush_caches()can never be used for this because it is invoked when cron runs (which can be 5 minutes or every minute on some sites). This would defeat the whole point of caching a container in the first place.The appropriate hook that should be used to invalidate the container on a cache clear is
hook_registry_files_alter().Comment #9
markhalliwellComment #10
jose reyero commentedSeen what you've finally comitted, looks ok but... I think we still need some drush command on top of that, here's why:
In the case the cointainer is actually broken, like when you get a missing service exception, backport_drupal_kernel() won't return any kernel at all which means we are not rebuilding anything. And this is exactly what happened to me between module versions, I'm already building some stuff on top of this....
So I think we still need some way to recover from a broken container / kernel, which was the purpose of that drush command. Anyway, never mind, I'll come back with a new patch because I think we'll be better off with an actual drush cr -for which I'll try some hook_drush_command_alter, to make it work for D7.
I guess I am not the only one continuously switching from d7 to d8 for several projects and writing 'drush cr' all the time in D7 too just to get some error...
(I'll create a new task for it if you don't mind).
Comment #11
markhalliwellBackporting the
drush crcommand would be far more preferable than implementing a custom command, yes.That being said, I would still argue that
drush crshould simply invoke whatdrush cc alldoes. Or rather, just proxy to thecache-clearcommand.Since this is only invoked when
registry_rebuild()is invoked, perhaps we should add an "else" block that does a complete rebuild when the kernel cannot be loaded.Comment #12
markhalliwellActually, this is the proper title
Comment #13
markhalliwellI'll let you work on this if you want, I'm working on some other things ATM.
Comment #16
markhalliwell