diff --git a/core/includes/errors.inc b/core/includes/errors.inc index 0524170..12d773a 100644 --- a/core/includes/errors.inc +++ b/core/includes/errors.inc @@ -163,7 +163,7 @@ function _drupal_render_exception_safe($exception) { * TRUE if an error should be displayed. */ function error_displayable($error = NULL) { - $error_level = variable_get('error_level', ERROR_REPORTING_DISPLAY_ALL); + $error_level = config('system.logging')->get('error_level'); $updating = (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update'); $all_errors_displayed = ($error_level == ERROR_REPORTING_DISPLAY_ALL); $error_needs_display = ($error_level == ERROR_REPORTING_DISPLAY_SOME && diff --git a/core/modules/dblog/config/dblog.logging.xml b/core/modules/dblog/config/dblog.logging.xml new file mode 100644 index 0000000..973f8d2 --- /dev/null +++ b/core/modules/dblog/config/dblog.logging.xml @@ -0,0 +1,4 @@ + + + 1000 + diff --git a/core/modules/dblog/dblog.install b/core/modules/dblog/dblog.install index 23f85ba..df14f32 100644 --- a/core/modules/dblog/dblog.install +++ b/core/modules/dblog/dblog.install @@ -92,8 +92,20 @@ function dblog_schema() { } /** - * Implements hook_uninstall(). + * @defgroup updates-7.x-to-8.x Updates from 7.x to 8.x + * @{ + * Update functions from 7.x to 8.x. */ -function dblog_uninstall() { - variable_del('dblog_row_limit'); + +/** + * Update settings to the new configuration system. + **/ +function dblog_update_8000() { + config_install_default_config('dblog'); + update_variables_to_config('dblog.logging'); } + +/** + * @} End of "defgroup updates-7.x-to-8.x" + * The next series of updates should start at 9000. + */ diff --git a/core/modules/dblog/dblog.module b/core/modules/dblog/dblog.module index a43e0a5..5294daf 100644 --- a/core/modules/dblog/dblog.module +++ b/core/modules/dblog/dblog.module @@ -102,7 +102,7 @@ function dblog_init() { */ function dblog_cron() { // Cleanup the watchdog table. - $row_limit = variable_get('dblog_row_limit', 1000); + $row_limit = config('dblog.logging')->get('dblog_row_limit'); // For row limit n, get the wid of the nth row in descending wid order. // Counting the most recent n rows avoids issues with wid number sequences, @@ -163,11 +163,24 @@ function dblog_form_system_logging_settings_alter(&$form, $form_state) { $form['dblog_row_limit'] = array( '#type' => 'select', '#title' => t('Database log messages to keep'), - '#default_value' => variable_get('dblog_row_limit', 1000), + '#default_value' => config('dblog.logging')->get('dblog_row_limit'), '#options' => array(0 => t('All')) + drupal_map_assoc(array(100, 1000, 10000, 100000, 1000000)), '#description' => t('The maximum number of messages to keep in the database log. Requires a cron maintenance task.', array('@cron' => url('admin/reports/status'))) ); $form['actions']['#weight'] = 1; + + $form['#submit'][] = 'dblog_logging_settings_submit'; +} + +/** + * Form submission handler for dblog logging settings. + * + * @ingroup forms + */ +function dblog_logging_settings_submit($form, &$form_state) { + config('dblog.logging') + ->set('dblog_row_limit', $form_state['values']['dblog_row_limit']) + ->save(); } /** diff --git a/core/modules/dblog/dblog.test b/core/modules/dblog/dblog.test index 92763c1..81ac5ee 100644 --- a/core/modules/dblog/dblog.test +++ b/core/modules/dblog/dblog.test @@ -63,11 +63,8 @@ class DBLogTestCase extends WebTestBase { $this->assertResponse(200); // Check row limit variable. - $current_limit = variable_get('dblog_row_limit', 1000); + $current_limit = config('dblog.logging')->get('dblog_row_limit'); $this->assertTrue($current_limit == $row_limit, t('[Cache] Row limit variable of @count equals row limit of @limit', array('@count' => $current_limit, '@limit' => $row_limit))); - // Verify dblog row limit equals specified row limit. - $current_limit = unserialize(db_query("SELECT value FROM {variable} WHERE name = :dblog_limit", array(':dblog_limit' => 'dblog_row_limit'))->fetchField()); - $this->assertTrue($current_limit == $row_limit, t('[Variable table] Row limit variable of @count equals row limit of @limit', array('@count' => $current_limit, '@limit' => $row_limit))); } /** diff --git a/core/modules/entity/tests/entity.test b/core/modules/entity/tests/entity.test index 1047279..b35fefa 100644 --- a/core/modules/entity/tests/entity.test +++ b/core/modules/entity/tests/entity.test @@ -105,7 +105,7 @@ class EntityTranslationTestCase extends WebTestBase { } function setUp() { - parent::setUp('entity_test', 'language', 'locale'); + parent::setUp('entity_test', 'locale'); // Enable translations for the test entity type. variable_set('entity_test_translation', TRUE); diff --git a/core/modules/field/modules/text/text.test b/core/modules/field/modules/text/text.test index a41e8cd..2c0801a 100644 --- a/core/modules/field/modules/text/text.test +++ b/core/modules/field/modules/text/text.test @@ -422,7 +422,7 @@ class TextTranslationTestCase extends WebTestBase { } function setUp() { - parent::setUp('locale', 'translation'); + parent::setUp('translation'); $full_html_format = filter_format_load('full_html'); $this->format = $full_html_format->format; diff --git a/core/modules/language/language.test b/core/modules/language/language.test index d48f2a9..b58365c 100644 --- a/core/modules/language/language.test +++ b/core/modules/language/language.test @@ -560,7 +560,6 @@ class LanguageUILanguageNegotiationTestCase extends WebTestBase { // is about the negotiation process which is solely in language module. parent::setUp(array('locale', 'language_test', 'block')); require_once DRUPAL_ROOT . '/core/includes/language.inc'; - drupal_load('module', 'locale'); $admin_user = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages', 'administer blocks')); $this->drupalLogin($admin_user); } diff --git a/core/modules/path/path.test b/core/modules/path/path.test index c742ad5..968f68a 100644 --- a/core/modules/path/path.test +++ b/core/modules/path/path.test @@ -312,7 +312,7 @@ class PathLanguageTestCase extends PathTestCase { } function setUp() { - parent::setUp('path', 'locale', 'translation'); + parent::setUp('path', 'translation'); // Create and login user. $this->web_user = $this->drupalCreateUser(array('edit any page content', 'create page content', 'administer url aliases', 'create url aliases', 'administer languages', 'translate content', 'access administration pages')); @@ -455,7 +455,7 @@ class PathLanguageUITestCase extends PathTestCase { } function setUp() { - parent::setUp('path', 'locale'); + parent::setUp('path', 'language'); // Create and login user. $web_user = $this->drupalCreateUser(array('edit any page content', 'create page content', 'administer url aliases', 'create url aliases', 'administer languages', 'access administration pages')); diff --git a/core/modules/search/search.test b/core/modules/search/search.test index 619055c..ca7b128 100644 --- a/core/modules/search/search.test +++ b/core/modules/search/search.test @@ -1963,7 +1963,7 @@ class SearchLanguageTestCase extends SearchWebTestCase { } function setUp() { - parent::setUp(array('locale')); + parent::setUp(array('language')); // Create and login user. $test_user = $this->drupalCreateUser(array('access content', 'search content', 'use advanced search', 'administer nodes', 'administer languages', 'access administration pages')); diff --git a/core/modules/syslog/config/syslog.logging.xml b/core/modules/syslog/config/syslog.logging.xml new file mode 100644 index 0000000..a31eada --- /dev/null +++ b/core/modules/syslog/config/syslog.logging.xml @@ -0,0 +1,6 @@ + + + drupal + !base_url|!timestamp|!type|!ip|!request_uri|!referer|!uid|!link|!message + + diff --git a/core/modules/syslog/syslog.install b/core/modules/syslog/syslog.install index 12ff4fb..1cd7a08 100644 --- a/core/modules/syslog/syslog.install +++ b/core/modules/syslog/syslog.install @@ -6,10 +6,39 @@ */ /** - * Implements hook_uninstall(). + * Implements hook_install(). */ -function syslog_uninstall() { - variable_del('syslog_identity'); - variable_del('syslog_facility'); - variable_del('syslog_format'); +function syslog_install() { + // The default facility setting depends on the operating system, so it needs + // to be set dynamically during installation. + config('syslog.logging') + ->set('syslog_facility', defined('LOG_LOCAL0') ? LOG_LOCAL0 : LOG_USER) + ->save(); } + +/** + * @defgroup updates-7.x-to-8.x Updates from 7.x to 8.x + * @{ + * Update functions from 7.x to 8.x. + */ + +/** + * Update settings to the new configuration system. + **/ +function syslog_update_8000() { + config_install_default_config('syslog'); + update_variables_to_config('syslog.logging'); + $config = config('syslog.logging'); + // The default facility setting depends on the operating system, so it needs + // to be set dynamically during update if no value is found. + if ($config->get('syslog_facility') === '') { + $config + ->set('syslog_facility', defined('LOG_LOCAL0') ? LOG_LOCAL0 : LOG_USER) + ->save(); + } +} + +/** + * @} End of "defgroup updates-7.x-to-8.x" + * The next series of updates should start at 9000. + */ diff --git a/core/modules/syslog/syslog.module b/core/modules/syslog/syslog.module index 1327606..7907d5e 100644 --- a/core/modules/syslog/syslog.module +++ b/core/modules/syslog/syslog.module @@ -45,18 +45,19 @@ function syslog_help($path, $arg) { * Implements hook_form_FORM_ID_alter(). */ function syslog_form_system_logging_settings_alter(&$form, &$form_state) { + $config = config('syslog.logging'); $help = module_exists('help') ? ' ' . l(t('More information'), 'admin/help/syslog') . '.' : NULL; $form['syslog_identity'] = array( '#type' => 'textfield', '#title' => t('Syslog identity'), - '#default_value' => variable_get('syslog_identity', 'drupal'), + '#default_value' => $config->get('syslog_identity'), '#description' => t('A string that will be prepended to every message logged to Syslog. If you have multiple sites logging to the same Syslog log file, a unique identity per site makes it easy to tell the log entries apart.') . $help, ); if (defined('LOG_LOCAL0')) { $form['syslog_facility'] = array( '#type' => 'select', '#title' => t('Syslog facility'), - '#default_value' => variable_get('syslog_facility', LOG_LOCAL0), + '#default_value' => $config->get('syslog_facility'), '#options' => syslog_facility_list(), '#description' => t('Depending on the system configuration, Syslog and other logging tools use this code to identify or filter messages from within the entire system log.') . $help, ); @@ -64,10 +65,25 @@ function syslog_form_system_logging_settings_alter(&$form, &$form_state) { $form['syslog_format'] = array( '#type' => 'textarea', '#title' => t('Syslog format'), - '#default_value' => variable_get('syslog_format', '!base_url|!timestamp|!type|!ip|!request_uri|!referer|!uid|!link|!message'), + '#default_value' => $config->get('syslog_format'), '#description' => t('Specify the format of the syslog entry. Available variables are:
!base_url
Base URL of the site.
!timestamp
Unix timestamp of the log entry.
!type
The category to which this message belongs.
!ip
IP address of the user triggering the message.
!request_uri
The requested URI.
!referer
HTTP Referer if available.
!uid
User ID.
!link
A link to associate with the message.
!message
The message to store in the log.
'), ); $form['actions']['#weight'] = 1; + + $form['#submit'][] = 'syslog_logging_settings_submit'; +} + +/** + * Form submission handler for logging settings. + * + * @ingroup forms + */ +function syslog_logging_settings_submit($form, &$form_state) { + config('syslog.logging') + ->set('syslog_identity', $form_state['values']['syslog_identity']) + ->set('syslog_facility', $form_state['values']['syslog_facility']) + ->set('syslog_format', $form_state['values']['syslog_format']) + ->save(); } /** @@ -95,14 +111,14 @@ function syslog_watchdog(array $log_entry) { global $base_url; $log_init = &drupal_static(__FUNCTION__, FALSE); + $config = config('syslog.logging'); if (!$log_init) { $log_init = TRUE; - $default_facility = defined('LOG_LOCAL0') ? LOG_LOCAL0 : LOG_USER; - openlog(variable_get('syslog_identity', 'drupal'), LOG_NDELAY, variable_get('syslog_facility', $default_facility)); + openlog($config->get('syslog_identity'), LOG_NDELAY, $config->get('syslog_facility')); } - $message = strtr(variable_get('syslog_format', '!base_url|!timestamp|!type|!ip|!request_uri|!referer|!uid|!link|!message'), array( + $message = strtr($config->get('syslog_format'), array( '!base_url' => $base_url, '!timestamp' => $log_entry['timestamp'], '!type' => $log_entry['type'], diff --git a/core/modules/system/config/system.logging.xml b/core/modules/system/config/system.logging.xml new file mode 100644 index 0000000..b1a6936 --- /dev/null +++ b/core/modules/system/config/system.logging.xml @@ -0,0 +1,4 @@ + + + 2 + diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index f3e2012..a7997c6 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -1642,7 +1642,7 @@ function system_logging_settings() { $form['error_level'] = array( '#type' => 'radios', '#title' => t('Error messages to display'), - '#default_value' => variable_get('error_level', ERROR_REPORTING_DISPLAY_ALL), + '#default_value' => config('system.logging')->get('error_level'), '#options' => array( ERROR_REPORTING_HIDE => t('None'), ERROR_REPORTING_DISPLAY_SOME => t('Errors and warnings'), @@ -1651,7 +1651,24 @@ function system_logging_settings() { '#description' => t('It is recommended that sites running on production environments do not display any errors.'), ); - return system_settings_form($form); + $form['actions'] = array('#type' => 'actions'); + $form['actions']['submit'] = array( + '#type' => 'submit', + '#value' => t('Save configuration'), + ); + return $form; +} + +/** + * Form submission handler for system_logging_settings(). + * + * @ingroup forms + */ +function system_logging_settings_submit($form, &$form_state) { + config('system.logging') + ->set('error_level', $form_state['values']['error_level']) + ->save(); + drupal_set_message('The configuration options have been saved.'); } /** diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 548691c..518392b 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1873,6 +1873,14 @@ function system_update_8010() { } /** + * Update settings to the new configuration system. + **/ +function system_update_8011() { + config_install_default_config('system'); + update_variables_to_config('system.logging'); +} + +/** * @} End of "defgroup updates-7.x-to-8.x". * The next series of updates should start at 9000. */ diff --git a/core/modules/system/system.test b/core/modules/system/system.test index 40f590e..3e7e982 100644 --- a/core/modules/system/system.test +++ b/core/modules/system/system.test @@ -439,29 +439,27 @@ class ModuleDependencyTestCase extends ModuleTestCase { } /** - * Attempt to enable translation module without locale enabled. + * Attempt to enable translation module without language enabled. */ function testEnableWithoutDependency() { - // Attempt to enable content translation without locale enabled. + // Attempt to enable content translation without language enabled. $edit = array(); $edit['modules[Core][translation][enable]'] = 'translation'; $this->drupalPost('admin/modules', $edit, t('Save configuration')); $this->assertText(t('Some required modules must be enabled'), t('Dependency required.')); - $this->assertModules(array('translation', 'locale', 'language'), FALSE); + $this->assertModules(array('translation', 'language'), FALSE); // Assert that the locale tables weren't enabled. $this->assertTableCount('language', FALSE); - $this->assertTableCount('locale', FALSE); $this->drupalPost(NULL, NULL, t('Continue')); $this->assertText(t('The configuration options have been saved.'), t('Modules status has been updated.')); - $this->assertModules(array('translation', 'locale'), TRUE); + $this->assertModules(array('translation', 'language'), TRUE); // Assert that the locale tables were enabled. $this->assertTableCount('language', TRUE); - $this->assertTableCount('locale', TRUE); } /** @@ -1222,7 +1220,7 @@ class DateTimeFunctionalTest extends WebTestBase { } function setUp() { - parent::setUp(array('locale')); + parent::setUp(array('language')); // Create admin user and log in admin user. $this->admin_user = $this->drupalCreateUser(array('administer site configuration')); diff --git a/core/modules/system/tests/common.test b/core/modules/system/tests/common.test index b50daad..e7f1801 100644 --- a/core/modules/system/tests/common.test +++ b/core/modules/system/tests/common.test @@ -868,7 +868,7 @@ class CommonDrupalHTTPRequestTestCase extends WebTestBase { } function setUp() { - parent::setUp('system_test', 'locale'); + parent::setUp('system_test', 'language'); } function testDrupalHTTPRequest() { @@ -1119,8 +1119,8 @@ class CommonJavaScriptTestCase extends WebTestBase { } function setUp() { - // Enable Locale and SimpleTest in the test environment. - parent::setUp('locale', 'simpletest', 'common_test'); + // Enable Language and SimpleTest in the test environment. + parent::setUp('language', 'simpletest', 'common_test'); // Disable preprocessing $config = config('system.performance'); @@ -2376,7 +2376,7 @@ class CommonFormatDateTestCase extends WebTestBase { } function setUp() { - parent::setUp('locale'); + parent::setUp('language'); variable_set('configurable_timezones', 1); variable_set('date_format_long', 'l, j. F Y - G:i'); variable_set('date_format_medium', 'j. F Y - G:i'); diff --git a/core/modules/system/tests/error.test b/core/modules/system/tests/error.test index a088902..6e2870c 100644 --- a/core/modules/system/tests/error.test +++ b/core/modules/system/tests/error.test @@ -23,6 +23,7 @@ class DrupalErrorHandlerUnitTest extends WebTestBase { * Test the error handler. */ function testErrorHandler() { + $config = config('system.logging'); $error_notice = array( '%type' => 'Notice', '!message' => 'Undefined variable: bananas', @@ -43,7 +44,7 @@ class DrupalErrorHandlerUnitTest extends WebTestBase { ); // Set error reporting to collect notices. - variable_set('error_level', ERROR_REPORTING_DISPLAY_ALL); + $config->set('error_level', ERROR_REPORTING_DISPLAY_ALL)->save(); $this->drupalGet('error-test/generate-warnings'); $this->assertResponse(200, t('Received expected HTTP status code.')); $this->assertErrorMessage($error_notice); @@ -51,7 +52,7 @@ class DrupalErrorHandlerUnitTest extends WebTestBase { $this->assertErrorMessage($error_user_notice); // Set error reporting to not collect notices. - variable_set('error_level', ERROR_REPORTING_DISPLAY_SOME); + $config->set('error_level', ERROR_REPORTING_DISPLAY_SOME)->save(); $this->drupalGet('error-test/generate-warnings'); $this->assertResponse(200, t('Received expected HTTP status code.')); $this->assertNoErrorMessage($error_notice); @@ -59,7 +60,7 @@ class DrupalErrorHandlerUnitTest extends WebTestBase { $this->assertErrorMessage($error_user_notice); // Set error reporting to not show any errors. - variable_set('error_level', ERROR_REPORTING_HIDE); + $config->set('error_level', ERROR_REPORTING_HIDE)->save(); $this->drupalGet('error-test/generate-warnings'); $this->assertResponse(200, t('Received expected HTTP status code.')); $this->assertNoErrorMessage($error_notice); diff --git a/core/modules/translation/translation.info b/core/modules/translation/translation.info index 7d574ab..b733f87 100644 --- a/core/modules/translation/translation.info +++ b/core/modules/translation/translation.info @@ -1,6 +1,6 @@ name = Content Translation description = Allows content to be translated into different languages. -dependencies[] = locale +dependencies[] = language package = Core version = VERSION core = 8.x diff --git a/core/modules/translation/translation.test b/core/modules/translation/translation.test index 1a0f0a0..ec6101b 100644 --- a/core/modules/translation/translation.test +++ b/core/modules/translation/translation.test @@ -25,7 +25,7 @@ class TranslationTestCase extends WebTestBase { } function setUp() { - parent::setUp('language', 'locale', 'translation', 'translation_test'); + parent::setUp('translation', 'translation_test'); // Setup users. $this->admin_user = $this->drupalCreateUser(array('bypass node access', 'administer nodes', 'administer languages', 'administer content types', 'administer blocks', 'access administration pages', 'translate content'));