Commit 6683f9a2 authored by Navneet Singh's avatar Navneet Singh Committed by Navneet Singh
Browse files

Merge pull request #2968 from goalgorilla/issue/3144794-fix-load-page-title-block-twice

Issue #3144794: Hero block display based on path is too fragile
parent a743dac3
Loading
Loading
Loading
Loading
+0 −18
Original line number Diff line number Diff line
@@ -23,21 +23,3 @@ visibility:
    pages: "/search/*\r\n*/stream\r\n*/events\r\n*/topics\r\n*/groups\r\n*/information\r\n*/members\r\n*/membership\r\n*/about\r\n/data-policy\r\n/data-policy/*"
    negate: true
    context_mapping: {  }
    'entity_bundle:node':
      id: 'entity_bundle:node'
      bundles:
        event: event
        page: page
        topic: topic
      negate: true
      context_mapping:
        node: '@node.node_route_context:node'
    group_type:
      id: group_type
      group_types:
        closed_group: closed_group
        open_group: open_group
        public_group: public_group
      negate: false
      context_mapping:
        group: '@group.group_route_context:group'
+8 −0
Original line number Diff line number Diff line
block.block.socialblue_pagetitleblock_content:
  expected_config: {  }
  update_actions:
    delete:
      visibility:
        request_path:
          'entity_bundle:node': {  }
          group_type: {  }
+14 −0
Original line number Diff line number Diff line
@@ -1575,3 +1575,17 @@ function social_core_update_11401(): void {
  $source = new FileStorage($config_path);
  $config_storage->write('core.entity_view_mode.node.email_card', (array) $source->read('core.entity_view_mode.node.email_card_11401'));
}

/**
 * Remove block visibility settings that were added in the wrong place.
 */
function social_core_update_11402(array &$sandbox): string {
  /** @var \Drupal\update_helper\UpdaterInterface $update_helper */
  $update_helper = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $update_helper->executeUpdate('social_core', __FUNCTION__);

  // Output logged messages to related channel of update execution.
  return $update_helper->logger()->output();
}
+23 −0
Original line number Diff line number Diff line
@@ -674,6 +674,29 @@ function social_core_block_access(Block $block, $operation, AccountInterface $ac
    }
  }

  // Make sure that socialblue_pagetitleblock_content doesn't show on nodes
  // pages. We can't add visibility 'entity_bundle:node' whether 'group_type'
  // since the block will disappear from pages like Access denied and some tests
  // will be failed. So, let's hide the block for node canonical instead.
  if (
    $operation === 'view' &&
    $block->getPluginId() === 'social_page_title_block' &&
    $block->id() === 'socialblue_pagetitleblock_content'
  ) {
    /** @var \Drupal\node\Entity\Node $node */
    $node = \Drupal::routeMatch()->getParameter('node');
    // Get the route name.
    $route_name = \Drupal::routeMatch()->getRouteName();

    // If it is a node we prevent the block from showing.
    if (
      $node instanceof NodeInterface &&
      $route_name === 'entity.node.canonical'
    ) {
      return AccessResult::forbidden();
    }
  }

  // No opinion.
  return AccessResult::neutral();
}