"Paths to be excluded while generating segments" option says regex is supported, but it is not

Created on 2 February 2021, almost 4 years ago
Updated 27 August 2024, 3 months ago

Problem/Motivation

In the settings form, there is a textarea element titled "Paths to be excluded while generating segments". The description says "Paths may use simple regex, i.e.: report/2[0-9][0-9][0-9]." However, this is not true.

Instead, path segments are checked as simple string matches.

Steps to reproduce

Fill in the setting area with a path on your site that follows a regular expression. Observe that the breadcrumb component is not removed.

Proposed resolution

Rather than a simple string comparison, match regular expressions using the same "regex!" syntax as other fields.

Remaining tasks

User interface changes

API changes

Data model changes

Notes

This includes the work of #3169128 . Otherwise, if a breadcrumb has three segments and the second part is matched as to be excluded, the first part is also excluded.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇺🇸United States patrickfweston Columbus, Ohio

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Merge request !31Resolve #3196198 "Paths to be" → (Merged) created by suresh prabhu parkala
  • I tested the patch in #16 and am getting:

    Warning: preg_match(): Unknown modifier 't' in Drupal\easy_breadcrumb\EasyBreadcrumbBuilder->build() (line 510 of modules/contrib/easy_breadcrumb/src/EasyBreadcrumbBuilder.php).

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India supriya1992

    #16 is working fine with regular expression without any error/warning.
    I attached the screenshot of the configuration and before/after applying patches.
    The "Paths to be excluded while generating segments" value should be a valid regex and shouldn't start and end with "/". "/" is already implemented in the code.

  • First commit to issue fork.
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.4 + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    6 pass
  • Status changed to Needs work about 1 year ago
  • I've rebased the merge request. So I can try and implement the fixes provided in #16 with all the latest code in 2.x-dev. I'm getting a similar error as @bhouge in #20. This comes down because this takes the whole line a preg_match (in my example node/3), and the problem here is because / is unescaped.

    That said even when I escape it as @supriya1992 did, it doesn't correctly match when I go to /node/3 page, because we are trying to compare the whole string to the last path element (In my case were trying to compare node\/3 to 3).

    Also, her config should not work in the first place report/2[0-9][0-9][0-9] should only validate to strings starting with report/2 and ending with 3 characters inclusive between 0 and 9, so a valid match would be report/2123

    Testing with Drupal 10.1 and PHP 8.1.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.4 + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    6 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.4 + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    6 pass
  • Status changed to Needs review about 1 year ago
  • Changed it so now it compares to $check_path and not $target_segment, also changed the description so it's visible that forward slashes have to be escaped with a backslash. Needs review.

  • 🇺🇸United States Greg Boggs Portland Oregon

    Thank you Admirlju!

  • Status changed to Needs work 9 months ago
  • 🇺🇸United States Greg Boggs Portland Oregon

    The MR needs a rebase against the latest release.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 8
    last update 9 months ago
    6 pass
  • Pipeline finished with Failed
    9 months ago
    Total: 141s
    #99151
  • Rebased against the latest release, DrupalCI is passing but for some reason, GitlabCI is not. And I'm not sure it's failing because of changes in this code. Could someone check this? For that reason leaving it as needs works.

  • Pipeline finished with Skipped
    9 months ago
    #99746
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 8
    last update 9 months ago
    6 pass
  • 🇺🇸United States Greg Boggs Portland Oregon

    Thanks Admirlju!

    I believe the Gitlab fail is coding standards which is pretty small, and we have another ticket for getting standards to pass, I'm going to merge.

  • This still isn't working for me ...

    I am trying to exclude layout pages from displaying breadcrumbs, so this is what I'm putting in the "Paths to be excluded while generating segments" field:

    node\/[0-9]+\/layout

    But when I go to /node/8/layout, the breadcrumb is still there.

    I am using version 2.0.6 of the module.

    I tried the module as-is, then I tried patching using MR!31, then I tried downloading 31.patch and applying that way. Nothing seems to work. What am I missing?

  • 🇺🇸United States Greg Boggs Portland Oregon

    Unfortunately, they dev release is not ready yet. This issue still needs an MR and tests passing:

    https://www.drupal.org/project/easy_breadcrumb/issues/3440889 🐛 Broken findMatchingRedirect() call Fixed

  • Status changed to Fixed 6 months ago
  • 🇺🇸United States Greg Boggs Portland Oregon
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • 🇺🇸United States joakland

    Reopening this issue. I'm on Drupal 10.3.1 using v2.0.7 of this module. Exclusion paths are throwing an error in all cases, regex or not. Here's the stack trace:

    Drupal\easy_breadcrumb\EasyBreadcrumbBuilder->build(Object) (Line: 83)
    Drupal\Core\Breadcrumb\BreadcrumbManager->build(Object) (Line: 73)
    Drupal\system\Plugin\Block\SystemBreadcrumbBlock->build() (Line: 171)
    Drupal\block\BlockViewBuilder::preRender(Array)
    call_user_func_array('Drupal\block\BlockViewBuilder::preRender', Array) (Line: 113)
    Drupal\Core\Render\Renderer->doTrustedCallback('Drupal\block\BlockViewBuilder::preRender', Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 870)
    Drupal\Core\Render\Renderer->doCallback('#pre_render', 'Drupal\block\BlockViewBuilder::preRender', Array) (Line: 432)
    Drupal\Core\Render\Renderer->doRender(Array) (Line: 504)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
    Drupal\Core\Render\Renderer->render(Array) (Line: 475)
    Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 78)
    __TwigTemplate_18fd583981cfc99363aff62dcde205fe->doDisplay(Array, Array) (Line: 360)
    Twig\Template->yield(Array) (Line: 335)
    Twig\Template->render(Array) (Line: 38)
    Twig\TemplateWrapper->render(Array) (Line: 33)
    twig_render_template('themes/contrib/seven/templates/page.html.twig', Array) (Line: 348)
    Drupal\Core\Theme\ThemeManager->render('page', Array) (Line: 491)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
    Drupal\Core\Render\Renderer->render(Array) (Line: 475)
    Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 87)
    __TwigTemplate_17782acc4d8ccae26dac5db17dcdc334->doDisplay(Array, Array) (Line: 360)
    Twig\Template->yield(Array) (Line: 335)
    Twig\Template->render(Array) (Line: 38)
    Twig\TemplateWrapper->render(Array) (Line: 33)
    twig_render_template('themes/contrib/seven/templates/classy/layout/html.html.twig', Array) (Line: 348)
    Drupal\Core\Theme\ThemeManager->render('html', Array) (Line: 491)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
    Drupal\Core\Render\Renderer->render(Array) (Line: 158)
    Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 159)
    Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
    Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
    call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 186)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    
  • Status changed to Postponed: needs info 3 months ago
  • 🇩🇪Germany spuky

    you did not change the Status to open...
    -> so I did that for you...

    but i can't reproduce that error message... could you share more about your config and how to reproduce your issue ?

  • 🇩🇪Germany spuky

    tried also with seven also working

    could it be that you are not escaping your entered paths

    path/test

    would give you warning (with the call stack mentioned) Warning: preg_match(): Unknown modifier 't' in ...

    path\/test

    would work

  • 🇩🇪Germany spuky

    I opend an Issue to Improve the description of that field.

  • Status changed to Fixed 3 months ago
  • 🇩🇪Germany spuky

    setting back to fixed

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024