Opened 5 years ago

Closed 4 months ago

Last modified 4 months ago

#7337 closed defect (bug) (fixed)

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

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

Description

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 7 months ago.
7337.diff (577 bytes) - added by andrewryno 4 months ago.

Download all attachments as: .zip

Change History (17)

comment:1   matt5 years ago

  • Milestone changed from 2.7 to 2.9
  • Keywords needs-patch added; permalinks, pathinfo removed
  • Component changed from General to Permalinks
  • Owner changed from anonymous to ryan

comment:4   ryan4 years ago

  • Milestone changed from 2.9 to Future Release

comment:5 follow-up: ↓ 7   solarissmoke2 years ago

  • Keywords close added

Is this still an issue?

  • Cc mikeschinkel@… added

comment:7 in reply to: ↑ 5   SergeyBiryukov22 months ago

  • Keywords close removed

Replying to solarissmoke:

Is this still an issue?

Yep, in some files:

  • canonical.php
  • link-template.php
  • nav-menu-template.php (maybe unrelated though)
  • rewrite.php
Version 0, edited 22 months ago by SergeyBiryukov (next)
  • Keywords has-patch added; needs-patch removed

Patched.

  • Milestone changed from Future Release to 3.6

Moving to 3.6 for review

  • 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

  • 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.

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

  • 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

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.

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.