Why are the hook_taxonomy_term_insert() and hook_taxonomy_term_update() hooks used in stead of hook_taxonomy_term_presave()? The taxonomy_term_save() function uses drupal_write_record() so it should work. And this way we have a db query less each time a term is saved...

Comments

Jelle_S created an issue. See original summary.

jmsosso’s picture

I also think it's better as @Jelle_S says. Here is the code:

function taxonomy_creation_date_taxonomy_term_presave($term) {
  $term->changed = REQUEST_TIME;
  if (empty($term->created)) {
    $term->created = REQUEST_TIME;
  }
}

Best regards.

StoraH’s picture

I agree. @jmsosso created a patch with the code.

osopolar’s picture

The function taxonomy_creation_date_taxonomy_term_update() could also be removed, as hook_taxonomy_term_presave() will work for both, insert and update.

bofrost’s picture

Status: Active » Fixed

I am not sure of the reason for the separate hooks. Maybe there was none ^^
Thanks for providing the patch, it is included in version 7.x.1.2 of the module.

  • bofrost committed f42c6e7 on 7.x-1.x
    Issue #2566181 by StoraH, jmsosso: Reduce db queries
    

Status: Fixed » Closed (fixed)

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