Issue by Spokje, catch, dww, longwave, alexpott: Remove updates added prior to 9.4.0 (9.4.4 for ckeditor) and add 9.4.0 database dumps

merge-requests/2476/merge
Alex Pott 2022-08-11 13:03:18 +01:00
parent 62a402a389
commit f3427282f2
No known key found for this signature in database
GPG Key ID: BDA67E7EE836E5CE
32 changed files with 36 additions and 632 deletions

View File

@ -5,37 +5,11 @@
* Post update functions for CKEditor.
*/
use Drupal\Core\Config\Entity\ConfigEntityUpdater;
use Drupal\editor\Entity\Editor;
/**
* Updates Text Editors using CKEditor 4 to omit settings for disabled plugins.
* Implements hook_removed_post_updates().
*/
function ckeditor_post_update_omit_settings_for_disabled_plugins(&$sandbox = []) {
$config_entity_updater = \Drupal::classResolver(ConfigEntityUpdater::class);
$config_entity_updater->update($sandbox, 'editor', function (Editor $editor): bool {
// Only try to update editors using CKEditor 4.
if ($editor->getEditor() !== 'ckeditor') {
return FALSE;
}
$enabled_plugins = _ckeditor_get_enabled_plugins($editor);
// Only update if the editor has plugin settings for disabled plugins.
$needs_update = FALSE;
$settings = $editor->getSettings();
// Updates are not needed if plugin settings are not defined for the editor.
if (!isset($settings['plugins'])) {
return FALSE;
}
foreach (array_keys($settings['plugins']) as $plugin_id) {
if (!in_array($plugin_id, $enabled_plugins, TRUE)) {
$needs_update = TRUE;
}
}
return $needs_update;
});
function ckeditor_removed_post_updates() {
return [
'ckeditor_post_update_omit_settings_for_disabled_plugins' => '10.0.0',
];
}

View File

@ -1,58 +0,0 @@
<?php
namespace Drupal\Tests\ckeditor\Functional\Update;
use Drupal\editor\Entity\Editor;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
/**
* Tests the update path for CKEditor plugin settings for disabled plugins.
*
* @group Update
*/
class CKEditorUpdateOmitDisabledPluginSettings extends UpdatePathTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-9.3.0.filled.standard.php.gz',
];
}
/**
* Ensure settings for disabled CKEditor 4 plugins are omitted on post update.
*/
public function testUpdateUpdateOmitDisabledSettingsPostUpdate() {
$editor = Editor::load('basic_html');
$settings = $editor->getSettings();
$this->assertArrayHasKey('stylescombo', $settings['plugins']);
$this->runUpdates();
$editor = Editor::load('basic_html');
$settings = $editor->getSettings();
$this->assertArrayNotHasKey('stylescombo', $settings['plugins']);
}
/**
* Ensure settings for disabled CKEditor 4 plugins are omitted on entity save.
*/
public function testUpdateUpdateOmitDisabledSettingsEntitySave() {
$editor = Editor::load('basic_html');
$settings = $editor->getSettings();
$this->assertArrayHasKey('stylescombo', $settings['plugins']);
$editor->save();
$editor = Editor::load('basic_html');
$settings = $editor->getSettings();
$this->assertArrayNotHasKey('stylescombo', $settings['plugins']);
}
}

View File

@ -5,49 +5,11 @@
* Post update functions for CKEditor 5.
*/
use Drupal\Core\Config\Entity\ConfigEntityUpdater;
use Drupal\editor\Entity\Editor;
/**
* Updates if an already migrated CKEditor 5 configuration for text formats
* has alignment shown as individual buttons instead of a dropdown.
* Implements hook_removed_post_updates().
*/
function ckeditor5_post_update_alignment_buttons(&$sandbox = []) {
$config_entity_updater = \Drupal::classResolver(ConfigEntityUpdater::class);
$callback = function (Editor $editor) {
// Only try to update editors using CKEditor 5.
if ($editor->getEditor() !== 'ckeditor5') {
return FALSE;
}
$needs_update = FALSE;
// Only update if the editor is using the non-dropdown buttons.
$settings = $editor->getSettings();
$old_alignment_buttons_to_types = [
'alignment:left' => 'left',
'alignment:right' => 'right',
'alignment:center' => 'center',
'alignment:justify' => 'justify',
];
if (is_array($settings['toolbar']['items'])) {
foreach ($old_alignment_buttons_to_types as $button => $type) {
if (in_array($button, $settings['toolbar']['items'], TRUE)) {
$settings['toolbar']['items'] = array_values(array_diff($settings['toolbar']['items'], [$button]));
$settings['plugins']['ckeditor5_alignment']['enabled_alignments'][] = $type;
if (!in_array('alignment', $settings['toolbar']['items'], TRUE)) {
$settings['toolbar']['items'][] = 'alignment';
}
// Flag this display as needing to be updated.
$needs_update = TRUE;
}
}
}
if ($needs_update) {
$editor->setSettings($settings);
}
return $needs_update;
};
$config_entity_updater->update($sandbox, 'editor', $callback);
function ckeditor5_removed_post_updates() {
return [
'ckeditor5_post_update_alignment_buttons' => '10.0.0',
];
}

View File

@ -1,62 +0,0 @@
<?php
namespace Drupal\Tests\ckeditor5\Functional\Update;
use Drupal\editor\Entity\Editor;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
use Drupal\Tests\ckeditor5\Traits\CKEditor5TestTrait;
/**
* Tests the update path for CKEditor 5 alignment.
*
* @group Update
*/
class CKEditor5UpdateAlignmentTest extends UpdatePathTestBase {
use CKEditor5TestTrait;
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-9.3.0.filled.standard.php.gz',
__DIR__ . '/../../../fixtures/update/ckeditor5-3259593.php',
];
}
/**
* Tests that CKEditor 5 alignment configurations that are individual buttons
* are updated to be in dropdown form in the toolbar.
*/
public function testUpdateAlignmentButtons() {
$editor = Editor::load('test_format');
$settings = $editor->getSettings();
$this->assertContains('alignment:center', $settings['toolbar']['items']);
$this->runUpdates();
$expected_toolbar_items = [
'link',
'bold',
'italic',
'sourceEditing',
'alignment',
];
$expected_alignment_plugin = [
'enabled_alignments' => [
'center',
],
];
$editor = Editor::load('test_format');
$settings = $editor->getSettings();
$this->assertEquals($expected_toolbar_items, $settings['toolbar']['items']);
$this->assertEquals($expected_alignment_plugin, $settings['plugins']['ckeditor5_alignment']);
}
}

View File

@ -5,7 +5,6 @@
* Exposes global functionality for creating image styles.
*/
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Routing\RouteMatchInterface;
@ -15,7 +14,6 @@ use Drupal\field\FieldConfigInterface;
use Drupal\field\FieldStorageConfigInterface;
use Drupal\file\FileInterface;
use Drupal\image\Entity\ImageStyle;
use Drupal\image\ImageConfigUpdater;
/**
* The name of the query parameter for image derivative tokens.
@ -370,15 +368,6 @@ function image_entity_presave(EntityInterface $entity) {
$entity->setSetting('default_image', $default_image);
}
/**
* Implements hook_ENTITY_TYPE_presave() for entity_view_display.
*/
function image_entity_view_display_presave(EntityViewDisplayInterface $view_display): void {
$config_updater = \Drupal::classResolver(ImageConfigUpdater::class);
assert($config_updater instanceof ImageConfigUpdater);
$config_updater->processImageLazyLoad($view_display);
}
/**
* Implements hook_ENTITY_TYPE_update() for 'field_storage_config'.
*/

View File

