mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +01:00
When users visit a Phame post URI with an old blog ID, canonicalize the URI instead of 404'ing
Summary: Fixes T13353. If you: - Visit a blog post and save the URI. - Move the blog post to a different blog. - Revisit the old URI. ...we currently 404. We know what you're trying to do and should just redirect you to the new URI instead. We already do this if you visit a URI with a noncanonical slug. Test Plan: - Created post A. - Copied the live URI. - Moved it to a different blog. - Visited the saved URI from the earlier step. - Before: 404. - After: Redirect to the canonical URI. Maniphest Tasks: T13353 Differential Revision: https://secure.phabricator.com/D20688
This commit is contained in:
parent
2ec39afcd1
commit
47d497aa60
1 changed files with 7 additions and 6 deletions
|
@ -93,10 +93,6 @@ abstract class PhameLiveController extends PhameController {
|
|||
->needHeaderImage(true)
|
||||
->withIDs(array($post_id));
|
||||
|
||||
if ($blog) {
|
||||
$post_query->withBlogPHIDs(array($blog->getPHID()));
|
||||
}
|
||||
|
||||
// Only show published posts on external domains.
|
||||
if ($is_external) {
|
||||
$post_query->withVisibility(
|
||||
|
@ -123,10 +119,15 @@ abstract class PhameLiveController extends PhameController {
|
|||
$this->post = $post;
|
||||
|
||||
// If we have a post, canonicalize the URI to the post's current slug and
|
||||
// redirect the user if it isn't correct.
|
||||
// redirect the user if it isn't correct. Likewise, canonicalize the URI
|
||||
// if the blog ID is wrong. See T13353.
|
||||
if ($post) {
|
||||
$slug = $request->getURIData('slug');
|
||||
if ($post->getSlug() != $slug) {
|
||||
|
||||
$wrong_slug = ($post->getSlug() !== $slug);
|
||||
$wrong_blog = ($post->getBlog()->getID() !== $blog->getID());
|
||||
|
||||
if ($wrong_slug || $wrong_blog) {
|
||||
if ($is_live) {
|
||||
if ($is_external) {
|
||||
$uri = $post->getExternalLiveURI();
|
||||
|
|
Loading…
Reference in a new issue