Skip to content
Snippets Groups Projects
Commit 932ef94e 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 74661908
No related branches found
No related tags found
38 merge requests!10663Issue #3495778: Update phpdoc in FileSaveHtaccessLoggingTest,!10451Issue #3472458 by watergate, smustgrave: CKEditor 5 show blocks label is not translated,!103032838547 Fix punctuation rules for inline label suffix colon with CSS only,!10150Issue #3467294 by quietone, nod_, smustgrave, catch, longwave: Change string...,!10130Resolve #3480321 "Second level menu",!9936Issue #3483087: Check the module:// prefix in the translation server path and replace it with the actual module path,!9933Issue #3394728 by ankondrat4: Undefined array key "#prefix" and deprecated function: explode() in Drupal\file\Element\ManagedFile::uploadAjaxCallback(),!9914Issue #3451136 by quietone, gapple, ghost of drupal past: Improve...,!9882Draft: Issue #3481777 In bulk_form ensure the triggering element is the bulk_form button,!9839Issue #3445469 by pooja_sharma, smustgrave: Add additional test coverage for...,!9815Issue #3480025: There is no way to remove entity cache items,!9757Issue #3478869 Add "All" or overview links to parent links,!9752Issue #3439910 by pooja_sharma, vensires: Fix Toolbar tests that rely on UID1's super user behavior,!9749Issue #3439910 by pooja_sharma, vensires: Fix Toolbar tests that rely on UID1's super user behavior,!9678Issue #3465132 by catch, Spokje, nod_: Show test run time by class in run-tests.sh output,!9578Issue #3304746 by scott_euser, casey, smustgrave: BigPipe cannot handle (GET)...,!9449Issue #3344041: Allow textarea widgets to be used for text (formatted) fields,!8945🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥...,!8893Resolve #3444391 "Navigation center sm logo",!8772Issue #3445909 by seanB, smustgrave, alexpott, catch: Add static caching to...,!8723Make dblog entities,!8708Filter out disabled display extenders on save,!8691#3459116 - Update Manager Settings: Validate same email address added multiple times,!8665Issue #3449743 by catch: Try to optimize test ordering when run-tests.sh is...,!8598Draft: Issue #3458215: Migrate Toolbar button to SDC,!8572Reorder checkboxes on "Development settings" page,!8538Issue #3457009: Fixing xxception message thrown.,!8516Update file EntityReferenceItem.php,!8505Issue #3456528: _node_mass_update_batch_process fails during user cancel when revision is deleted,!8494Issue #3452511: Convert ProviderRepositoryTest to a kernel test,!8482Resolve #3456202 "Phpunit tests support",!8463Prevent re-install if site already exists,!8392Issue #3454196: Filter placeholders without arguments are not replaced when HTML corrector filter applied afterwards,!8384Issue #3446403 by edutrul, jnicola, mradcliffe: [name]: This field is missing for example recipe,!8304Issue #2990766 by camilledavis, Gauravvvv, mgifford: Location of "Skip to...,!8178Issue #3439909 by SolimanHarkas, vensires: Fix Taxonomy tests that rely on...,!8138Remove inactive initiatives from maintainers list,!5829Porting tabledrag CSS refactor from D10 branch
Pipeline #175751 passed with warnings
Pipeline: drupal

