Chris@0: 'Table that contains logs of all system events.', Chris@0: 'fields' => [ Chris@0: 'wid' => [ Chris@0: 'type' => 'serial', Chris@0: 'not null' => TRUE, Chris@0: 'description' => 'Primary Key: Unique watchdog event ID.', Chris@0: ], Chris@0: 'uid' => [ Chris@0: 'type' => 'int', Chris@0: 'unsigned' => TRUE, Chris@0: 'not null' => TRUE, Chris@0: 'default' => 0, Chris@0: 'description' => 'The {users}.uid of the user who triggered the event.', Chris@0: ], Chris@0: 'type' => [ Chris@0: 'type' => 'varchar_ascii', Chris@0: 'length' => 64, Chris@0: 'not null' => TRUE, Chris@0: 'default' => '', Chris@0: 'description' => 'Type of log message, for example "user" or "page not found."', Chris@0: ], Chris@0: 'message' => [ Chris@0: 'type' => 'text', Chris@0: 'not null' => TRUE, Chris@0: 'size' => 'big', Chris@0: 'description' => 'Text of log message to be passed into the t() function.', Chris@0: ], Chris@0: 'variables' => [ Chris@0: 'type' => 'blob', Chris@0: 'not null' => TRUE, Chris@0: 'size' => 'big', Chris@0: 'description' => 'Serialized array of variables that match the message string and that is passed into the t() function.', Chris@0: ], Chris@0: 'severity' => [ Chris@0: 'type' => 'int', Chris@0: 'unsigned' => TRUE, Chris@0: 'not null' => TRUE, Chris@0: 'default' => 0, Chris@0: 'size' => 'tiny', Chris@0: 'description' => 'The severity level of the event; ranges from 0 (Emergency) to 7 (Debug)', Chris@0: ], Chris@0: 'link' => [ Chris@0: 'type' => 'text', Chris@0: 'not null' => FALSE, Chris@0: 'description' => 'Link to view the result of the event.', Chris@0: ], Chris@0: 'location' => [ Chris@0: 'type' => 'text', Chris@0: 'not null' => TRUE, Chris@0: 'description' => 'URL of the origin of the event.', Chris@0: ], Chris@0: 'referer' => [ Chris@0: 'type' => 'text', Chris@0: 'not null' => FALSE, Chris@0: 'description' => 'URL of referring page.', Chris@0: ], Chris@0: 'hostname' => [ Chris@0: 'type' => 'varchar_ascii', Chris@0: 'length' => 128, Chris@0: 'not null' => TRUE, Chris@0: 'default' => '', Chris@0: 'description' => 'Hostname of the user who triggered the event.', Chris@0: ], Chris@0: 'timestamp' => [ Chris@0: 'type' => 'int', Chris@0: 'not null' => TRUE, Chris@0: 'default' => 0, Chris@0: 'description' => 'Unix timestamp of when event occurred.', Chris@0: ], Chris@0: ], Chris@0: 'primary key' => ['wid'], Chris@0: 'indexes' => [ Chris@0: 'type' => ['type'], Chris@0: 'uid' => ['uid'], Chris@0: 'severity' => ['severity'], Chris@0: ], Chris@0: ]; Chris@0: Chris@0: return $schema; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Use standard plugin for wid and uid fields. Use dblog_types for type filter. Chris@0: */ Chris@0: function dblog_update_8400() { Chris@0: $config_factory = \Drupal::configFactory(); Chris@0: Chris@0: foreach ($config_factory->listAll('views.view.') as $view_config_name) { Chris@0: $view = $config_factory->getEditable($view_config_name); Chris@0: if ($view->get('base_table') != 'watchdog') { Chris@0: continue; Chris@0: } Chris@0: Chris@0: $save = FALSE; Chris@0: foreach ($view->get('display') as $display_name => $display) { Chris@0: // Iterate through all the fields of watchdog views based tables. Chris@0: if (isset($display['display_options']['fields'])) { Chris@0: foreach ($display['display_options']['fields'] as $field_name => $field) { Chris@0: // We are only interested in wid and uid fields from the watchdog Chris@0: // table that still use the numeric id. Chris@0: if (isset($field['table']) && Chris@0: $field['table'] === 'watchdog' && Chris@0: $field['plugin_id'] == 'numeric' && Chris@0: in_array($field['field'], ['wid', 'uid'])) { Chris@0: Chris@0: $save = TRUE; Chris@0: $new_value = $field; Chris@0: $new_value['plugin_id'] = 'standard'; Chris@0: Chris@0: // Delete all the attributes related to numeric fields. Chris@0: unset( Chris@0: $new_value['set_precision'], Chris@0: $new_value['precision'], Chris@0: $new_value['decimal'], Chris@0: $new_value['separator'], Chris@0: $new_value['format_plural'], Chris@0: $new_value['format_plural_string'], Chris@0: $new_value['prefix'], Chris@0: $new_value['suffix'] Chris@0: ); Chris@0: $view->set("display.$display_name.display_options.fields.$field_name", $new_value); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // Iterate all filters looking for type filters to update. Chris@0: if (isset($display['display_options']['filters'])) { Chris@0: foreach ($display['display_options']['filters'] as $filter_name => $filter) { Chris@0: if (isset($filter['table']) && Chris@0: $filter['table'] === 'watchdog' && Chris@0: $filter['plugin_id'] == 'in_operator' && Chris@0: $filter['field'] == 'type') { Chris@0: Chris@0: $save = TRUE; Chris@0: $filter['plugin_id'] = 'dblog_types'; Chris@0: $view->set("display.$display_name.display_options.filters.$filter_name", $filter); Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: if ($save) { Chris@0: $view->save(); Chris@0: } Chris@0: } Chris@0: } Chris@17: Chris@17: /** Chris@17: * Change 'No logs message available.' area plugin type. Chris@17: */ Chris@17: function dblog_update_8600() { Chris@17: $config_factory = \Drupal::configFactory(); Chris@17: Chris@17: $view = \Drupal::configFactory()->getEditable('views.view.watchdog'); Chris@17: if (empty($view)) { Chris@17: return; Chris@17: } Chris@17: Chris@17: $empty_text = $view->get('display.default.display_options.empty'); Chris@17: if (!isset($empty_text['area']['content']['value'])) { Chris@17: return; Chris@17: } Chris@17: Chris@17: // Only update the empty text if is untouched from the original version. Chris@17: if ($empty_text['area']['id'] == 'area' && Chris@17: $empty_text['area']['plugin_id'] == 'text' && Chris@17: $empty_text['area']['field'] == 'area' && Chris@17: $empty_text['area']['content']['value'] == 'No log messages available.') { Chris@17: Chris@17: $new_config = [ Chris@17: 'id' => 'area_text_custom', Chris@17: 'table' => 'views', Chris@17: 'field' => 'area_text_custom', Chris@17: 'relationship' => 'none', Chris@17: 'group_type' => 'group', Chris@17: 'admin_label' => 'No log messages available.', Chris@17: 'empty' => TRUE, Chris@17: 'tokenize' => FALSE, Chris@17: 'content' => 'No log messages available.', Chris@17: 'plugin_id' => 'text_custom', Chris@17: ]; Chris@17: $view->set('display.default.display_options.empty.area', $new_config); Chris@17: $view->save(); Chris@17: } Chris@17: }