If you're in database 1, which has vocabs A, B, and C, and then you switch to database 2, which has vocabs E, F, and G, modules expecting to find vocabs E, F, and G are going to be mighty surprised when they get A, B, and C back.
This patch adds the ability to reset this function's static variable cache.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | vocabulary_static_reset.patch | 2.54 KB | catch |
| #7 | vocabulary_static_reset.patch | 2.48 KB | catch |
| #6 | vocabulary_static_reset.patch | 5.68 KB | catch |
| #5 | vocabulary_static_reset.patch | 5.71 KB | catch |
| #1 | taxonomy-reset-vocabulary-cache-296910-1.patch | 932 bytes | webchick |
Comments
Comment #1
webchickComment #2
moshe weitzman commentedany chance you can add same for taxonomy_get_tree?
Comment #3
dries commentedWhere is the test case? :)
Comment #4
webchickDag nabbit. ;) I also should document the new parameter. I was in a hurry.
I actually don't know how to write a test case for this. :( The only thing I can think is to do a db_set_active to the parent Drupal site, add some terms there, then db_set_active() back to the test instance's database and add some terms there, and make sure the ones I get back are the proper ones. But currently, all of our test runs are isolated from the main database and I don't really want to break that rule. And I'm not sure otherwise how to get at that static $vocabularies variable in order to verify that it's been reset when I ask it to.
Any ideas?
Comment #5
catchHere's an updated patch and test for this. Patch includes fixes to #244662: Vocabulary load returns NULL as well because these will both be in the taxonomy_vocabulary_load() test case. I'll re-roll when that gets in.
We may want to add this reset into taxonomy_save_vocabulary() - but if we do that then I can't use it as easily for the test ;) - remove the TRUE argument from taxonomy_vocabulary_load to reproduce the bug. iirc, there's other issues with taxonomy_save_vocabulary() - so I might want to leave changes there for (yet another) followup patch.
Comment #6
catchNow that #244662: Vocabulary load returns NULL is in, here's an updated patch for the $reset. Since forum.test contains hacks to avoid failing without this, I'm marking as critical. forum.test cleanups will be attached to a new issue per webchick's request on the previous one shortly.
Comment #7
catchAnd the right patch.
Comment #8
catchOnly reset the cache for the vid that's being loaded. All taxonomy tests pass.
Comment #9
damien tournoud commentedThis looks really great. And that static is blocking me from writing a test for #277200: Add tests for vocabulary hierarchy.
Comment #10
webchickCommitted. Thanks!
Comment #11
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.