Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -3613,8 +3613,7 @@ |
3614 | 3614 | $section = $sectionIndex; |
3615 | 3615 | $tooltip = ''; |
3616 | 3616 | } |
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() ) ){ |
3619 | 3618 | $editlink = $sk->doEditSectionLink( $titleObj, $section, $tooltip ); |
3620 | 3619 | } else { |
3621 | 3620 | $editlink = ''; |
Index: trunk/phase3/includes/parser/ParserCache.php |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | function getKey( &$article, &$user ) { |
31 | 31 | global $action; |
32 | 32 | $hash = $user->getPageRenderingHash(); |
33 | | - if( !$article->mTitle->quickUserCan( 'edit' ) ) { |
| 33 | + if( !$article->mTitle->quickUserCan( 'edit', $user ) ) { |
34 | 34 | // section edit links are suppressed even if the user has them on |
35 | 35 | $edit = '!edit=0'; |
36 | 36 | } else { |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -999,11 +999,12 @@ |
1000 | 1000 | * |
1001 | 1001 | * May provide false positives, but should never provide a false negative. |
1002 | 1002 | * |
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 |
1004 | 1005 | * @return boolean |
1005 | 1006 | */ |
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 ); |
1008 | 1009 | } |
1009 | 1010 | |
1010 | 1011 | /** |
— | — | @@ -1025,13 +1026,17 @@ |
1026 | 1027 | |
1027 | 1028 | /** |
1028 | 1029 | * 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 |
1031 | 1033 | * @return boolean |
1032 | 1034 | */ |
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()); |
1036 | 1041 | } |
1037 | 1042 | |
1038 | 1043 | /** |
— | — | @@ -1134,7 +1139,7 @@ |
1135 | 1140 | * @param bool $doExpensiveQueries Set this to false to avoid doing unnecessary queries. |
1136 | 1141 | * @return array Array of arrays of the arguments to wfMsg to explain permissions problems. |
1137 | 1142 | */ |
1138 | | - public function getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries = true ) { |
| 1143 | + private function getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries = true ) { |
1139 | 1144 | wfProfileIn( __METHOD__ ); |
1140 | 1145 | |
1141 | 1146 | $errors = array(); |