Opened 5 years ago

Closed 8 months ago

Last modified 8 months ago

#6110 closed defect (bug) (wontfix)

Custom permalinks created from plugin hooking in to WP redirects don't work.

Reported by: nerrad Owned by:
Priority: high Milestone:
Component: Permalinks Version: 2.5
Severity: major Keywords:
Cc: docwhat

Description

This might be related to ticket #5995:

I've been testing the new version of my Organize Series Plugin which works fine in WP 2.3.x with the redirect hooks. However in 2.5 none of the plugin specific redirects work.

To be clearer:
In 2.3.x http://localhost/series/series-name would redirect properly to the "series" archive page.
After upgrading to 2.5 http://localhost/series/series-name returns 404 error.

I've tried regenning permalinks, but that doesn't fix the problem. Is there something that's changed with how plugins should be hooking into the permalink system in 2.5?

Attachments (2)

series-taxonomy.php.txt (32.3 KB) - added by nerrad 5 years ago.
Plugin file that contains the rewrite code.
6110.rewrite.diff (1.3 KB) - added by DD32 5 years ago.

Download all attachments as: .zip

Change History (26)

  • Priority changed from normal to high

comment:2   DD325 years ago

Can you link to the plugin, Or provide some code of whats not working?

This code is still working for me: http://dd32.id.au/files/wordpress/test-rewrite.php But i admit some things in there dont use the WP API.

nerrad5 years ago

Plugin file that contains the rewrite code.

See attached file DD32 that contains the code. Again, I have no problems with WP2.3.3 but for some reason I get problems with 2.5

I should also say that without permalinks (i.e. the default http://path/index.php?param=) everything works as expected. But as soon as I flip to permalinks my series archive pages return 404 BUT all other pages and posts work as expected.

comment:5   DD325 years ago

Hm......... I cant reproduce the problem your having:

http://dd32.no-ip.com:8080/wordpress/series/test-series/

using the plugin from here: http://www.unfoldingneurons.com/2008/organize-series-20-beta-1-release

I'm using the Permalink structure: /%year%/%monthnum%/%day%/%postname%/ I can see if using something like /%category%/%postname%/ could cause a 404 maybe..

Feel free to contact me off list @ wordpress@… if you want me to try more things, or to know more about my environment.. BTW, I had to make a change to part of the code to suppress some errors:

series-taxonomy.php
Line 36:
From: if (array_key_exists('object_id', $spost)) {
To: if ( is_array($spost) && array_key_exists('object_id', $spost)) {

$spost was an Integer, which was throwing a Warning(If errors are turned on) Change it to:

if ( (is_array($spost) || is_object($spost) ) && array_key_exists('object_id', $spost)) {

if you accept an object there too..

Thanks for the bugcatch - I just caught that myself this morning and used a different fix :)

Thanks for your offer to help to - I've sent off an email.

A thought - maybe this could point in the right direction. Are there any changes to the core rewrite rule-sets (from 2.3.3 - 2.5) that "might" make one more greedy and thus snag my plugin redirect before it get's processed (my plugin redirect just appends to the redirect array)?

comment:8   DD325 years ago

It'd be due to the verbose page rules which were introduced.
Silly me didnt realise that i had a patch applied still which added the verbose page rules AFTER the hook that plugins add pages on.

I'll attach a patch of the change i had made, Its probably hanging around in a previous trac ticket somewhere too.

DD325 years ago

comment:9   DD325 years ago

A Work around is to add the plugins rules at the start of the array:

$rules = current rules
$rewrite = plugin generated rules
	return ( $rewrite + $rules );
rather than:
	return ( $rules + $rewrite );

But that requires WordPress to check those rules first, While not a problem specifically, a lot of plugins are setup to add rules to the end of the list, rather than the start

DD32;
I tried the workaround - it doesn't work. Stumped again. It's as if the 'rewrite_rules_array' filter isn't doing anything.

it doesn't work. Stumped again

So am i then.. Hopefully someone else can help more, 'cos i'm stumpted.

(You did try re-generating the rules didnt you?)

Yes I regenerated the rules and tried different tokens as well.

Okay something strange just happened - it started working. So...it looks like the workaround DOES work. I've confirmed it. (might have been a cacheing thing with my browser or something).

I still think this warrants attention for 2.5 however. Your patch would do the trick and prevent potential headaches for plugins that do redirects...

Here is another plugin that was affected: YADIS
http://svn.wp-plugins.org/yadis/tags/1.2.1/yadis.php

This is with Wordpress 2.5 released.

Ciao!

  • Cc docwhat added
  • Component changed from General to Permalinks
  • Owner changed from anonymous to ryan

Pretty sure this is.. well.. a wontfix ticket now.. However the patch does look useful (Add the greedy rules definately at the end of the rule list)

Could come undone by any plugins which add extra-hungry rules at the end of the list.. But they've been broken since the greedy rules were introduced.

  • Milestone changed from 2.9 to 3.0
  • Milestone changed from 3.0 to Future Release
  • Owner changed from ryan to dd32
  • Status changed from new to reviewing

Moving to future release due to no traction.

Will review this after release.

  • Owner dd32 deleted
  • Resolution set to wontfix
  • Status changed from reviewing to closed

"Moving to future release due to no traction." is 2 years old. Attached patch is 5 years old. Most of the commentary here is about plugins which may not even be active anymore. dd32 declared "wontfix" 3 years ago.

  • Milestone Future Release deleted

agree with the ticket status change. Just piping in though that Organize Series is still very active ;)

Note: See TracTickets for help on using tickets.