Skip to content
Snippets Groups Projects
Commit 0ae39120 authored by Neil Drumm's avatar Neil Drumm :wave:
Browse files

#31874 by David Lesieur. Call taxonomy hook for insert and update after the term is fully saved.

parent f4e1c078
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -427,7 +427,7 @@ function taxonomy_form_term_submit($form_id, $form_values) { ...@@ -427,7 +427,7 @@ function taxonomy_form_term_submit($form_id, $form_values) {
function taxonomy_save_term(&$edit) { function taxonomy_save_term(&$edit) {
if ($edit['tid'] && $edit['name']) { if ($edit['tid'] && $edit['name']) {
db_query("UPDATE {term_data} SET name = '%s', description = '%s', weight = %d WHERE tid = %d", $edit['name'], $edit['description'], $edit['weight'], $edit['tid']); db_query("UPDATE {term_data} SET name = '%s', description = '%s', weight = %d WHERE tid = %d", $edit['name'], $edit['description'], $edit['weight'], $edit['tid']);
module_invoke_all('taxonomy', 'update', 'term', $edit); $hook = 'update';
$status = SAVED_UPDATED; $status = SAVED_UPDATED;
} }
else if ($edit['tid']) { else if ($edit['tid']) {
...@@ -436,7 +436,7 @@ function taxonomy_save_term(&$edit) { ...@@ -436,7 +436,7 @@ function taxonomy_save_term(&$edit) {
else { else {
$edit['tid'] = db_next_id('{term_data}_tid'); $edit['tid'] = db_next_id('{term_data}_tid');
db_query("INSERT INTO {term_data} (tid, name, description, vid, weight) VALUES (%d, '%s', '%s', %d, %d)", $edit['tid'], $edit['name'], $edit['description'], $edit['vid'], $edit['weight']); db_query("INSERT INTO {term_data} (tid, name, description, vid, weight) VALUES (%d, '%s', '%s', %d, %d)", $edit['tid'], $edit['name'], $edit['description'], $edit['vid'], $edit['weight']);
module_invoke_all('taxonomy', 'insert', 'term', $edit); $hook = 'insert';
$status = SAVED_NEW; $status = SAVED_NEW;
} }
...@@ -478,6 +478,10 @@ function taxonomy_save_term(&$edit) { ...@@ -478,6 +478,10 @@ function taxonomy_save_term(&$edit) {
} }
} }
if (isset($hook)) {
module_invoke_all('taxonomy', $hook, 'term', $edit);
}
cache_clear_all(); cache_clear_all();
return $status; return $status;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment