@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+7 -6
+7 -6
src/applications/phame/controller/PhameLiveController.php
··· 93 93 ->needHeaderImage(true) 94 94 ->withIDs(array($post_id)); 95 95 96 - if ($blog) { 97 - $post_query->withBlogPHIDs(array($blog->getPHID())); 98 - } 99 - 100 96 // Only show published posts on external domains. 101 97 if ($is_external) { 102 98 $post_query->withVisibility( ··· 123 119 $this->post = $post; 124 120 125 121 // If we have a post, canonicalize the URI to the post's current slug and 126 - // redirect the user if it isn't correct. 122 + // redirect the user if it isn't correct. Likewise, canonicalize the URI 123 + // if the blog ID is wrong. See T13353. 127 124 if ($post) { 128 125 $slug = $request->getURIData('slug'); 129 - if ($post->getSlug() != $slug) { 126 + 127 + $wrong_slug = ($post->getSlug() !== $slug); 128 + $wrong_blog = ($post->getBlog()->getID() !== $blog->getID()); 129 + 130 + if ($wrong_slug || $wrong_blog) { 130 131 if ($is_live) { 131 132 if ($is_external) { 132 133 $uri = $post->getExternalLiveURI();