#175775

    Pipeline: drupal

    #175765

      Pipeline: drupal

      #175758

        ...@@ -59,12 +59,6 @@ public static function create(ContainerInterface $container, array $configuratio ...@@ -59,12 +59,6 @@ public static function create(ContainerInterface $container, array $configuratio
        * {@inheritdoc} * {@inheritdoc}
        */ */
        protected function blockAccess(AccountInterface $account): AccessResultInterface { 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'); return AccessResult::allowedIfHasPermission($account, 'access shortcuts');
        } }
        ...@@ -72,6 +66,11 @@ protected function blockAccess(AccountInterface $account): AccessResultInterface ...@@ -72,6 +66,11 @@ protected function blockAccess(AccountInterface $account): AccessResultInterface
        * {@inheritdoc} * {@inheritdoc}
        */ */
        public function build(): array { 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 [ return [
        'shortcuts' => [ 'shortcuts' => [
        // @phpstan-ignore-next-line // @phpstan-ignore-next-line
        ......
        ...@@ -11,11 +11,11 @@ ...@@ -11,11 +11,11 @@
        use Drupal\Tests\system\Functional\Cache\PageCacheTagsTestBase; use Drupal\Tests\system\Functional\Cache\PageCacheTagsTestBase;
        /** /**
        * Tests for \Drupal\navigation\Plugin\Block\ShortcutsNavigationBlock. * Tests for \Drupal\navigation\Plugin\Block\NavigationShortcutsBlock.
        * *
        * @group navigation * @group navigation
        */ */
        class ShortcutsNavigationBlockTest extends PageCacheTagsTestBase { class NavigationShortcutsBlockTest extends PageCacheTagsTestBase {
        use AssertPageCacheContextsAndTagsTrait; use AssertPageCacheContextsAndTagsTrait;
        ...@@ -80,7 +80,7 @@ public function testNavigationBlock() { ...@@ -80,7 +80,7 @@ public function testNavigationBlock() {
        // Verify that users without the 'access shortcuts' permission can't see the // Verify that users without the 'access shortcuts' permission can't see the
        // shortcuts. // shortcuts.
        $this->drupalLogin($this->drupalCreateUser(['access navigation'])); $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, 'MISS');
        $this->verifyDynamicPageCache($test_page_url, 'HIT'); $this->verifyDynamicPageCache($test_page_url, 'HIT');
        ...@@ -103,6 +103,7 @@ public function testNavigationBlock() { ...@@ -103,6 +103,7 @@ public function testNavigationBlock() {
        'access shortcuts', 'access shortcuts',
        'administer site configuration', 'administer site configuration',
        'access administration pages', 'access administration pages',
        'configure any layout',
        ]); ]);
        // Create two different users with the same role to assert that the second // Create two different users with the same role to assert that the second
        ...@@ -169,44 +170,57 @@ public function testNavigationBlock() { ...@@ -169,44 +170,57 @@ public function testNavigationBlock() {
        ]); ]);
        $new_shortcut->save(); $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 // Assign the new shortcut set to user 2 and confirm that links are changed
        // automatically. // automatically.
        // \Drupal::entityTypeManager() \Drupal::entityTypeManager()
        // ->getStorage('shortcut_set') ->getStorage('shortcut_set')
        // ->assignUser($new_set, $site_configuration_user2); ->assignUser($new_set, $site_configuration_user2);
        // // $this->verifyDynamicPageCache($test_page_url, 'HIT'); $this->verifyDynamicPageCache($test_page_url, 'HIT');
        // $this->assertSession()->linkExists('Cron'); $this->assertSession()->linkExists('Cron');
        // $this->assertSession()->linkExists('New Llama'); $this->assertSession()->linkExists('New Llama');
        // // // Confirm that links for user 1 have not been affected. // Confirm that links for user 1 have not been affected.
        // $this->drupalLogin($site_configuration_user1); $this->drupalLogin($site_configuration_user1);
        // $this->verifyDynamicPageCache($test_page_url, 'HIT'); $this->verifyDynamicPageCache($test_page_url, 'HIT');
        // $this->assertSession()->linkExists('Cron'); $this->assertSession()->linkExists('Cron');
        // $this->assertSession()->linkNotExists('New Llama'); $this->assertSession()->linkNotExists('New Llama');
        // Confirm that removing assignment automatically changes the links too. // Confirm that removing assignment automatically changes the links too.
        // $this->drupalLogin($site_configuration_user2); $this->drupalLogin($site_configuration_user2);
        // $this->verifyDynamicPageCache($test_page_url, 'HIT'); $this->verifyDynamicPageCache($test_page_url, 'HIT');
        // $this->assertSession()->linkExists('Cron'); $this->assertSession()->linkExists('Cron');
        // $this->assertSession()->linkExists('New Llama'); $this->assertSession()->linkExists('New Llama');
        // \Drupal::entityTypeManager() \Drupal::entityTypeManager()
        // ->getStorage('shortcut_set') ->getStorage('shortcut_set')
        // ->unassignUser($site_configuration_user2); ->unassignUser($site_configuration_user2);
        // $this->verifyDynamicPageCache($test_page_url, 'HIT'); $this->verifyDynamicPageCache($test_page_url, 'HIT');
        // $this->assertSession()->linkExists('Cron'); $this->assertSession()->linkExists('Cron');
        // $this->assertSession()->linkNotExists('New Llama'); $this->assertSession()->linkNotExists('New Llama');
        // Confirm that deleting a shortcut set automatically changes the links too. // Confirm that deleting a shortcut set automatically changes the links too.
        // \Drupal::entityTypeManager() \Drupal::entityTypeManager()
        // ->getStorage('shortcut_set') ->getStorage('shortcut_set')
        // ->assignUser($new_set, $site_configuration_user2); ->assignUser($new_set, $site_configuration_user2);
        // $this->verifyDynamicPageCache($test_page_url, 'HIT'); $this->verifyDynamicPageCache($test_page_url, 'HIT');
        // $this->assertSession()->linkExists('Cron'); $this->assertSession()->linkExists('Cron');
        // $this->assertSession()->linkExists('New Llama'); $this->assertSession()->linkExists('New Llama');
        // \Drupal::entityTypeManager() \Drupal::entityTypeManager()
        // ->getStorage('shortcut_set') ->getStorage('shortcut_set')
        // ->delete([$new_set]); ->delete([$new_set]);
        // $this->verifyDynamicPageCache($test_page_url, 'HIT'); $this->verifyDynamicPageCache($test_page_url, 'HIT');
        // $this->assertSession()->linkExists('Cron'); $this->assertSession()->linkExists('Cron');
        // $this->assertSession()->linkNotExists('New Llama'); $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.
        Finish editing this message first!
        Please register or to comment