diff --git a/src/aphront/AphrontRequest.php b/src/aphront/AphrontRequest.php index f15b289d38..e88a5a5e36 100644 --- a/src/aphront/AphrontRequest.php +++ b/src/aphront/AphrontRequest.php @@ -123,6 +123,11 @@ final class AphrontRequest extends Phobject { */ public function getInt($name, $default = null) { if (isset($this->requestData[$name])) { + // Converting from array to int is "undefined". Don't rely on whatever + // PHP decides to do. + if (is_array($this->requestData[$name])) { + return $default; + } return (int)$this->requestData[$name]; } else { return $default; diff --git a/src/applications/phame/controller/post/PhamePostEditController.php b/src/applications/phame/controller/post/PhamePostEditController.php index 923af4d967..91df519adb 100644 --- a/src/applications/phame/controller/post/PhamePostEditController.php +++ b/src/applications/phame/controller/post/PhamePostEditController.php @@ -32,18 +32,27 @@ final class PhamePostEditController extends PhamePostController { } $blog_id = $post->getBlog()->getID(); } else { - $blog_id = $request->getInt('blog'); + $blog_id = head($request->getArr('blog')); + if (!$blog_id) { + $blog_id = $request->getStr('blog'); + } } - $blog = id(new PhameBlogQuery()) + $query = id(new PhameBlogQuery()) ->setViewer($viewer) - ->withIDs(array($blog_id)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, - )) - ->executeOne(); + )); + + if (ctype_digit($blog_id)) { + $query->withIDs(array($blog_id)); + } else { + $query->withPHIDs(array($blog_id)); + } + + $blog = $query->executeOne(); if (!$blog) { return new Aphront404Response(); } @@ -60,10 +69,11 @@ final class PhamePostEditController extends PhamePostController { $crumbs = parent::buildApplicationCrumbs(); $blog = $this->getBlog(); - - $crumbs->addTextCrumb( - $blog->getName(), - $blog->getViewURI()); + if ($blog) { + $crumbs->addTextCrumb( + $blog->getName(), + $blog->getViewURI()); + } return $crumbs; }