r38204 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38203‎ | r38204 | r38205 >
Date:20:35, 29 July 2008
Author:ialex
Status:old
Tags:
Comment:
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
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/includes/parser/ParserCache.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -3613,8 +3613,7 @@
36143614 $section = $sectionIndex;
36153615 $tooltip = '';
36163616 }
3617 - // Use Title::getUserPermissionsErrorsInternal() so that we can pass our User object
3618 - if( $titleObj->getUserPermissionsErrorsInternal( 'edit', $this->mOptions->getUser(), false ) === array() ){
 3617+ if( $titleObj->quickUserCan( 'edit', $this->mOptions->getUser() ) ){
36193618 $editlink = $sk->doEditSectionLink( $titleObj, $section, $tooltip );
36203619 } else {
36213620 $editlink = '';
Index: trunk/phase3/includes/parser/ParserCache.php
@@ -29,7 +29,7 @@
3030 function getKey( &$article, &$user ) {
3131 global $action;
3232 $hash = $user->getPageRenderingHash();
33 - if( !$article->mTitle->quickUserCan( 'edit' ) ) {
 33+ if( !$article->mTitle->quickUserCan( 'edit', $user ) ) {
3434 // section edit links are suppressed even if the user has them on
3535 $edit = '!edit=0';
3636 } else {
Index: trunk/phase3/includes/Title.php
@@ -999,11 +999,12 @@
10001000 *
10011001 * May provide false positives, but should never provide a false negative.
10021002 *
1003 - * @param string $action action that permission needs to be checked for
 1003+ * @param $action String: action that permission needs to be checked for
 1004+ * @param $user User object, optional
10041005 * @return boolean
10051006 */
1006 - public function quickUserCan( $action ) {
1007 - return $this->userCan( $action, false );
 1007+ public function quickUserCan( $action, $user = null ) {
 1008+ return $this->userCan( $action, false, $user );
10081009 }
10091010
10101011 /**
@@ -1025,13 +1026,17 @@
10261027
10271028 /**
10281029 * Can $wgUser perform $action on this page?
1029 - * @param string $action action that permission needs to be checked for
1030 - * @param bool $doExpensiveQueries Set this to false to avoid doing unnecessary queries.
 1030+ * @param $action String: action that permission needs to be checked for
 1031+ * @param $doExpensiveQueries Bool: set this to false to avoid doing unnecessary queries.
 1032+ * @param $user User object, optional
10311033 * @return boolean
10321034 */
1033 - public function userCan( $action, $doExpensiveQueries = true ) {
1034 - global $wgUser;
1035 - return ( $this->getUserPermissionsErrorsInternal( $action, $wgUser, $doExpensiveQueries ) === array());
 1035+ public function userCan( $action, $doExpensiveQueries = true, $user = null ) {
 1036+ if( $user === null ){
 1037+ global $wgUser;
 1038+ $user = $wgUser;
 1039+ }
 1040+ return ( $this->getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries ) === array());
10361041 }
10371042
10381043 /**
@@ -1134,7 +1139,7 @@
11351140 * @param bool $doExpensiveQueries Set this to false to avoid doing unnecessary queries.
11361141 * @return array Array of arrays of the arguments to wfMsg to explain permissions problems.
11371142 */
1138 - public function getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries = true ) {
 1143+ private function getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries = true ) {
11391144 wfProfileIn( __METHOD__ );
11401145
11411146 $errors = array();

Follow-up revisions

RevisionCommit summaryAuthorDate
r38208Revert r38196, r38204 -- "(bugs 6089, 13079) Show edit section links for tran...brion23:56, 29 July 2008

Status & tagging log