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

Issue #3445184 by plopesc, matthieuscarset, m4olivei: Fatal error when...

Issue #3445184 by plopesc, matthieuscarset, m4olivei: Fatal error when accessing Navigation Blocks on a minimal profile installation because of the Shortcut block

(cherry picked from commit e96135b2)
parent df997735
Branches
Tags
17 merge requests!12212Issue #3445525 by alexpott, japerry, catch, mglaman, longwave: Add BC layer...,!10602Issue #3438769 by vinmayiswamy, antonnavi, michelle, amateescu: Sub workspace does not clear,!10301Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time login...,!10187Issue #3487488 by dakwamine: ExtensionMimeTypeGuesser::guessMimeType must support file names with "0" (zero) like foo.0.zip,!9929Issue #3445469 by pooja_sharma, smustgrave: Add additional test coverage for...,!9787Resolve issue 3479427 - bootstrap barrio issue under Windows,!9742Issue #3463908 by catch, quietone: Split OptionsFieldUiTest into two,!9526Issue #3458177 by mondrake, catch, quietone, godotislate, longwave, larowlan,...,!8949Backport .gitlabci.yml changes.,!8738Issue #3424162 by camilledavis, dineshkumarbollu, smustgrave: Claro...,!8704Make greek characters available in ckeditor5,!8533Issue #3446962 by kim.pepper: Remove incorrectly added...,!8517Issue #3443748 by NexusNovaz, smustgrave: Testcase creates false positive,!7445Issue #3440169: When using drupalGet(), provide an associative array for $headers,!6502Draft: Resolve #2938524 "Plach testing issue",!38582585169-10.1.x,!3226Issue #2987537: Custom menu link entity type should not declare "bundle" entity key
Pipeline #176153 passed
Pipeline: drupal

