core/modules/rest/rest.install | 36 ------------- core/modules/rest/rest.module | 27 ---------- .../rest/src/Plugin/views/display/RestExport.php | 18 ------- .../Update/RestExportAuthCorrectionUpdateTest.php | 36 ------------- .../rest-export-with-authentication-correction.php | 63 ---------------------- 5 files changed, 180 deletions(-) diff --git a/core/modules/rest/rest.install b/core/modules/rest/rest.install index a20956f..c2d9412 100644 --- a/core/modules/rest/rest.install +++ b/core/modules/rest/rest.install @@ -24,39 +24,3 @@ function rest_requirements($phase) { } return $requirements; } - -/** - * Ensure the right REST authentication method is used. - * - * This fixes the bug in https://www.drupal.org/node/2825204. - */ -function rest_update_8401() { - $config_factory = \Drupal::configFactory(); - $auth_providers = \Drupal::service('authentication_collector')->getSortedProviders(); - $process_auth = function ($auth_option) use ($auth_providers) { - foreach ($auth_providers as $provider_id => $provider_data) { - // The provider belongs to the module that declares it as a service. - if (strtok($provider_data->_serviceId, '.') === $auth_option) { - return $provider_id; - } - } - - return $auth_option; - }; - - foreach ($config_factory->listAll('views.view.') as $view_config_name) { - $save = FALSE; - $view = $config_factory->getEditable($view_config_name); - $displays = $view->get('display'); - foreach ($displays as $display_name => $display) { - if ('rest_export' === $display['display_plugin'] && !empty($display['display_options']['auth'])) { - $displays[$display_name]['display_options']['auth'] = array_map($process_auth, $display['display_options']['auth']); - $save = TRUE; - } - } - if ($save) { - $view->set('display', $displays); - $view->save(TRUE); - } - } -} diff --git a/core/modules/rest/rest.module b/core/modules/rest/rest.module index ba61a17..3c061af 100644 --- a/core/modules/rest/rest.module +++ b/core/modules/rest/rest.module @@ -28,30 +28,3 @@ function rest_help($route_name, RouteMatchInterface $route_match) { return $output; } } - -/** - * Implements hook_view_presave(). - * - * @see rest_update_8401() - */ -function rest_view_presave(ViewEntityInterface $view) { - // Fix the auth options on import, much like what rest_update_8401() does. - $auth_providers = \Drupal::service('authentication_collector')->getSortedProviders(); - $process_auth = function ($auth_option) use ($auth_providers) { - foreach ($auth_providers as $provider_id => $provider_data) { - // The provider belongs to the module that declares it as a service. - if (strtok($provider_data->_serviceId, '.') === $auth_option) { - return $provider_id; - } - } - - return $auth_option; - }; - - foreach (array_keys($view->get('display')) as $display_id) { - $display = &$view->getDisplay($display_id); - if ($display['display_plugin'] === 'rest_export' && !empty($display['display_options']['auth'])) { - $display['display_options']['auth'] = array_map($process_auth, $display['display_options']['auth']); - } - } -} diff --git a/core/modules/rest/src/Plugin/views/display/RestExport.php b/core/modules/rest/src/Plugin/views/display/RestExport.php index 52daee0..2b33cff 100644 --- a/core/modules/rest/src/Plugin/views/display/RestExport.php +++ b/core/modules/rest/src/Plugin/views/display/RestExport.php @@ -94,22 +94,6 @@ class RestExport extends PathPluginBase implements ResponseDisplayPluginInterfac protected $authenticationProviderIds; /** - * The authentication providers' modules, keyed by provider ID. - * - * Authentication providers like 'cookie' and 'basic_auth' are the array - * keys. The array values are the module names, e.g.: - * @code - * ['cookie' => 'user', 'basic_auth' => 'basic_auth'] - * @endcode - * - * @deprecated as of 8.4.x, will be removed in before Drupal 9.0.0, see - * https://www.drupal.org/node/2825204. - * - * @var string[] - */ - protected $authenticationProviders; - - /** * The serialization format providers, keyed by format. * * @var string[] @@ -146,8 +130,6 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition // basic_auth) as keys and modules providing those as values (user, // basic_auth). $this->authenticationProviderIds = array_keys($authentication_providers); - // For BC reasons we keep around authenticationProviders as before. - $this->authenticationProviders = $authentication_providers; $this->formatProviders = $serializer_format_providers; } diff --git a/core/modules/rest/src/Tests/Update/RestExportAuthCorrectionUpdateTest.php b/core/modules/rest/src/Tests/Update/RestExportAuthCorrectionUpdateTest.php deleted file mode 100644 index aeca71f..0000000 --- a/core/modules/rest/src/Tests/Update/RestExportAuthCorrectionUpdateTest.php +++ /dev/null @@ -1,36 +0,0 @@ -databaseDumpFiles = [ - __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz', - __DIR__ . '/../../../tests/fixtures/update/rest-export-with-authentication-correction.php', - ]; - } - - /** - * Ensures that update hook is run for "rest" module. - */ - public function testUpdate() { - $this->runUpdates(); - - // Get particular view. - $view = \Drupal::entityTypeManager()->getStorage('view')->load('rest_export_with_authorization_correction'); - $displays = $view->get('display'); - $this->assertIdentical($displays['rest_export_1']['display_options']['auth'], ['cookie'], 'Cookie is used for authentication'); - } - -} diff --git a/core/modules/rest/tests/fixtures/update/rest-export-with-authentication-correction.php b/core/modules/rest/tests/fixtures/update/rest-export-with-authentication-correction.php deleted file mode 100644 index 6cbd04e..0000000 --- a/core/modules/rest/tests/fixtures/update/rest-export-with-authentication-correction.php +++ /dev/null @@ -1,63 +0,0 @@ -insert('key_value') - ->fields([ - 'collection' => 'system.schema', - 'name' => 'rest', - '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(); - -$connection->insert('config') - ->fields([ - 'name' => 'rest.settings', - 'data' => serialize([ - 'link_domain' => '~', - ]), - 'collection' => '', - ]) - ->execute(); - -$connection->insert('config') - ->fields([ - 'name' => 'views.view.rest_export_with_authorization_correction', - ]) - ->execute(); - -$connection->merge('config') - ->condition('name', 'views.view.rest_export_with_authorization_correction') - ->condition('collection', '') - ->fields([ - 'data' => serialize(Yaml::decode(file_get_contents('core/modules/views/tests/modules/views_test_config/test_views/views.view.rest_export_with_authorization_correction.yml'))), - ]) - ->execute();