Duplicate templates in same namespace is valid use case

Created on 22 July 2022, over 2 years ago
Updated 14 June 2023, almost 2 years ago

Hello,

I have in my Drupal log warning like below. I don't think it's something wrong. In my scenario it's perfectly valid to have same names in different folders. This message could be useful during development for some, but it's definitely wrong in production environment. It's possible to make it optionable?

Found multiple files for the "@page/styleguide.twig" template; it is recommended to only have one "styleguide.twig" file in the "page" namespace’s "themes/custom/proficio/static/templates/page" directory

Source: https://git.drupalcode.org/project/components/-/blob/3.x/src/Template/Co...

Thank you

✨ Feature request
Status

Needs work

Version

3.0

Component

Code

Created by

πŸ‡¨πŸ‡ΏCzech Republic parisek

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.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update almost 2 years ago
    35 pass, 1 fail
  • πŸ‡¨πŸ‡ΏCzech Republic parisek

    Added MR and disabled logging warning "Found multiple files for the", seems it's not wide issue, patch is enough :)

  • πŸ‡¨πŸ‡ΏCzech Republic parisek
  • First commit to issue fork.
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    35 pass, 1 fail
  • Status changed to Needs review over 1 year ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    CI aborted
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    CI aborted
  • Attached a patch which allows sites to opt out of the warning using their settings.php file:

    // Don't attempt to track duplicate templates.
    $settings['components_ignore_duplicate_templates'] = TRUE;
    

    Or on the theme/module level:

    components:
      # Ignore duplicate templates.
      ignore_duplicate_templates: true
    

    This still requires tests to be implemented, but works for my use case. So feedback is more than welcome on the current implementation.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    61 pass
  • Pipeline finished with Success
    8 months ago
    Total: 234s
    #258223
  • Pipeline finished with Success
    7 months ago
    Total: 157s
    #285598
  • Status changed to RTBC about 1 month ago
  • πŸ‡¬πŸ‡§United Kingdom John Cook

    I had problems applying the diff / patch using cweagans/composer-patches, with a segment being rejected in components.info.yml. This was due to versioning information added by the packaging script on Drupal.org. I manually added the two line change before testing. I don't see this being a problem once the issue has been merged.

    I tested with just the patch to make sure that the duplicates are reported by default. As expected, the errors appeared in the watchdog log.

    Then I tried again after adding $settings['components_ignore_duplicate_templates'] = TRUE; to my settings.php. After I cleared the cache and refreshed the same page, the errors are no longer logged.

    Moving to RTBC.

  • πŸ‡¬πŸ‡§United Kingdom John Cook

    As a side note, I noticed this bug because I have /web as a symlink to /docroot after changing host providers.

Production build 0.71.5 2024