diff --git a/core/includes/common.inc b/core/includes/common.inc index 0f252ca..e4b5f9c 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -7159,21 +7159,20 @@ function drupal_get_filetransfer_info() { /** * Instantiates and statically caches the correct class for a queue. * - * The following variables can be set by variable_set or $conf overrides: - * - queue_class_$name: The class to be used for the queue $name. - * - queue_default_class: The class to use when queue_class_$name is not - * defined. Defaults to Drupal\Core\Queue\System, a reliable backend using - * SQL. - * - queue_default_reliable_class: The class to use when queue_class_$name is - * not defined and the queue_default_class is not reliable. Defaults to + * The following values can be set by configuration or $conf overrides: + * - class.$name: The class to be used for the queue $name. + * - class.default: The class to use when class.$name is not defined. Defaults + * to Drupal\Core\Queue\System, a reliable backend using SQL. + * - class.default_reliable: The class to use when class.$name is not defined + * and the class.default is not reliable. Defaults to * Drupal\Core\Queue\System. * * @param string $name * The name of the queue to work with. * @param bool $reliable - * TRUE if the ordering of items and guaranteeing every item executes at - * least once is important, FALSE if scalability is the main concern. Defaults - * to FALSE. + * TRUE if the ordering of items and guaranteeing every item executes at least + * once is important, FALSE if scalability is the main concern. Defaults to + * FALSE. * * @return Drupal\Core\Queue\QueueInterface * The queue object for a given name. @@ -7183,13 +7182,16 @@ function drupal_get_filetransfer_info() { function queue($name, $reliable = FALSE) { static $queues; if (!isset($queues[$name])) { - $class = variable_get('queue_class_' . $name, NULL); + $config = config('system.queue'); + $class = $config->get('class.' . $name) ?: NULL; if ($class && $reliable && in_array('Drupal\Core\Queue\ReliableQueueInterface', class_implements($class))) { - $class = variable_get('queue_default_reliable_class', 'Drupal\Core\Queue\System'); + $class = $config->get('class.default_reliable') ?: 'Drupal\Core\Queue\System'; } elseif (!$class) { - $class = variable_get('queue_default_class', 'Drupal\Core\Queue\System'); + $class = $config->get('class.default') ?: 'Drupal\Core\Queue\System'; } + // @todo Should there be a check if $class implements QueryInterface or + // ReliableQueryInterface? $queues[$name] = new $class($name); } return $queues[$name]; diff --git a/core/modules/system/config/system.queue.yml b/core/modules/system/config/system.queue.yml new file mode 100644 index 0000000..87c3b4e --- /dev/null +++ b/core/modules/system/config/system.queue.yml @@ -0,0 +1,3 @@ +class: + default: 'Drupal\Core\Queue\System' + default_reliable: 'Drupal\Core\Queue\System' diff --git a/core/modules/system/system.install b/core/modules/system/system.install index bbd6118..25e53e5 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -2188,6 +2188,27 @@ function system_update_8030() { } /** + * Convert queue variables to configuration system. + * + * @ingroup config_upgrade + */ +function system_update_8031() { + // First, convert the two default class values. + update_variables_to_config('system.queue', array( + 'queue_default_class' => 'class.default', + 'queue_default_reliable_class' => 'class.default_reliable', + )); + // Then, convert any remaining variables in form of 'queue_class_'.$name. + $resource = db_query("SELECT name FROM {variable} WHERE name LIKE 'queue_class_%'"); + while ($data = db_fetch_object($resource)) { + $name = str_replace('queue_class_', '', $data->name); + update_variables_to_config('system.queue', array( + $data->name => 'class.' . $name, + )); + } +} + +/** * @} End of "defgroup updates-7.x-to-8.x". * The next series of updates should start at 9000. */