Commit 8290784f authored by generalredneck's avatar generalredneck

[#1853554] Added functionality to delete a node title index on node delete.

parent fe5a7557
......@@ -84,11 +84,21 @@ function views_natural_sort_node_update($node) {
_views_natural_sort_store_node($node);
}
/**
* Implementation of hook_node_delete().
*
* This keep sour natural sort index clean.
*/
function views_natural_sort_node_delete($node) {
_views_natural_sort_remove_node($node);
}
/**
* Helper function for writing node data to our sort index.
*
* @param $node
* A drupal node object containing at least a nid and title.
*
* @return int
* MergeQuery::STATUS_UPDATE or MergeQuery::STATUS_INSERT
*/
......@@ -106,6 +116,21 @@ function _views_natural_sort_store_node($node) {
->execute();
}
/**
* Helper function for removing node data from our sort index.
*
* @param $node
* A drupal node object containing at least a nid.
*
* @return int
* The number of rows deleted.
*/
function _views_natural_sort_remove_node($node) {
return db_delete('views_natural_sort')
->condition('nid', $node->nid)
->execute();
}
/**
* Encodes a string into an ascii-sortable such:
* - Leading articles in common languages are ingored: The A An El La Le Il
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment