Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phame/controller/PhameLiveController.php
Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | protected function setupLiveEnvironment() { | ||||
$this->isLive = $is_live; | $this->isLive = $is_live; | ||||
if (strlen($post_id)) { | if (strlen($post_id)) { | ||||
$post_query = id(new PhamePostQuery()) | $post_query = id(new PhamePostQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->needHeaderImage(true) | ->needHeaderImage(true) | ||||
->withIDs(array($post_id)); | ->withIDs(array($post_id)); | ||||
if ($blog) { | |||||
$post_query->withBlogPHIDs(array($blog->getPHID())); | |||||
} | |||||
// Only show published posts on external domains. | // Only show published posts on external domains. | ||||
if ($is_external) { | if ($is_external) { | ||||
$post_query->withVisibility( | $post_query->withVisibility( | ||||
array(PhameConstants::VISIBILITY_PUBLISHED)); | array(PhameConstants::VISIBILITY_PUBLISHED)); | ||||
} | } | ||||
$post = $post_query->executeOne(); | $post = $post_query->executeOne(); | ||||
if (!$post) { | if (!$post) { | ||||
Show All 10 Lines | protected function setupLiveEnvironment() { | ||||
} else { | } else { | ||||
$post = null; | $post = null; | ||||
} | } | ||||
$this->blog = $blog; | $this->blog = $blog; | ||||
$this->post = $post; | $this->post = $post; | ||||
// If we have a post, canonicalize the URI to the post's current slug and | // 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) { | if ($post) { | ||||
$slug = $request->getURIData('slug'); | $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_live) { | ||||
if ($is_external) { | if ($is_external) { | ||||
$uri = $post->getExternalLiveURI(); | $uri = $post->getExternalLiveURI(); | ||||
} else { | } else { | ||||
$uri = $post->getInternalLiveURI(); | $uri = $post->getInternalLiveURI(); | ||||
} | } | ||||
} else { | } else { | ||||
$uri = $post->getViewURI(); | $uri = $post->getViewURI(); | ||||
▲ Show 20 Lines • Show All 97 Lines • Show Last 20 Lines |