Ticket #6110 (new defect)

Opened 6 months ago

Last modified 5 months ago

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

Reported by: nerrad Assigned to: anonymous
Priority: high Milestone: 2.9
Component: General 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

series-taxonomy.php.txt (32.3 kB) - added by nerrad on 03/07/08 05:36:34.
Plugin file that contains the rewrite code.
6110.rewrite.diff (1.3 kB) - added by DD32 on 03/07/08 23:03:44.

Change History

03/07/08 04:05:22 changed by nerrad

  • priority changed from normal to high.

03/07/08 04:15:42 changed by DD32

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.

03/07/08 05:36:34 changed by nerrad

  • attachment series-taxonomy.php.txt added.

Plugin file that contains the rewrite code.

03/07/08 05:37:50 changed by nerrad

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

03/07/08 05:51:11 changed by nerrad

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.

03/07/08 06:10:09 changed by DD32

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@dd32.id.au 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..

03/07/08 15:18:40 changed by nerrad

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.

03/07/08 15:41:05 changed by nerrad

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)?

03/07/08 23:03:03 changed by DD32

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.

03/07/08 23:03:44 changed by DD32

  • attachment 6110.rewrite.diff added.

03/07/08 23:06:25 changed by DD32

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

03/08/08 02:03:18 changed by nerrad

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

03/08/08 02:12:38 changed by DD32

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?)

03/08/08 02:13:16 changed by nerrad

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

03/08/08 02:43:07 changed by nerrad

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

03/08/08 02:47:45 changed by nerrad

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

04/01/08 14:36:00 changed by docwhat

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!

04/01/08 14:36:08 changed by docwhat

  • cc set to docwhat.