diff --git a/core/includes/errors.inc b/core/includes/errors.inc index 2365e2a..cba08e2 100644 --- a/core/includes/errors.inc +++ b/core/includes/errors.inc @@ -10,22 +10,22 @@ use Symfony\Component\HttpFoundation\Response; /** * Error reporting level: display no errors. */ -const ERROR_REPORTING_HIDE = 0; +const ERROR_REPORTING_HIDE = 'hide'; /** * Error reporting level: display errors and warnings. */ -const ERROR_REPORTING_DISPLAY_SOME = 1; +const ERROR_REPORTING_DISPLAY_SOME = 'some'; /** * Error reporting level: display all messages. */ -const ERROR_REPORTING_DISPLAY_ALL = 2; +const ERROR_REPORTING_DISPLAY_ALL = 'all'; /** * Error reporting level: display all messages, plus backtrace information. */ -const ERROR_REPORTING_DISPLAY_VERBOSE = 3; +const ERROR_REPORTING_DISPLAY_VERBOSE = 'verbose'; /** * Maps PHP error constants to watchdog severity levels. @@ -172,7 +172,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_level == ERROR_REPORTING_DISPLAY_VERBOSE); diff --git a/core/modules/dblog/config/dblog.settings.yml b/core/modules/dblog/config/dblog.settings.yml new file mode 100644 index 0000000..88add88 --- /dev/null +++ b/core/modules/dblog/config/dblog.settings.yml @@ -0,0 +1 @@ +row_limit: 1000 diff --git a/core/modules/dblog/dblog.install b/core/modules/dblog/dblog.install index 23f85ba..919bab3 100644 --- a/core/modules/dblog/dblog.install +++ b/core/modules/dblog/dblog.install @@ -92,8 +92,21 @@ 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() { + update_variables_to_config('dblog.settings', array( + 'dblog_row_limit' => 'row_limit', + )); } + +/** + * @} 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..25ad6c5 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.settings')->get('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,21 @@ 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.settings')->get('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 system_logging_settings(). + * + * @see dblog_form_system_logging_settings_alter() + */ +function dblog_logging_settings_submit($form, &$form_state) { + config('dblog.settings')->set('row_limit', $form_state['values']['dblog_row_limit'])->save(); } /** diff --git a/core/modules/dblog/lib/Drupal/dblog/Tests/DBLogTest.php b/core/modules/dblog/lib/Drupal/dblog/Tests/DBLogTest.php index 17667c9..fd1e9af 100644 --- a/core/modules/dblog/lib/Drupal/dblog/Tests/DBLogTest.php +++ b/core/modules/dblog/lib/Drupal/dblog/Tests/DBLogTest.php @@ -65,11 +65,8 @@ class DBLogTest extends WebTestBase { $this->assertResponse(200); // Check row limit variable. - $current_limit = variable_get('dblog_row_limit', 1000); + $current_limit = config('dblog.settings')->get('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/syslog/config/syslog.settings.yml b/core/modules/syslog/config/syslog.settings.yml new file mode 100644 index 0000000..1aa5b90 --- /dev/null +++ b/core/modules/syslog/config/syslog.settings.yml @@ -0,0 +1,3 @@ +identity: drupal +facility: '' +format: '!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..7ae9f89 100644 --- a/core/modules/syslog/syslog.install +++ b/core/modules/syslog/syslog.install @@ -6,10 +6,32 @@ */ /** - * 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.settings')->set('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() { + update_variables_to_config('syslog.settings', array( + 'syslog_identity' => 'identity', + 'syslog_facility' => 'facility', + 'syslog_format' => 'format', + )); +} + +/** + * @} 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..e138656 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.settings'); $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('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('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,24 @@ 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('format'), '#description' => t('Specify the format of the syslog entry. Available variables are:
!base_url
!timestamp
!type
!ip
!request_uri
!referer
!uid
!link
!message