2015-10-02 08:26:50 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Post update functions for Views.
|
|
|
|
*/
|
|
|
|
|
2022-09-30 10:20:29 +00:00
|
|
|
use Drupal\Core\Config\Entity\ConfigEntityUpdater;
|
|
|
|
use Drupal\views\ViewEntityInterface;
|
|
|
|
use Drupal\views\ViewsConfigUpdater;
|
|
|
|
|
2018-02-18 16:10:25 +00:00
|
|
|
/**
|
2020-03-11 20:58:38 +00:00
|
|
|
* Implements hook_removed_post_updates().
|
|
|
|
*/
|
|
|
|
function views_removed_post_updates() {
|
|
|
|
return [
|
|
|
|
'views_post_update_update_cacheability_metadata' => '9.0.0',
|
|
|
|
'views_post_update_cleanup_duplicate_views_data' => '9.0.0',
|
|
|
|
'views_post_update_field_formatter_dependencies' => '9.0.0',
|
|
|
|
'views_post_update_taxonomy_index_tid' => '9.0.0',
|
|
|
|
'views_post_update_serializer_dependencies' => '9.0.0',
|
|
|
|
'views_post_update_boolean_filter_values' => '9.0.0',
|
|
|
|
'views_post_update_grouped_filters' => '9.0.0',
|
|
|
|
'views_post_update_revision_metadata_fields' => '9.0.0',
|
|
|
|
'views_post_update_entity_link_url' => '9.0.0',
|
|
|
|
'views_post_update_bulk_field_moved' => '9.0.0',
|
|
|
|
'views_post_update_filter_placeholder_text' => '9.0.0',
|
|
|
|
'views_post_update_views_data_table_dependencies' => '9.0.0',
|
|
|
|
'views_post_update_table_display_cache_max_age' => '9.0.0',
|
|
|
|
'views_post_update_exposed_filter_blocks_label_display' => '9.0.0',
|
|
|
|
'views_post_update_make_placeholders_translatable' => '9.0.0',
|
|
|
|
'views_post_update_limit_operator_defaults' => '9.0.0',
|
|
|
|
'views_post_update_remove_core_key' => '9.0.0',
|
2022-02-08 12:16:18 +00:00
|
|
|
'views_post_update_field_names_for_multivalue_fields' => '10.0.0',
|
|
|
|
'views_post_update_configuration_entity_relationships' => '10.0.0',
|
|
|
|
'views_post_update_rename_default_display_setting' => '10.0.0',
|
|
|
|
'views_post_update_remove_sorting_global_text_field' => '10.0.0',
|
|
|
|
'views_post_update_title_translations' => '10.0.0',
|
|
|
|
'views_post_update_sort_identifier' => '10.0.0',
|
2022-08-11 12:02:30 +00:00
|
|
|
'views_post_update_provide_revision_table_relationship' => '10.0.0',
|
|
|
|
'views_post_update_image_lazy_load' => '10.0.0',
|
2020-03-11 20:58:38 +00:00
|
|
|
];
|
2019-10-22 19:40:16 +00:00
|
|
|
}
|
2022-09-30 10:20:29 +00:00
|
|
|
|
2023-02-24 13:50:15 +00:00
|
|
|
/**
|
|
|
|
* Update Views config schema to make boolean custom titles translatable.
|
|
|
|
*/
|
|
|
|
function views_post_update_boolean_custom_titles(?array &$sandbox = NULL): void {
|
|
|
|
// Empty update to rebuild Views config schema.
|
|
|
|
}
|
|
|
|
|
2022-09-30 10:20:29 +00:00
|
|
|
/**
|
|
|
|
* Add eager load option to all oembed type field configurations.
|
|
|
|
*/
|
|
|
|
function views_post_update_oembed_eager_load(?array &$sandbox = NULL): void {
|
|
|
|
/** @var \Drupal\views\ViewsConfigUpdater $view_config_updater */
|
|
|
|
$view_config_updater = \Drupal::classResolver(ViewsConfigUpdater::class);
|
|
|
|
\Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'view', function (ViewEntityInterface $view) use ($view_config_updater): bool {
|
|
|
|
return $view_config_updater->needsOembedEagerLoadFieldUpdate($view);
|
|
|
|
});
|
|
|
|
}
|
Issue #3192234 by heddn, pivica, Qusai Taha, yogeshmpawar, bingolitte, Phil Wolstenholme, smustgrave, Berdir, devkinetic, maximpodorov, ranjith_kumar_k_u, nikitagupta, ankithashetty, vsujeetkumar, pooja saraah, timohuisman, glynster, Luke.Leber, Ahmad Abbad, flyke, chetanbharambe, Graber, zcht, sasanikolic, John Pitcairn, catch, Rar9, Anybody, Ambient.Impact, alexpott, manarak, Fabianx, longwave, benmorss, Martijn de Wit, Wim Leers, larowlan: Apply width and height attributes to allow responsive image tag use loading="lazy"
2022-11-18 11:31:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add lazy load options to all responsive image type field configurations.
|
|
|
|
*/
|
|
|
|
function views_post_update_responsive_image_lazy_load(?array &$sandbox = NULL): void {
|
|
|
|
/** @var \Drupal\views\ViewsConfigUpdater $view_config_updater */
|
|
|
|
$view_config_updater = \Drupal::classResolver(ViewsConfigUpdater::class);
|
|
|
|
\Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'view', function (ViewEntityInterface $view) use ($view_config_updater): bool {
|
|
|
|
return $view_config_updater->needsResponsiveImageLazyLoadFieldUpdate($view);
|
|
|
|
});
|
|
|
|
}
|
Issue #2921810 by claudiu.cristea, nod_, seanB, yogeshmpawar, dww, Wilfred Waltman, joelpittet, askibinski, ankithashetty, ravi.shankar, jonathanshaw, alexpott, kostyashupenko, webchick, danflanagan8, catch, droplet, larowlan, mpdonadio, jhedstrom, AaronMcHale, dawehner, Wim Leers, ckrina, worldlinemine: Allow TimestampFormatter to show as a fully cacheable time difference with JS
2023-03-03 16:35:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Update timestamp formatter settings for views.
|
|
|
|
*/
|
|
|
|
function views_post_update_timestamp_formatter(array &$sandbox = NULL): void {
|
|
|
|
/** @var \Drupal\views\ViewsConfigUpdater $view_config_updater */
|
|
|
|
$view_config_updater = \Drupal::classResolver(ViewsConfigUpdater::class);
|
|
|
|
\Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'view', function (ViewEntityInterface $view) use ($view_config_updater): bool {
|
|
|
|
return $view_config_updater->needsTimestampFormatterTimeDiffUpdate($view);
|
|
|
|
});
|
|
|
|
}
|
Issue #2831233 by mradcliffe, philltran, vsujeetkumar, selwynpolit, s.messaris, cpierce42, acbramley, Lendude, Nitin shrivastava, jibran, mohit_aghera, mike.roman, Kumar Kundan, adityasingh, _utsavsharma, jedihe, Munavijayalakshmi, KapilV, efpapado, anushrikumari, kalyansamanta, ameymudras, interX, nishantghetiya, gambry, alexpott, larowlan, antojose, catch, Nicolas Bouteille, nicoloye, Kristen Pol, bygeoffthompson: Field tokens for "historical data" fields (revisions) contain a hyphen, breaking twig templates and throwing an assertion error
2023-03-29 01:21:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Fix '-revision_id' replacement token syntax.
|
|
|
|
*/
|
|
|
|
function views_post_update_fix_revision_id_part(&$sandbox = NULL): void {
|
|
|
|
/** @var \Drupal\views\ViewsConfigUpdater $view_config_updater */
|
|
|
|
$view_config_updater = \Drupal::classResolver(ViewsConfigUpdater::class);
|
|
|
|
$view_config_updater->setDeprecationsEnabled(FALSE);
|
|
|
|
\Drupal::classResolver(ConfigEntityUpdater::class)
|
|
|
|
->update($sandbox, 'view', function (ViewEntityInterface $view) use ($view_config_updater) {
|
|
|
|
return $view_config_updater->needsRevisionFieldHyphenFix($view);
|
|
|
|
});
|
|
|
|
}
|
2023-07-18 13:18:16 +00:00
|
|
|
|
2023-09-22 19:14:48 +00:00
|
|
|
/**
|
|
|
|
* Add labels to views which don't have one.
|
|
|
|
*/
|
|
|
|
function views_post_update_add_missing_labels(&$sandbox = NULL): void {
|
|
|
|
/** @var \Drupal\views\ViewsConfigUpdater $view_config_updater */
|
|
|
|
$view_config_updater = \Drupal::classResolver(ViewsConfigUpdater::class);
|
|
|
|
\Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'view', function (ViewEntityInterface $view) use ($view_config_updater): bool {
|
|
|
|
return $view_config_updater->addLabelIfMissing($view);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-07-18 13:18:16 +00:00
|
|
|
/**
|
|
|
|
* Remove the skip_cache settings.
|
|
|
|
*/
|
|
|
|
function views_post_update_remove_skip_cache_setting(): void {
|
|
|
|
\Drupal::configFactory()
|
|
|
|
->getEditable('views.settings')
|
|
|
|
->clear('skip_cache')
|
|
|
|
->save(TRUE);
|
|
|
|
}
|
2023-08-16 09:10:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove default_argument_skip_url setting.
|
|
|
|
*/
|
|
|
|
function views_post_update_remove_default_argument_skip_url(array &$sandbox = NULL): void {
|
|
|
|
/** @var \Drupal\views\ViewsConfigUpdater $view_config_updater */
|
|
|
|
$view_config_updater = \Drupal::classResolver(ViewsConfigUpdater::class);
|
|
|
|
\Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'view', function (ViewEntityInterface $view) use ($view_config_updater): bool {
|
|
|
|
return $view_config_updater->needsDefaultArgumentSkipUrlUpdate($view);
|
|
|
|
});
|
|
|
|
}
|
Issue #2352175 by b_sharpe, Berdir, smustgrave, Wim Leers, catch, bkosborne, fgm, alexpott, xjm, dawehner, gregsullivan: Taxonomy views filters should not have user context
2023-09-11 21:35:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes User context from views with taxonomy filters.
|
|
|
|
*/
|
|
|
|
function views_post_update_taxonomy_filter_user_context(?array &$sandbox = NULL): void {
|
|
|
|
/** @var \Drupal\views\ViewsConfigUpdater $view_config_updater */
|
|
|
|
$view_config_updater = \Drupal::classResolver(ViewsConfigUpdater::class);
|
|
|
|
\Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'view', function (ViewEntityInterface $view) use ($view_config_updater): bool {
|
|
|
|
return $view_config_updater->needsTaxonomyTermFilterUpdate($view);
|
|
|
|
});
|
|
|
|
}
|
2024-01-07 21:38:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a default pager heading.
|
|
|
|
*/
|
|
|
|
function views_post_update_pager_heading(?array &$sandbox = NULL): void {
|
|
|
|
/** @var \Drupal\views\ViewsConfigUpdater $view_config_updater */
|
|
|
|
$view_config_updater = \Drupal::classResolver(ViewsConfigUpdater::class);
|
|
|
|
\Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'view', function (ViewEntityInterface $view) use ($view_config_updater): bool {
|
|
|
|
return $view_config_updater->needsPagerHeadingUpdate($view);
|
|
|
|
});
|
|
|
|
}
|
2024-01-09 10:30:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes entity display cache metadata from views with rendered entity fields.
|
|
|
|
*/
|
|
|
|
function views_post_update_rendered_entity_field_cache_metadata(?array &$sandbox = NULL): void {
|
|
|
|
/** @var \Drupal\views\ViewsConfigUpdater $view_config_updater */
|
|
|
|
$view_config_updater = \Drupal::classResolver(ViewsConfigUpdater::class);
|
|
|
|
\Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'view', function (ViewEntityInterface $view) use ($view_config_updater): bool {
|
|
|
|
return $view_config_updater->needsRenderedEntityFieldUpdate($view);
|
|
|
|
});
|
|
|
|
}
|