From: Ori Livneh Date: Thu, 8 Oct 2015 06:04:59 +0000 (-0700) Subject: Small clean-ups for OutputPage::userCanPreview X-Git-Tag: 1.31.0-rc.0~9488 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=a69eac16aa3b780c129a2be90b8e31924d47cb12;p=lhc%2Fweb%2Fwiklou.git Small clean-ups for OutputPage::userCanPreview Change-Id: Ibd973750b60cbcc8d1289686de6cabcfdca5c5d9 --- diff --git a/includes/OutputPage.php b/includes/OutputPage.php index f48497fd8b..d85c60c3f6 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -3312,22 +3312,31 @@ class OutputPage extends ContextSource { * @return bool */ public function userCanPreview() { - if ( $this->getRequest()->getVal( 'action' ) != 'submit' - || !$this->getRequest()->wasPosted() - || !$this->getUser()->matchEditToken( - $this->getRequest()->getVal( 'wpEditToken' ) ) - ) { + $request = $this->getRequest(); + if ( $request->getVal( 'action' ) !== 'submit' || !$request->wasPosted() ) { + return false; + } + + $user = $this->getUser(); + if ( !$user->matchEditToken( $request->getVal( 'wpEditToken' ) ) ) { return false; } - if ( !$this->getTitle()->isJsSubpage() && !$this->getTitle()->isCssSubpage() ) { + + $title = $this->getTitle(); + if ( !$title->isJsSubpage() && !$title->isCssSubpage() ) { return false; } - if ( !$this->getTitle()->isSubpageOf( $this->getUser()->getUserPage() ) ) { + if ( !$title->isSubpageOf( $user->getUserPage() ) ) { // Don't execute another user's CSS or JS on preview (T85855) return false; } - return !count( $this->getTitle()->getUserPermissionsErrors( 'edit', $this->getUser() ) ); + $errors = $title->getUserPermissionsErrors( 'edit', $user ); + if ( count( $errors ) !== 0 ) { + return false; + } + + return true; } /**