Opened 4 years ago
Last modified 19 months ago
#9824 reopened task (blessed)
make better use of stubs when verbose rules should apply
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Future Release |
| Component: | Rewrite Rules | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | scribu, Ryan_B, wp@…, blt4, dromsey@… |
Description
Related to:
http://core.trac.wordpress.org/ticket/6603#comment:27
Problem fixed is:
posts show up as www.apexprd.org/page/2 and not /news-and-events/page/2 as it should.
with permalinks set to /something/$postname%/
we arguably don't necessarily need verbose rules here, since there is a stub.
Attachments (6)
Change History (40)
- Keywords needs-patch added
- Milestone changed from Future Release to 2.9
- Type changed from defect (bug) to enhancement
- Owner Denis-de-Bernardy deleted
- Status changed from new to assigned
comment:10
Ryan_B — 3 years ago
In wp-includes/rewrite.php on line 1984.
change code to if ( preg_match("#\A/%(?:postname|category|tag|author)%#", $this->permalink_structure) )
Works on my test. It appears the current regular expression returns looks at the first wildcard and if it is postname, category, tag, or author returns true, forcing verbose page rules. However per discussion on wp-hackers mailing list verbose page rules need not apply in all cases where one of those items is the first wildcard, if preceeded by a static string, such as /blog/%pagename%. My new regular expression specifically looks at the first element in the path and if it is one of those 4 wildcards returns true, otherwise if its some other wildcard or a string like /blog/... returns false ensuring verbose page rules are set only when absolutley necessary.
Sorry I was unable to provide a .diff for this, I could not get the current code to checkout from subversion, some error I have been unable to resolve, so since its a minor fix figured i'd just include it as a comment here to be included in next release hopefully.
comment:11
blt4 — 3 years ago
Attached is a patch that should fix this.
Current code makes the verbose rules judgement based on the first structure tag. This post suggests you should be able to use a static string in front of a string structure tag to prevent verbose rules.
For example, the following permalink custom structure should not trigger verbose rules, but does in WP 3.0.1:
/view/%pagenum%
comment:12
blt4 — 3 years ago
- Cc blt4 added
comment:13
scribu — 3 years ago
- Keywords has-patch added; needs-patch removed
- Milestone changed from Future Release to 3.1
comment:14
scribu — 3 years ago
- Resolution set to fixed
- Status changed from assigned to closed
comment:15
nacin — 3 years ago
comment:16
nacin — 3 years ago
comment:17
nacin — 2 years ago
This resulted in #16041. Suggest revert and punt.
comment:18
nacin — 2 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
SergeyBiryukov — 2 years ago
comment:19
SergeyBiryukov — 2 years ago
I guess we need to exclude the standard prefixes, e.g. /index.php without mod_rewrite and /blog on Multisite. This also fixes the issue in #16041. Uploaded the patch.
comment:20
ryan — 2 years ago
comment:21
nacin — 2 years ago
- Milestone changed from 3.1 to Future Release
comment:22
nacin — 2 years ago
Additional issues: #16136.
comment:23
scribu — 2 years ago
- Component changed from Optimization to Rewrite Rules
comment:24
scribu — 2 years ago
- Component changed from Rewrite Rules to Performance
- Milestone changed from Future Release to 3.2
I think we should take another swing at this.
comment:25
goto10 — 2 years ago
- Cc dromsey@… added
comment:26
nacin — 2 years ago
- Keywords needs-patch added; has-patch removed
- Milestone changed from 3.2 to Future Release
comment:27
nacin — 23 months ago
- Component changed from Performance to Rewrite Rules
- Milestone changed from Future Release to 3.3
comment:28
nacin — 22 months ago
- Type changed from enhancement to task (blessed)
Is there something not covered by 9824.3.patch?
SergeyBiryukov — 22 months ago
Refreshed for 3.3.
comment:31
follow-up:
↓ 32
nacin — 22 months ago
Looks like it. It doesn't cause any issue in either #16136 or #16041?
The thing I see is that /blog can be changed via a manual edit to the permalink_structure. If we're on the main site of a subdirectory multisite, perhaps we should pop off the first segment? Might need wpmuguru to explain what people may change that to.
comment:32
in reply to:
↑ 31
SergeyBiryukov — 22 months ago
- Keywords has-patch added; needs-patch removed
Replying to nacin:
Nope.
The thing I see is that /blog can be changed via a manual edit to the permalink_structure. сIf we're on the main site of a subdirectory multisite, perhaps we should pop off the first segment?
Done in 9824.5.patch. Perhaps instead of a hardcoded value, it should be a variable in WP_Rewrite, like $wp_rewrite->index?
comment:33
nacin — 21 months ago
This ticket is mitigated by the fix in #16687, but it'd still be nice to get this in.
comment:34
ryan — 19 months ago
- Milestone changed from 3.3 to Future Release

see also #9825