Issue #3196245 by prudloff, longwave, smustgrave, berdir, catch: UserPermissionsForm should not use overridden permissions
(cherry picked from commit 02513abe69
)
merge-requests/11281/merge
parent
49e96345c9
commit
5363423360
|
@ -86,7 +86,7 @@ class UserPermissionsForm extends FormBase {
|
|||
* An array of role objects.
|
||||
*/
|
||||
protected function getRoles() {
|
||||
return $this->roleStorage->loadMultiple();
|
||||
return $this->roleStorage->loadMultipleOverrideFree();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\user_config_override_test;
|
||||
|
||||
use Drupal\Core\Config\StorableConfigBase;
|
||||
use Drupal\Core\Cache\CacheableMetadata;
|
||||
use Drupal\Core\Config\ConfigFactoryOverrideInterface;
|
||||
use Drupal\Core\Config\StorageInterface;
|
||||
|
||||
/**
|
||||
* Tests overridden permissions.
|
||||
*/
|
||||
class ConfigOverrider implements ConfigFactoryOverrideInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadOverrides($names): array {
|
||||
return [
|
||||
'user.role.anonymous' => [
|
||||
'permissions' => [9999 => 'access content'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCacheSuffix(): string {
|
||||
return 'user_config_override_test';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCacheableMetadata($name): CacheableMetadata {
|
||||
return new CacheableMetadata();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createConfigObject($name, $collection = StorageInterface::DEFAULT_COLLECTION): StorableConfigBase|null {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
name: 'Permission config overrider'
|
||||
type: module
|
||||
package: Testing
|
||||
version: VERSION
|
|
@ -0,0 +1,5 @@
|
|||
services:
|
||||
user_config_override_test.overrider:
|
||||
class: Drupal\user_config_override_test\ConfigOverrider
|
||||
tags:
|
||||
- { name: config.factory.override }
|
|
@ -37,6 +37,13 @@ class UserPermissionsTest extends BrowserTestBase {
|
|||
*/
|
||||
protected $defaultTheme = 'stark';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $modules = [
|
||||
'user_config_override_test',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -333,4 +340,16 @@ class UserPermissionsTest extends BrowserTestBase {
|
|||
$assert_session->pageTextNotContains("Entity view display 'node.article.default': Component");
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that the permission form does not use overridden config.
|
||||
*
|
||||
* @see \Drupal\user_config_override_test\ConfigOverrider
|
||||
*/
|
||||
public function testOverriddenPermission(): void {
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
$this->drupalGet('admin/people/permissions');
|
||||
$this->assertSession()->checkboxNotChecked('anonymous[access content]');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue