Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When updating the term hierarchy in admin/structure/taxonomy/ page, it should also invoke the hook_taxonomy_term_update() or any other appropriate hook, therefore, the module can be notified on the hierarchy changes as well.
Comment | File | Size | Author |
---|---|---|---|
#18 | core-notify_hierarchy_update-1591404-18.patch | 601 bytes | MiroslavBanov |
#13 | core-use_taxonomy_term_save-1591404-13.patch | 1.89 KB | Anonymous (not verified) |
#10 | core-use_taxonomy_term_save-1591404-10.patch | 1.86 KB | Anonymous (not verified) |
#9 | core-use_taxonomy_term_save-1591404-9.patch | 1.86 KB | Anonymous (not verified) |
#8 | core-use_taxonomy_term_save-1591404-6.patch | 1.86 KB | Anonymous (not verified) |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedSubscribe
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedpatch is attached. Since the code does not conform to the api, I think this should be a bug report. We should be using taxonomy_term_save() when updating terms, not altering the DB directly.
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedUpdated patch is attached. Since the code does not conform to the api, I think this should be a bug report. We should be using taxonomy_term_save() when updating terms, not altering the DB directly.
Comment #4
apotek CreditAttribution: apotek commentedThis is a good, clean, wholesome move towards leveraging the module's own API, and would enable us module developers to hook into term updates in a much cleaner fashion.
+100 :)
Comment #5
apotek CreditAttribution: apotek commentedHave tested this patch and it works for me.
Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commentedUpdated patch. Previous patch causes this issue: https://drupal.org/node/2016417
Comment #8
Anonymous (not verified) CreditAttribution: Anonymous commentedUpdating patch that failed testing
Comment #9
Anonymous (not verified) CreditAttribution: Anonymous commentedUpdating patch that failed testing
Comment #10
Anonymous (not verified) CreditAttribution: Anonymous commentedUpdating patch that failed testing
Comment #11
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #13
Anonymous (not verified) CreditAttribution: Anonymous commentedUpdated patch attached
Comment #14
apotek CreditAttribution: apotek commentedThis passed three weeks ago. Any reason not to commit?
Comment #15
David_Rothstein CreditAttribution: David_Rothstein commentedThis does definitely seem like the "right" thing to do (and I have had to implement workarounds in the past to get around the fact that this isn't happening), but I think we need to discuss whether we actually should do it in Drupal 7 at this point. There's a possible performance impact on the admin page if tons of terms are going to be saved at once, plus the sudden triggering of hooks on each one of these which didn't happen before could have unexpected effects depending on what those hook implementations are doing. As an extreme example, I have worked on sites that use https://drupal.org/project/deploy to deploy changes to taxonomy terms between sites on save, and it would be unexpected to suddenly deal with 50 or so of those on a single page request.
Also, #1818560: Convert taxonomy entities to the new Entity Field API did this for Drupal 8 (as part of a larger set of changes) and didn't wind up with a @todo, so I'm curious why the implementation in this issue came out so different...
There are some minor code style issues in the patch too, such as:
"else {" should be on its own line, and use @todo - see https://drupal.org/coding-standards
Comment #16
Anonymous (not verified) CreditAttribution: Anonymous commentedThe taxonomy term page already has performance issues. I can't list a vocabulary's terms when the list tops 3000.
Making this change would deliver a complete set of terms modified. Other modules expect the appropriate hooks to be triggered when terms are modified. Changing a term's hierarchy should be captured as a change to a term.
Comment #17
apotek CreditAttribution: apotek commented@David_Rothstein I appreciate your really thoughtful response. It would be interesting if someone could test this patch with deploy or migrate module (any kind of bulk movement of terms). But in the end, this really is the right thing to do. You can't really argue with @SpaJenniOs here.
And a change to a term should trigger some kind of hook/event that can tapped in to.
Now, where we might find some operable middle ground is that maybe a change to a term's hierarchy doesn't necessarily have to trigger a taxonomy_term_save(). Perhaps what should happen is that we create a new hook for the taxonomy module. taxonomy_term_update_hierarchy(). That function could do a module_invoke_all.
Doing it this way would have two benefits:
1. Reduce the impact on existing code since no modules have implemented this new hook yet.
2. Still allow modules to hook into the change to the hierarchy and respond in an appropriately drupally fashion.
The drawback is that we loose the centrality of taxonomy_term_save(), which is, as @SpaJenniOS points out, the "real" place where term changes should be channeled and worked with.
Comment #18
MiroslavBanov CreditAttribution: MiroslavBanov commentedHere is the other approach - to invoke a different hook so other modules can react to the hierarchy change.