Commit 1bc53594 authored by xjm's avatar xjm
Browse files

Issue #2484667 by joshi.rohit100, Berdir: Do not run query in node_cron() if...

Issue #2484667 by joshi.rohit100, Berdir: Do not run query in node_cron() if search.module is not enabled
parent 608f81bf
...@@ -622,19 +622,21 @@ function node_cron() { ...@@ -622,19 +622,21 @@ function node_cron() {
// Calculate the oldest and newest node created times, for use in search // Calculate the oldest and newest node created times, for use in search
// rankings. (Note that field aliases have to be variables passed by // rankings. (Note that field aliases have to be variables passed by
// reference.) // reference.)
$min_alias = 'min_created'; if (\Drupal::moduleHandler()->moduleExists('search')) {
$max_alias = 'max_created'; $min_alias = 'min_created';
$result = \Drupal::entityQueryAggregate('node') $max_alias = 'max_created';
->aggregate('created', 'MIN', NULL, $min_alias) $result = \Drupal::entityQueryAggregate('node')
->aggregate('created', 'MAX', NULL, $max_alias) ->aggregate('created', 'MIN', NULL, $min_alias)
->execute(); ->aggregate('created', 'MAX', NULL, $max_alias)
if (isset($result[0])) { ->execute();
// Make an array with definite keys and store it in the state system. if (isset($result[0])) {
$array = array( // Make an array with definite keys and store it in the state system.
'min_created' => $result[0][$min_alias], $array = array(
'max_created' => $result[0][$max_alias], 'min_created' => $result[0][$min_alias],
); 'max_created' => $result[0][$max_alias],
\Drupal::state()->set('node.min_max_update_time', $array); );
\Drupal::state()->set('node.min_max_update_time', $array);
}
} }
} }
......
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