Update core 8.3.0

This commit is contained in:
Rob Davies 2017-04-13 15:53:35 +01:00
parent da7a7918f8
commit cd7a898e66
6144 changed files with 132297 additions and 87747 deletions

View file

@ -63,7 +63,7 @@ class SysLog implements LoggerInterface {
/**
* {@inheritdoc}
*/
public function log($level, $message, array $context = array()) {
public function log($level, $message, array $context = []) {
global $base_url;
// Ensure we have a connection available.
@ -73,7 +73,7 @@ class SysLog implements LoggerInterface {
$message_placeholders = $this->parser->parseMessagePlaceholders($message, $context);
$message = empty($message_placeholders) ? $message : strtr($message, $message_placeholders);
$entry = strtr($this->config->get('format'), array(
$entry = strtr($this->config->get('format'), [
'!base_url' => $base_url,
'!timestamp' => $context['timestamp'],
'!type' => $context['channel'],
@ -83,7 +83,7 @@ class SysLog implements LoggerInterface {
'!uid' => $context['uid'],
'!link' => strip_tags($context['link']),
'!message' => strip_tags($message),
));
]);
syslog($level, $entry);
}

View file

@ -1,41 +0,0 @@
<?php
namespace Drupal\syslog\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Tests syslog settings.
*
* @group syslog
*/
class SyslogTest extends WebTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('syslog');
/**
* Tests the syslog settings page.
*/
function testSettings() {
$admin_user = $this->drupalCreateUser(array('administer site configuration'));
$this->drupalLogin($admin_user);
// If we're on Windows, there is no configuration form.
if (defined('LOG_LOCAL6')) {
$this->drupalPostForm('admin/config/development/logging', array('syslog_facility' => LOG_LOCAL6), t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'));
$this->drupalGet('admin/config/development/logging');
if ($this->parse()) {
$field = $this->xpath('//option[@value=:value]', array(':value' => LOG_LOCAL6)); // Should be one field.
$this->assertTrue($field[0]['selected'] == 'selected', 'Facility value saved.');
}
}
}
}

View file

@ -17,7 +17,7 @@ function syslog_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.syslog':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Syslog module logs events by sending messages to the logging facility of your web server\'s operating system. Syslog is an operating system administrative logging tool that provides valuable information for use in system management and security auditing. Most suited to medium and large sites, Syslog provides filtering tools that allow messages to be routed by type and severity. For more information, see the <a href=":syslog">online documentation for the Syslog module</a>, as well as PHP\'s documentation pages for the <a href="http://php.net/manual/function.openlog.php">openlog</a> and <a href="http://php.net/manual/function.syslog.php">syslog</a> functions.', array(':syslog' => 'https://www.drupal.org/documentation/modules/syslog')) . '</p>';
$output .= '<p>' . t('The Syslog module logs events by sending messages to the logging facility of your web server\'s operating system. Syslog is an operating system administrative logging tool that provides valuable information for use in system management and security auditing. Most suited to medium and large sites, Syslog provides filtering tools that allow messages to be routed by type and severity. For more information, see the <a href=":syslog">online documentation for the Syslog module</a>, as well as PHP\'s documentation pages for the <a href="http://php.net/manual/function.openlog.php">openlog</a> and <a href="http://php.net/manual/function.syslog.php">syslog</a> functions.', [':syslog' => 'https://www.drupal.org/documentation/modules/syslog']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Logging for UNIX, Linux, and Mac OS X') . '</dt>';
@ -35,27 +35,27 @@ function syslog_help($route_name, RouteMatchInterface $route_match) {
function syslog_form_system_logging_settings_alter(&$form, FormStateInterface $form_state) {
$config = \Drupal::configFactory()->getEditable('syslog.settings');
$help = \Drupal::moduleHandler()->moduleExists('help') ? ' ' . \Drupal::l(t('More information'), new Url('help.page', ['name' => 'syslog'])) . '.' : NULL;
$form['syslog_identity'] = array(
$form['syslog_identity'] = [
'#type' => 'textfield',
'#title' => t('Syslog identity'),
'#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(
$form['syslog_facility'] = [
'#type' => 'select',
'#title' => t('Syslog facility'),
'#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,
);
];
}
$form['syslog_format'] = array(
$form['syslog_format'] = [
'#type' => 'textarea',
'#title' => t('Syslog format'),
'#default_value' => $config->get('format'),
'#description' => t('Specify the format of the syslog entry. Available variables are: <dl><dt><code>!base_url</code></dt><dd>Base URL of the site.</dd><dt><code>!timestamp</code></dt><dd>Unix timestamp of the log entry.</dd><dt><code>!type</code></dt><dd>The category to which this message belongs.</dd><dt><code>!ip</code></dt><dd>IP address of the user triggering the message.</dd><dt><code>!request_uri</code></dt><dd>The requested URI.</dd><dt><code>!referer</code></dt><dd>HTTP Referer if available.</dd><dt><code>!uid</code></dt><dd>User ID.</dd><dt><code>!link</code></dt><dd>A link to associate with the message.</dd><dt><code>!message</code></dt><dd>The message to store in the log.</dd></dl>'),
);
];
$form['#submit'][] = 'syslog_logging_settings_submit';
}
@ -80,7 +80,7 @@ function syslog_logging_settings_submit($form, FormStateInterface $form_state) {
* An array of syslog facilities for UNIX/Linux.
*/
function syslog_facility_list() {
return array(
return [
LOG_LOCAL0 => 'LOG_LOCAL0',
LOG_LOCAL1 => 'LOG_LOCAL1',
LOG_LOCAL2 => 'LOG_LOCAL2',
@ -89,5 +89,5 @@ function syslog_facility_list() {
LOG_LOCAL5 => 'LOG_LOCAL5',
LOG_LOCAL6 => 'LOG_LOCAL6',
LOG_LOCAL7 => 'LOG_LOCAL7',
);
];
}

View file

@ -0,0 +1,40 @@
<?php
namespace Drupal\Tests\syslog\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Tests syslog settings.
*
* @group syslog
*/
class SyslogTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['syslog'];
/**
* Tests the syslog settings page.
*/
public function testSettings() {
$admin_user = $this->drupalCreateUser(['administer site configuration']);
$this->drupalLogin($admin_user);
// If we're on Windows, there is no configuration form.
if (defined('LOG_LOCAL6')) {
$this->drupalPostForm('admin/config/development/logging', ['syslog_facility' => LOG_LOCAL6], t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'));
$this->drupalGet('admin/config/development/logging');
// Should be one field.
$field = $this->xpath('//option[@value=:value]', [':value' => LOG_LOCAL6]);
$this->assertSame('selected', $field[0]->getAttribute('selected'), 'Facility value saved.');
}
}
}

View file

@ -2,7 +2,7 @@
namespace Drupal\Tests\syslog\Kernel\Migrate\d6;
use Drupal\config\Tests\SchemaCheckTestTrait;
use Drupal\Tests\SchemaCheckTestTrait;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
@ -17,7 +17,7 @@ class MigrateSyslogConfigsTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = array('syslog');
public static $modules = ['syslog'];
/**
* {@inheritdoc}

View file

@ -2,7 +2,7 @@
namespace Drupal\Tests\syslog\Kernel\Migrate\d7;
use Drupal\config\Tests\SchemaCheckTestTrait;
use Drupal\Tests\SchemaCheckTestTrait;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
/**