Skip to content
Snippets Groups Projects
Commit 30fb2bde authored by catch's avatar catch
Browse files

Issue #3497325 by berdir, smustgrave: Config entity static cache is not...

Issue #3497325 by berdir, smustgrave: Config entity static cache is not cleared correctly when multiple language overrides are used
parent 5dc03f8a
No related branches found
No related tags found
2 merge requests!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!10223132456: Fix issue where views instances are emptied before an ajax request is complete
Pipeline #430498 passed with warnings
Pipeline: drupal

#430508

    Pipeline: drupal

    #430505

      Pipeline: drupal

      #430499

        ......@@ -3481,6 +3481,12 @@
        'count' => 1,
        'path' => __DIR__ . '/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php',
        ];
        $ignoreErrors[] = [
        'message' => '#^Method Drupal\\\\Core\\\\Config\\\\Entity\\\\ConfigEntityStorage\\:\\:resetCache\\(\\) has no return type specified\\.$#',
        'identifier' => 'missingType.return',
        'count' => 1,
        'path' => __DIR__ . '/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php',
        ];
        $ignoreErrors[] = [
        'message' => '#^Method Drupal\\\\Core\\\\Config\\\\Entity\\\\ConfigEntityType\\:\\:checkStorageClass\\(\\) has no return type specified\\.$#',
        'identifier' => 'missingType.return',
        ......@@ -310,6 +310,17 @@ protected function buildCacheId($id) {
        return parent::buildCacheId($id) . ':' . ($this->overrideFree ? '' : implode(':', $this->configFactory->getCacheKeys()));
        }
        /**
        * {@inheritdoc}
        */
        public function resetCache(?array $ids = NULL) {
        if ($this->entityType->isStaticallyCacheable()) {
        // Always invalidate through the cache tag, since config entities may
        // be cached under different cache keys depending on the override flag.
        $this->memoryCache->invalidateTags([$this->memoryCacheTag]);
        }
        }
        /**
        * Invokes a hook on behalf of the entity.
        *
        ......
        ......@@ -4,7 +4,6 @@
        use Drupal\Core\Entity\EntityInterface;
        use Drupal\Core\StringTranslation\StringTranslationTrait;
        use Drupal\user\Entity\Role;
        use Drupal\filter\FilterFormatInterface;
        use Drupal\Core\Form\FormStateInterface;
        use Drupal\system\Entity\Action;
        ......@@ -487,8 +486,12 @@ public function formSystemRegionalSettingsAlter(&$form, FormStateInterface $form
        public function filterFormatDisable(FilterFormatInterface $filter_format): void {
        // Remove the permission from any roles.
        $permission = $filter_format->getPermissionName();
        /** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $role_storage */
        $role_storage = \Drupal::entityTypeManager()->getStorage('user_role');
        /** @var \Drupal\user\Entity\Role $role */
        foreach (Role::loadMultiple() as $role) {
        foreach ($role_storage->loadMultipleOverrideFree() as $role) {
        if ($role->hasPermission($permission)) {
        $role->revokePermission($permission)->save();
        }
        ......
        ......@@ -14,7 +14,6 @@
        use Drupal\Core\Session\AnonymousUserSession;
        use Drupal\Core\Site\Settings;
        use Drupal\Core\Url;
        use Drupal\user\Entity\Role;
        use Drupal\user\Entity\User;
        use Drupal\user\UserInterface;
        ......@@ -587,7 +586,8 @@ function user_role_change_permissions($rid, array $permissions = []) {
        */
        function user_role_grant_permissions($rid, array $permissions = []) {
        // Grant new permissions for the role.
        if ($role = Role::load($rid)) {
        $role_storage = \Drupal::entityTypeManager()->getStorage('user_role');
        if ($role = $role_storage->loadOverrideFree($rid)) {
        foreach ($permissions as $permission) {
        $role->grantPermission($permission);
        }
        ......@@ -608,7 +608,8 @@ function user_role_grant_permissions($rid, array $permissions = []) {
        */
        function user_role_revoke_permissions($rid, array $permissions = []) {
        // Revoke permissions for the role.
        $role = Role::load($rid);
        $role_storage = \Drupal::entityTypeManager()->getStorage('user_role');
        $role = $role_storage->loadOverrideFree($rid);
        foreach ($permissions as $permission) {
        $role->revokePermission($permission);
        }
        ......
        ......@@ -110,6 +110,12 @@ public function testConfigOverride(): void {
        // Enable overrides and reload the entity and ensure the cache is used.
        $this->assertSame($entity_override->_loadStamp, $storage->load($this->entityId)->_loadStamp);
        // Reset the cache, ensure that all variations of this entity are
        // invalidated.
        $storage->resetCache([$this->entityId]);
        $this->assertNotSame($entity_no_override->_loadStamp, $storage->loadOverrideFree($this->entityId)->_loadStamp);
        $this->assertNotSame($entity_override->_loadStamp, $storage->load($this->entityId)->_loadStamp);
        }
        }
        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