Skip to content
Snippets Groups Projects
Verified Commit d494e667 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3443493 by smustgrave, Gábor Hojtsy, mikelutz: Remove deprecated code...

Issue #3443493 by smustgrave, Gábor Hojtsy, mikelutz: Remove deprecated code from lib/State and lib/Session
parent 41943e87
No related branches found
No related tags found
26 merge requests!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!9470[10.3.x-only-DO-NOT-MERGE]: #3331771 Fix file_get_contents(): Passing null to parameter,!8540Issue #3457061: Bootstrap Modal dialog Not closing after 10.3.0 Update,!8528Issue #3456871 by Tim Bozeman: Support NULL services,!8373Issue #3427374 by danflanagan8, Vighneshh: taxonomy_tid ViewsArgumentDefault...,!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3651Issue #3347736: Create new SDC component for Olivero (header-search),!3531Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!3355Issue #3209129: Scrolling problems when adding a block via layout builder,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2062Issue #3246454: Add weekly granularity to views date sort,!1105Issue #3025039: New non translatable field on translatable content throws error,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #158745 canceled
Pipeline: drupal

#158746

    ......@@ -2,18 +2,12 @@
    namespace Drupal\Core\Session;
    use Drupal\Core\Entity\EntityTypeManagerInterface;
    /**
    * Checks permissions for an account.
    */
    class PermissionChecker implements PermissionCheckerInterface {
    public function __construct(protected EntityTypeManagerInterface|AccessPolicyProcessorInterface $processor) {
    if ($this->processor instanceof EntityTypeManagerInterface) {
    @trigger_error('Calling ' . __METHOD__ . '() without the $processor argument is deprecated in drupal:10.3.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3402107', E_USER_DEPRECATED);
    $this->processor = \Drupal::service('access_policy_processor');
    }
    public function __construct(protected AccessPolicyProcessorInterface $processor) {
    }
    /**
    ......
    ......@@ -13,47 +13,21 @@
    */
    class PermissionsHashGenerator implements PermissionsHashGeneratorInterface {
    /**
    * The private key service.
    *
    * @var \Drupal\Core\PrivateKey
    */
    protected $privateKey;
    /**
    * The cache backend interface to use for the static cache.
    *
    * @var \Drupal\Core\Cache\CacheBackendInterface
    */
    protected $static;
    /**
    * The access policy processor.
    *
    * @var \Drupal\Core\Session\AccessPolicyProcessorInterface
    */
    protected $processor;
    /**
    * Constructs a PermissionsHashGenerator object.
    *
    * @param \Drupal\Core\PrivateKey $private_key
    * @param \Drupal\Core\PrivateKey $privateKey
    * The private key service.
    * @param \Drupal\Core\Cache\CacheBackendInterface $static
    * The cache backend interface to use for the static cache.
    * @param \Drupal\Core\Session\AccessPolicyProcessorInterface|\Drupal\Core\Cache\CacheBackendInterface $processor
    * @param \Drupal\Core\Session\AccessPolicyProcessorInterface $processor
    * The access policy processor.
    */
    public function __construct(PrivateKey $private_key, CacheBackendInterface $static, AccessPolicyProcessorInterface|CacheBackendInterface $processor) {
    $this->privateKey = $private_key;
    if ($processor instanceof CacheBackendInterface) {
    @trigger_error('Calling ' . __METHOD__ . '() without the $processor argument is deprecated in drupal:10.3.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3402110', E_USER_DEPRECATED);
    $this->static = $processor;
    $this->processor = \Drupal::service('access_policy_processor');
    return;
    }
    $this->static = $static;
    $this->processor = $processor;
    public function __construct(
    protected PrivateKey $privateKey,
    protected CacheBackendInterface $static,
    protected AccessPolicyProcessorInterface $processor,
    ) {
    }
    /**
    ......@@ -100,25 +74,6 @@ public function generate(AccountInterface $account) {
    return $hash;
    }
    /**
    * Generates a hash that uniquely identifies the user's permissions.
    *
    * @param string[] $roles
    * The user's roles.
    *
    * @return string
    * The permissions hash.
    *
    * @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. There is no
    * replacement.
    *
    * @see https://www.drupal.org/node/3435842
    */
    protected function doGenerate(array $roles) {
    @trigger_error(__METHOD__ . '() is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3435842', E_USER_DEPRECATED);
    return '';
    }
    /**
    * {@inheritdoc}
    */
    ......
    ......@@ -17,37 +17,21 @@ class SessionHandler extends AbstractProxy implements \SessionHandlerInterface {
    use DependencySerializationTrait;
    /**
    * The request stack.
    *
    * @var \Symfony\Component\HttpFoundation\RequestStack
    */
    protected $requestStack;
    /**
    * The database connection.
    *
    * @var \Drupal\Core\Database\Connection
    */
    protected $connection;
    /**
    * Constructs a new SessionHandler instance.
    *
    * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
    * @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
    * The request stack.
    * @param \Drupal\Core\Database\Connection $connection
    * The database connection.
    * @param \Drupal\Component\Datetime\TimeInterface|null $time
    * @param \Drupal\Component\Datetime\TimeInterface $time
    * The time service.
    */
    public function __construct(RequestStack $request_stack, Connection $connection, protected ?TimeInterface $time = NULL) {
    $this->requestStack = $request_stack;
    $this->connection = $connection;
    if (!$time) {
    @trigger_error('Calling ' . __METHOD__ . '() without the $time argument is deprecated in drupal:10.3.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/3387233', E_USER_DEPRECATED);
    $this->time = \Drupal::service(TimeInterface::class);
    }
    public function __construct(
    protected RequestStack $requestStack,
    protected Connection $connection,
    protected TimeInterface $time,
    ) {
    }
    /**
    ......
    ......@@ -7,7 +7,6 @@
    use Drupal\Core\DependencyInjection\DependencySerializationTrait;
    use Symfony\Component\HttpFoundation\RequestStack;
    use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
    use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy;
    /**
    * Manages user sessions.
    ......@@ -30,27 +29,6 @@ class SessionManager extends NativeSessionStorage implements SessionManagerInter
    use DependencySerializationTrait;
    /**
    * The request stack.
    *
    * @var \Symfony\Component\HttpFoundation\RequestStack
    */
    protected $requestStack;
    /**
    * The database connection to use.
    *
    * @var \Drupal\Core\Database\Connection
    */
    protected $connection;
    /**
    * The session configuration.
    *
    * @var \Drupal\Core\Session\SessionConfigurationInterface
    */
    protected $sessionConfiguration;
    /**
    * Whether a lazy session has been started.
    *
    ......@@ -71,15 +49,15 @@ class SessionManager extends NativeSessionStorage implements SessionManagerInter
    /**
    * Constructs a new session manager instance.
    *
    * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
    * @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
    * The request stack.
    * @param \Drupal\Core\Database\Connection $connection
    * The database connection.
    * @param \Drupal\Core\Session\MetadataBag $metadata_bag
    * The session metadata bag.
    * @param \Drupal\Core\Session\SessionConfigurationInterface $session_configuration
    * @param \Drupal\Core\Session\SessionConfigurationInterface $sessionConfiguration
    * The session configuration interface.
    * @param \Drupal\Component\Datetime\TimeInterface|null|\Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy|\SessionHandlerInterface $time
    * @param \Drupal\Component\Datetime\TimeInterface $time
    * The time service.
    * @param \Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy|\SessionHandlerInterface|null $handler
    * The object to register as a PHP session handler.
    ......@@ -87,26 +65,14 @@ class SessionManager extends NativeSessionStorage implements SessionManagerInter
    * @see \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage::setSaveHandler()
    */
    public function __construct(
    RequestStack $request_stack,
    Connection $connection,
    MetadataBag $metadata_bag,
    SessionConfigurationInterface $session_configuration,
    protected TimeInterface|AbstractProxy|\SessionHandlerInterface|null $time = NULL,
    protected RequestStack $requestStack,
    protected Connection $connection,
    protected MetadataBag $metadata_bag,
    protected SessionConfigurationInterface $sessionConfiguration,
    protected TimeInterface $time,
    $handler = NULL,
    ) {
    $options = [];
    $this->sessionConfiguration = $session_configuration;
    $this->requestStack = $request_stack;
    $this->connection = $connection;
    if (!$time || $time instanceof AbstractProxy || $time instanceof \SessionHandlerInterface) {
    @trigger_error('Calling ' . __METHOD__ . '() without the $time argument is deprecated in drupal:10.3.0 and it will be the 5th argument in drupal:11.0.0. See https://www.drupal.org/node/3387233', E_USER_DEPRECATED);
    if ($time instanceof AbstractProxy || $time instanceof \SessionHandlerInterface) {
    $handler = $time;
    }
    $this->time = \Drupal::service(TimeInterface::class);
    }
    parent::__construct($options, $handler, $metadata_bag);
    parent::__construct([], $handler, $metadata_bag);
    }
    /**
    ......
    ......@@ -119,11 +119,7 @@ public function hasRole(string $rid): bool {
    /**
    * {@inheritdoc}
    */
    public function hasPermission(/* string */$permission) {
    if (!is_string($permission)) {
    @trigger_error('Calling ' . __METHOD__ . '() with a $permission parameter of type other than string is deprecated in drupal:10.3.0 and will cause an error in drupal:11.0.0. See https://www.drupal.org/node/3411485', E_USER_DEPRECATED);
    return FALSE;
    }
    public function hasPermission(string $permission) {
    return \Drupal::service('permission_checker')->hasPermission($permission, $this);
    }
    ......
    ......@@ -2,7 +2,6 @@
    namespace Drupal\Core\State;
    use Drupal\Core\Asset\AssetQueryString;
    use Drupal\Core\Cache\CacheBackendInterface;
    use Drupal\Core\Cache\CacheCollector;
    use Drupal\Core\KeyValueStore\KeyValueFactoryInterface;
    ......@@ -13,22 +12,6 @@
    */
    class State extends CacheCollector implements StateInterface {
    /**
    * Information about all deprecated state, keyed by legacy state key.
    *
    * Each entry should be an array that defines the following keys:
    * - 'replacement': The new name for the state.
    * - 'message': The deprecation message to use for trigger_error().
    *
    * @var array
    */
    private static array $deprecatedState = [
    'system.css_js_query_string' => [
    'replacement' => AssetQueryString::STATE_KEY,
    'message' => 'The \'system.css_js_query_string\' state is deprecated in drupal:10.2.0. Use \Drupal\Core\Asset\AssetQueryStringInterface::get() and ::reset() instead. See https://www.drupal.org/node/3358337.',
    ],
    ];
    /**
    * The key value store to use.
    *
    ......@@ -55,13 +38,6 @@ public function __construct(KeyValueFactoryInterface $key_value_factory, CacheBa
    * {@inheritdoc}
    */
    public function get($key, $default = NULL) {
    // If the caller is asking for the value of a deprecated state, trigger a
    // deprecation message about it.
    if (isset(self::$deprecatedState[$key])) {
    // phpcs:ignore Drupal.Semantics.FunctionTriggerError
    @trigger_error(self::$deprecatedState[$key]['message'], E_USER_DEPRECATED);
    $key = self::$deprecatedState[$key]['replacement'];
    }
    return parent::get($key) ?? $default;
    }
    ......@@ -91,11 +67,6 @@ public function getMultiple(array $keys) {
    * {@inheritdoc}
    */
    public function set($key, $value) {
    if (isset(self::$deprecatedState[$key])) {
    // phpcs:ignore Drupal.Semantics.FunctionTriggerError
    @trigger_error(self::$deprecatedState[$key]['message'], E_USER_DEPRECATED);
    $key = self::$deprecatedState[$key]['replacement'];
    }
    $this->keyValueStore->set($key, $value);
    // If another request had a cache miss before this request, and also hasn't
    // written to cache yet, then it may already have read this value from the
    ......
    <?php
    declare(strict_types=1);
    namespace Drupal\KernelTests\Core\State;
    use Drupal\KernelTests\KernelTestBase;
    /**
    * Tests the legacy state deprecations.
    *
    * @group system
    * @group legacy
    * @coversDefaultClass \Drupal\Core\State\State
    */
    class LegacyStateTest extends KernelTestBase {
    /**
    * @covers ::get
    * @covers ::set
    */
    public function testDeprecatedState(): void {
    $state = $this->container->get('state');
    $this->expectDeprecation('The \'system.css_js_query_string\' state is deprecated in drupal:10.2.0. Use \Drupal\Core\Asset\AssetQueryStringInterface::get() and ::reset() instead. See https://www.drupal.org/node/3358337.');
    $state->set('system.css_js_query_string', 'foo');
    $this->expectDeprecation('The \'system.css_js_query_string\' state is deprecated in drupal:10.2.0. Use \Drupal\Core\Asset\AssetQueryStringInterface::get() and ::reset() instead. See https://www.drupal.org/node/3358337.');
    $this->assertEquals('foo', $state->get('system.css_js_query_string'));
    $this->assertEquals('foo', \Drupal::service('asset.query_string')->get());
    }
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment