reverted: --- b/core/modules/system/src/Permissions.php +++ /dev/null @@ -1,61 +0,0 @@ -moduleHandler = $module_handler; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('module_handler') - ); - } - - /** - * Returns an array of content permissions. - * - * If the 'node' module is not installed this method will provide the - * 'access content' permission. - * - * @return array - * The transition permissions. - */ - public function contentPermissions() { - $permissions = []; - if (!$this->moduleHandler->moduleExists('node')) { - $permissions['access content'] = [ - 'title' => $this->t('View published content'), - ]; - } - return $permissions; - } - -} diff -u b/core/modules/system/system.permissions.yml b/core/modules/system/system.permissions.yml --- b/core/modules/system/system.permissions.yml +++ b/core/modules/system/system.permissions.yml @@ -15,6 +15,10 @@ view the administration theme: title: 'View the administration theme' description: 'This is only used when the site is configured to use a separate administration theme on the Appearance page.' +# Note that the 'access content' permission is moved to the Node section of the +# permission form when the Node module is enabled. +access content: + title: 'View published content' access site reports: title: 'View site reports' restrict access: true @@ -27,2 +30,0 @@ -permission_callbacks: - - \Drupal\system\Permissions::contentPermissions diff -u b/core/modules/system/tests/src/Kernel/PermissionsTest.php b/core/modules/system/tests/src/Kernel/PermissionsTest.php --- b/core/modules/system/tests/src/Kernel/PermissionsTest.php +++ b/core/modules/system/tests/src/Kernel/PermissionsTest.php @@ -5,7 +5,6 @@ use Drupal\KernelTests\KernelTestBase; /** - * @coversDefaultClass \Drupal\system\Permissions * @group system */ class PermissionsTest extends KernelTestBase { @@ -19,9 +18,7 @@ ]; /** - * Tests the 'access content' permission. - * - * @covers ::contentPermissions + * Tests the 'access content' permission is provided by the System module. */ public function testAccessContentPermission() { // Uninstalling modules requires the users_data table to exist. @@ -35,7 +32,7 @@ $this->container->get('module_installer')->install(['node']); $permissions = $this->container->get('user.permissions')->getPermissions(); - $this->assertSame('node', $permissions['access content']['provider']); + $this->assertSame('system', $permissions['access content']['provider']); // Uninstall the 'node' module, assert that it is again the 'system' module. $this->container->get('module_installer')->uninstall(['node']); only in patch2: unchanged: --- a/core/modules/node/node.permissions.yml +++ b/core/modules/node/node.permissions.yml @@ -12,8 +12,6 @@ administer nodes: restrict access: true access content overview: title: 'Access the Content overview page' -access content: - title: 'View published content' view own unpublished content: title: 'View own unpublished content' view all revisions: only in patch2: unchanged: --- a/core/modules/user/src/Form/UserPermissionsForm.php +++ b/core/modules/user/src/Form/UserPermissionsForm.php @@ -129,6 +129,21 @@ public function buildForm(array $form, FormStateInterface $form_state) { $permissions_by_provider[$permission['provider']][$permission_name] = $permission; } + // Move the access content permission to the Node module if it is installed. + if ($this->moduleHandler->moduleExists('node')) { + // Insert 'access content' before the 'view own unpublished content' key + // in order to maintain the UI even though the permission is provided by + // the system module. + $keys = array_keys($permissions_by_provider['node']); + $offset = (int) array_search('view own unpublished content', $keys); + $permissions_by_provider['node'] = array_merge( + array_slice($permissions_by_provider['node'], 0, $offset), + ['access content' => $permissions_by_provider['system']['access content']], + array_slice($permissions_by_provider['node'], $offset) + ); + unset($permissions_by_provider['system']['access content']); + } + foreach ($permissions_by_provider as $provider => $permissions) { // Module name. $form['permissions'][$provider] = [ only in patch2: unchanged: --- a/core/modules/user/src/Tests/UserPermissionsTest.php +++ b/core/modules/user/src/Tests/UserPermissionsTest.php @@ -164,4 +164,24 @@ public function testUserRoleChangePermissions() { $this->assertNotEqual($previous_permissions_hash, $current_permissions_hash, 'Permissions hash has changed.'); } + /** + * Verify 'access content' is listed in the correct location. + */ + public function testAccessContentPermission() { + $this->drupalLogin($this->adminUser); + + // When Node is not installed the 'access content' permission is listed next + // to 'access site reports'. + $this->drupalGet('admin/people/permissions'); + $next_row = $this->xpath('//tr[@data-drupal-selector=\'edit-permissions-access-content\']/following-sibling::tr[1]'); + $this->assertEqual('edit-permissions-access-site-reports', $next_row[0]->attributes()['data-drupal-selector']); + + // When Node is installed the 'access content' permission is listed next to + // to 'view own unpublished content'. + \Drupal::service('module_installer')->install(['node']); + $this->drupalGet('admin/people/permissions'); + $next_row = $this->xpath('//tr[@data-drupal-selector=\'edit-permissions-access-content\']/following-sibling::tr[1]'); + $this->assertEqual('edit-permissions-view-own-unpublished-content', $next_row[0]->attributes()['data-drupal-selector']); + } + }