This is an inofficial follow-up of #319346: blogapi_mt_set_post_categories() allows assigning arbitrary categories to posts regardless of taxonomy settings.
It wasn't possible in D6 and below, but we should now be able to use the taxonomy load_multiple functions instead of doing arbitrary queries in the validate function, atleast with a few tweaks to those functions :)
What this patch contains:
1. Re-introduce the tests that weren't commited in #319346: blogapi_mt_set_post_categories() allows assigning arbitrary categories to posts regardless of taxonomy settings
2. Add the same node type handling to taxonomy_term_load_multiple() that is already in taxonomy_vocabulary_load_multiple()
3. Use a inner join if a type is specified in taxonomy_vocabulary_load_multiple (I am not 100% sure, but using leftJoin doesn't make sense to me for that)
4. Add term_access tags to both load functions.. not sure, do we need a different tag for vocabulary?
5. use taxonomy_*_load_multiple() functions in blogapi_mt_validate_terms()
catch and I discussed if we should create a general taxonomy validation function for that stuff, but I'm not sure how to do the validation error handling. Any ideas?
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | blogapi.use_taxonomy_api-474072-17.patch | 9.51 KB | jrchamp |
| #14 | blogapi.use_taxonomy_api-474072-14.patch | 9.5 KB | jrchamp |
| #12 | blogapi.use_taxonomy_api3.patch | 9.95 KB | berdir |
| #10 | blogapi.use_taxonomy_api2.patch | 10.21 KB | berdir |
| blogapi.use_taxonomy_api.patch | 11.75 KB | berdir |
Comments
Comment #1
catchSubscribing. Not sure if vocabularies should have a different tag or not. Since we already do the node type join for vocabularies it doesn't seem too bad adding it for terms too - certainly a lot nicer than blogapi querying directly.
Comment #2
catchAlso, this code will have to change drastically if and when #412518: Convert taxonomy_node_* related code to use field API + upgrade path gets in. Long term that's going to be the way to remove special casing of nodes in taxonomy.module, but while we've got it, might as well have it centralised.
Comment #3
berdirTagging with the dbtng conversion tag. it's not actually a dbtng conversion, but it is imho the proper way to get rid of another two db_rewrite_sql calls :)
The problem imho is that hook_node_validate() implementations do use form_set_error to set the errors, so these aren't catched when saving a node with blogapi. If there would be a generic way to do it, we could move the validation to taxonomy_node_validate and then just display the error in blogapi.module
Comment #4
catchTook another look at this and I'm happy. Marking RTBC.
Comment #5
jrchamp commentedA delightful side note is that this appears to kill off the last use of the db_placeholders in core which "is deprecated in Drupal 7 and will be removed as soon as it is expunged from core".
Comment #6
catch1 function calls db_placeholders. Very nice.
Comment #8
berdirRe-setting status.
Comment #9
berdirUps, that wasn't a testbot error, I have to re-roll.
Comment #10
berdirOk, updated, changes.
- used taxonomy api functions for updating a vocabulary in the tests
- used vocabulary_access in vocabulary_load_multiple. term_access will break things I think.
Comment #11
jrchamp commentedYou calculate the array_unique($node->taxonomy) twice.
Would it be better to simply do:
and:
Comment #12
berdirGood catch, re-rolled.
Comment #14
jrchamp commentedRe-rolled. It appears someone removed the drupalLogin($web_user) call, which the patch from #12 also removed.
Comment #15
berdirThis was RTBC already and there were only minor changes since then..
Comment #16
catchHate to do this but:
Could use a line break before those inline comments to make the test code less dense.
Comment #17
jrchamp commentedRerolled with spacing change request from #16.
Comment #18
catchlovely.
Comment #19
dries commentedCommitted to CVS HEAD. Thanks!