Unverified Commit 18d53198 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3097752 by andypost, longwave, Stefdewa, Wim Leers, Berdir, alexpott:...

Issue #3097752 by andypost, longwave, Stefdewa, Wim Leers, Berdir, alexpott: Remove views.module BC layers
parent 1d1f2222
Loading
Loading
Loading
Loading
+0 −48
Original line number Diff line number Diff line
@@ -5,9 +5,7 @@
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\Core\Entity\ContentEntityTypeInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\views\Plugin\DependentWithRemovalPluginInterface;
use Drupal\views\Views;
@@ -295,10 +293,6 @@ public function preSave(EntityStorageInterface $storage) {

    $displays = $this->get('display');

    // @todo Remove this line and support for pre-8.3 table names in Drupal 9.
    // @see https://www.drupal.org/project/drupal/issues/3069405 .
    $this->fixTableNames($displays);

    // Sort the displays.
    ksort($displays);
    $this->set('display', ['default' => $displays['default']] + $displays);
@@ -311,48 +305,6 @@ public function preSave(EntityStorageInterface $storage) {
    }
  }

  /**
   * Fixes table names for revision metadata fields of revisionable entities.
   *
   * Views for revisionable entity types using revision metadata fields might
   * be using the wrong table to retrieve the fields after system_update_8300
   * has moved them correctly to the revision table. This method updates the
   * views to use the correct tables.
   *
   * @param array &$displays
   *   An array containing display handlers of a view.
   *
   * @todo Remove this method and its usage in Drupal 9. See
   *   https://www.drupal.org/project/drupal/issues/3069405.
   * @see https://www.drupal.org/node/2831499
   */
  private function fixTableNames(array &$displays) {
    // Fix wrong table names for entity revision metadata fields.
    foreach ($displays as $display => $display_data) {
      if (isset($display_data['display_options']['fields'])) {
        foreach ($display_data['display_options']['fields'] as $property_name => $property_data) {
          if (isset($property_data['entity_type']) && isset($property_data['field']) && isset($property_data['table'])) {
            $entity_type = $this->entityTypeManager()->getDefinition($property_data['entity_type']);
            // We need to update the table name only for revisionable entity
            // types, otherwise the view is already using the correct table.
            if (($entity_type instanceof ContentEntityTypeInterface) && is_subclass_of($entity_type->getClass(), FieldableEntityInterface::class) && $entity_type->isRevisionable()) {
              $revision_metadata_fields = $entity_type->getRevisionMetadataKeys();
              // @see \Drupal\Core\Entity\Sql\SqlContentEntityStorage::initTableLayout()
              $revision_table = $entity_type->getRevisionTable() ?: $entity_type->id() . '_revision';

              // Check if this is a revision metadata field and if it uses the
              // wrong table.
              if (in_array($property_data['field'], $revision_metadata_fields) && $property_data['table'] != $revision_table) {
                @trigger_error('Support for pre-8.3.0 revision table names in imported views is deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Imported views must reference the correct tables. See https://www.drupal.org/node/2831499', E_USER_DEPRECATED);
                $displays[$display]['display_options']['fields'][$property_name]['table'] = $revision_table;
              }
            }
          }
        }
      }
    }
  }

  /**
   * Fills in the cache metadata of this view.
   *
+1 −5
Original line number Diff line number Diff line
@@ -91,12 +91,8 @@ class ViewsEntitySchemaSubscriber implements EntityTypeListenerInterface, EventS
   * @param \Psr\Log\LoggerInterface $logger
   *   A logger instance.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager, LoggerInterface $logger = NULL) {
  public function __construct(EntityTypeManagerInterface $entity_type_manager, LoggerInterface $logger) {
    $this->entityTypeManager = $entity_type_manager;
    if (!$logger) {
      @trigger_error('Calling ViewsEntitySchemaSubscriber::__construct() with the $logger argument is supported in drupal:8.7.1 and will be required before drupal:9.0.0. See https://www.drupal.org/project/drupal/issues/3052492.', E_USER_DEPRECATED);
      $logger = \Drupal::service('logger.channel.default');
    }
    $this->logger = $logger;
  }

+1 −5
Original line number Diff line number Diff line
@@ -41,12 +41,8 @@ class ViewsExposedForm extends FormBase {
   * @param \Drupal\Core\Path\CurrentPathStack $current_path_stack
   *   The current path stack.
   */
  public function __construct(ExposedFormCache $exposed_form_cache, CurrentPathStack $current_path_stack = NULL) {
  public function __construct(ExposedFormCache $exposed_form_cache, CurrentPathStack $current_path_stack) {
    $this->exposedFormCache = $exposed_form_cache;
    if ($current_path_stack === NULL) {
      @trigger_error('The path.current service must be passed to ViewsExposedForm::__construct(), it is required before Drupal 9.0.0. See https://www.drupal.org/node/3066604', E_USER_DEPRECATED);
      $current_path_stack = \Drupal::service('path.current');
    }
    $this->currentPathStack = $current_path_stack;
  }

+2 −7
Original line number Diff line number Diff line
@@ -79,20 +79,15 @@ class ViewsSelection extends SelectionPluginBase implements ContainerFactoryPlug
   *   The module handler service.
   * @param \Drupal\Core\Session\AccountInterface $current_user
   *   The current user.
   * @param \Drupal\Core\Render\RendererInterface|null $renderer
   * @param \Drupal\Core\Render\RendererInterface $renderer
   *   The renderer.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, AccountInterface $current_user, RendererInterface $renderer = NULL) {
  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, AccountInterface $current_user, RendererInterface $renderer) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);

    $this->entityTypeManager = $entity_type_manager;
    $this->moduleHandler = $module_handler;
    $this->currentUser = $current_user;

    if (!$renderer) {
      @trigger_error('Calling ' . __METHOD__ . ' without the $renderer argument is deprecated in drupal:8.8.0 and is required in drupal:9.0.0. See https://www.drupal.org/node/2791359', E_USER_DEPRECATED);
      $renderer = \Drupal::service('renderer');
    }
    $this->renderer = $renderer;
  }

+0 −12
Original line number Diff line number Diff line
<?php

namespace Drupal\views\Plugin\views;

use Drupal\Component\Plugin\PluginInspectionInterface;

/**
 * @deprecated in drupal:8.3.0 and is removed from drupal:9.0.0.
 */
interface PluginInterface extends PluginInspectionInterface {

}
Loading