function apachesolr_user_update in Apache Solr Search 8
Same name and namespace in other branches
- 7 apachesolr.module \apachesolr_user_update()
Implements hook_user_update().
Mark nodes as needing re-indexing if the author name changes.
Performance issue with Mysql To know why PDO in drupal does not support UPDATE and JOIN at once.
See also
http://api.drupal.org/api/drupal/includes--database--database.inc/functi...
File
- ./
apachesolr.module, line 626 - Integration with the Apache Solr search application.
Code
function apachesolr_user_update(&$edit, $account, $category) {
if (isset($account->name) && isset($account->original) && isset($account->original->name) && $account->name != $account->original->name) {
$table = apachesolr_get_indexer_table('node');
switch (db_driver()) {
case 'mysql':
$table = db_escape_table($table);
$query = "UPDATE {{$table}} asn\n INNER JOIN {node} n ON asn.entity_id = n.nid SET asn.changed = :changed\n WHERE n.uid = :uid";
$result = db_query($query, array(
':changed' => REQUEST_TIME,
':uid' => $account->uid,
));
break;
default:
$nids = db_select('node')
->fields('node', array(
'nid',
))
->where("uid = :uid", array(
':uid' => $account->uid,
));
$update = db_update($table)
->condition('entity_id', $nids, 'IN')
->fields(array(
'changed' => REQUEST_TIME,
))
->execute();
}
}
}