Commit 14f5b68d authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

chore: #3560876 NavigationUserBlock::buildLinks() doesn't check if the user could be loaded

By: berdir
By: smustgrave
(cherry picked from commit d2246d5e)
(cherry picked from commit 7ef42dab)
parent e2239424
Loading
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -57,6 +57,15 @@ public static function buildLinks(string $label): array {
    // Load the current user so that they can be added as a cacheable dependency
    // of the final render array.
    $account = User::load(\Drupal::currentUser()->id());
    if (!$account) {
      // In certain edge case, the user load may fail, such as a late lazy
      // builder in tests when it was already deleted.
      return [
        '#cache' => [
          'contexts' => ['user'],
        ],
      ];
    }

    $menu_definition = [
      'menu_name' => static::NAVIGATION_LINKS_MENU,