@ -5,10 +5,6 @@
* Post-update functions for Image.
*/
use Drupal\Core\Config\Entity\ConfigEntityUpdater;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\image\ImageConfigUpdater;
/**
* Implements hook_removed_post_updates().
*/
@ -16,15 +12,6 @@ function image_removed_post_updates() {
return [
'image_post_update_image_style_dependencies' => '9.0.0',
'image_post_update_scale_and_crop_effect_add_anchor' => '9.0.0',
'image_post_update_image_loading_attribute' => '10.0.0',
];
}
/**
* Add the image loading attribute setting to image field formatter instances.
*/
function image_post_update_image_loading_attribute(array &$sandbox = NULL): void {
$image_config_updater = \Drupal::classResolver(ImageConfigUpdater::class);
\Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'entity_view_display', function (EntityViewDisplayInterface $view_display) use ($image_config_updater): bool {
return $image_config_updater->processImageLazyLoad($view_display);
});
}

View File

@ -1,43 +0,0 @@
<?php
namespace Drupal\image;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
/**
* Provides a BC layer for modules providing old configurations.
*
* @internal
* This class is only meant to fix outdated image configuration and its
* methods should not be invoked directly. It will be removed once all the
* deprecated methods have been removed.
*/
final class ImageConfigUpdater {
/**
* Re-order mappings by breakpoint ID and descending numeric multiplier order.
*
* @param \Drupal\Core\Entity\Display\EntityViewDisplayInterface $view_display
* The view display.
*
* @return bool
* Whether the display was updated.
*/
public function processImageLazyLoad(EntityViewDisplayInterface $view_display): bool {
$changed = FALSE;
foreach ($view_display->getComponents() as $field => $component) {
if (isset($component['type'])
&& ($component['type'] === 'image')
&& !array_key_exists('image_loading', $component['settings'])
) {
$component['settings']['image_loading']['attribute'] = 'lazy';
$view_display->setComponent($field, $component);
$changed = TRUE;
}
}
return $changed;
}
}

View File

@ -1,41 +0,0 @@
<?php
namespace Drupal\Tests\image\Functional;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
/**
* Tests lazy-load upgrade path.
*
* @group image
*/
class ImageLazyLoadUpdateTest extends UpdatePathTestBase {
/**
* {@inheritdoc}
*/
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-9.3.0.filled.standard.php.gz',
];
}
/**
* Test new lazy-load setting upgrade path.
*
* @see image_post_update_image_loading_attribute
*/
public function testUpdate() {
$storage = \Drupal::entityTypeManager()->getStorage('entity_view_display');
/** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $view_display */
$view_display = $storage->load('node.article.default');
$component = $view_display->getComponent('field_image');
$this->assertArrayNotHasKey('image_loading', $component['settings']);
$this->runUpdates();
$view_display = $storage->load('node.article.default');
$component = $view_display->getComponent('field_image');
$this->assertArrayHasKey('image_loading', $component['settings']);
$this->assertEquals('lazy', $component['settings']['image_loading']['attribute']);
}
}

View File

@ -80,19 +80,5 @@ function jsonapi_requirements($phase) {
* Implements hook_update_last_removed().
*/
function jsonapi_update_last_removed() {
return 8701;
}
/**
* Set values for maintenance_header_retry_seconds min and max.
*
* @see https://www.drupal.org/node/3247453
*/
function jsonapi_update_9401() {
$config = \Drupal::configFactory()->getEditable('jsonapi.settings');
$config->set('maintenance_header_retry_seconds', [
'min' => 5,
'max' => 10,
]);
$config->save(TRUE);
return 9401;
}

View File

@ -5,8 +5,6 @@
* Post update functions for Media.
*/
use Drupal\Core\Field\Entity\BaseFieldOverride;
/**
* Implements hook_removed_post_updates().
*/
@ -16,21 +14,6 @@ function media_removed_post_updates() {
'media_post_update_storage_handler' => '9.0.0',
'media_post_update_enable_standalone_url' => '9.0.0',
'media_post_update_add_status_extra_filter' => '9.0.0',
'media_post_update_modify_base_field_author_override' => '10.0.0',
];
}
/**
* Updates stale references to Drupal\media\Entity\Media::getCurrentUserId.
*/
function media_post_update_modify_base_field_author_override() {
$uid_fields = \Drupal::entityTypeManager()
->getStorage('base_field_override')
->getQuery()
->condition('entity_type', 'media')
->condition('field_name', 'uid')
->condition('default_value_callback', 'Drupal\media\Entity\Media::getCurrentUserId')
->execute();
foreach (BaseFieldOverride::loadMultiple($uid_fields) as $base_field_override) {
$base_field_override->setDefaultValueCallback('Drupal\media\Entity\Media::getDefaultEntityOwner')->save();
}
}

View File

@ -47,7 +47,7 @@ class Mysql8RequirePrimaryKeyUpdateTest extends UpdatePathTestBase {
* {@inheritdoc}
*/
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles[] = __DIR__ . '/../../../../system/tests/fixtures/update/drupal-9.3.0.bare.standard.php.gz';
$this->databaseDumpFiles[] = __DIR__ . '/../../../../system/tests/fixtures/update/drupal-9.4.0.bare.standard.php.gz';
}
/**

View File

@ -5,8 +5,6 @@
* Post update functions for Node.
*/
use Drupal\Core\Field\Entity\BaseFieldOverride;
/**
* Implements hook_removed_post_updates().
*/
@ -16,21 +14,6 @@ function node_removed_post_updates() {
'node_post_update_node_revision_views_data' => '9.0.0',
'node_post_update_glossary_view_published' => '10.0.0',
'node_post_update_rebuild_node_revision_routes' => '10.0.0',
'node_post_update_modify_base_field_author_override' => '10.0.0',
];
}
/**
* Updates stale references to Drupal\node\Entity\Node::getCurrentUserId.
*/
function node_post_update_modify_base_field_author_override() {
$uid_fields = \Drupal::entityTypeManager()
->getStorage('base_field_override')
->getQuery()
->condition('entity_type', 'node')
->condition('field_name', 'uid')
->condition('default_value_callback', 'Drupal\node\Entity\Node::getCurrentUserId')
->execute();
foreach (BaseFieldOverride::loadMultiple($uid_fields) as $base_field_override) {
$base_field_override->setDefaultValueCallback('Drupal\node\Entity\Node::getDefaultEntityOwner')->save();
}
}

View File

@ -1376,7 +1376,7 @@ function system_requirements($phase) {
'title' => t('The version of Drupal you are trying to update from is too old'),
'description' => t('Updating to Drupal @current_major is only supported from Drupal version @required_min_version or higher. If you are trying to update from an older version, first update to the latest version of Drupal @previous_major. (<a href=":url">Drupal upgrade guide</a>)', [
'@current_major' => 10,
'@required_min_version' => '9.3.0',
'@required_min_version' => '9.4.0',
'@previous_major' => 9,
':url' => 'https://www.drupal.org/docs/upgrading-drupal/drupal-8-and-higher',
]),

View File

@ -5,8 +5,6 @@
* Post update functions for System.
*/
use Drupal\Core\Database\Database;
/**
* Implements hook_removed_post_updates().
*/
@ -42,31 +40,6 @@ function system_removed_post_updates() {
'system_post_update_service_advisory_settings' => '10.0.0',
'system_post_update_delete_authorize_settings' => '10.0.0',
'system_post_update_sort_all_config' => '10.0.0',
'system_post_update_enable_provider_database_driver' => '10.0.0',
];
}
/**
* Enable the modules that are providing the listed database drivers.
*/
function system_post_update_enable_provider_database_driver() {
$modules_to_install = [];
foreach (Database::getAllConnectionInfo() as $targets) {
foreach ($targets as $target) {
// Provider determination taken from Connection::getProvider().
[$first, $second] = explode('\\', $target['namespace'] ?? '', 3);
$provider = ($first === 'Drupal' && strtolower($second) === $second) ? $second : 'core';
if ($provider !== 'core' && !\Drupal::moduleHandler()->moduleExists($provider)) {
$autoload = $target['autoload'] ?? '';
// We are only enabling the module for database drivers that are
// provided by a module.
if (str_contains($autoload, 'src/Driver/Database/')) {
$modules_to_install[$provider] = TRUE;
}
}
}
}
if ($modules_to_install !== []) {
\Drupal::service('module_installer')->install(array_keys($modules_to_install));
}
}

View File

@ -68,7 +68,7 @@ class UpdatePathLastRemovedTest extends BrowserTestBase {
$assert_session = $this->assertSession();
$assert_session->pageTextContains('Requirements problem');
$assert_session->pageTextContains('The version of Drupal you are trying to update from is too old');
$assert_session->pageTextContains('Updating to Drupal 10 is only supported from Drupal version 9.3.0 or higher. If you are trying to update from an older version, first update to the latest version of Drupal 9');
$assert_session->pageTextContains('Updating to Drupal 10 is only supported from Drupal version 9.4.0 or higher. If you are trying to update from an older version, first update to the latest version of Drupal 9');
$assert_session->pageTextNotContains('Unsupported schema version: Update test with hook_update_last_removed() implementation');
$assert_session->linkNotExists('Continue');

View File

@ -25,7 +25,7 @@ class UpdatePathTestBaseFilledTest extends UpdatePathTestBaseTest {
*/
protected function setDatabaseDumpFiles() {
parent::setDatabaseDumpFiles();
$this->databaseDumpFiles[0] = __DIR__ . '/../../../../tests/fixtures/update/drupal-9.3.0.filled.standard.php.gz';
$this->databaseDumpFiles[0] = __DIR__ . '/../../../../tests/fixtures/update/drupal-9.4.0.filled.standard.php.gz';
}
/**

View File

@ -69,7 +69,7 @@ class DbImportCommandTest extends KernelTestBase {
$command = new DbImportCommand();
$command_tester = new CommandTester($command);
$command_tester->execute([
'script' => __DIR__ . '/../../../fixtures/update/drupal-9.3.0.bare.standard.php.gz',
'script' => __DIR__ . '/../../../fixtures/update/drupal-9.4.0.bare.standard.php.gz',
'--database' => $this->databasePrefix,
]);

View File

@ -1,49 +0,0 @@
<?php
namespace Drupal\Tests\update\Functional\Update;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
use Drupal\Tests\user\Traits\UserCreationTrait;
use Drupal\user\Entity\Role;
/**
* Tests update_post_update_add_view_update_notifications_permission().
*
* @group Update
* @group legacy
*/
class UpdateAddViewUpdateNotificationsPermissionTest extends UpdatePathTestBase {
use UserCreationTrait;
/**
* {@inheritdoc}
*/
protected function setDatabaseDumpFiles(): void {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-9.3.0.filled.standard.php.gz',
];
}
/**
* Tests that the 'view update notifications' permission is correctly granted.
*/
public function testViewUpdateNotificationsPermission(): void {
// Add a new 'Junior Admin' role with the legacy permission we care about.
$junior_admin = $this->createRole(
['administer site configuration'],
'junior_admin', 'Junior Admin'
);
$role = Role::load('junior_admin');
$this->assertTrue($role->hasPermission('administer site configuration'), 'Junior Admin role has legacy permission.');
$this->assertFalse($role->hasPermission('view update notifications'), 'Junior Admin role does not have the new permission.');
$this->runUpdates();
$role = Role::load('junior_admin');
$this->assertTrue($role->hasPermission('administer site configuration'), 'Junior Admin role still has the legacy permission.');
$this->assertTrue($role->hasPermission('view update notifications'), 'Junior Admin role now has the new permission.');
}
}

View File

@ -6,11 +6,10 @@
*/
/**
* Add 'view update notifications' to roles with 'administer site configuration'.
* Implements hook_removed_post_updates().
*/
function update_post_update_add_view_update_notifications_permission(&$sandbox) {
$roles = user_roles(FALSE, 'administer site configuration');
foreach ($roles as $role) {
$role->grantPermission('view update notifications')->save();
}
function update_remove_post_updates() {
return [
'update_post_update_add_view_update_notifications_permission' => '10.0.0',
];
}

View File

@ -110,25 +110,6 @@ class ViewsConfigUpdater implements ContainerInjectionInterface {
$this->deprecationsEnabled = $enabled;
}
/**
* Performs all required updates.
*
* @param \Drupal\views\ViewEntityInterface $view
* The View to update.
*
* @return bool
* Whether the view was updated.
*/
public function updateAll(ViewEntityInterface $view) {
return $this->processDisplayHandlers($view, FALSE, function (&$handler, $handler_type, $key, $display_id) use ($view) {
$changed = FALSE;
if ($this->processImageLazyLoadFieldHandler($handler, $handler_type, $view)) {
$changed = TRUE;
}
return $changed;
});
}
/**
* Processes all display handlers.
*
@ -170,48 +151,4 @@ class ViewsConfigUpdater implements ContainerInjectionInterface {
return $changed;
}
/**
* Add lazy load options to all image type field configurations.
*
* @param \Drupal\views\ViewEntityInterface $view
* The View to update.
*
* @return bool
* Whether the view was updated.
*/
public function needsImageLazyLoadFieldUpdate(ViewEntityInterface $view) {
return $this->processDisplayHandlers($view, TRUE, function (&$handler, $handler_type) use ($view) {
return $this->processImageLazyLoadFieldHandler($handler, $handler_type, $view);
});
}
/**
* Processes image type fields.
*
* @param array $handler
* A display handler.
* @param string $handler_type
* The handler type.
* @param \Drupal\views\ViewEntityInterface $view
* The View being updated.
*
* @return bool
* Whether the handler was updated.
*/
protected function processImageLazyLoadFieldHandler(array &$handler, string $handler_type, ViewEntityInterface $view) {
$changed = FALSE;
// Add any missing settings for lazy loading.
if (($handler_type === 'field')
&& isset($handler['plugin_id'], $handler['type'])
&& $handler['plugin_id'] === 'field'
&& $handler['type'] === 'image'
&& !isset($handler['settings']['image_loading'])) {
$handler['settings']['image_loading'] = ['attribute' => 'lazy'];
$changed = TRUE;
}
return $changed;
}
}

View File

@ -12,11 +12,9 @@ use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Drupal\views\Plugin\Derivative\ViewsLocalTask;
use Drupal\views\ViewEntityInterface;
use Drupal\views\ViewExecutable;
use Drupal\views\Entity\View;
use Drupal\views\Views;
use Drupal\views\ViewsConfigUpdater;
/**
* Implements hook_help().
@ -817,12 +815,3 @@ function views_view_delete(EntityInterface $entity) {
}
}
}
/**
* Implements hook_ENTITY_TYPE_presave().
*/
function views_view_presave(ViewEntityInterface $view) {
/** @var \Drupal\views\ViewsConfigUpdater $config_updater */
$config_updater = \Drupal::classResolver(ViewsConfigUpdater::class);
$config_updater->updateAll($view);
}

View File

@ -5,10 +5,6 @@
* Post update functions for Views.
*/
use Drupal\Core\Config\Entity\ConfigEntityUpdater;
use Drupal\views\ViewEntityInterface;
use Drupal\views\ViewsConfigUpdater;
/**
* Implements hook_removed_post_updates().
*/
@ -37,23 +33,7 @@ function views_removed_post_updates() {
'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',
'views_post_update_provide_revision_table_relationship' => '10.0.0',
'views_post_update_image_lazy_load' => '10.0.0',
];
}
/**
* Clear caches due to adding a relationship from revision table to base table.
*/
function views_post_update_provide_revision_table_relationship() {
// Empty post-update hook.
}
/**
* Add lazy load options to all image type field configurations.
*/
function views_post_update_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->needsImageLazyLoadFieldUpdate($view);
});
}

View File

@ -5,8 +5,6 @@
* Post update functions for the Workspaces module.
*/
use Drupal\Core\Field\Entity\BaseFieldOverride;
/**
* Implements hook_removed_post_updates().
*/
@ -17,21 +15,6 @@ function workspaces_removed_post_updates() {
'workspaces_post_update_move_association_data' => '9.0.0',
'workspaces_post_update_update_deploy_form_display' => '9.0.0',
'workspaces_post_update_remove_association_schema_data' => '10.0.0',
'workspaces_post_update_modify_base_field_author_override' => '10.0.0',
];
}
/**
* Updates stale references to Drupal\workspaces\Entity\Workspace::getCurrentUserId.
*/
function workspaces_post_update_modify_base_field_author_override() {
$uid_fields = \Drupal::entityTypeManager()
->getStorage('base_field_override')
->getQuery()
->condition('entity_type', 'workspace')
->condition('field_name', 'uid')
->condition('default_value_callback', 'Drupal\workspaces\Entity\Workspace::getCurrentUserId')
->execute();
foreach (BaseFieldOverride::loadMultiple($uid_fields) as $base_field_override) {
$base_field_override->setDefaultValueCallback('Drupal\workspaces\Entity\Workspace::getDefaultEntityOwner')->save();
}
}

