When moving terms to new parents, we should invoke taxonomy_term_save instead of directly updating the database.

Patch to follow

CommentFileSizeAuthor
#5 taxonomy_manager-update_taxonomy_manager_move-1986420-1.patch1.6 KBAnonymous (not verified)
#1 taxonomy_manager-update_taxonomy_manager_move-1986420-1.patch1.6 KBAnonymous (not verified)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

Anonymous’s picture

Assigned: » Unassigned
apotek’s picture

This is a good point. A move operation currently doesn't allow any other module to hook into it. The two ways to deal with this as far as I can see, is to do what @SpaJenniOs is suggesting in her patch, which, by calling taxonomy_term_save(), will call all the following hooks:

...
  module_invoke_all('taxonomy_term_presave', $term);
  module_invoke_all('entity_presave', $term, 'taxonomy_term');
...
  module_invoke_all("taxonomy_term_$op", $term); // save, delete, etc etc.
  module_invoke_all("entity_$op", $term, 'taxonomy_term');

which would allow other modules to interact with the move operation.

The other option is to modify the move function by making it create its own hooks that other modules can hook into, ie, put something like this in the function:

module_invoke_all("taxonomy_manager_move", $parents, $children, $options);

I think SpaJenniOs's solution is the preferable one since it relies on the taxonomy module's code and doesn't create a new hook, but if there is a reason taxonomy_term_save cannot be used, creating a hook for other module developers to use will work too.

@SpaJenniOs: If you roll this patch against the dev branch instead, I think you can get your patch into the testing bot.

Anonymous’s picture

Version: 7.x-1.0-rc2 » 7.x-1.x-dev
Anonymous’s picture

mh86’s picture

Status: Needs review » Fixed

Committed a slightly adapted version of #5. See http://drupalcode.org/project/taxonomy_manager.git/commitdiff/505c6eb

Thanks a lot for the patch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.