[wp-trac] [WordPress Trac] #43539: Custom feed types breaks redirect_canonical behavior
WordPress Trac
noreply at wordpress.org
Sat Mar 17 19:05:54 UTC 2018
#43539: Custom feed types breaks redirect_canonical behavior
--------------------------+------------------------------
Reporter: satantime | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Canonical | Version: 4.9.4
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by satantime):
No problem, try to do next steps:
1 fresh wp installation.
2 add to functions.php of current theme next code:
{{{#!php
add_action('init', 'test_feed');
function test_feed()
{
add_feed('test', 'void');
}
add_filter('request', 'test_request');
function test_request($value)
{
$value = array(
'feed' => 'test',
);
return $value;
}
}}}
3. in file /wp-includes/canonical.php after line 531 and before 532 add
{{{#!php
header('Content-Type: text/plain');
var_dump($redirect_url);
exit;
}}}
4. execute `curl -v curl -v http://stream.localhost/feed/test/`
and you'll see status 200 but output will be
http://stream.localhost/feed/test/feed/test/ - this url is potential url
to trigger redirect.
But there's no redirect because check on original line 532 `if (
!redirect_canonical($redirect_url, false) ) {` returns
`http://stream.localhost/feed/test/feed/test/feed/test/` instead of empty
string and that's caused because core WP doesn't handle properly custom
feed types in redirect_canonical function and always adds /feed/test/ on
top of current url. More info you can find on screenshots from the
description of this ticket.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43539#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list