Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -1928,11 +1928,10 @@ |
1929 | 1929 | |
1930 | 1930 | 'TitleReadWhitelist': called at the end of read permissions checks, just before |
1931 | 1931 | adding the default error message if nothing allows the user to read the page. |
1932 | | - Return false will prevent core from adding its error message, but you need |
1933 | | - to removed extensions' error messages from $errors yourself. |
| 1932 | + If a handler wants a title to *not* be whitelisted, it should also return false. |
1934 | 1933 | $title: Title object being checked against |
1935 | 1934 | $user: Current user object |
1936 | | -&$errors: errors |
| 1935 | +&$whitelisted: Boolean value of whether this title is whitelisted |
1937 | 1936 | |
1938 | 1937 | 'UndeleteForm::showHistory': called in UndeleteForm::showHistory, after a |
1939 | 1938 | PageArchive object has been created but before any further processing is done. |
Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -3754,7 +3754,7 @@ |
3755 | 3755 | * |
3756 | 3756 | * @param $event String: event name |
3757 | 3757 | * @param $args Array: parameters passed to hook functions |
3758 | | - * @return Boolean |
| 3758 | + * @return Boolean True if no handler aborted the hook |
3759 | 3759 | */ |
3760 | 3760 | function wfRunHooks( $event, $args = array() ) { |
3761 | 3761 | return Hooks::run( $event, $args ); |
Index: trunk/phase3/includes/Hooks.php |
— | — | @@ -86,7 +86,7 @@ |
87 | 87 | * |
88 | 88 | * @param $event String: event name |
89 | 89 | * @param $args Array: parameters passed to hook functions |
90 | | - * @return Boolean |
| 90 | + * @return Boolean True if no handler aborted the hook |
91 | 91 | */ |
92 | 92 | public static function run( $event, $args = array() ) { |
93 | 93 | global $wgHooks; |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -1965,12 +1965,11 @@ |
1966 | 1966 | * @return Array list of errors |
1967 | 1967 | */ |
1968 | 1968 | private function checkReadPermissions( $action, $user, $errors, $doExpensiveQueries, $short ) { |
1969 | | - global $wgWhitelistRead; |
| 1969 | + global $wgWhitelistRead, $wgGroupPermissions, $wgRevokePermissions;; |
1970 | 1970 | static $useShortcut = null; |
1971 | 1971 | |
1972 | 1972 | # Initialize the $useShortcut boolean, to determine if we can skip quite a bit of code below |
1973 | 1973 | if ( is_null( $useShortcut ) ) { |
1974 | | - global $wgGroupPermissions, $wgRevokePermissions; |
1975 | 1974 | $useShortcut = true; |
1976 | 1975 | if ( empty( $wgGroupPermissions['*']['read'] ) ) { |
1977 | 1976 | # Not a public wiki, so no shortcut |
— | — | @@ -1993,7 +1992,6 @@ |
1994 | 1993 | } |
1995 | 1994 | |
1996 | 1995 | $whitelisted = false; |
1997 | | - |
1998 | 1996 | if ( $useShortcut ) { |
1999 | 1997 | # Shortcut for public wikis, allows skipping quite a bit of code |
2000 | 1998 | $whitelisted = true; |
— | — | @@ -2036,11 +2034,12 @@ |
2037 | 2035 | } |
2038 | 2036 | } |
2039 | 2037 | |
2040 | | - # If the user is allowed to read tge page; don't call the hook |
2041 | | - if ( $whitelisted && !count( $errors ) ) { |
2042 | | - return array(); |
2043 | | - } elseif ( wfRunHooks( 'TitleReadWhitelist', array( $this, $user, &$errors ) ) && !$whitelisted ) { |
2044 | | - $errors[] = $this->missingPermissionError( $action, $short ); |
| 2038 | + if ( !$whitelisted ) { |
| 2039 | + # If the title is not whitelisted, give extensions a chance to do so... |
| 2040 | + wfRunHooks( 'TitleReadWhitelist', array( $this, $user, &$whitelisted ) ); |
| 2041 | + if ( !$whitelisted ) { |
| 2042 | + $errors[] = $this->missingPermissionError( $action, $short ); |
| 2043 | + } |
2045 | 2044 | } |
2046 | 2045 | |
2047 | 2046 | return $errors; |