X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fdblog%2Fdblog.install;fp=web%2Fcore%2Fmodules%2Fdblog%2Fdblog.install;h=8da830b310e57fac146e5e66d91c53e599eb5679;hp=f226ed04d9c9f310745e85e4604306cc958889d2;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/modules/dblog/dblog.install b/web/core/modules/dblog/dblog.install index f226ed04d..8da830b31 100644 --- a/web/core/modules/dblog/dblog.install +++ b/web/core/modules/dblog/dblog.install @@ -90,3 +90,69 @@ function dblog_schema() { return $schema; } + +/** + * Use standard plugin for wid and uid fields. Use dblog_types for type filter. + */ +function dblog_update_8400() { + $config_factory = \Drupal::configFactory(); + + foreach ($config_factory->listAll('views.view.') as $view_config_name) { + $view = $config_factory->getEditable($view_config_name); + if ($view->get('base_table') != 'watchdog') { + continue; + } + + $save = FALSE; + foreach ($view->get('display') as $display_name => $display) { + // Iterate through all the fields of watchdog views based tables. + if (isset($display['display_options']['fields'])) { + foreach ($display['display_options']['fields'] as $field_name => $field) { + // We are only interested in wid and uid fields from the watchdog + // table that still use the numeric id. + if (isset($field['table']) && + $field['table'] === 'watchdog' && + $field['plugin_id'] == 'numeric' && + in_array($field['field'], ['wid', 'uid'])) { + + $save = TRUE; + $new_value = $field; + $new_value['plugin_id'] = 'standard'; + + // Delete all the attributes related to numeric fields. + unset( + $new_value['set_precision'], + $new_value['precision'], + $new_value['decimal'], + $new_value['separator'], + $new_value['format_plural'], + $new_value['format_plural_string'], + $new_value['prefix'], + $new_value['suffix'] + ); + $view->set("display.$display_name.display_options.fields.$field_name", $new_value); + } + } + } + + // Iterate all filters looking for type filters to update. + if (isset($display['display_options']['filters'])) { + foreach ($display['display_options']['filters'] as $filter_name => $filter) { + if (isset($filter['table']) && + $filter['table'] === 'watchdog' && + $filter['plugin_id'] == 'in_operator' && + $filter['field'] == 'type') { + + $save = TRUE; + $filter['plugin_id'] = 'dblog_types'; + $view->set("display.$display_name.display_options.filters.$filter_name", $filter); + } + } + } + } + + if ($save) { + $view->save(); + } + } +}