Closed (fixed)
Project:
Drupal core
Version:
6.x-dev
Component:
theme system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Oct 2007 at 13:09 UTC
Updated:
12 Nov 2007 at 22:42 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
djnz commentedCoding style corrected
Comment #2
gábor hojtsyWell, you took the existing
substr($template, 0, strpos($template, '.'));and wrapped it inside anif (strpos($template, '.') !== FALSE). How does this solve the problem? Who reviewed this?Comment #3
djnz commentedIt solves the problem perfectly. substr($template, 0, strpos($template, '.')); will return an empty string if there is no '.' in $template, so if (strpos($template, '.') !== FALSE) will prevent that code trying to strip a non-existant '.foo'
Comment #4
Anonymous (not verified) commentedBased on http://www.php.net/manual/en/function.strpos.php this patch is correct.
Comment #5
dvessel commentedNow why would a template not have an extension?
Comment #6
dvessel commentedComment #7
merlinofchaos commenteddjnz's patch appears correct to me. Allow me to 'splain.
PHPTemplate uses a tiered extension of .tpl.php -- however, the method we use to list files chops off the .php extension. This means we're left with a filename of 'foo.tpl' which won't match anything. To match, we have to chop off that .tpl.
djnz's patch is fixing the case where there is no extra extension at all. In his case, it will be 'foo.smarty'.
I believe this is right.
Comment #8
merlinofchaos commentedAddendum: We probably should not run strpos() multiple times, so we should use something like:
Though I guess strpos is probably fast enough, given our filenames won't be more than 32 characters long, likely, so maybe that optimization doesn't matter.
Comment #9
dvessel commentedThanks for the clarification merlinofchaos.
Comment #10
gábor hojtsyThanks for the clarification. Now I understand and see that the documentation definitely needs improvement here. This is how it looks like, and how it confuses me.
It says $template will have one extension chopped off, but it actually means it is already chopped off at this stage. So this is what confused us. What about?
Also included merlinofchaos' suggestion here (not tested). I think this comment covers what we discussed here way better. Opinions?
Comment #11
Anonymous (not verified) commentedIs it important to know that one has been removed already? How about simply
Comment #12
merlinofchaos commentedHmm. Technically the 'will have' is correct English, but 'have' is one of those words with too many meanings. The funny thing is, every time I try to rewrite it in my head I turn back to that phrase. May be a personal overuse.
Earnie: I think it's good to note that the last extension is chopped off already. Gabor's version of the comment is good by me and makes plenty of sense.
Comment #13
gábor hojtsyHonestly my problem with 'will have' is that I don't know whether it 'will have' before the code block is run (ie. it is not yet in that form) is 'will have' before the code block is run (ie. it is already in that format). Technically when one reads the code, the code 'will' run, so this might look like ok, but I think is confusing. At least for a non-native English speaker like me.
Comment #14
djnz commentedIt is through this process that we iterate towards perfection...
Amended patch attached, with Gábor's amended comment and merlin's temporary variable efficiency improvement.
Comment #15
dvessel commentedlooks good. tink this is ready to go.
Comment #16
gábor hojtsyThanks guys, committed.
Comment #17
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.