register_shutdown_function()分配了一个函数,在为一个请求执行完PHP脚本以后将执行这个函数。因为在索引完所有的内容以前,PHP可能会终止运行,所以使用这个函数来追踪最后索引项目的ID。
/**
* Shutdown function to make sure we remember the last element processed.
*/
function legacysearch_update_shutdown() {
global $last_change, $last_id;
if ($last_change && $last_id) {
variable_set('legacysearch_cron_last', $last_change);
variable_set('legacysearch_cron_last_id', $last_id);
}
}
老葛的Drupal培训班 Think in Drupal
评论
官方勘误:
官方勘误: http://www.drupalbook.com/errata2?page=6 Page 306
variable_set('legacysearch_cron_last', $last_change);
variable_set('legacysearch_cron_last_change', $last_change);