Give Phame blogs an explicit 404 controller
Summary:
Ref T11076. Ref T9897. Bad links on Phame blogs are currently made worse because we try to prompt you to login on a non-cookie domain.
Instead, just 404 in a vanilla way. Do so cleanly on external domains.
Test Plan: {F1672399}
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T9897, T11076
Differential Revision: https://secure.phabricator.com/D16010
This commit is contained in:
@@ -70,6 +70,8 @@ abstract class PhameLiveController extends PhameController {
|
||||
|
||||
$blog = $blog_query->executeOne();
|
||||
if (!$blog) {
|
||||
$this->isExternal = $is_external;
|
||||
$this->isLive = $is_live;
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
@@ -81,6 +83,9 @@ abstract class PhameLiveController extends PhameController {
|
||||
$blog = null;
|
||||
}
|
||||
|
||||
$this->isExternal = $is_external;
|
||||
$this->isLive = $is_live;
|
||||
|
||||
if ($post_id) {
|
||||
$post_query = id(new PhamePostQuery())
|
||||
->setViewer($viewer)
|
||||
@@ -109,8 +114,6 @@ abstract class PhameLiveController extends PhameController {
|
||||
$post = null;
|
||||
}
|
||||
|
||||
$this->isExternal = $is_external;
|
||||
$this->isLive = $is_live;
|
||||
$this->blog = $blog;
|
||||
$this->post = $post;
|
||||
|
||||
@@ -188,4 +191,30 @@ abstract class PhameLiveController extends PhameController {
|
||||
return $crumbs;
|
||||
}
|
||||
|
||||
public function willSendResponse(AphrontResponse $response) {
|
||||
if ($this->getIsExternal()) {
|
||||
if ($response instanceof Aphront404Response) {
|
||||
$page = $this->newPage()
|
||||
->setCrumbs($this->buildApplicationCrumbs());
|
||||
|
||||
$response = id(new Phame404Response())
|
||||
->setPage($page);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::willSendResponse($response);
|
||||
}
|
||||
|
||||
public function newPage() {
|
||||
$page = parent::newPage();
|
||||
|
||||
if ($this->getIsLive()) {
|
||||
$page
|
||||
->setShowChrome(false)
|
||||
->setShowFooter(false);
|
||||
}
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user