diff --git a/core/modules/syslog/config/install/syslog.settings.yml b/core/modules/syslog/config/install/syslog.settings.yml index 1aa5b9087452ba9cac28a3c30a4e5cbf25a8bc5e..396b751798657c6bbc0e8bd07232dff5778c3162 100644 --- a/core/modules/syslog/config/install/syslog.settings.yml +++ b/core/modules/syslog/config/install/syslog.settings.yml @@ -1,3 +1,6 @@ identity: drupal -facility: '' +# The default facility setting depends on the operating system, and will be +# overwritten during installation. +# @see syslog_install(). +facility: 8 format: '!base_url|!timestamp|!type|!ip|!request_uri|!referer|!uid|!link|!message' diff --git a/core/modules/syslog/config/schema/syslog.schema.yml b/core/modules/syslog/config/schema/syslog.schema.yml index 5d2707a5a15158728caabdd4ae0c39d6dcb00326..f980828f806ce8e906209ab7cffbea63aea0e4c2 100644 --- a/core/modules/syslog/config/schema/syslog.schema.yml +++ b/core/modules/syslog/config/schema/syslog.schema.yml @@ -8,7 +8,7 @@ syslog.settings: type: string label: 'Identity' facility: - type: string + type: integer label: 'Facility' format: type: string diff --git a/core/modules/syslog/src/Tests/Update/SyslogUpdateTest.php b/core/modules/syslog/src/Tests/Update/SyslogUpdateTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2b0482ff930739081eef8b861ea9726e87472c7c --- /dev/null +++ b/core/modules/syslog/src/Tests/Update/SyslogUpdateTest.php @@ -0,0 +1,39 @@ +<?php + +namespace Drupal\syslog\Tests\Update; + +use Drupal\system\Tests\Update\UpdatePathTestBase; + +/** + * Tests that syslog settings are properly updated during database updates. + * + * @group syslog + */ +class SyslogUpdateTest extends UpdatePathTestBase { + + /** + * {@inheritdoc} + */ + protected function setDatabaseDumpFiles() { + $this->databaseDumpFiles = [ + __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.filled.standard.php.gz', + ]; + } + + /** + * Tests that syslog.settings.facility has been converted from string to int. + * + * @see syslog_update_8400() + */ + public function testSyslogSettingsFacilityDataType() { + $config = $this->config('syslog.settings'); + $this->assertIdentical('128', $config->get('facility')); + + // Run updates. + $this->runUpdates(); + + $config = $this->config('syslog.settings'); + $this->assertIdentical(128, $config->get('facility')); + } + +} diff --git a/core/modules/syslog/syslog.install b/core/modules/syslog/syslog.install index e3377c8aeb74240fe7cc10bf1d89ba7fa62fff98..f0ce5cc68a3bd22f15c34d36c6acdfd455bbf014 100644 --- a/core/modules/syslog/syslog.install +++ b/core/modules/syslog/syslog.install @@ -13,3 +13,12 @@ function syslog_install() { // to be set dynamically during installation. \Drupal::configFactory()->getEditable('syslog.settings')->set('facility', defined('LOG_LOCAL0') ? LOG_LOCAL0 : LOG_USER)->save(); } + +/** + * Convert syslog.settings.facility to an integer. + */ +function syslog_update_8400() { + $config = \Drupal::configFactory()->getEditable('syslog.settings'); + $facility = (int) $config->get('facility'); + $config->set('facility', $facility)->save(TRUE); +} diff --git a/core/modules/syslog/tests/src/Kernel/Migrate/d6/MigrateSyslogConfigsTest.php b/core/modules/syslog/tests/src/Kernel/Migrate/d6/MigrateSyslogConfigsTest.php index aa66203113d6ff96680c44567931d00c82a24247..935af8d8aa05920d92777f4c0c216c5ae50cde85 100644 --- a/core/modules/syslog/tests/src/Kernel/Migrate/d6/MigrateSyslogConfigsTest.php +++ b/core/modules/syslog/tests/src/Kernel/Migrate/d6/MigrateSyslogConfigsTest.php @@ -33,7 +33,7 @@ protected function setUp() { public function testSyslogSettings() { $config = $this->config('syslog.settings'); $this->assertIdentical('drupal', $config->get('identity')); - $this->assertIdentical('128', $config->get('facility')); + $this->assertIdentical(128, $config->get('facility')); $this->assertConfigSchema(\Drupal::service('config.typed'), 'syslog.settings', $config->get()); } diff --git a/core/modules/syslog/tests/src/Kernel/Migrate/d7/MigrateSyslogConfigsTest.php b/core/modules/syslog/tests/src/Kernel/Migrate/d7/MigrateSyslogConfigsTest.php index 2996b4241930f4c9665f544f49327e6ec5d4348a..ef5d8c305dd205cd1317f4212128e9206119feea 100644 --- a/core/modules/syslog/tests/src/Kernel/Migrate/d7/MigrateSyslogConfigsTest.php +++ b/core/modules/syslog/tests/src/Kernel/Migrate/d7/MigrateSyslogConfigsTest.php @@ -36,7 +36,7 @@ protected function setUp() { public function testSyslogSettings() { $config = $this->config('syslog.settings'); // 8 == LOG_USER - $this->assertIdentical('8', $config->get('facility')); + $this->assertIdentical(8, $config->get('facility')); $this->assertIdentical('!base_url|!timestamp|!type|!ip|!request_uri|!referer|!uid|!link|!message', $config->get('format')); $this->assertIdentical('drupal', $config->get('identity')); }