Closed (fixed)
Project:
Drupal core
Version:
8.4.x-dev
Component:
theme system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
22 Oct 2016 at 22:52 UTC
Updated:
1 May 2018 at 17:36 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
joelpittetComment #4
joelpittetLow-level and trivial patch. Rerolled.
Comment #5
lauriiiI spent quite a long time figuring this out, testing multiple different stages of Drupal 8. I can confirm that this is not needed anymore. This was added as part of #342350: Override template files based on template filename as well as hook name but I can confirm that that use case doesn't need this bit of code anymore. There's also tests proving that this use case still works.
I also searched for the reason why this became redundant. It was caused by this issue #2226207: Make 'template' the default output option for hook_theme() where we separated paths from the template names.
Should we use === here?
Comment #6
joelpittetI think we should use
===, you're right because of those silly edge cases:php -r "var_dump(0 == 'a'); " => TRUEThank you for the review
Comment #7
lauriiiThanks for the change. This looks good now!
Comment #8
alexpottCommitted 7294785 and pushed to 8.4.x. Thanks!
Nice - this looks way more robust.
Comment #11
markhalliwellWell, this change certainly snuck its way in...
Here's a change record (which this should have had):
https://www.drupal.org/node/2952033
Comment #12
joelpittet@markcarver, I think you may have misinterpreted the patch.
Before:
[$info['template'], str_replace($info['theme path'] . '/templates/', '', $info['template'])];in_array()checks both templates: one as a whole and one without thetheme path + templatesAfter:
Only
$info['template'] === $templateThe rub is that
$info['template']never has the path in it. So the second check is the same as the first always.Here's a sample of the output of both variables separated by a colon:
I'm going to unpublish your CR for now so people don't get confused. Hope you don't mind, please correct me if I made a mistake though.
Comment #13
markhalliwellIntentional or not, this suddenly "opened up" template discovery to anywhere in the theme when it was previously limited to just the
/templatesdirectory.I had to adjust the Drupal Bootstrap base theme accordingly.
Comment #14
joelpittetI don't think it did though... how? did you read the explanation on what it does and how this changed nothing from what I can see, maybe I'm not seeing what you are seeing, please explain.
Comment #15
markhalliwellAfter re-evaluating this and what @joelpittet mentioned, I'm not convinced this does what I originally said it did.
The registry still defaults to the
/templatesdirectory of a theme:http://cgit.drupalcode.org/drupal/tree/core/lib/Drupal/Core/Theme/Regist...
I think I got confused between
$info['path'](which is for the template) and$info['theme path']which is the root directory of the theme (and what drupal_find_theme_templates() was using).I've deleted the change record.