Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -19,25 +19,25 @@ use Drupal\Core\Logger\RfcLogLevel;
|
|||
* - options: Array of options for the select list for the filter.
|
||||
*/
|
||||
function dblog_filters() {
|
||||
$filters = array();
|
||||
$filters = [];
|
||||
|
||||
foreach (_dblog_get_message_types() as $type) {
|
||||
$types[$type] = t($type);
|
||||
}
|
||||
|
||||
if (!empty($types)) {
|
||||
$filters['type'] = array(
|
||||
$filters['type'] = [
|
||||
'title' => t('Type'),
|
||||
'where' => "w.type = ?",
|
||||
'options' => $types,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$filters['severity'] = array(
|
||||
$filters['severity'] = [
|
||||
'title' => t('Severity'),
|
||||
'where' => 'w.severity = ?',
|
||||
'options' => RfcLogLevel::getLevels(),
|
||||
);
|
||||
];
|
||||
|
||||
return $filters;
|
||||
}
|
||||
|
|
|
@ -9,84 +9,84 @@
|
|||
* Implements hook_schema().
|
||||
*/
|
||||
function dblog_schema() {
|
||||
$schema['watchdog'] = array(
|
||||
$schema['watchdog'] = [
|
||||
'description' => 'Table that contains logs of all system events.',
|
||||
'fields' => array(
|
||||
'wid' => array(
|
||||
'fields' => [
|
||||
'wid' => [
|
||||
'type' => 'serial',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Primary Key: Unique watchdog event ID.',
|
||||
),
|
||||
'uid' => array(
|
||||
],
|
||||
'uid' => [
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'The {users}.uid of the user who triggered the event.',
|
||||
),
|
||||
'type' => array(
|
||||
],
|
||||
'type' => [
|
||||
'type' => 'varchar_ascii',
|
||||
'length' => 64,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
'description' => 'Type of log message, for example "user" or "page not found."',
|
||||
),
|
||||
'message' => array(
|
||||
],
|
||||
'message' => [
|
||||
'type' => 'text',
|
||||
'not null' => TRUE,
|
||||
'size' => 'big',
|
||||
'description' => 'Text of log message to be passed into the t() function.',
|
||||
),
|
||||
'variables' => array(
|
||||
],
|
||||
'variables' => [
|
||||
'type' => 'blob',
|
||||
'not null' => TRUE,
|
||||
'size' => 'big',
|
||||
'description' => 'Serialized array of variables that match the message string and that is passed into the t() function.',
|
||||
),
|
||||
'severity' => array(
|
||||
],
|
||||
'severity' => [
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'size' => 'tiny',
|
||||
'description' => 'The severity level of the event; ranges from 0 (Emergency) to 7 (Debug)',
|
||||
),
|
||||
'link' => array(
|
||||
],
|
||||
'link' => [
|
||||
'type' => 'text',
|
||||
'not null' => FALSE,
|
||||
'description' => 'Link to view the result of the event.',
|
||||
),
|
||||
'location' => array(
|
||||
],
|
||||
'location' => [
|
||||
'type' => 'text',
|
||||
'not null' => TRUE,
|
||||
'description' => 'URL of the origin of the event.',
|
||||
),
|
||||
'referer' => array(
|
||||
],
|
||||
'referer' => [
|
||||
'type' => 'text',
|
||||
'not null' => FALSE,
|
||||
'description' => 'URL of referring page.',
|
||||
),
|
||||
'hostname' => array(
|
||||
],
|
||||
'hostname' => [
|
||||
'type' => 'varchar_ascii',
|
||||
'length' => 128,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
'description' => 'Hostname of the user who triggered the event.',
|
||||
),
|
||||
'timestamp' => array(
|
||||
],
|
||||
'timestamp' => [
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'Unix timestamp of when event occurred.',
|
||||
),
|
||||
),
|
||||
'primary key' => array('wid'),
|
||||
'indexes' => array(
|
||||
'type' => array('type'),
|
||||
'uid' => array('uid'),
|
||||
'severity' => array('severity'),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
'primary key' => ['wid'],
|
||||
'indexes' => [
|
||||
'type' => ['type'],
|
||||
'uid' => ['uid'],
|
||||
'severity' => ['severity'],
|
||||
],
|
||||
];
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
|
|
@ -21,13 +21,13 @@ function dblog_help($route_name, RouteMatchInterface $route_match) {
|
|||
case 'help.page.dblog':
|
||||
$output = '';
|
||||
$output .= '<h3>' . t('About') . '</h3>';
|
||||
$output .= '<p>' . t('The Database Logging module logs system events in the Drupal database. For more information, see the <a href=":dblog">online documentation for the Database Logging module</a>.', array(':dblog' => 'https://www.drupal.org/documentation/modules/dblog')) . '</p>';
|
||||
$output .= '<p>' . t('The Database Logging module logs system events in the Drupal database. For more information, see the <a href=":dblog">online documentation for the Database Logging module</a>.', [':dblog' => 'https://www.drupal.org/documentation/modules/dblog']) . '</p>';
|
||||
$output .= '<h3>' . t('Uses') . '</h3>';
|
||||
$output .= '<dl>';
|
||||
$output .= '<dt>' . t('Monitoring your site') . '</dt>';
|
||||
$output .= '<dd>' . t('The Database Logging module allows you to view an event log on the <a href=":dblog">Recent log messages</a> page. The log is a chronological list of recorded events containing usage data, performance data, errors, warnings and operational information. Administrators should check the log on a regular basis to ensure their site is working properly.', array(':dblog' => \Drupal::url('dblog.overview'))) . '</dd>';
|
||||
$output .= '<dd>' . t('The Database Logging module allows you to view an event log on the <a href=":dblog">Recent log messages</a> page. The log is a chronological list of recorded events containing usage data, performance data, errors, warnings and operational information. Administrators should check the log on a regular basis to ensure their site is working properly.', [':dblog' => \Drupal::url('dblog.overview')]) . '</dd>';
|
||||
$output .= '<dt>' . t('Debugging site problems') . '</dt>';
|
||||
$output .= '<dd>' . t('In case of errors or problems with the site, the <a href=":dblog">Recent log messages</a> page can be useful for debugging, since it shows the sequence of events. The log messages include usage information, warnings, and errors.', array(':dblog' => \Drupal::url('dblog.overview'))) . '</dd>';
|
||||
$output .= '<dd>' . t('In case of errors or problems with the site, the <a href=":dblog">Recent log messages</a> page can be useful for debugging, since it shows the sequence of events. The log messages include usage information, warnings, and errors.', [':dblog' => \Drupal::url('dblog.overview')]) . '</dd>';
|
||||
$output .= '</dl>';
|
||||
return $output;
|
||||
|
||||
|
@ -41,12 +41,12 @@ function dblog_help($route_name, RouteMatchInterface $route_match) {
|
|||
*/
|
||||
function dblog_menu_links_discovered_alter(&$links) {
|
||||
if (\Drupal::moduleHandler()->moduleExists('search')) {
|
||||
$links['dblog.search'] = array(
|
||||
$links['dblog.search'] = [
|
||||
'title' => new TranslatableMarkup('Top search phrases'),
|
||||
'route_name' => 'dblog.search',
|
||||
'description' => new TranslatableMarkup('View most popular search phrases.'),
|
||||
'parent' => 'system.admin_reports',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
return $links;
|
||||
|
@ -66,7 +66,7 @@ function dblog_cron() {
|
|||
// e.g. auto_increment value > 1 or rows deleted directly from the table.
|
||||
if ($row_limit > 0) {
|
||||
$min_row = db_select('watchdog', 'w')
|
||||
->fields('w', array('wid'))
|
||||
->fields('w', ['wid'])
|
||||
->orderBy('wid', 'DESC')
|
||||
->range($row_limit - 1, 1)
|
||||
->execute()->fetchField();
|
||||
|
@ -95,14 +95,14 @@ function _dblog_get_message_types() {
|
|||
* Implements hook_form_FORM_ID_alter() for system_logging_settings().
|
||||
*/
|
||||
function dblog_form_system_logging_settings_alter(&$form, FormStateInterface $form_state) {
|
||||
$row_limits = array(100, 1000, 10000, 100000, 1000000);
|
||||
$form['dblog_row_limit'] = array(
|
||||
$row_limits = [100, 1000, 10000, 100000, 1000000];
|
||||
$form['dblog_row_limit'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => t('Database log messages to keep'),
|
||||
'#default_value' => \Drupal::configFactory()->getEditable('dblog.settings')->get('row_limit'),
|
||||
'#options' => array(0 => t('All')) + array_combine($row_limits, $row_limits),
|
||||
'#description' => t('The maximum number of messages to keep in the database log. Requires a <a href=":cron">cron maintenance task</a>.', array(':cron' => \Drupal::url('system.status')))
|
||||
);
|
||||
'#options' => [0 => t('All')] + array_combine($row_limits, $row_limits),
|
||||
'#description' => t('The maximum number of messages to keep in the database log. Requires a <a href=":cron">cron maintenance task</a>.', [':cron' => \Drupal::url('system.status')])
|
||||
];
|
||||
|
||||
$form['#submit'][] = 'dblog_logging_settings_submit';
|
||||
}
|
||||
|
|
|
@ -9,208 +9,208 @@
|
|||
* Implements hook_views_data().
|
||||
*/
|
||||
function dblog_views_data() {
|
||||
$data = array();
|
||||
$data = [];
|
||||
|
||||
$data['watchdog']['table']['group'] = t('Watchdog');
|
||||
$data['watchdog']['table']['wizard_id'] = 'watchdog';
|
||||
|
||||
$data['watchdog']['table']['base'] = array(
|
||||
$data['watchdog']['table']['base'] = [
|
||||
'field' => 'wid',
|
||||
'title' => t('Log entries'),
|
||||
'help' => t('Contains a list of log entries.'),
|
||||
);
|
||||
];
|
||||
|
||||
$data['watchdog']['wid'] = array(
|
||||
$data['watchdog']['wid'] = [
|
||||
'title' => t('WID'),
|
||||
'help' => t('Unique watchdog event ID.'),
|
||||
'field' => array(
|
||||
'field' => [
|
||||
'id' => 'numeric',
|
||||
),
|
||||
'filter' => array(
|
||||
],
|
||||
'filter' => [
|
||||
'id' => 'numeric',
|
||||
),
|
||||
'argument' => array(
|
||||
],
|
||||
'argument' => [
|
||||
'id' => 'numeric',
|
||||
),
|
||||
'sort' => array(
|
||||
],
|
||||
'sort' => [
|
||||
'id' => 'standard',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$data['watchdog']['uid'] = array(
|
||||
$data['watchdog']['uid'] = [
|
||||
'title' => t('UID'),
|
||||
'help' => t('The user ID of the user on which the log entry was written..'),
|
||||
'field' => array(
|
||||
'field' => [
|
||||
'id' => 'numeric',
|
||||
),
|
||||
'filter' => array(
|
||||
],
|
||||
'filter' => [
|
||||
'id' => 'numeric',
|
||||
),
|
||||
'argument' => array(
|
||||
],
|
||||
'argument' => [
|
||||
'id' => 'numeric',
|
||||
),
|
||||
'relationship' => array(
|
||||
],
|
||||
'relationship' => [
|
||||
'title' => t('User'),
|
||||
'help' => t('The user on which the log entry as written.'),
|
||||
'base' => 'users',
|
||||
'base field' => 'uid',
|
||||
'id' => 'standard',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$data['watchdog']['type'] = array(
|
||||
$data['watchdog']['type'] = [
|
||||
'title' => t('Type'),
|
||||
'help' => t('The type of the log entry, for example "user" or "page not found".'),
|
||||
'field' => array(
|
||||
'field' => [
|
||||
'id' => 'standard',
|
||||
),
|
||||
'argument' => array(
|
||||
],
|
||||
'argument' => [
|
||||
'id' => 'string',
|
||||
),
|
||||
'filter' => array(
|
||||
],
|
||||
'filter' => [
|
||||
'id' => 'in_operator',
|
||||
'options callback' => '_dblog_get_message_types',
|
||||
),
|
||||
'sort' => array(
|
||||
],
|
||||
'sort' => [
|
||||
'id' => 'standard',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$data['watchdog']['message'] = array(
|
||||
$data['watchdog']['message'] = [
|
||||
'title' => t('Message'),
|
||||
'help' => t('The actual message of the log entry.'),
|
||||
'field' => array(
|
||||
'field' => [
|
||||
'id' => 'dblog_message',
|
||||
),
|
||||
'argument' => array(
|
||||
],
|
||||
'argument' => [
|
||||
'id' => 'string',
|
||||
),
|
||||
'filter' => array(
|
||||
],
|
||||
'filter' => [
|
||||
'id' => 'string',
|
||||
),
|
||||
'sort' => array(
|
||||
],
|
||||
'sort' => [
|
||||
'id' => 'standard',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$data['watchdog']['variables'] = array(
|
||||
$data['watchdog']['variables'] = [
|
||||
'title' => t('Variables'),
|
||||
'help' => t('The variables of the log entry in a serialized format.'),
|
||||
'field' => array(
|
||||
'field' => [
|
||||
'id' => 'serialized',
|
||||
'click sortable' => FALSE,
|
||||
),
|
||||
'argument' => array(
|
||||
],
|
||||
'argument' => [
|
||||
'id' => 'string',
|
||||
),
|
||||
'filter' => array(
|
||||
],
|
||||
'filter' => [
|
||||
'id' => 'string',
|
||||
),
|
||||
'sort' => array(
|
||||
],
|
||||
'sort' => [
|
||||
'id' => 'standard',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$data['watchdog']['severity'] = array(
|
||||
$data['watchdog']['severity'] = [
|
||||
'title' => t('Severity level'),
|
||||
'help' => t('The severity level of the event; ranges from 0 (Emergency) to 7 (Debug).'),
|
||||
'field' => array(
|
||||
'field' => [
|
||||
'id' => 'machine_name',
|
||||
'options callback' => 'Drupal\dblog\Controller\DbLogController::getLogLevelClassMap',
|
||||
),
|
||||
'filter' => array(
|
||||
],
|
||||
'filter' => [
|
||||
'id' => 'in_operator',
|
||||
'options callback' => 'Drupal\dblog\Controller\DbLogController::getLogLevelClassMap',
|
||||
),
|
||||
'sort' => array(
|
||||
],
|
||||
'sort' => [
|
||||
'id' => 'standard',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$data['watchdog']['link'] = array(
|
||||
$data['watchdog']['link'] = [
|
||||
'title' => t('Operations'),
|
||||
'help' => t('Operation links for the event.'),
|
||||
'field' => array(
|
||||
'field' => [
|
||||
'id' => 'dblog_operations',
|
||||
),
|
||||
'argument' => array(
|
||||
],
|
||||
'argument' => [
|
||||
'id' => 'string',
|
||||
),
|
||||
'filter' => array(
|
||||
],
|
||||
'filter' => [
|
||||
'id' => 'string',
|
||||
),
|
||||
'sort' => array(
|
||||
],
|
||||
'sort' => [
|
||||
'id' => 'standard',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$data['watchdog']['location'] = array(
|
||||
$data['watchdog']['location'] = [
|
||||
'title' => t('Location'),
|
||||
'help' => t('URL of the origin of the event.'),
|
||||
'field' => array(
|
||||
'field' => [
|
||||
'id' => 'standard',
|
||||
),
|
||||
'argument' => array(
|
||||
],
|
||||
'argument' => [
|
||||
'id' => 'string',
|
||||
),
|
||||
'filter' => array(
|
||||
],
|
||||
'filter' => [
|
||||
'id' => 'string',
|
||||
),
|
||||
'sort' => array(
|
||||
],
|
||||
'sort' => [
|
||||
'id' => 'standard',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$data['watchdog']['referer'] = array(
|
||||
$data['watchdog']['referer'] = [
|
||||
'title' => t('Referer'),
|
||||
'help' => t('URL of the previous page.'),
|
||||
'field' => array(
|
||||
'field' => [
|
||||
'id' => 'standard',
|
||||
),
|
||||
'argument' => array(
|
||||
],
|
||||
'argument' => [
|
||||
'id' => 'string',
|
||||
),
|
||||
'filter' => array(
|
||||
],
|
||||
'filter' => [
|
||||
'id' => 'string',
|
||||
),
|
||||
'sort' => array(
|
||||
],
|
||||
'sort' => [
|
||||
'id' => 'standard',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$data['watchdog']['hostname'] = array(
|
||||
$data['watchdog']['hostname'] = [
|
||||
'title' => t('Hostname'),
|
||||
'help' => t('Hostname of the user who triggered the event.'),
|
||||
'field' => array(
|
||||
'field' => [
|
||||
'id' => 'standard',
|
||||
),
|
||||
'argument' => array(
|
||||
],
|
||||
'argument' => [
|
||||
'id' => 'string',
|
||||
),
|
||||
'filter' => array(
|
||||
],
|
||||
'filter' => [
|
||||
'id' => 'string',
|
||||
),
|
||||
'sort' => array(
|
||||
],
|
||||
'sort' => [
|
||||
'id' => 'standard',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$data['watchdog']['timestamp'] = array(
|
||||
$data['watchdog']['timestamp'] = [
|
||||
'title' => t('Timestamp'),
|
||||
'help' => t('Date when the event occurred.'),
|
||||
'field' => array(
|
||||
'field' => [
|
||||
'id' => 'date',
|
||||
),
|
||||
'argument' => array(
|
||||
],
|
||||
'argument' => [
|
||||
'id' => 'date',
|
||||
),
|
||||
'filter' => array(
|
||||
],
|
||||
'filter' => [
|
||||
'id' => 'date',
|
||||
),
|
||||
'sort' => array(
|
||||
],
|
||||
'sort' => [
|
||||
'id' => 'date',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ class DbLogController extends ControllerBase {
|
|||
* An array of log level classes.
|
||||
*/
|
||||
public static function getLogLevelClassMap() {
|
||||
return array(
|
||||
return [
|
||||
RfcLogLevel::DEBUG => 'dblog-debug',
|
||||
RfcLogLevel::INFO => 'dblog-info',
|
||||
RfcLogLevel::NOTICE => 'dblog-notice',
|
||||
|
@ -103,7 +103,7 @@ class DbLogController extends ControllerBase {
|
|||
RfcLogLevel::CRITICAL => 'dblog-critical',
|
||||
RfcLogLevel::ALERT => 'dblog-alert',
|
||||
RfcLogLevel::EMERGENCY => 'dblog-emergency',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,13 +115,13 @@ class DbLogController extends ControllerBase {
|
|||
* @return array
|
||||
* A render array as expected by drupal_render().
|
||||
*
|
||||
* @see dblog_clear_log_form()
|
||||
* @see dblog_event()
|
||||
* @see Drupal\dblog\Form\DblogClearLogConfirmForm
|
||||
* @see Drupal\dblog\Controller\DbLogController::eventDetails()
|
||||
*/
|
||||
public function overview() {
|
||||
|
||||
$filter = $this->buildFilterQuery();
|
||||
$rows = array();
|
||||
$rows = [];
|
||||
|
||||
$classes = static::getLogLevelClassMap();
|
||||
|
||||
|
@ -129,32 +129,32 @@ class DbLogController extends ControllerBase {
|
|||
|
||||
$build['dblog_filter_form'] = $this->formBuilder->getForm('Drupal\dblog\Form\DblogFilterForm');
|
||||
|
||||
$header = array(
|
||||
$header = [
|
||||
// Icon column.
|
||||
'',
|
||||
array(
|
||||
[
|
||||
'data' => $this->t('Type'),
|
||||
'field' => 'w.type',
|
||||
'class' => array(RESPONSIVE_PRIORITY_MEDIUM)),
|
||||
array(
|
||||
'class' => [RESPONSIVE_PRIORITY_MEDIUM]],
|
||||
[
|
||||
'data' => $this->t('Date'),
|
||||
'field' => 'w.wid',
|
||||
'sort' => 'desc',
|
||||
'class' => array(RESPONSIVE_PRIORITY_LOW)),
|
||||
'class' => [RESPONSIVE_PRIORITY_LOW]],
|
||||
$this->t('Message'),
|
||||
array(
|
||||
[
|
||||
'data' => $this->t('User'),
|
||||
'field' => 'ufd.name',
|
||||
'class' => array(RESPONSIVE_PRIORITY_MEDIUM)),
|
||||
array(
|
||||
'class' => [RESPONSIVE_PRIORITY_MEDIUM]],
|
||||
[
|
||||
'data' => $this->t('Operations'),
|
||||
'class' => array(RESPONSIVE_PRIORITY_LOW)),
|
||||
);
|
||||
'class' => [RESPONSIVE_PRIORITY_LOW]],
|
||||
];
|
||||
|
||||
$query = $this->database->select('watchdog', 'w')
|
||||
->extend('\Drupal\Core\Database\Query\PagerSelectExtender')
|
||||
->extend('\Drupal\Core\Database\Query\TableSortExtender');
|
||||
$query->fields('w', array(
|
||||
$query->fields('w', [
|
||||
'wid',
|
||||
'uid',
|
||||
'severity',
|
||||
|
@ -163,7 +163,7 @@ class DbLogController extends ControllerBase {
|
|||
'message',
|
||||
'variables',
|
||||
'link',
|
||||
));
|
||||
]);
|
||||
$query->leftJoin('users_field_data', 'ufd', 'w.uid = ufd.uid');
|
||||
|
||||
if (!empty($filter['where'])) {
|
||||
|
@ -181,45 +181,45 @@ class DbLogController extends ControllerBase {
|
|||
$log_text = Unicode::truncate($title, 56, TRUE, TRUE);
|
||||
// The link generator will escape any unsafe HTML entities in the final
|
||||
// text.
|
||||
$message = $this->l($log_text, new Url('dblog.event', array('event_id' => $dblog->wid), array(
|
||||
'attributes' => array(
|
||||
$message = $this->l($log_text, new Url('dblog.event', ['event_id' => $dblog->wid], [
|
||||
'attributes' => [
|
||||
// Provide a title for the link for useful hover hints. The
|
||||
// Attribute object will escape any unsafe HTML entities in the
|
||||
// final text.
|
||||
'title' => $title,
|
||||
),
|
||||
)));
|
||||
],
|
||||
]));
|
||||
}
|
||||
$username = array(
|
||||
$username = [
|
||||
'#theme' => 'username',
|
||||
'#account' => $this->userStorage->load($dblog->uid),
|
||||
);
|
||||
$rows[] = array(
|
||||
'data' => array(
|
||||
];
|
||||
$rows[] = [
|
||||
'data' => [
|
||||
// Cells.
|
||||
array('class' => array('icon')),
|
||||
['class' => ['icon']],
|
||||
$this->t($dblog->type),
|
||||
$this->dateFormatter->format($dblog->timestamp, 'short'),
|
||||
$message,
|
||||
array('data' => $username),
|
||||
array('data' => array('#markup' => $dblog->link)),
|
||||
),
|
||||
['data' => $username],
|
||||
['data' => ['#markup' => $dblog->link]],
|
||||
],
|
||||
// Attributes for table row.
|
||||
'class' => array(Html::getClass('dblog-' . $dblog->type), $classes[$dblog->severity]),
|
||||
);
|
||||
'class' => [Html::getClass('dblog-' . $dblog->type), $classes[$dblog->severity]],
|
||||
];
|
||||
}
|
||||
|
||||
$build['dblog_table'] = array(
|
||||
$build['dblog_table'] = [
|
||||
'#type' => 'table',
|
||||
'#header' => $header,
|
||||
'#rows' => $rows,
|
||||
'#attributes' => array('id' => 'admin-dblog', 'class' => array('admin-dblog')),
|
||||
'#attributes' => ['id' => 'admin-dblog', 'class' => ['admin-dblog']],
|
||||
'#empty' => $this->t('No log messages available.'),
|
||||
'#attached' => array(
|
||||
'library' => array('dblog/drupal.dblog'),
|
||||
),
|
||||
);
|
||||
$build['dblog_pager'] = array('#type' => 'pager');
|
||||
'#attached' => [
|
||||
'library' => ['dblog/drupal.dblog'],
|
||||
],
|
||||
];
|
||||
$build['dblog_pager'] = ['#type' => 'pager'];
|
||||
|
||||
return $build;
|
||||
|
||||
|
@ -236,60 +236,60 @@ class DbLogController extends ControllerBase {
|
|||
* format expected by drupal_render();
|
||||
*/
|
||||
public function eventDetails($event_id) {
|
||||
$build = array();
|
||||
if ($dblog = $this->database->query('SELECT w.*, u.uid FROM {watchdog} w LEFT JOIN {users} u ON u.uid = w.uid WHERE w.wid = :id', array(':id' => $event_id))->fetchObject()) {
|
||||
$build = [];
|
||||
if ($dblog = $this->database->query('SELECT w.*, u.uid FROM {watchdog} w LEFT JOIN {users} u ON u.uid = w.uid WHERE w.wid = :id', [':id' => $event_id])->fetchObject()) {
|
||||
$severity = RfcLogLevel::getLevels();
|
||||
$message = $this->formatMessage($dblog);
|
||||
$username = array(
|
||||
$username = [
|
||||
'#theme' => 'username',
|
||||
'#account' => $dblog->uid ? $this->userStorage->load($dblog->uid) : User::getAnonymousUser(),
|
||||
);
|
||||
$rows = array(
|
||||
array(
|
||||
array('data' => $this->t('Type'), 'header' => TRUE),
|
||||
];
|
||||
$rows = [
|
||||
[
|
||||
['data' => $this->t('Type'), 'header' => TRUE],
|
||||
$this->t($dblog->type),
|
||||
),
|
||||
array(
|
||||
array('data' => $this->t('Date'), 'header' => TRUE),
|
||||
],
|
||||
[
|
||||
['data' => $this->t('Date'), 'header' => TRUE],
|
||||
$this->dateFormatter->format($dblog->timestamp, 'long'),
|
||||
),
|
||||
array(
|
||||
array('data' => $this->t('User'), 'header' => TRUE),
|
||||
array('data' => $username),
|
||||
),
|
||||
array(
|
||||
array('data' => $this->t('Location'), 'header' => TRUE),
|
||||
],
|
||||
[
|
||||
['data' => $this->t('User'), 'header' => TRUE],
|
||||
['data' => $username],
|
||||
],
|
||||
[
|
||||
['data' => $this->t('Location'), 'header' => TRUE],
|
||||
$this->l($dblog->location, $dblog->location ? Url::fromUri($dblog->location) : Url::fromRoute('<none>')),
|
||||
),
|
||||
array(
|
||||
array('data' => $this->t('Referrer'), 'header' => TRUE),
|
||||
],
|
||||
[
|
||||
['data' => $this->t('Referrer'), 'header' => TRUE],
|
||||
$this->l($dblog->referer, $dblog->referer ? Url::fromUri($dblog->referer) : Url::fromRoute('<none>')),
|
||||
),
|
||||
array(
|
||||
array('data' => $this->t('Message'), 'header' => TRUE),
|
||||
],
|
||||
[
|
||||
['data' => $this->t('Message'), 'header' => TRUE],
|
||||
$message,
|
||||
),
|
||||
array(
|
||||
array('data' => $this->t('Severity'), 'header' => TRUE),
|
||||
],
|
||||
[
|
||||
['data' => $this->t('Severity'), 'header' => TRUE],
|
||||
$severity[$dblog->severity],
|
||||
),
|
||||
array(
|
||||
array('data' => $this->t('Hostname'), 'header' => TRUE),
|
||||
],
|
||||
[
|
||||
['data' => $this->t('Hostname'), 'header' => TRUE],
|
||||
$dblog->hostname,
|
||||
),
|
||||
array(
|
||||
array('data' => $this->t('Operations'), 'header' => TRUE),
|
||||
array('data' => array('#markup' => $dblog->link)),
|
||||
),
|
||||
);
|
||||
$build['dblog_table'] = array(
|
||||
],
|
||||
[
|
||||
['data' => $this->t('Operations'), 'header' => TRUE],
|
||||
['data' => ['#markup' => $dblog->link]],
|
||||
],
|
||||
];
|
||||
$build['dblog_table'] = [
|
||||
'#type' => 'table',
|
||||
'#rows' => $rows,
|
||||
'#attributes' => array('class' => array('dblog-event')),
|
||||
'#attached' => array(
|
||||
'library' => array('dblog/drupal.dblog'),
|
||||
),
|
||||
);
|
||||
'#attributes' => ['class' => ['dblog-event']],
|
||||
'#attached' => [
|
||||
'library' => ['dblog/drupal.dblog'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
return $build;
|
||||
|
@ -311,9 +311,9 @@ class DbLogController extends ControllerBase {
|
|||
$filters = dblog_filters();
|
||||
|
||||
// Build query.
|
||||
$where = $args = array();
|
||||
$where = $args = [];
|
||||
foreach ($_SESSION['dblog_overview_filter'] as $key => $filter) {
|
||||
$filter_where = array();
|
||||
$filter_where = [];
|
||||
foreach ($filter as $value) {
|
||||
$filter_where[] = $filters[$key]['where'];
|
||||
$args[] = $value;
|
||||
|
@ -324,10 +324,10 @@ class DbLogController extends ControllerBase {
|
|||
}
|
||||
$where = !empty($where) ? implode(' AND ', $where) : '';
|
||||
|
||||
return array(
|
||||
return [
|
||||
'where' => $where,
|
||||
'args' => $args,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -369,8 +369,6 @@ class DbLogController extends ControllerBase {
|
|||
* Messages are not truncated on this page because events detailed herein do
|
||||
* not have links to a detailed view.
|
||||
*
|
||||
* Use one of the above *Report() methods.
|
||||
*
|
||||
* @param string $type
|
||||
* Type of database log events to display (e.g., 'search').
|
||||
*
|
||||
|
@ -378,10 +376,10 @@ class DbLogController extends ControllerBase {
|
|||
* A build array in the format expected by drupal_render().
|
||||
*/
|
||||
public function topLogMessages($type) {
|
||||
$header = array(
|
||||
array('data' => $this->t('Count'), 'field' => 'count', 'sort' => 'desc'),
|
||||
array('data' => $this->t('Message'), 'field' => 'message'),
|
||||
);
|
||||
$header = [
|
||||
['data' => $this->t('Count'), 'field' => 'count', 'sort' => 'desc'],
|
||||
['data' => $this->t('Message'), 'field' => 'message'],
|
||||
];
|
||||
|
||||
$count_query = $this->database->select('watchdog');
|
||||
$count_query->addExpression('COUNT(DISTINCT(message))');
|
||||
|
@ -392,7 +390,7 @@ class DbLogController extends ControllerBase {
|
|||
->extend('\Drupal\Core\Database\Query\TableSortExtender');
|
||||
$query->addExpression('COUNT(wid)', 'count');
|
||||
$query = $query
|
||||
->fields('w', array('message', 'variables'))
|
||||
->fields('w', ['message', 'variables'])
|
||||
->condition('w.type', $type)
|
||||
->groupBy('message')
|
||||
->groupBy('variables')
|
||||
|
@ -401,23 +399,23 @@ class DbLogController extends ControllerBase {
|
|||
$query->setCountQuery($count_query);
|
||||
$result = $query->execute();
|
||||
|
||||
$rows = array();
|
||||
$rows = [];
|
||||
foreach ($result as $dblog) {
|
||||
if ($message = $this->formatMessage($dblog)) {
|
||||
$rows[] = array($dblog->count, $message);
|
||||
$rows[] = [$dblog->count, $message];
|
||||
}
|
||||
}
|
||||
|
||||
$build['dblog_top_table'] = array(
|
||||
$build['dblog_top_table'] = [
|
||||
'#type' => 'table',
|
||||
'#header' => $header,
|
||||
'#rows' => $rows,
|
||||
'#empty' => $this->t('No log messages available.'),
|
||||
'#attached' => array(
|
||||
'library' => array('dblog/drupal.dblog'),
|
||||
),
|
||||
);
|
||||
$build['dblog_top_pager'] = array('#type' => 'pager');
|
||||
'#attached' => [
|
||||
'library' => ['dblog/drupal.dblog'],
|
||||
],
|
||||
];
|
||||
$build['dblog_top_pager'] = ['#type' => 'pager'];
|
||||
|
||||
return $build;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ class DblogClearLogConfirmForm extends ConfirmFormBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
$_SESSION['dblog_overview_filter'] = array();
|
||||
$_SESSION['dblog_overview_filter'] = [];
|
||||
$this->connection->truncate('watchdog')->execute();
|
||||
drupal_set_message($this->t('Database log cleared.'));
|
||||
$form_state->setRedirectUrl($this->getCancelUrl());
|
||||
|
|
|
@ -23,39 +23,39 @@ class DblogFilterForm extends FormBase {
|
|||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$filters = dblog_filters();
|
||||
|
||||
$form['filters'] = array(
|
||||
$form['filters'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => $this->t('Filter log messages'),
|
||||
'#open' => TRUE,
|
||||
);
|
||||
];
|
||||
foreach ($filters as $key => $filter) {
|
||||
$form['filters']['status'][$key] = array(
|
||||
$form['filters']['status'][$key] = [
|
||||
'#title' => $filter['title'],
|
||||
'#type' => 'select',
|
||||
'#multiple' => TRUE,
|
||||
'#size' => 8,
|
||||
'#options' => $filter['options'],
|
||||
);
|
||||
];
|
||||
if (!empty($_SESSION['dblog_overview_filter'][$key])) {
|
||||
$form['filters']['status'][$key]['#default_value'] = $_SESSION['dblog_overview_filter'][$key];
|
||||
}
|
||||
}
|
||||
|
||||
$form['filters']['actions'] = array(
|
||||
$form['filters']['actions'] = [
|
||||
'#type' => 'actions',
|
||||
'#attributes' => array('class' => array('container-inline')),
|
||||
);
|
||||
$form['filters']['actions']['submit'] = array(
|
||||
'#attributes' => ['class' => ['container-inline']],
|
||||
];
|
||||
$form['filters']['actions']['submit'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Filter'),
|
||||
);
|
||||
];
|
||||
if (!empty($_SESSION['dblog_overview_filter'])) {
|
||||
$form['filters']['actions']['reset'] = array(
|
||||
$form['filters']['actions']['reset'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Reset'),
|
||||
'#limit_validation_errors' => array(),
|
||||
'#submit' => array('::resetForm'),
|
||||
);
|
||||
'#limit_validation_errors' => [],
|
||||
'#submit' => ['::resetForm'],
|
||||
];
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ class DblogFilterForm extends FormBase {
|
|||
* The current state of the form.
|
||||
*/
|
||||
public function resetForm(array &$form, FormStateInterface $form_state) {
|
||||
$_SESSION['dblog_overview_filter'] = array();
|
||||
$_SESSION['dblog_overview_filter'] = [];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ class DbLog implements LoggerInterface {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function log($level, $message, array $context = array()) {
|
||||
public function log($level, $message, array $context = []) {
|
||||
// Remove any backtraces since they may contain an unserializable variable.
|
||||
unset($context['backtrace']);
|
||||
|
||||
|
@ -64,7 +64,7 @@ class DbLog implements LoggerInterface {
|
|||
try {
|
||||
$this->connection
|
||||
->insert('watchdog')
|
||||
->fields(array(
|
||||
->fields([
|
||||
'uid' => $context['uid'],
|
||||
'type' => Unicode::substr($context['channel'], 0, 64),
|
||||
'message' => $message,
|
||||
|
@ -75,7 +75,7 @@ class DbLog implements LoggerInterface {
|
|||
'referer' => $context['referer'],
|
||||
'hostname' => Unicode::substr($context['ip'], 0, 128),
|
||||
'timestamp' => $context['timestamp'],
|
||||
))
|
||||
])
|
||||
->execute();
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
|
|
|
@ -38,13 +38,13 @@ class DBLogResource extends ResourceBase {
|
|||
*/
|
||||
public function get($id = NULL) {
|
||||
if ($id) {
|
||||
$record = db_query("SELECT * FROM {watchdog} WHERE wid = :wid", array(':wid' => $id))
|
||||
$record = db_query("SELECT * FROM {watchdog} WHERE wid = :wid", [':wid' => $id])
|
||||
->fetchAssoc();
|
||||
if (!empty($record)) {
|
||||
return new ResourceResponse($record);
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException(t('Log entry with ID @id was not found', array('@id' => $id)));
|
||||
throw new NotFoundHttpException(t('Log entry with ID @id was not found', ['@id' => $id]));
|
||||
}
|
||||
|
||||
throw new BadRequestHttpException(t('No log entry ID was provided'));
|
||||
|
|
|
@ -34,7 +34,7 @@ class DblogMessage extends FieldPluginBase {
|
|||
*/
|
||||
protected function defineOptions() {
|
||||
$options = parent::defineOptions();
|
||||
$options['replace_variables'] = array('default' => TRUE);
|
||||
$options['replace_variables'] = ['default' => TRUE];
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
@ -45,11 +45,11 @@ class DblogMessage extends FieldPluginBase {
|
|||
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
|
||||
parent::buildOptionsForm($form, $form_state);
|
||||
|
||||
$form['replace_variables'] = array(
|
||||
$form['replace_variables'] = [
|
||||
'#title' => $this->t('Replace variables'),
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => $this->options['replace_variables'],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,7 @@ class DbLogTest extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('dblog', 'node', 'forum', 'help', 'block');
|
||||
public static $modules = ['dblog', 'node', 'forum', 'help', 'block'];
|
||||
|
||||
/**
|
||||
* A user with some relevant administrative permissions.
|
||||
|
@ -47,8 +47,8 @@ class DbLogTest extends WebTestBase {
|
|||
$this->drupalPlaceBlock('page_title_block');
|
||||
|
||||
// Create users with specific permissions.
|
||||
$this->adminUser = $this->drupalCreateUser(array('administer site configuration', 'access administration pages', 'access site reports', 'administer users'));
|
||||
$this->webUser = $this->drupalCreateUser(array());
|
||||
$this->adminUser = $this->drupalCreateUser(['administer site configuration', 'access administration pages', 'access site reports', 'administer users']);
|
||||
$this->webUser = $this->drupalCreateUser([]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,7 +58,7 @@ class DbLogTest extends WebTestBase {
|
|||
* Database Logging module functionality through both the admin and user
|
||||
* interfaces.
|
||||
*/
|
||||
function testDbLog() {
|
||||
public function testDbLog() {
|
||||
// Log in the admin user.
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
|
@ -70,8 +70,8 @@ class DbLogTest extends WebTestBase {
|
|||
$this->verifyBreadcrumbs();
|
||||
$this->verifyLinkEscaping();
|
||||
// Verify the overview table sorting.
|
||||
$orders = array('Date', 'Type', 'User');
|
||||
$sorts = array('asc', 'desc');
|
||||
$orders = ['Date', 'Type', 'User'];
|
||||
$sorts = ['asc', 'desc'];
|
||||
foreach ($orders as $order) {
|
||||
foreach ($sorts as $sort) {
|
||||
$this->verifySort($sort, $order);
|
||||
|
@ -124,14 +124,14 @@ class DbLogTest extends WebTestBase {
|
|||
*/
|
||||
private function verifyRowLimit($row_limit) {
|
||||
// Change the database log row limit.
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit['dblog_row_limit'] = $row_limit;
|
||||
$this->drupalPostForm('admin/config/development/logging', $edit, t('Save configuration'));
|
||||
$this->assertResponse(200);
|
||||
|
||||
// Check row limit variable.
|
||||
$current_limit = $this->config('dblog.settings')->get('row_limit');
|
||||
$this->assertTrue($current_limit == $row_limit, format_string('[Cache] Row limit variable of @count equals row limit of @limit', array('@count' => $current_limit, '@limit' => $row_limit)));
|
||||
$this->assertTrue($current_limit == $row_limit, format_string('[Cache] Row limit variable of @count equals row limit of @limit', ['@count' => $current_limit, '@limit' => $row_limit]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -145,8 +145,27 @@ class DbLogTest extends WebTestBase {
|
|||
$this->generateLogEntries($row_limit + 10);
|
||||
// Verify that the database log row count exceeds the row limit.
|
||||
$count = db_query('SELECT COUNT(wid) FROM {watchdog}')->fetchField();
|
||||
$this->assertTrue($count > $row_limit, format_string('Dblog row count of @count exceeds row limit of @limit', array('@count' => $count, '@limit' => $row_limit)));
|
||||
$this->assertTrue($count > $row_limit, format_string('Dblog row count of @count exceeds row limit of @limit', ['@count' => $count, '@limit' => $row_limit]));
|
||||
|
||||
// Get the number of enabled modules. Cron adds a log entry for each module.
|
||||
$list = \Drupal::moduleHandler()->getImplementations('cron');
|
||||
$module_count = count($list);
|
||||
$cron_detailed_count = $this->runCron();
|
||||
$this->assertTrue($cron_detailed_count == $module_count + 2, format_string('Cron added @count of @expected new log entries', ['@count' => $cron_detailed_count, '@expected' => $module_count + 2]));
|
||||
|
||||
// Test disabling of detailed cron logging.
|
||||
$this->config('system.cron')->set('logging', 0)->save();
|
||||
$cron_count = $this->runCron();
|
||||
$this->assertTrue($cron_count = 1, format_string('Cron added @count of @expected new log entries', ['@count' => $cron_count, '@expected' => 1]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs cron and returns number of new log entries.
|
||||
*
|
||||
* @return int
|
||||
* Number of new watchdog entries.
|
||||
*/
|
||||
private function runCron() {
|
||||
// Get last ID to compare against; log entries get deleted, so we can't
|
||||
// reliably add the number of newly created log entries to the current count
|
||||
// to measure number of log entries created by cron.
|
||||
|
@ -158,12 +177,7 @@ class DbLogTest extends WebTestBase {
|
|||
// Get last ID after cron was run.
|
||||
$current_id = db_query('SELECT MAX(wid) FROM {watchdog}')->fetchField();
|
||||
|
||||
// Get the number of enabled modules. Cron adds a log entry for each module.
|
||||
$list = \Drupal::moduleHandler()->getImplementations('cron');
|
||||
$module_count = count($list);
|
||||
|
||||
$count = $current_id - $last_id;
|
||||
$this->assertTrue(($current_id - $last_id) == $module_count + 2, format_string('Cron added @count of @expected new log entries', array('@count' => $count, '@expected' => $module_count + 2)));
|
||||
return $current_id - $last_id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -189,7 +203,7 @@ class DbLogTest extends WebTestBase {
|
|||
* entry.
|
||||
* - 'timestamp': Int unix timestamp.
|
||||
*/
|
||||
private function generateLogEntries($count, $options = array()) {
|
||||
private function generateLogEntries($count, $options = []) {
|
||||
global $base_root;
|
||||
|
||||
// This long URL makes it just a little bit harder to pass the link part of
|
||||
|
@ -198,10 +212,10 @@ class DbLogTest extends WebTestBase {
|
|||
$link = urldecode('/content/xo%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A-lake-isabelle');
|
||||
|
||||
// Prepare the fields to be logged
|
||||
$log = $options + array(
|
||||
$log = $options + [
|
||||
'channel' => 'custom',
|
||||
'message' => 'Dblog test log message',
|
||||
'variables' => array(),
|
||||
'variables' => [],
|
||||
'severity' => RfcLogLevel::NOTICE,
|
||||
'link' => $link,
|
||||
'user' => $this->adminUser,
|
||||
|
@ -210,7 +224,7 @@ class DbLogTest extends WebTestBase {
|
|||
'referer' => \Drupal::request()->server->get('HTTP_REFERER'),
|
||||
'ip' => '127.0.0.1',
|
||||
'timestamp' => REQUEST_TIME,
|
||||
);
|
||||
];
|
||||
|
||||
$logger = $this->container->get('logger.dblog');
|
||||
$message = $log['message'] . ' Entry #';
|
||||
|
@ -236,7 +250,7 @@ class DbLogTest extends WebTestBase {
|
|||
* (optional) The log entry severity.
|
||||
*/
|
||||
protected function filterLogsEntries($type = NULL, $severity = NULL) {
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
if (!is_null($type)) {
|
||||
$edit['type[]'] = $type;
|
||||
}
|
||||
|
@ -307,8 +321,8 @@ class DbLogTest extends WebTestBase {
|
|||
private function verifyEvents() {
|
||||
// Invoke events.
|
||||
$this->doUser();
|
||||
$this->drupalCreateContentType(array('type' => 'article', 'name' => t('Article')));
|
||||
$this->drupalCreateContentType(array('type' => 'page', 'name' => t('Basic page')));
|
||||
$this->drupalCreateContentType(['type' => 'article', 'name' => t('Article')]);
|
||||
$this->drupalCreateContentType(['type' => 'page', 'name' => t('Basic page')]);
|
||||
$this->doNode('article');
|
||||
$this->doNode('page');
|
||||
$this->doNode('forum');
|
||||
|
@ -327,7 +341,7 @@ class DbLogTest extends WebTestBase {
|
|||
* The order by which the table should be sorted.
|
||||
*/
|
||||
public function verifySort($sort = 'asc', $order = 'Date') {
|
||||
$this->drupalGet('admin/reports/dblog', array('query' => array('sort' => $sort, 'order' => $order)));
|
||||
$this->drupalGet('admin/reports/dblog', ['query' => ['sort' => $sort, 'order' => $order]]);
|
||||
$this->assertResponse(200);
|
||||
$this->assertText(t('Recent log messages'), 'DBLog report was displayed correctly and sorting went fine.');
|
||||
}
|
||||
|
@ -337,12 +351,12 @@ class DbLogTest extends WebTestBase {
|
|||
* page.
|
||||
*/
|
||||
private function verifyLinkEscaping() {
|
||||
$link = \Drupal::l('View', Url::fromRoute('entity.node.canonical', array('node' => 1)));
|
||||
$link = \Drupal::l('View', Url::fromRoute('entity.node.canonical', ['node' => 1]));
|
||||
$message = 'Log entry added to do the verifyLinkEscaping test.';
|
||||
$this->generateLogEntries(1, array(
|
||||
$this->generateLogEntries(1, [
|
||||
'message' => $message,
|
||||
'link' => $link,
|
||||
));
|
||||
]);
|
||||
|
||||
$result = db_query_range('SELECT wid FROM {watchdog} ORDER BY wid DESC', 0, 1);
|
||||
$this->drupalGet('admin/reports/dblog/event/' . $result->fetchField());
|
||||
|
@ -360,7 +374,7 @@ class DbLogTest extends WebTestBase {
|
|||
$pass = user_password();
|
||||
// Add a user using the form to generate an add user event (which is not
|
||||
// triggered by drupalCreateUser).
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit['name'] = $name;
|
||||
$edit['mail'] = $name . '@example.com';
|
||||
$edit['pass[pass1]'] = $pass;
|
||||
|
@ -370,7 +384,7 @@ class DbLogTest extends WebTestBase {
|
|||
$this->assertResponse(200);
|
||||
// Retrieve the user object.
|
||||
$user = user_load_by_name($name);
|
||||
$this->assertTrue($user != NULL, format_string('User @name was loaded', array('@name' => $name)));
|
||||
$this->assertTrue($user != NULL, format_string('User @name was loaded', ['@name' => $name]));
|
||||
// pass_raw property is needed by drupalLogin.
|
||||
$user->pass_raw = $pass;
|
||||
// Log in user.
|
||||
|
@ -378,18 +392,18 @@ class DbLogTest extends WebTestBase {
|
|||
// Log out user.
|
||||
$this->drupalLogout();
|
||||
// Fetch the row IDs in watchdog that relate to the user.
|
||||
$result = db_query('SELECT wid FROM {watchdog} WHERE uid = :uid', array(':uid' => $user->id()));
|
||||
$result = db_query('SELECT wid FROM {watchdog} WHERE uid = :uid', [':uid' => $user->id()]);
|
||||
foreach ($result as $row) {
|
||||
$ids[] = $row->wid;
|
||||
}
|
||||
$count_before = (isset($ids)) ? count($ids) : 0;
|
||||
$this->assertTrue($count_before > 0, format_string('DBLog contains @count records for @name', array('@count' => $count_before, '@name' => $user->getUsername())));
|
||||
$this->assertTrue($count_before > 0, format_string('DBLog contains @count records for @name', ['@count' => $count_before, '@name' => $user->getUsername()]));
|
||||
|
||||
// Log in the admin user.
|
||||
$this->drupalLogin($this->adminUser);
|
||||
// Delete the user created at the start of this test.
|
||||
// We need to POST here to invoke batch_process() in the internal browser.
|
||||
$this->drupalPostForm('user/' . $user->id() . '/cancel', array('user_cancel_method' => 'user_cancel_reassign'), t('Cancel account'));
|
||||
$this->drupalPostForm('user/' . $user->id() . '/cancel', ['user_cancel_method' => 'user_cancel_reassign'], t('Cancel account'));
|
||||
|
||||
// View the database log report.
|
||||
$this->drupalGet('admin/reports/dblog');
|
||||
|
@ -399,13 +413,13 @@ class DbLogTest extends WebTestBase {
|
|||
// Add user.
|
||||
// Default display includes name and email address; if too long, the email
|
||||
// address is replaced by three periods.
|
||||
$this->assertLogMessage(t('New user: %name %email.', array('%name' => $name, '%email' => '<' . $user->getEmail() . '>')), 'DBLog event was recorded: [add user]');
|
||||
$this->assertLogMessage(t('New user: %name %email.', ['%name' => $name, '%email' => '<' . $user->getEmail() . '>']), 'DBLog event was recorded: [add user]');
|
||||
// Log in user.
|
||||
$this->assertLogMessage(t('Session opened for %name.', array('%name' => $name)), 'DBLog event was recorded: [login user]');
|
||||
$this->assertLogMessage(t('Session opened for %name.', ['%name' => $name]), 'DBLog event was recorded: [login user]');
|
||||
// Log out user.
|
||||
$this->assertLogMessage(t('Session closed for %name.', array('%name' => $name)), 'DBLog event was recorded: [logout user]');
|
||||
$this->assertLogMessage(t('Session closed for %name.', ['%name' => $name]), 'DBLog event was recorded: [logout user]');
|
||||
// Delete user.
|
||||
$message = t('Deleted user: %name %email.', array('%name' => $name, '%email' => '<' . $user->getEmail() . '>'));
|
||||
$message = t('Deleted user: %name %email.', ['%name' => $name, '%email' => '<' . $user->getEmail() . '>']);
|
||||
$message_text = Unicode::truncate(Html::decodeEntities(strip_tags($message)), 56, TRUE, TRUE);
|
||||
// Verify that the full message displays on the details page.
|
||||
$link = FALSE;
|
||||
|
@ -443,7 +457,7 @@ class DbLogTest extends WebTestBase {
|
|||
*/
|
||||
private function doNode($type) {
|
||||
// Create user.
|
||||
$perm = array('create ' . $type . ' content', 'edit own ' . $type . ' content', 'delete own ' . $type . ' content');
|
||||
$perm = ['create ' . $type . ' content', 'edit own ' . $type . ' content', 'delete own ' . $type . ' content'];
|
||||
$user = $this->drupalCreateUser($perm);
|
||||
// Log in user.
|
||||
$this->drupalLogin($user);
|
||||
|
@ -456,13 +470,13 @@ class DbLogTest extends WebTestBase {
|
|||
$this->assertResponse(200);
|
||||
// Retrieve the node object.
|
||||
$node = $this->drupalGetNodeByTitle($title);
|
||||
$this->assertTrue($node != NULL, format_string('Node @title was loaded', array('@title' => $title)));
|
||||
$this->assertTrue($node != NULL, format_string('Node @title was loaded', ['@title' => $title]));
|
||||
// Edit the node.
|
||||
$edit = $this->getContentUpdate($type);
|
||||
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
|
||||
$this->assertResponse(200);
|
||||
// Delete the node.
|
||||
$this->drupalPostForm('node/' . $node->id() . '/delete', array(), t('Delete'));
|
||||
$this->drupalPostForm('node/' . $node->id() . '/delete', [], t('Delete'));
|
||||
$this->assertResponse(200);
|
||||
// View the node (to generate page not found event).
|
||||
$this->drupalGet('node/' . $node->id());
|
||||
|
@ -479,11 +493,11 @@ class DbLogTest extends WebTestBase {
|
|||
|
||||
// Verify that node events were recorded.
|
||||
// Was node content added?
|
||||
$this->assertLogMessage(t('@type: added %title.', array('@type' => $type, '%title' => $title)), 'DBLog event was recorded: [content added]');
|
||||
$this->assertLogMessage(t('@type: added %title.', ['@type' => $type, '%title' => $title]), 'DBLog event was recorded: [content added]');
|
||||
// Was node content updated?
|
||||
$this->assertLogMessage(t('@type: updated %title.', array('@type' => $type, '%title' => $title)), 'DBLog event was recorded: [content updated]');
|
||||
$this->assertLogMessage(t('@type: updated %title.', ['@type' => $type, '%title' => $title]), 'DBLog event was recorded: [content updated]');
|
||||
// Was node content deleted?
|
||||
$this->assertLogMessage(t('@type: deleted %title.', array('@type' => $type, '%title' => $title)), 'DBLog event was recorded: [content deleted]');
|
||||
$this->assertLogMessage(t('@type: deleted %title.', ['@type' => $type, '%title' => $title]), 'DBLog event was recorded: [content deleted]');
|
||||
|
||||
// View the database log access-denied report page.
|
||||
$this->drupalGet('admin/reports/access-denied');
|
||||
|
@ -510,18 +524,18 @@ class DbLogTest extends WebTestBase {
|
|||
private function getContent($type) {
|
||||
switch ($type) {
|
||||
case 'forum':
|
||||
$content = array(
|
||||
$content = [
|
||||
'title[0][value]' => $this->randomMachineName(8),
|
||||
'taxonomy_forums' => array(1),
|
||||
'taxonomy_forums' => [1],
|
||||
'body[0][value]' => $this->randomMachineName(32),
|
||||
);
|
||||
];
|
||||
break;
|
||||
|
||||
default:
|
||||
$content = array(
|
||||
$content = [
|
||||
'title[0][value]' => $this->randomMachineName(8),
|
||||
'body[0][value]' => $this->randomMachineName(32),
|
||||
);
|
||||
];
|
||||
break;
|
||||
}
|
||||
return $content;
|
||||
|
@ -537,9 +551,9 @@ class DbLogTest extends WebTestBase {
|
|||
* Random content needed by various node types.
|
||||
*/
|
||||
private function getContentUpdate($type) {
|
||||
$content = array(
|
||||
$content = [
|
||||
'body[0][value]' => $this->randomMachineName(32),
|
||||
);
|
||||
];
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
@ -553,10 +567,10 @@ class DbLogTest extends WebTestBase {
|
|||
global $base_root;
|
||||
// Get a count of how many watchdog entries already exist.
|
||||
$count = db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField();
|
||||
$log = array(
|
||||
$log = [
|
||||
'channel' => 'system',
|
||||
'message' => 'Log entry added to test the doClearTest clear down.',
|
||||
'variables' => array(),
|
||||
'variables' => [],
|
||||
'severity' => RfcLogLevel::NOTICE,
|
||||
'link' => NULL,
|
||||
'user' => $this->adminUser,
|
||||
|
@ -565,20 +579,20 @@ class DbLogTest extends WebTestBase {
|
|||
'referer' => \Drupal::request()->server->get('HTTP_REFERER'),
|
||||
'ip' => '127.0.0.1',
|
||||
'timestamp' => REQUEST_TIME,
|
||||
);
|
||||
];
|
||||
// Add a watchdog entry.
|
||||
$this->container->get('logger.dblog')->log($log['severity'], $log['message'], $log);
|
||||
// Make sure the table count has actually been incremented.
|
||||
$this->assertEqual($count + 1, db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField(), format_string('\Drupal\dblog\Logger\DbLog->log() added an entry to the dblog :count', array(':count' => $count)));
|
||||
$this->assertEqual($count + 1, db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField(), format_string('\Drupal\dblog\Logger\DbLog->log() added an entry to the dblog :count', [':count' => $count]));
|
||||
// Log in the admin user.
|
||||
$this->drupalLogin($this->adminUser);
|
||||
// Post in order to clear the database table.
|
||||
$this->clearLogsEntries();
|
||||
// Confirm that the logs should be cleared.
|
||||
$this->drupalPostForm(NULL, array(), 'Confirm');
|
||||
$this->drupalPostForm(NULL, [], 'Confirm');
|
||||
// Count the rows in watchdog that previously related to the deleted user.
|
||||
$count = db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField();
|
||||
$this->assertEqual($count, 0, format_string('DBLog contains :count records after a clear.', array(':count' => $count)));
|
||||
$this->assertEqual($count, 0, format_string('DBLog contains :count records after a clear.', [':count' => $count]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -591,21 +605,21 @@ class DbLogTest extends WebTestBase {
|
|||
db_delete('watchdog')->execute();
|
||||
|
||||
// Generate 9 random watchdog entries.
|
||||
$type_names = array();
|
||||
$types = array();
|
||||
$type_names = [];
|
||||
$types = [];
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$type_names[] = $type_name = $this->randomMachineName();
|
||||
$severity = RfcLogLevel::EMERGENCY;
|
||||
for ($j = 0; $j < 3; $j++) {
|
||||
$types[] = $type = array(
|
||||
$types[] = $type = [
|
||||
'count' => $j + 1,
|
||||
'type' => $type_name,
|
||||
'severity' => $severity++,
|
||||
);
|
||||
$this->generateLogEntries($type['count'], array(
|
||||
];
|
||||
$this->generateLogEntries($type['count'], [
|
||||
'channel' => $type['type'],
|
||||
'severity' => $type['severity'],
|
||||
));
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -644,14 +658,14 @@ class DbLogTest extends WebTestBase {
|
|||
$this->assertEqual(array_sum($count), $type['count'], 'Count matched');
|
||||
}
|
||||
|
||||
$this->drupalGet('admin/reports/dblog', array('query' => array('order' => 'Type')));
|
||||
$this->drupalGet('admin/reports/dblog', ['query' => ['order' => 'Type']]);
|
||||
$this->assertResponse(200);
|
||||
$this->assertText(t('Operations'), 'Operations text found');
|
||||
|
||||
// Clear all logs and make sure the confirmation message is found.
|
||||
$this->clearLogsEntries();
|
||||
// Confirm that the logs should be cleared.
|
||||
$this->drupalPostForm(NULL, array(), 'Confirm');
|
||||
$this->drupalPostForm(NULL, [], 'Confirm');
|
||||
$this->assertText(t('Database log cleared.'), 'Confirmation message found');
|
||||
}
|
||||
|
||||
|
@ -666,16 +680,16 @@ class DbLogTest extends WebTestBase {
|
|||
* - user: (string) The user associated with this database log event.
|
||||
*/
|
||||
protected function getLogEntries() {
|
||||
$entries = array();
|
||||
$entries = [];
|
||||
if ($table = $this->getLogsEntriesTable()) {
|
||||
$table = array_shift($table);
|
||||
foreach ($table->tbody->tr as $row) {
|
||||
$entries[] = array(
|
||||
$entries[] = [
|
||||
'severity' => $this->getSeverityConstant($row['class']),
|
||||
'type' => $this->asText($row->td[1]),
|
||||
'message' => $this->asText($row->td[3]),
|
||||
'user' => $this->asText($row->td[4]),
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
return $entries;
|
||||
|
@ -781,7 +795,7 @@ class DbLogTest extends WebTestBase {
|
|||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
// Generate a single watchdog entry.
|
||||
$this->generateLogEntries(1, array('user' => $tempuser, 'uid' => $tempuser_uid));
|
||||
$this->generateLogEntries(1, ['user' => $tempuser, 'uid' => $tempuser_uid]);
|
||||
$wid = db_query('SELECT MAX(wid) FROM {watchdog}')->fetchField();
|
||||
|
||||
// Check if the full message displays on the details page.
|
||||
|
|
|
@ -18,7 +18,7 @@ class DbLogResourceTest extends RESTTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('hal', 'dblog');
|
||||
public static $modules = ['hal', 'dblog'];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
@ -33,12 +33,12 @@ class DbLogResourceTest extends RESTTestBase {
|
|||
// Write a log message to the DB.
|
||||
$this->container->get('logger.channel.rest')->notice('Test message');
|
||||
// Get the ID of the written message.
|
||||
$id = db_query_range("SELECT wid FROM {watchdog} WHERE type = :type ORDER BY wid DESC", 0, 1, array(':type' => 'rest'))
|
||||
$id = db_query_range("SELECT wid FROM {watchdog} WHERE type = :type ORDER BY wid DESC", 0, 1, [':type' => 'rest'])
|
||||
->fetchField();
|
||||
|
||||
// Create a user account that has the required permissions to read
|
||||
// the watchdog resource via the REST API.
|
||||
$account = $this->drupalCreateUser(array('restful get dblog'));
|
||||
$account = $this->drupalCreateUser(['restful get dblog']);
|
||||
$this->drupalLogin($account);
|
||||
|
||||
$response = $this->httpRequest(Url::fromRoute('rest.dblog.GET.' . $this->defaultFormat, ['id' => $id, '_format' => $this->defaultFormat]), 'GET');
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\dblog\Tests;
|
||||
namespace Drupal\Tests\dblog\Functional;
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests logging of connection failures.
|
||||
*
|
||||
* @group dblog
|
||||
*/
|
||||
class ConnectionFailureTest extends WebTestBase {
|
||||
class ConnectionFailureTest extends BrowserTestBase {
|
||||
|
||||
public static $modules = array('dblog');
|
||||
public static $modules = ['dblog'];
|
||||
|
||||
/**
|
||||
* Tests logging of connection failures.
|
||||
*/
|
||||
function testConnectionFailureLogging() {
|
||||
public function testConnectionFailureLogging() {
|
||||
$logger = \Drupal::service('logger.factory');
|
||||
|
||||
// MySQL errors like "1153 - Got a packet bigger than 'max_allowed_packet'
|
|
@ -31,7 +31,7 @@ class DbLogFormInjectionTest extends KernelTestBase implements FormInterface {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('system', 'dblog', 'user');
|
||||
public static $modules = ['system', 'dblog', 'user'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -82,10 +82,10 @@ class DbLogFormInjectionTest extends KernelTestBase implements FormInterface {
|
|||
$this->installSchema('system', ['key_value_expire', 'sequences']);
|
||||
$this->installEntitySchema('user');
|
||||
$this->logger = \Drupal::logger('test_logger');
|
||||
$test_user = User::create(array(
|
||||
$test_user = User::create([
|
||||
'name' => 'foobar',
|
||||
'mail' => 'foobar@example.com',
|
||||
));
|
||||
]);
|
||||
$test_user->save();
|
||||
\Drupal::service('current_user')->setAccount($test_user);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Drupal\Tests\dblog\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\config\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,14 +22,14 @@ class ViewsIntegrationTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_dblog');
|
||||
public static $testViews = ['test_dblog'];
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('dblog', 'dblog_test_views', 'user');
|
||||
public static $modules = ['dblog', 'dblog_test_views', 'user'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -40,9 +40,9 @@ class ViewsIntegrationTest extends ViewsKernelTestBase {
|
|||
// Rebuild the router, otherwise we can't generate links.
|
||||
$this->container->get('router.builder')->rebuild();
|
||||
|
||||
$this->installSchema('dblog', array('watchdog'));
|
||||
$this->installSchema('dblog', ['watchdog']);
|
||||
|
||||
ViewTestData::createTestViews(get_class($this), array('dblog_test_views'));
|
||||
ViewTestData::createTestViews(get_class($this), ['dblog_test_views']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,35 +53,35 @@ class ViewsIntegrationTest extends ViewsKernelTestBase {
|
|||
// Remove the watchdog entries added by the potential batch process.
|
||||
$this->container->get('database')->truncate('watchdog')->execute();
|
||||
|
||||
$entries = array();
|
||||
$entries = [];
|
||||
// Setup a watchdog entry without tokens.
|
||||
$entries[] = array(
|
||||
$entries[] = [
|
||||
'message' => $this->randomMachineName(),
|
||||
'variables' => array('link' => \Drupal::l('Link', new Url('<front>'))),
|
||||
);
|
||||
'variables' => ['link' => \Drupal::l('Link', new Url('<front>'))],
|
||||
];
|
||||
// Setup a watchdog entry with one token.
|
||||
$entries[] = array(
|
||||
$entries[] = [
|
||||
'message' => '@token1',
|
||||
'variables' => array('@token1' => $this->randomMachineName(), 'link' => \Drupal::l('Link', new Url('<front>'))),
|
||||
);
|
||||
'variables' => ['@token1' => $this->randomMachineName(), 'link' => \Drupal::l('Link', new Url('<front>'))],
|
||||
];
|
||||
// Setup a watchdog entry with two tokens.
|
||||
$entries[] = array(
|
||||
$entries[] = [
|
||||
'message' => '@token1 @token2',
|
||||
// Setup a link with a tag which is filtered by
|
||||
// \Drupal\Component\Utility\Xss::filterAdmin() in order to make sure
|
||||
// that strings which are not marked as safe get filtered.
|
||||
'variables' => array(
|
||||
'variables' => [
|
||||
'@token1' => $this->randomMachineName(),
|
||||
'@token2' => $this->randomMachineName(),
|
||||
'link' => '<a href="' . \Drupal::url('<front>') . '"><object>Link</object></a>',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$logger_factory = $this->container->get('logger.factory');
|
||||
foreach ($entries as $entry) {
|
||||
$entry += array(
|
||||
$entry += [
|
||||
'type' => 'test-views',
|
||||
'severity' => RfcLogLevel::NOTICE,
|
||||
);
|
||||
];
|
||||
$logger_factory->get($entry['type'])->log($entry['severity'], $entry['message'], $entry['variables']);
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue