diff --git a/core/modules/rest/rest.install b/core/modules/rest/rest.install index a7eab1c..a34d05e 100644 --- a/core/modules/rest/rest.install +++ b/core/modules/rest/rest.install @@ -33,8 +33,10 @@ function rest_update_8202() { $displays = $view->get('display'); foreach ($displays as $display_name => &$display) { if ($display['display_plugin'] == 'rest_export') { - $display['display_options']['auth'] = []; - $save = TRUE; + if (!isset($display['display_options'])) { + $display['display_options']['auth'] = []; + $save = TRUE; + } } } if ($save) { diff --git a/core/modules/views/src/Tests/Update/ViewsUpdateTest.php b/core/modules/views/src/Tests/Update/RestExportAuthUpdateTest.php similarity index 90% rename from core/modules/views/src/Tests/Update/ViewsUpdateTest.php rename to core/modules/views/src/Tests/Update/RestExportAuthUpdateTest.php index ac13472..4f3c0c6 100644 --- a/core/modules/views/src/Tests/Update/ViewsUpdateTest.php +++ b/core/modules/views/src/Tests/Update/RestExportAuthUpdateTest.php @@ -9,7 +9,7 @@ * * @group Update */ -class ViewsUpdateTest extends UpdatePathTestBase { +class RestExportAuthUpdateTest extends UpdatePathTestBase { /** * {@inheritdoc} @@ -28,7 +28,7 @@ public function testUpdate() { $this->runUpdates(); // Get particular view. - $view = \Drupal::entityTypeManager()->getStorage('view')->load('rest_export'); + $view = \Drupal::entityTypeManager()->getStorage('view')->load('rest_export_with_authorization'); $displays = $view->get('display'); $this->assertIdentical($displays['rest_export_1']['display_options']['auth']['basic_auth'], 'basic_auth', 'Basic authentication is set as authentication method.'); } diff --git a/core/modules/views/tests/fixtures/update/rest-export-with-authentication.php b/core/modules/views/tests/fixtures/update/rest-export-with-authentication.php index 60dd872..bdf9453 100644 --- a/core/modules/views/tests/fixtures/update/rest-export-with-authentication.php +++ b/core/modules/views/tests/fixtures/update/rest-export-with-authentication.php @@ -5,16 +5,67 @@ $connection = Drupal\Core\Database\Database::getConnection(); $config = $connection; +// Set the schema version. +$connection->insert('key_value') + ->fields([ + 'collection' => 'system.schema', + 'name' => 'rest', + 'value' => 'i:8000;', + ]) + ->fields([ + 'collection' => 'system.schema', + 'name' => 'serialization', + 'value' => 'i:8000;', + ]) + ->fields([ + 'collection' => 'system.schema', + 'name' => 'basic_auth', + 'value' => 'i:8000;', + ]) + ->execute(); + +// Update core.extension. +$extensions = $connection->select('config') + ->fields('config', ['data']) + ->condition('collection', '') + ->condition('name', 'core.extension') + ->execute() + ->fetchField(); +$extensions = unserialize($extensions); +$extensions['module']['rest'] = 0; +$extensions['module']['serialization'] = 0; +$extensions['module']['basic_auth'] = 0; +$connection->update('config') + ->fields([ + 'data' => serialize($extensions), + ]) + ->condition('collection', '') + ->condition('name', 'core.extension') + ->execute(); + +$config = [ + 'resources' => [ + ], + 'link_domain' => '~', +]; +$data = $connection->insert('config') + ->fields([ + 'name' => 'rest.settings', + 'data' => serialize($config), + 'collection' => '' + ]) + ->execute(); + $connection->insert('config') ->fields([ - 'name' => 'views.view.rest_export', + 'name' => 'views.view.rest_export_with_authorization', ]) ->execute(); $connection->merge('config') - ->condition('name', 'views.view.rest_export') + ->condition('name', 'views.view.rest_export_with_authorization') ->condition('collection', '') ->fields([ - 'data' => serialize(Yaml::decode(file_get_contents('core/modules/views/tests/modules/views_test_config/test_views/views.view.test_duplicate_field_handlers.yml'))) + 'data' => serialize(Yaml::decode(file_get_contents('core/modules/views/tests/modules/views_test_config/test_views/views.view.rest_export_with_authorization.yml'))) ]) ->execute();