Skip to content
Snippets Groups Projects
Commit 3a8efc82 authored by Adam Nagy's avatar Adam Nagy Committed by David Cameron
Browse files

Issue #3391559: Update views.view.aggregator_rss_feed update path resets the...

Issue #3391559: Update views.view.aggregator_rss_feed update path resets the display path to site root
parent 111a3505
No related branches found
No related tags found
1 merge request!8Issue #3391559: Update views.view.aggregator_rss_feed update path resets the display path to site root
...@@ -49,13 +49,11 @@ function aggregator_update_8601() { ...@@ -49,13 +49,11 @@ function aggregator_update_8601() {
'granularity' => 'second', 'granularity' => 'second',
], ],
]); ]);
$view_config->set('display.feed_items.display_options', [ $view_config->set('display.feed_items.display_options.row', [
'row' => [ 'type' => 'aggregator_rss',
'type' => 'aggregator_rss', 'options' => [
'options' => [ 'relationship' => 'none',
'relationship' => 'none', 'view_mode' => 'summary',
'view_mode' => 'summary',
],
], ],
]); ]);
$view_config->save(); $view_config->save();
...@@ -116,6 +114,44 @@ function aggregator_update_8605() { ...@@ -116,6 +114,44 @@ function aggregator_update_8605() {
$update_manager->uninstallFieldStorageDefinition($definition); $update_manager->uninstallFieldStorageDefinition($definition);
} }
/**
* Restore RSS view display options.
*/
function aggregator_update_8606(): void {
$view_config = \Drupal::configFactory()->getEditable('views.view.aggregator_rss_feed');
// Make certain we're fixing a feed display just to be safe.
if ($view_config->get('display.feed_items.display_plugin') != 'feed') {
return;
}
// The original aggregator_update_8601() update unset all keys in the
// display_options, including the path. Restore them if they don't exist. We
// can't assume that some weren't edited somehow, so check each individually.
$has_updates = FALSE;
$display_options = $view_config->get('display.feed_items.display_options');
if (!isset($display_options['defaults']['arguments'])) {
$display_options['defaults']['arguments'] = TRUE;
$has_updates = TRUE;
}
if (!isset($display_options['display_description'])) {
$display_options['display_description'] = '';
$has_updates = TRUE;
}
if (!isset($display_options['display_extenders'])) {
$display_options['display_extenders'] = [];
$has_updates = TRUE;
}
if (!isset($display_options['path'])) {
$display_options['path'] = 'aggregator/rss';
$has_updates = TRUE;
}
if ($has_updates) {
$view_config->set('display.feed_items.display_options', $display_options);
$view_config->save();
}
}
/** /**
* Determines whether the RSS view config has been altered from the default. * Determines whether the RSS view config has been altered from the default.
* *
......
This diff is collapsed.
<?php
namespace Drupal\Tests\aggregator\Functional\Update;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
/**
* @covers aggregator_update_8606()
* @group Update
* @group aggregator
*/
class AggregatorUpdateBrokenRssFeedViewTest extends UpdatePathTestBase {
/**
* {@inheritdoc}
*/
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
DRUPAL_ROOT . '/core/modules/system/tests/fixtures/update/drupal-9.4.0.bare.standard.php.gz',
__DIR__ . '/../../../fixtures/update/aggregator.php',
__DIR__ . '/../../../fixtures/update/aggregator_2_1_0.php',
];
}
/**
* Ensure views.view.aggregator_rss_feed is updated.
*/
public function testUpdateHookN(): void {
$old_view_config = \Drupal::config('views.view.aggregator_rss_feed');
$this->assertSame([
'row' => [
'type' => 'aggregator_rss',
'options' => [
'relationship' => 'none',
'view_mode' => 'summary',
],
],
], $old_view_config->get('display.feed_items.display_options'));
$this->runUpdates();
$new_view_config = \Drupal::config('views.view.aggregator_rss_feed');
$this->assertSame([
'row' => [
'type' => 'aggregator_rss',
'options' => [
'relationship' => 'none',
'view_mode' => 'summary',
],
],
'defaults' => [
'arguments' => TRUE,
],
'display_description' => '',
'display_extenders' => [],
'path' => 'aggregator/rss',
], $new_view_config->get('display.feed_items.display_options'));
}
}
...@@ -60,6 +60,12 @@ class AggregatorUpdateRssFeedViewTest extends UpdatePathTestBase { ...@@ -60,6 +60,12 @@ class AggregatorUpdateRssFeedViewTest extends UpdatePathTestBase {
'view_mode' => 'summary', 'view_mode' => 'summary',
], ],
], ],
'defaults' => [
'arguments' => TRUE,
],
'display_description' => '',
'display_extenders' => [],
'path' => 'aggregator/rss',
], $view_config->get('display.feed_items.display_options')); ], $view_config->get('display.feed_items.display_options'));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment