Comment 4 for bug 343821

Revision history for this message
Paul Nus (paul-thenusfamily) wrote : Re: [Bug 343821] Re: Comments Error

Worked like a charm.

I found the function in plugin/rewrite.php ...I assumed you meant there. Ill
let you know if I find anything else. This one appears to be fixed.

On Tue, Mar 17, 2009 at 12:16 AM, Alex Stansfield <email address hidden>wrote:

> Hi Paul,
>
> I've replicated and, hopefully, fixed this bug. I'm a little worried
> about knock on problems as it required a change to the rewrite rules
> which are basically a kind of voodoo magic.
>
> If you wish to test it out then edit the plugin/filters.php file. Find
> the function "wps_post_rewrite_rules" and replace it with the one below.
>
> function wps_post_rewrite_rules( $rules ) {
> global $wps_this_subdomain, $wp_rewrite;
>
> // If we have %category% in the permalink we also need to create
> rules without it.
> // This is because the category might be the subdomain and so
> wouldn't be in the url
> if ( strstr( $wp_rewrite->permalink_structure, '%category%' ) &&
> $wps_this_subdomain && ($wps_this_subdomain->type == WPS_TYPE_CAT) ) {
> // Grab the permalink structure
> $perma_tmp = $wp_rewrite->permalink_structure;
>
> // Remove the /%category section
> $perma_tmp = str_replace('/%category%','',$perma_tmp);
>
> // Create the extra rules using this new structure
> $extra_rules =
> $wp_rewrite->generate_rewrite_rules($perma_tmp, EP_PERMALINK);
>
> // Now we have to remove the rule that matches a category on
> it's own
> // this is reinstated later but just can't come before the
> extra rules
> $unset_key =
> array_search('index.php?category_name=$matches[1]', $extra_rules);
>
> if ($unset_key) {
> unset($extra_rules[$unset_key]);
> }
>
> // Check for the problem attachment rules and remove them.
> // Pray this doesn't break anything ;)
> foreach ($extra_rules as $regexp => $url) {
> if (strpos($url, 'attachment=$matches') &&
> (strpos($regexp, 'attachment') === false)) {
> unset($extra_rules[$regexp]);
> }
> }
>
> // merge to two rule sets into one
> $rules = array_merge($extra_rules, $rules);
> }
>
> // Check if the permalink structure has any date parts
> $has_date = false;
> foreach ( array( '%year%', '%monthnum%', '%day%' ) as $datepart ) {
> if ( strstr( $wp_rewrite->permalink_structure, $datepart ) )
> {
> $has_date = true;
> }
> }
>
> // If there is a date part in the permalink structure filter by the
> subdomain we're on
> // This is incase we're actually looking at an date archive rather
> than a post
> if ( $has_date && $wps_this_subdomain) {
> $rules = $wps_this_subdomain->addRewriteFilter($rules);
> }
>
> //print('<pre>'.print_r($rules,true).'</pre>');
>
> return $rules;
> }
>
>
> Let me know how you get on and if you notice anything else go wrong. If
> it's ok for you I will release an 0.6.1-rc2 with the fix and see if anyone
> else find issues with it.
>
> Cheers,
>
> Alex
>
> ** Changed in: wordpress-csd
> Importance: Undecided => High
> Status: Confirmed => In Progress
>
> --
> Comments Error
> https://bugs.launchpad.net/bugs/343821
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in Wordpress Subdomains Plugin: In Progress
>
> Bug description:
> Getting an error when trying to add a comment to a subdomain'd category
> article.
>
> Actually, the error is when it tries to display the comments after it has
> been submitted because the appending of the comment is successful. I have
> tried this with and without all my other plugins installed and get the same
> results. Basically, the error is a result of trying to view comments and not
> the task of adding them.
>
>
> Example:
>
> The following URL using the plugin is invalid (IE: Error 404 - Not Found)
>
> http://sports.paulnus.com/iowa-football-signatures/comment-page-1#comment-174
>
> The actual URL being transformed is valid (IE: this works fine)
>
> http://www.paulnus.com/sports/iowa-football-signatures/comment-page-1#comment-174
>
>