I think it would be beneficial to have a hook_alter in the ajax callback, so that other modules can tap into the fact that the weight has been updated.

For example, if you are uisng third party storage (let's say, SOLR and search_api), you would want to reindex the node when the weight is changed. On other weight_set_weight calls, you already have hooks that can tap into the data (node insert & update), but for the ajax, we currently have no way for other modules to know about the weight change.

Will apply patch and an example of usage in a short while.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

thehideki’s picture

EDIT: Edited the usage for actual Search Api integration

Example usage:

function HOOK_weight_set_ajax_alter(&$node) {
  if (module_exists('search_api') {
    // mark as dirty
    $conditions = array(
      'enabled' => 1,
      'item_type' => 'node',
      'read_only' => 0,
    );
    $indexes = search_api_index_load_multiple(FALSE, $conditions);
    if (!$indexes) {
      return;
    }
    search_api_get_datasource_controller('node')->trackItemChange(array($node->nid), $indexes);
  }
}
thehideki’s picture

  • davisben committed 3000437 on 7.x-2.x authored by thehideki
    Issue #2313817 by thehideki: Add hook_alter to weight_set_ajax().
    
davisben’s picture

Status: Active » Fixed

Committed. Thanks for the patch!

Status: Fixed » Closed (fixed)

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