diff --git a/core/modules/tracker/config/tracker.settings.yml b/core/modules/tracker/config/tracker.settings.yml new file mode 100644 index 0000000..2e8e65f --- /dev/null +++ b/core/modules/tracker/config/tracker.settings.yml @@ -0,0 +1 @@ +batch_size: 1000 diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php index 2706d3b..8db9fd7 100644 --- a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php +++ b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php @@ -214,7 +214,7 @@ class TrackerTest extends WebTestBase { $this->drupalPost('comment/reply/' . $nodes[3]->nid, $comment, t('Save')); // Start indexing backwards from node 3. - variable_set('tracker_index_nid', 3); + config('tracker.settings')->set('index_nid', 3)->save(); // Clear the current tracker tables and rebuild them. db_delete('tracker_node') diff --git a/core/modules/tracker/tracker.install b/core/modules/tracker/tracker.install index 6d2d317..d09307a 100644 --- a/core/modules/tracker/tracker.install +++ b/core/modules/tracker/tracker.install @@ -6,20 +6,12 @@ */ /** - * Implements hook_uninstall(). - */ -function tracker_uninstall() { - variable_del('tracker_index_nid'); - variable_del('tracker_batch_size'); -} - -/** * Implements hook_enable(). */ function tracker_enable() { $max_nid = db_query('SELECT MAX(nid) FROM {node}')->fetchField(); if ($max_nid != 0) { - variable_set('tracker_index_nid', $max_nid); + config('tracker.settings')->set('index_nid', $max_nid)->save(); // To avoid timing out while attempting to do a complete indexing, we // simply call our cron job to remove stale records and begin the process. tracker_cron(); @@ -116,3 +108,23 @@ function tracker_schema() { return $schema; } + +/** + * @defgroup updates-7.x-to-8.x Updates from 7.x to 8.x + * @{ + * Update functions from 7.x to 8.x. + */ + +/** + * Moves tracker settings from variable to config. + */ +function tracker_update_8000() { + update_variables_to_config('tracker.settings', array( + 'tracker_batch_size' => 'batch_size', + )); +} + +/** + * @} End of "defgroup updates-7.x-to-8.x". + * The next series of updates should start at 9000. + */ diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module index dbedf12..4ef3b32 100644 --- a/core/modules/tracker/tracker.module +++ b/core/modules/tracker/tracker.module @@ -79,8 +79,9 @@ function tracker_menu() { * process, 'tracker_index_nid' will be 0. */ function tracker_cron() { - $max_nid = variable_get('tracker_index_nid', 0); - $batch_size = variable_get('tracker_batch_size', 1000); + $config = config('tracker.settings'); + $max_nid = $config->get('index_nid'); + $batch_size = $config->get('batch_size'); if ($max_nid > 0) { $last_nid = FALSE; $result = db_query_range('SELECT nid, uid, status FROM {node} WHERE nid <= :max_nid ORDER BY nid DESC', 0, $batch_size, array(':max_nid' => $max_nid), array('target' => 'slave')); @@ -143,13 +144,13 @@ function tracker_cron() { if ($last_nid !== FALSE) { // Prepare a starting point for the next run. - variable_set('tracker_index_nid', $last_nid - 1); + $config->set('index_nid', $last_nid - 1)->save(); watchdog('tracker', 'Indexed %count content items for tracking.', array('%count' => $count)); } else { // If all nodes have been indexed, set to zero to skip future cron runs. - variable_set('tracker_index_nid', 0); + $config->set('index_nid', 0)->save(); } } }