View File

@ -54,11 +54,11 @@ abstract class UpdatePathTestBase extends BrowserTestBase {
/**
* The file path(s) to the dumped database(s) to load into the child site.
*
* The file system/tests/fixtures/update/drupal-9.3.0.bare.standard.php.gz is
* The file system/tests/fixtures/update/drupal-9.4.0.bare.standard.php.gz is
* normally included first -- this sets up the base database from a bare
* standard Drupal installation.
*
* The file system/tests/fixtures/update/drupal-9.3.0.filled.standard.php.gz
* The file system/tests/fixtures/update/drupal-9.4.0.filled.standard.php.gz
* can also be used in case we want to test with a database filled with
* content, and with all core modules enabled.
*

View File

@ -22,7 +22,7 @@ class UpdatePathTestBaseTest extends UpdatePathTestBase {
* {@inheritdoc}
*/
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles[] = __DIR__ . '/../../../../modules/system/tests/fixtures/update/drupal-9.3.0.bare.standard.php.gz';
$this->databaseDumpFiles[] = __DIR__ . '/../../../../modules/system/tests/fixtures/update/drupal-9.4.0.bare.standard.php.gz';
$this->databaseDumpFiles[] = __DIR__ . '/../../../../modules/system/tests/fixtures/update/drupal-8.update-test-schema-enabled.php';
$this->databaseDumpFiles[] = __DIR__ . '/../../../../modules/system/tests/fixtures/update/drupal-8.update-test-semver-update-n-enabled.php';
}

View File

@ -6,10 +6,10 @@
*/
/**
* Sets the default `base_primary_color` value of Olivero's theme settings.
* Implements hook_removed_post_updates().
*/
function olivero_post_update_add_olivero_primary_color() {
\Drupal::configFactory()->getEditable('olivero.settings')
->set('base_primary_color', '#1b9ae4')
->save();
function olivero_removed_post_updates() {
return [
'olivero_post_update_add_olivero_primary_color' => '10.0.0',
];
}

View File

@ -1,25 +0,0 @@
<?php
/**
* @file
* Test fixture.
*/
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// Update core.extension.
$extensions = $connection->select('config')
->fields('config', ['data'])
->condition('collection', '')
->condition('name', 'core.extension')
->execute()
->fetchField();
$extensions = unserialize($extensions);
$extensions['theme']['olivero'] = 0;
$connection->update('config')
->fields(['data' => serialize($extensions)])
->condition('collection', '')
->condition('name', 'core.extension')
->execute();

View File

@ -1,43 +0,0 @@
<?php
namespace Drupal\Tests\olivero\Functional\Update;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
/**
* Tests the update path for Olivero.
*
* @group Update
*/
class OliveroPostUpdateTest extends UpdatePathTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../../../modules/system/tests/fixtures/update/drupal-9.3.0.filled.standard.php.gz',
__DIR__ . '/../../../fixtures/update/olivero-3257274.php',
];
}
/**
* Tests update hook setting base primary color.
*/
public function testOliveroPrimaryColorUpdate() {
$config = $this->config('olivero.settings');
$this->assertEmpty($config->get('base_primary_color'));
// Run updates.
$this->runUpdates();
$config = $this->config('olivero.settings');
$this->assertSame('#1b9ae4', $config->get('base_primary_color'));
}
}