Make WordPress Core

Opened 6 years ago

Closed 18 months ago

Last modified 18 months ago

#7337 closed defect (bug) (fixed)

Consistently use $wp_rewrite->index instead of hardcoding "index.php"

Reported by: markjaquith Owned by: ryan
Milestone: 3.6 Priority: low
Severity: minor Version: 2.6
Component: Permalinks Keywords: has-patch
Focuses: Cc:


A few place in our URL generation and canonicalization code use hardcoded "index.php" instead of using $wp_rewrite->index

This prevents people from using custom PATHINFO permalinks.

Attachments (2)

wp-rewrite-index.diff (4.9 KB) - added by wonderboymusic 21 months ago.
7337.diff (577 bytes) - added by andrewryno 18 months ago.

Download all attachments as: .zip

Change History (17)

comment:1 matt6 years ago

  • Milestone changed from 2.7 to 2.9

comment:2 Denis-de-Bernardy5 years ago

  • Keywords needs-patch added; permalinks pathinfo removed

comment:3 Denis-de-Bernardy5 years ago

  • Component changed from General to Permalinks
  • Owner changed from anonymous to ryan

comment:4 ryan5 years ago

  • Milestone changed from 2.9 to Future Release

comment:5 follow-up: solarissmoke3 years ago

  • Keywords close added

Is this still an issue?

comment:6 mikeschinkel3 years ago

  • Cc mikeschinkel@… added

comment:7 in reply to: ↑ 5 SergeyBiryukov3 years ago

  • Keywords close removed

Replying to solarissmoke:

Is this still an issue?

Yep, in some files:

  • wp-admin/options-permalink.php
  • wp-includes/canonical.php
  • wp-includes/link-template.php
  • wp-includes/nav-menu-template.php (maybe unrelated though)
  • wp-includes/rewrite.php
Last edited 3 years ago by SergeyBiryukov (previous) (diff)

comment:8 wonderboymusic21 months ago

  • Keywords has-patch added; needs-patch removed


comment:9 wonderboymusic19 months ago

  • Milestone changed from Future Release to 3.6

Moving to 3.6 for review

comment:10 markjaquith18 months ago

  • Resolution set to fixed
  • Status changed from new to closed

In 23305:

Consistently use $wp_rewrite->index instead of hardcoding "index.php".

props wonderboymusic. fixes #7337

comment:11 andrewryno18 months ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

This breaks _wp_menu_item_classes_by_context() in nav-menu-template.php.

Notice: Undefined variable: wp_rewrite in wp-includes/nav-menu-template.php on line 370
Notice: Trying to get property of non-object in wp-includes/nav-menu-template.php on line 370

Need $wp_rewrite to be global for it to work.

Not sure if it breaks other places, but this is the only one I've seen.

andrewryno18 months ago

comment:12 wonderboymusic18 months ago

I wrote the patch a while ago, thanks for catching that :)

comment:13 ryan18 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 23309:

Declare wp_rewrite as global in _wp_menu_item_classes_by_context().

Props andrewryno
fixes #7337

comment:14 Viper007Bond18 months ago

Why not have a helper function that returns this value so that the $wp_rewrite global isn't needed? Much less prone to issues and doesn't require using global.

comment:15 andrewryno18 months ago

That would probably be better. Mine was a rather quick patch and I believe it's a global in other instances (and a global was already being defined for $wp_query) so it just made it seem more consistent.

Note: See TracTickets for help on using tickets.