Commit ec9f9b5e authored by catch's avatar catch

Issue #1799218 by ACF, Albert Volkman, anenkov, penyaskito, znerol, LinL:...

Issue #1799218 by ACF, Albert Volkman, anenkov, penyaskito, znerol, LinL: Convert taxonomy_override_selector() and taxonomy_terms_per_page_admin() variables to use configuration system.
parent 380cdbc6
......@@ -455,7 +455,7 @@ function hook_field_presave($entity_type, $entity, $field, $instance, $langcode,
* @see hook_field_delete()
*/
function hook_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
if (variable_get('taxonomy_maintain_index_table', TRUE) && $field['storage']['type'] == 'field_sql_storage' && $entity_type == 'node' && $entity->status) {
if (config('taxonomy.settings')->get('maintain_index_table') && $field['storage']['type'] == 'field_sql_storage' && $entity_type == 'node' && $entity->status) {
$query = db_insert('taxonomy_index')->fields(array('nid', 'tid', 'sticky', 'created', ));
foreach ($items as $item) {
$query->values(array(
......@@ -496,7 +496,7 @@ function hook_field_insert($entity_type, $entity, $field, $instance, $langcode,
* @see hook_field_delete()
*/
function hook_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) {
if (variable_get('taxonomy_maintain_index_table', TRUE) && $field['storage']['type'] == 'field_sql_storage' && $entity_type == 'node') {
if (config('taxonomy.settings')->get('maintain_index_table') && $field['storage']['type'] == 'field_sql_storage' && $entity_type == 'node') {
$first_call = &drupal_static(__FUNCTION__, array());
// We don't maintain data for old revisions, so clear all previous values
......
......@@ -85,6 +85,12 @@ public function testVariableUpgrade() {
'protocols.3' => 'mailto',
);
$expected_config['taxonomy.settings'] = array(
'override_selector' => '1',
'terms_per_page_count' => '32',
'maintain_index_table' => '0',
);
$expected_config['filter.settings'] = array(
'fallback_format' => 'plain_text'
);
......
......@@ -95,6 +95,18 @@
'name' => 'user_cancel_method',
'value' => 's:20:"user_cancel_reassign"',
))
->values(array(
'name' => 'taxonomy_override_selector',
'value' => 'i:1;',
))
->values(array(
'name' => 'taxonomy_terms_per_page_admin',
'value' => 'i:32;',
))
->values(array(
'name' => 'taxonomy_maintain_index_table',
'value' => 'i:0;',
))
->values(array(
'name' => 'filter_allowed_protocols',
'value' => 'a:4:{i:0;s:4:"http";i:1;s:5:"https";i:2;s:3:"ftp";i:3;s:6:"mailto";}',
......@@ -121,4 +133,3 @@
->fields(array('value' => 's:10:"plain_text";'))
->condition('name', 'filter_fallback_format')
->execute();
maintain_index_table: '1'
override_selector: '0'
terms_per_page_admin: '100'
......@@ -63,11 +63,11 @@ public function form(array $form, array &$form_state, EntityInterface $term) {
'#weight' => 10,
);
// taxonomy_get_tree and taxonomy_term_load_parents may contain large numbers of
// items so we check for taxonomy_override_selector before loading the
// full vocabulary. Contrib modules can then intercept before
// hook_form_alter to provide scalable alternatives.
if (!variable_get('taxonomy_override_selector', FALSE)) {
// taxonomy_get_tree and taxonomy_term_load_parents may contain large
// numbers of items so we check for taxonomy.settings:override_selector
// before loading the full vocabulary. Contrib modules can then intercept
// before hook_form_alter to provide scalable alternatives.
if (!config('taxonomy.settings')->get('override_selector')) {
$parent = array_keys(taxonomy_term_load_parents($term->tid));
$children = taxonomy_get_tree($vocabulary->vid, $term->tid);
......
......@@ -151,7 +151,7 @@ function taxonomy_overview_terms($form, &$form_state, Vocabulary $vocabulary) {
$form['#parent_fields'] = FALSE;
$page = isset($_GET['page']) ? $_GET['page'] : 0;
$page_increment = variable_get('taxonomy_terms_per_page_admin', 100); // Number of terms per page.
$page_increment = config('taxonomy.settings')->get('terms_per_page_admin'); // Number of terms per page.
$page_entries = 0; // Elements shown on this page.
$before_entries = 0; // Elements at the root level before this page.
$after_entries = 0; // Elements at the root level after this page.
......
......@@ -9,9 +9,6 @@
* Implements hook_uninstall().
*/
function taxonomy_uninstall() {
// Remove variables.
variable_del('taxonomy_override_selector');
variable_del('taxonomy_terms_per_page_admin');
// Remove taxonomy_term bundles.
$vocabularies = db_query("SELECT machine_name FROM {taxonomy_vocabulary}")->fetchCol();
foreach ($vocabularies as $vocabulary) {
......@@ -349,3 +346,15 @@ function taxonomy_update_8003(&$sandbox) {
$sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
}
/**
* Moves taxonomy settings from variable to config.
*/
function taxonomy_update_8004() {
update_variables_to_config('taxonomy.settings', array(
'taxonomy_override_selector' => 'override_selector',
'taxonomy_terms_per_page_admin' => 'terms_per_page_count',
'taxonomy_maintain_index_table' => 'maintain_index_table',
));
}
......@@ -185,7 +185,7 @@ function taxonomy_field_extra_fields() {
* An array of nids matching the query.
*/
function taxonomy_select_nodes($tid, $pager = TRUE, $limit = FALSE, $order = array('t.sticky' => 'DESC', 't.created' => 'DESC')) {
if (!variable_get('taxonomy_maintain_index_table', TRUE)) {
if (!config('taxonomy.settings')->get('maintain_index_table')) {
return array();
}
$query = db_select('taxonomy_index', 't');
......@@ -1390,8 +1390,8 @@ function taxonomy_rdf_mapping() {
* published nodes and common sort criteria such as sticky and created.
* This is used as a lookup table by taxonomy_select_nodes(). When using other
* field storage engines or alternative methods of denormalizing this data
* you should set the variable 'taxonomy_maintain_index_table' to FALSE
* to avoid unnecessary writes in SQL.
* you should set the taxonomy.settings:maintain_index_table to '0' to avoid
* unnecessary writes in SQL.
*/
/**
......@@ -1432,7 +1432,7 @@ function taxonomy_build_node_index($node) {
// We maintain a denormalized table of term/node relationships, containing
// only data for current, published nodes.
$status = NULL;
if (variable_get('taxonomy_maintain_index_table', TRUE)) {
if (config('taxonomy.settings')->get('maintain_index_table')) {
// If a node property is not set in the node object when node_save() is
// called, the old value from $node->original is used.
if (!empty($node->original)) {
......@@ -1512,7 +1512,7 @@ function taxonomy_node_predelete(Node $node) {
* The node entity.
*/
function taxonomy_delete_node_index(Node $node) {
if (variable_get('taxonomy_maintain_index_table', TRUE)) {
if (config('taxonomy.settings')->get('maintain_index_table')) {
db_delete('taxonomy_index')->condition('nid', $node->nid)->execute();
}
}
......@@ -1521,7 +1521,7 @@ function taxonomy_delete_node_index(Node $node) {
* Implements hook_taxonomy_term_delete().
*/
function taxonomy_taxonomy_term_delete(Term $term) {
if (variable_get('taxonomy_maintain_index_table', TRUE)) {
if (config('taxonomy.settings')->get('maintain_index_table')) {
// Clean up the {taxonomy_index} table when terms are deleted.
db_delete('taxonomy_index')->condition('tid', $term->tid)->execute();
}
......
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