From: Alexandre Emsenhuber Date: Tue, 29 Jul 2008 20:35:11 +0000 (+0000) Subject: Per talk with Simetrical, add a param to Title::quickUserCan and Title::userCan inste... X-Git-Tag: 1.31.0-rc.0~46297 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/pie.php?a=commitdiff_plain;h=b19693ddb4e92923769b1dcd06c662510f305c8a;p=lhc%2Fweb%2Fwiklou.git Per talk with Simetrical, add a param to Title::quickUserCan and Title::userCan instead of making Title::getUserPermissionsErrorsInternal() public, also update ParserCache to use this param --- diff --git a/includes/Title.php b/includes/Title.php index 82d480b6be..825c9ae7b0 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -999,11 +999,12 @@ class Title { * * May provide false positives, but should never provide a false negative. * - * @param string $action action that permission needs to be checked for + * @param $action String: action that permission needs to be checked for + * @param $user User object, optional * @return boolean */ - public function quickUserCan( $action ) { - return $this->userCan( $action, false ); + public function quickUserCan( $action, $user = null ) { + return $this->userCan( $action, false, $user ); } /** @@ -1025,13 +1026,17 @@ class Title { /** * Can $wgUser perform $action on this page? - * @param string $action action that permission needs to be checked for - * @param bool $doExpensiveQueries Set this to false to avoid doing unnecessary queries. + * @param $action String: action that permission needs to be checked for + * @param $doExpensiveQueries Bool: set this to false to avoid doing unnecessary queries. + * @param $user User object, optional * @return boolean */ - public function userCan( $action, $doExpensiveQueries = true ) { - global $wgUser; - return ( $this->getUserPermissionsErrorsInternal( $action, $wgUser, $doExpensiveQueries ) === array()); + public function userCan( $action, $doExpensiveQueries = true, $user = null ) { + if( $user === null ){ + global $wgUser; + $user = $wgUser; + } + return ( $this->getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries ) === array()); } /** @@ -1134,7 +1139,7 @@ class Title { * @param bool $doExpensiveQueries Set this to false to avoid doing unnecessary queries. * @return array Array of arrays of the arguments to wfMsg to explain permissions problems. */ - public function getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries = true ) { + private function getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries = true ) { wfProfileIn( __METHOD__ ); $errors = array(); diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 8d2b690301..52a61e42cd 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -3613,8 +3613,7 @@ class Parser $section = $sectionIndex; $tooltip = ''; } - // Use Title::getUserPermissionsErrorsInternal() so that we can pass our User object - if( $titleObj->getUserPermissionsErrorsInternal( 'edit', $this->mOptions->getUser(), false ) === array() ){ + if( $titleObj->quickUserCan( 'edit', $this->mOptions->getUser() ) ){ $editlink = $sk->doEditSectionLink( $titleObj, $section, $tooltip ); } else { $editlink = ''; diff --git a/includes/parser/ParserCache.php b/includes/parser/ParserCache.php index bf11da2eeb..b2bd2ba8e0 100644 --- a/includes/parser/ParserCache.php +++ b/includes/parser/ParserCache.php @@ -29,7 +29,7 @@ class ParserCache { function getKey( &$article, &$user ) { global $action; $hash = $user->getPageRenderingHash(); - if( !$article->mTitle->quickUserCan( 'edit' ) ) { + if( !$article->mTitle->quickUserCan( 'edit', $user ) ) { // section edit links are suppressed even if the user has them on $edit = '!edit=0'; } else {