#176181

    Pipeline: drupal

    #176177

      Pipeline: drupal

      #176176

        +6
        ......@@ -59,12 +59,6 @@ public static function create(ContainerInterface $container, array $configuratio
        * {@inheritdoc}
        */
        protected function blockAccess(AccountInterface $account): AccessResultInterface {
        // This navigation block requires shortcut module. Once the plugin is moved
        // to the module, this should not be necessary.
        if (!$this->moduleHandler->moduleExists('shortcut')) {
        return AccessResult::forbidden();
        }
        return AccessResult::allowedIfHasPermission($account, 'access shortcuts');
        }
        ......@@ -72,6 +66,11 @@ protected function blockAccess(AccountInterface $account): AccessResultInterface
        * {@inheritdoc}
        */
        public function build(): array {
        // This navigation block requires shortcut module. Once the plugin is moved
        // to the module, this should not be necessary.
        if (!$this->moduleHandler->moduleExists('shortcut')) {
        return [];
        }
        return [
        'shortcuts' => [
        // @phpstan-ignore-next-line
        ......
        ......@@ -11,11 +11,11 @@
        use Drupal\Tests\system\Functional\Cache\PageCacheTagsTestBase;
        /**
        * Tests for \Drupal\navigation\Plugin\Block\ShortcutsNavigationBlock.
        * Tests for \Drupal\navigation\Plugin\Block\NavigationShortcutsBlock.
        *
        * @group navigation
        */
        class ShortcutsNavigationBlockTest extends PageCacheTagsTestBase {
        class NavigationShortcutsBlockTest extends PageCacheTagsTestBase {
        use AssertPageCacheContextsAndTagsTrait;
        ......@@ -80,7 +80,7 @@ public function testNavigationBlock() {
        // Verify that users without the 'access shortcuts' permission can't see the
        // shortcuts.
        $this->drupalLogin($this->drupalCreateUser(['access navigation']));
        $this->assertSession()->linkNotExists('Shortcuts');
        $this->assertSession()->pageTextNotContains('Shortcuts');
        $this->verifyDynamicPageCache($test_page_url, 'MISS');
        $this->verifyDynamicPageCache($test_page_url, 'HIT');
        ......@@ -103,6 +103,7 @@ public function testNavigationBlock() {
        'access shortcuts',
        'administer site configuration',
        'access administration pages',
        'configure any layout',
        ]);
        // Create two different users with the same role to assert that the second
        ......@@ -169,44 +170,57 @@ public function testNavigationBlock() {
        ]);
        $new_shortcut->save();
        // @todo Uncomment once tests are executed against 10.3.x.
        // Assign the new shortcut set to user 2 and confirm that links are changed
        // automatically.
        // \Drupal::entityTypeManager()
        // ->getStorage('shortcut_set')
        // ->assignUser($new_set, $site_configuration_user2);
        // // $this->verifyDynamicPageCache($test_page_url, 'HIT');
        // $this->assertSession()->linkExists('Cron');
        // $this->assertSession()->linkExists('New Llama');
        // // // Confirm that links for user 1 have not been affected.
        // $this->drupalLogin($site_configuration_user1);
        // $this->verifyDynamicPageCache($test_page_url, 'HIT');
        // $this->assertSession()->linkExists('Cron');
        // $this->assertSession()->linkNotExists('New Llama');
        \Drupal::entityTypeManager()
        ->getStorage('shortcut_set')
        ->assignUser($new_set, $site_configuration_user2);
        $this->verifyDynamicPageCache($test_page_url, 'HIT');
        $this->assertSession()->linkExists('Cron');
        $this->assertSession()->linkExists('New Llama');
        // Confirm that links for user 1 have not been affected.
        $this->drupalLogin($site_configuration_user1);
        $this->verifyDynamicPageCache($test_page_url, 'HIT');
        $this->assertSession()->linkExists('Cron');
        $this->assertSession()->linkNotExists('New Llama');
        // Confirm that removing assignment automatically changes the links too.
        // $this->drupalLogin($site_configuration_user2);
        // $this->verifyDynamicPageCache($test_page_url, 'HIT');
        // $this->assertSession()->linkExists('Cron');
        // $this->assertSession()->linkExists('New Llama');
        // \Drupal::entityTypeManager()
        // ->getStorage('shortcut_set')
        // ->unassignUser($site_configuration_user2);
        // $this->verifyDynamicPageCache($test_page_url, 'HIT');
        // $this->assertSession()->linkExists('Cron');
        // $this->assertSession()->linkNotExists('New Llama');
        $this->drupalLogin($site_configuration_user2);
        $this->verifyDynamicPageCache($test_page_url, 'HIT');
        $this->assertSession()->linkExists('Cron');
        $this->assertSession()->linkExists('New Llama');
        \Drupal::entityTypeManager()
        ->getStorage('shortcut_set')
        ->unassignUser($site_configuration_user2);
        $this->verifyDynamicPageCache($test_page_url, 'HIT');
        $this->assertSession()->linkExists('Cron');
        $this->assertSession()->linkNotExists('New Llama');
        // Confirm that deleting a shortcut set automatically changes the links too.
        // \Drupal::entityTypeManager()
        // ->getStorage('shortcut_set')
        // ->assignUser($new_set, $site_configuration_user2);
        // $this->verifyDynamicPageCache($test_page_url, 'HIT');
        // $this->assertSession()->linkExists('Cron');
        // $this->assertSession()->linkExists('New Llama');
        // \Drupal::entityTypeManager()
        // ->getStorage('shortcut_set')
        // ->delete([$new_set]);
        // $this->verifyDynamicPageCache($test_page_url, 'HIT');
        // $this->assertSession()->linkExists('Cron');
        // $this->assertSession()->linkNotExists('New Llama');
        \Drupal::entityTypeManager()
        ->getStorage('shortcut_set')
        ->assignUser($new_set, $site_configuration_user2);
        $this->verifyDynamicPageCache($test_page_url, 'HIT');
        $this->assertSession()->linkExists('Cron');
        $this->assertSession()->linkExists('New Llama');
        \Drupal::entityTypeManager()
        ->getStorage('shortcut_set')
        ->delete([$new_set]);
        $this->verifyDynamicPageCache($test_page_url, 'HIT');
        $this->assertSession()->linkExists('Cron');
        $this->assertSession()->linkNotExists('New Llama');
        // Verify that block disappears gracefully when shortcut module is disabled.
        // Shortcut entities has to be removed first.
        $link_storage = \Drupal::entityTypeManager()->getStorage('shortcut');
        $link_storage->delete($link_storage->loadMultiple());
        \Drupal::service('module_installer')->uninstall(['shortcut']);
        $this->verifyDynamicPageCache($test_page_url, 'MISS');
        $this->assertSession()->statusCodeEquals(200);
        $this->assertSession()->pageTextNotContains('Shortcuts');
        // Confirm that Navigation Blocks page is working.
        // @see https://www.drupal.org/project/drupal/issues/3445184
        $this->drupalGet('/admin/config/user-interface/navigation-block');
        $this->assertSession()->statusCodeEquals(200);
        }
        }
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment