Opened 11 months ago
Last modified 13 days ago
#21213 new defect (bug)
Underscores get stripped out in $type ( get_query_template() )
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.6 |
| Component: | Template | Version: | 2.5 |
| Severity: | normal | Keywords: | needs-testing has-patch |
| Cc: | scribu |
Description
What happens is:
$type = preg_replace( '|[^a-z0-9-]+|', '', $type );
strips underscore. Effectively, incoming "front_page" becomes frontpage, which leads to not working (but documented) hook front_page_template.
I tested this on: nginx 1.2.1/php-fpm 5.4.3 (homebrew macos) and nginx 1.0/php-fpm 5.3.3 with the latest revision ATM
The fix is as simple as
$type = preg_replace( '|[^a-z0-9-_]+|', '', $type );
Patch is attached.
Attachments (2)
Change History (9)
rinatkhaziev — 11 months ago
comment:2
follow-up:
↓ 3
SergeyBiryukov — 11 months ago
Also mentioned in ticket:15337:9.
comment:3
in reply to:
↑ 2
rinatkhaziev — 11 months ago
Replying to SergeyBiryukov:
Also mentioned in ticket:15337:9.
This is related to your link for sure, the only thing is that front page would be left as "front-page" instead of "front_page". front_page_template is the hook for modifying template hierarchy.
SergeyBiryukov — 4 months ago
comment:4
SergeyBiryukov — 4 months ago
- Milestone changed from Awaiting Review to 3.6
- Version changed from 3.4.1 to 2.5
Related: [7223], [7224]. template_php.patch seems sane.
An alternative would be to rename the filter to front-page_template: 21213.patch.
$type[0]_$type[1]_template filter would need the same change for consistency, see #15337.
comment:5
retire2maui — 2 weeks ago
- Version changed from 2.5 to trunk
I was getting ready to report this same bug for the attachment page template file $mimetype_$subtype.php. For example, template files text_plain.php and image_jpeg.php will not work but textplain.php and imagejpeg.php do work. The template_php.patch fix will resolve this issue also, but 21213.patch obviously won't.
comment:6
SergeyBiryukov — 2 weeks ago
- Version changed from trunk to 2.5
Version number indicates when the bug was initially introduced/reported.
Note that both patches change the name of the filter fired for the front page template. I did a quick check on the plugins directory, this can break at least one plugin which filters frontpage_template: http://plugins.trac.wordpress.org/browser/page-transitions/trunk/main.php#L33
Haven't found any others, but I did find three plugins that filter on front_page_template:
- app-your-wordpress-uppsite/themes/webapp/functions.php
- commentpress-core/themes/commentpress-theme/functions.php
- wparty/wparty-theme.php

proposed patch for the bug