Multiple problems with breadcrumbs on node edit forms (and probably on other entity forms too)

Created on 2 September 2024, 4 months ago

Problem/Motivation

My client reported a problem about breadcrumb usually display the wrong content type label on node edit forms. After clearing the cache the breadcrumb displays other node type label constantly.

After investigating gin_preprocess_breadcrumb i found other strange implementations too.

Not clear why this breadcrumb built with concatenating strings, instead of using the normal string translations? For example for Hungarian translation i would prefer the "@content_type szerkesztΓ©se" translation, instead of the current "SzerkesztΓ©s @content_type" format. (For most cases it would be acceptable the current word order, but it would be require a : after the word "SzerkesztΓ©s".

Not clear if the preprocess using other entities to build the text of breadcrumb to override the normal one why not add cache tags and/or cache context to the $variables to signal when this breadcrumb can be reused?

Steps to reproduce

Create multiple node types (i.e. page, blog). Enable any type of caching. Create a page node. Create a blog node. Go to edit the page node. Go to edit blog node. If there is no cache clear in the background, the in most cases the breadcrumb on blog node edit form will say "Edit Page".

Proposed resolution

If Gin theme insist to override breadcrumb via a hook_preprocess_breadcrumb i suggest it should add proper cache tags and/or context to the $variables to reduce the chance of display the wrong cached values.

Please do not concatenate strings to display! Use the string translation.

Remaining tasks

Decide if it absolutely necessary to override the breadcrumb?

Decide if it overriding the breadcrumb via a preprocess is the best solution.

Change the current behaviour.

User interface changes

None.

API changes

Probably none.

Data model changes

None.

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡­πŸ‡ΊHungary tikaszvince

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

Merge Requests

Comments & Activities

  • Issue created by @tikaszvince
  • πŸ‡¨πŸ‡­Switzerland saschaeggi Zurich

    If Gin theme insist to override breadcrumb via a hook_preprocess_breadcrumb i suggest it should add proper cache tags and/or context to the $variables to reduce the chance of display the wrong cached values.

    Please do not concatenate strings to display! Use the string translation.

    Please feel free to open an MR to address these issues

  • Merge request !491Resolve #3471569 "Node edit breadcrumb" β†’ (Open) created by tikaszvince
  • Pipeline finished with Failed
    4 months ago
    Total: 179s
    #271737
  • Pipeline finished with Success
    4 months ago
    Total: 158s
    #271741
  • Status changed to Needs review 4 months ago
  • πŸ‡­πŸ‡ΊHungary tikaszvince

    I've created a merge request with the requested changes.

  • πŸ‡¬πŸ‡·Greece kostask

    I could not reproduce the bug you mention. I get Edit Page/ Edit Article correctly.
    Editing the Article bundle name to Article2 keeps the breadcrumb as Edit Article (instead of Edit Article2) so the cache tags of the bundle need to be added.

    I agree string translation should be used instead of concatenation though.

  • Pipeline finished with Failed
    3 months ago
    Total: 208s
    #294701
  • Pipeline finished with Failed
    3 months ago
    Total: 179s
    #299769
  • πŸ‡­πŸ‡ΊHungary tikaszvince

    It looks good.
    Thank you

  • Pipeline finished with Failed
    about 2 months ago
    Total: 211s
    #319122
  • πŸ‡­πŸ‡ΊHungary tikaszvince

    On various cases the original problem still exists.
    I try to add more cache tags to built breadcrumb.

  • Pipeline finished with Failed
    about 2 months ago
    Total: 226s
    #319153
  • πŸ‡¬πŸ‡§United Kingdom joachim

    The problem is not cache tags, it's cache context.

    After one visit to a node edit form, my cache_render table has an entry with this CID:

    > entity_view:block:gin_breadcrumbs:[languages:language_content]=en:[languages:language_interface]=en:[route.book_navigation]=book.none:[theme]=gin:[user.permissions]=is-admin

    So the next page -- whatever it is -- will get that same cache entry.

  • Pipeline finished with Failed
    about 2 months ago
    Total: 261s
    #324780
  • Status changed to RTBC about 1 month ago
  • πŸ‡¬πŸ‡§United Kingdom joachim

    Latest version of the MR fixes the problem I've been seeing.

    The t() issues seem to be fixed too.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 225s
    #332766
  • Pipeline finished with Success
    about 1 month ago
    Total: 256s
    #332772
  • πŸ‡¬πŸ‡·Greece kostask

    Fixed the tests, it is still RTBC.

  • Pipeline finished with Success
    about 1 month ago
    Total: 251s
    #332877
  • πŸ‡¬πŸ‡§United Kingdom joachim
  • πŸ‡¨πŸ‡­Switzerland saschaeggi Zurich

    Hey @tikaszvince πŸ‘‹

    Thanks for working on this πŸ™‡πŸ™Œ

    I've left some code suggestions otherwise this LGTM.
    Moving this back to needs work for now.

    Thank you

  • Pipeline finished with Success
    22 days ago
    Total: 233s
    #351581
  • Pipeline finished with Failed
    22 days ago
    Total: 208s
    #351608
  • πŸ‡­πŸ‡ΊHungary tikaszvince

    Hi @saschaeggi,

    Updated the MR with the new helper method placed in the same file. If that is not the right place for this function please move it.

  • πŸ‡¨πŸ‡­Switzerland saschaeggi Zurich

    Thank you, LGTM, I've fixed one small phpcs issue.

    Let's wait for a community review that everything works as expected and afterwards we can move forward with merging this 🀝

  • Pipeline finished with Success
    21 days ago
    Total: 190s
    #351887
Production build 0.71.5 2024