Index: trunk/phase3/includes/api/ApiQueryRecentChanges.php |
— | — | @@ -129,7 +129,7 @@ |
130 | 130 | * @param $resultPageSet ApiPageSet |
131 | 131 | */ |
132 | 132 | public function run( $resultPageSet = null ) { |
133 | | - global $wgUser; |
| 133 | + $user = $this->getUser(); |
134 | 134 | /* Get the parameters of the request. */ |
135 | 135 | $params = $this->extractRequestParams(); |
136 | 136 | |
— | — | @@ -163,7 +163,7 @@ |
164 | 164 | |
165 | 165 | // Check permissions |
166 | 166 | if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ) { |
167 | | - if ( !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol() ) { |
| 167 | + if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) { |
168 | 168 | $this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' ); |
169 | 169 | } |
170 | 170 | } |
— | — | @@ -219,7 +219,7 @@ |
220 | 220 | /* Set up internal members based upon params. */ |
221 | 221 | $this->initProperties( $prop ); |
222 | 222 | |
223 | | - if ( $this->fld_patrolled && !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol() ) { |
| 223 | + if ( $this->fld_patrolled && !$user->useRCPatrol() && !$user->useNPPatrol() ) { |
224 | 224 | $this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' ); |
225 | 225 | } |
226 | 226 | |
Index: trunk/phase3/includes/api/ApiWatch.php |
— | — | @@ -41,8 +41,8 @@ |
42 | 42 | } |
43 | 43 | |
44 | 44 | public function execute() { |
45 | | - global $wgUser; |
46 | | - if ( !$wgUser->isLoggedIn() ) { |
| 45 | + $user = $this->getUser(); |
| 46 | + if ( !$user->isLoggedIn() ) { |
47 | 47 | $this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' ); |
48 | 48 | } |
49 | 49 | |
— | — | @@ -59,11 +59,11 @@ |
60 | 60 | if ( $params['unwatch'] ) { |
61 | 61 | $res['unwatched'] = ''; |
62 | 62 | $res['message'] = wfMsgExt( 'removedwatchtext', array( 'parse' ), $title->getPrefixedText() ); |
63 | | - $success = UnwatchAction::doUnwatch( $title, $wgUser ); |
| 63 | + $success = UnwatchAction::doUnwatch( $title, $user ); |
64 | 64 | } else { |
65 | 65 | $res['watched'] = ''; |
66 | 66 | $res['message'] = wfMsgExt( 'addedwatchtext', array( 'parse' ), $title->getPrefixedText() ); |
67 | | - $success = WatchAction::doWatch( $title, $wgUser ); |
| 67 | + $success = WatchAction::doWatch( $title, $user ); |
68 | 68 | } |
69 | 69 | if ( !$success ) { |
70 | 70 | $this->dieUsageMsg( 'hookaborted' ); |
Index: trunk/phase3/includes/api/ApiMove.php |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | } |
42 | 42 | |
43 | 43 | public function execute() { |
44 | | - global $wgUser; |
| 44 | + $user = $this->getUser(); |
45 | 45 | $params = $this->extractRequestParams(); |
46 | 46 | if ( is_null( $params['reason'] ) ) { |
47 | 47 | $params['reason'] = ''; |
— | — | @@ -75,9 +75,9 @@ |
76 | 76 | && !RepoGroup::singleton()->getLocalRepo()->findFile( $toTitle ) |
77 | 77 | && wfFindFile( $toTitle ) ) |
78 | 78 | { |
79 | | - if ( !$params['ignorewarnings'] && $wgUser->isAllowed( 'reupload-shared' ) ) { |
| 79 | + if ( !$params['ignorewarnings'] && $user->isAllowed( 'reupload-shared' ) ) { |
80 | 80 | $this->dieUsageMsg( 'sharedfile-exists' ); |
81 | | - } elseif ( !$wgUser->isAllowed( 'reupload-shared' ) ) { |
| 81 | + } elseif ( !$user->isAllowed( 'reupload-shared' ) ) { |
82 | 82 | $this->dieUsageMsg( 'cantoverwrite-sharedfile' ); |
83 | 83 | } |
84 | 84 | } |
— | — | @@ -89,7 +89,7 @@ |
90 | 90 | } |
91 | 91 | |
92 | 92 | $r = array( 'from' => $fromTitle->getPrefixedText(), 'to' => $toTitle->getPrefixedText(), 'reason' => $params['reason'] ); |
93 | | - if ( !$params['noredirect'] || !$wgUser->isAllowed( 'suppressredirect' ) ) { |
| 93 | + if ( !$params['noredirect'] || !$user->isAllowed( 'suppressredirect' ) ) { |
94 | 94 | $r['redirectcreated'] = ''; |
95 | 95 | } |
96 | 96 | |
Index: trunk/phase3/includes/api/ApiFileRevert.php |
— | — | @@ -47,14 +47,12 @@ |
48 | 48 | } |
49 | 49 | |
50 | 50 | public function execute() { |
51 | | - global $wgUser; |
52 | | - |
53 | 51 | $this->params = $this->extractRequestParams(); |
54 | 52 | // Extract the file and archiveName from the request parameters |
55 | 53 | $this->validateParameters(); |
56 | 54 | |
57 | 55 | // Check whether we're allowed to revert this file |
58 | | - $this->checkPermissions( $wgUser ); |
| 56 | + $this->checkPermissions( $this->getUser() ); |
59 | 57 | |
60 | 58 | $sourceUrl = $this->file->getArchiveVirtualUrl( $this->archiveName ); |
61 | 59 | $status = $this->file->upload( $sourceUrl, $this->params['comment'], $this->params['comment'] ); |
Index: trunk/phase3/includes/api/ApiLogout.php |
— | — | @@ -42,13 +42,13 @@ |
43 | 43 | } |
44 | 44 | |
45 | 45 | public function execute() { |
46 | | - global $wgUser; |
47 | | - $oldName = $wgUser->getName(); |
48 | | - $wgUser->logout(); |
| 46 | + $user = $this->getUser(); |
| 47 | + $oldName = $user->getName(); |
| 48 | + $user->logout(); |
49 | 49 | |
50 | 50 | // Give extensions to do something after user logout |
51 | 51 | $injected_html = ''; |
52 | | - wfRunHooks( 'UserLogoutComplete', array( &$wgUser, &$injected_html, $oldName ) ); |
| 52 | + wfRunHooks( 'UserLogoutComplete', array( &$user, &$injected_html, $oldName ) ); |
53 | 53 | } |
54 | 54 | |
55 | 55 | public function isReadMode() { |
Index: trunk/phase3/includes/api/ApiParse.php |
— | — | @@ -62,7 +62,8 @@ |
63 | 63 | |
64 | 64 | // The parser needs $wgTitle to be set, apparently the |
65 | 65 | // $title parameter in Parser::parse isn't enough *sigh* |
66 | | - global $wgParser, $wgUser, $wgTitle, $wgLang; |
| 66 | + // TODO: Does this still need $wgTitle? |
| 67 | + global $wgParser, $wgTitle, $wgLang; |
67 | 68 | |
68 | 69 | // Currently unnecessary, code to act as a safeguard against any change in current behaviour of uselang breaks |
69 | 70 | $oldLang = null; |
— | — | @@ -179,7 +180,7 @@ |
180 | 181 | } |
181 | 182 | |
182 | 183 | if ( $params['pst'] || $params['onlypst'] ) { |
183 | | - $this->pstText = $wgParser->preSaveTransform( $this->text, $titleObj, $wgUser, $popts ); |
| 184 | + $this->pstText = $wgParser->preSaveTransform( $this->text, $titleObj, $this->getUser(), $popts ); |
184 | 185 | } |
185 | 186 | if ( $params['onlypst'] ) { |
186 | 187 | // Build a result and bail out |
Index: trunk/phase3/includes/api/ApiProtect.php |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | } |
41 | 41 | |
42 | 42 | public function execute() { |
43 | | - global $wgUser, $wgRestrictionLevels; |
| 43 | + global $wgRestrictionLevels; |
44 | 44 | $params = $this->extractRequestParams(); |
45 | 45 | |
46 | 46 | $titleObj = Title::newFromText( $params['title'] ); |
— | — | @@ -47,7 +47,7 @@ |
48 | 48 | $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); |
49 | 49 | } |
50 | 50 | |
51 | | - $errors = $titleObj->getUserPermissionsErrors( 'protect', $wgUser ); |
| 51 | + $errors = $titleObj->getUserPermissionsErrors( 'protect', $this->getUser() ); |
52 | 52 | if ( $errors ) { |
53 | 53 | // We don't care about multiple errors, just report one of them |
54 | 54 | $this->dieUsageMsg( reset( $errors ) ); |
Index: trunk/phase3/includes/api/ApiPurge.php |
— | — | @@ -43,10 +43,10 @@ |
44 | 44 | * Purges the cache of a page |
45 | 45 | */ |
46 | 46 | public function execute() { |
47 | | - global $wgUser; |
| 47 | + $user = $this->getUser(); |
48 | 48 | $params = $this->extractRequestParams(); |
49 | | - if ( !$wgUser->isAllowed( 'purge' ) && !$this->getMain()->isInternalMode() && |
50 | | - !$this->getMain()->getRequest()->wasPosted() ) { |
| 49 | + if ( !$user->isAllowed( 'purge' ) && !$this->getMain()->isInternalMode() && |
| 50 | + !$this->getRequest()->wasPosted() ) { |
51 | 51 | $this->dieUsageMsg( array( 'mustbeposted', $this->getModuleName() ) ); |
52 | 52 | } |
53 | 53 | |
— | — | @@ -75,7 +75,7 @@ |
76 | 76 | $r['purged'] = ''; |
77 | 77 | |
78 | 78 | if( $forceLinkUpdate ) { |
79 | | - if ( !$wgUser->pingLimiter() ) { |
| 79 | + if ( !$user->pingLimiter() ) { |
80 | 80 | global $wgParser, $wgEnableParserCache; |
81 | 81 | $popts = new ParserOptions(); |
82 | 82 | $p_result = $wgParser->parse( $article->getContent(), $title, $popts ); |
Index: trunk/phase3/includes/api/ApiRollback.php |
— | — | @@ -52,11 +52,11 @@ |
53 | 53 | $params = $this->extractRequestParams(); |
54 | 54 | |
55 | 55 | // User and title already validated in call to getTokenSalt from Main |
56 | | - $titleObj = $this->getTitle(); |
| 56 | + $titleObj = $this->getRbTitle(); |
57 | 57 | $articleObj = new Article( $titleObj ); |
58 | 58 | $summary = ( isset( $params['summary'] ) ? $params['summary'] : '' ); |
59 | 59 | $details = array(); |
60 | | - $retval = $articleObj->doRollback( $this->getUser(), $summary, $params['token'], $params['markbot'], $details ); |
| 60 | + $retval = $articleObj->doRollback( $this->getRbUser(), $summary, $params['token'], $params['markbot'], $details ); |
61 | 61 | |
62 | 62 | if ( $retval ) { |
63 | 63 | // We don't care about multiple errors, just report one of them |
— | — | @@ -141,10 +141,10 @@ |
142 | 142 | } |
143 | 143 | |
144 | 144 | public function getTokenSalt() { |
145 | | - return array( $this->getTitle()->getPrefixedText(), $this->getUser() ); |
| 145 | + return array( $this->getRbTitle()->getPrefixedText(), $this->getRbUser() ); |
146 | 146 | } |
147 | 147 | |
148 | | - private function getUser() { |
| 148 | + private function getRbUser() { |
149 | 149 | if ( $this->mUser !== null ) { |
150 | 150 | return $this->mUser; |
151 | 151 | } |
— | — | @@ -165,7 +165,7 @@ |
166 | 166 | /** |
167 | 167 | * @return Title |
168 | 168 | */ |
169 | | - private function getTitle() { |
| 169 | + private function getRbTitle() { |
170 | 170 | if ( $this->mTitleObj !== null ) { |
171 | 171 | return $this->mTitleObj; |
172 | 172 | } |
Index: trunk/phase3/includes/api/ApiQueryDeletedrevs.php |
— | — | @@ -41,9 +41,9 @@ |
42 | 42 | } |
43 | 43 | |
44 | 44 | public function execute() { |
45 | | - global $wgUser; |
| 45 | + $user = $this->getUser(); |
46 | 46 | // Before doing anything at all, let's check permissions |
47 | | - if ( !$wgUser->isAllowed( 'deletedhistory' ) ) { |
| 47 | + if ( !$user->isAllowed( 'deletedhistory' ) ) { |
48 | 48 | $this->dieUsage( 'You don\'t have permission to view deleted revision information', 'permissiondenied' ); |
49 | 49 | } |
50 | 50 | |
— | — | @@ -113,7 +113,7 @@ |
114 | 114 | $this->addWhere( 'ar_text_id = old_id' ); |
115 | 115 | |
116 | 116 | // This also means stricter restrictions |
117 | | - if ( !$wgUser->isAllowed( 'undelete' ) ) { |
| 117 | + if ( !$user->isAllowed( 'undelete' ) ) { |
118 | 118 | $this->dieUsage( 'You don\'t have permission to view deleted revision content', 'permissiondenied' ); |
119 | 119 | } |
120 | 120 | } |
— | — | @@ -132,7 +132,7 @@ |
133 | 133 | |
134 | 134 | if ( $fld_token ) { |
135 | 135 | // Undelete tokens are identical for all pages, so we cache one here |
136 | | - $token = $wgUser->editToken( '', $this->getMain()->getRequest() ); |
| 136 | + $token = $user->editToken( '', $this->getMain()->getRequest() ); |
137 | 137 | } |
138 | 138 | |
139 | 139 | $dir = $params['dir']; |
Index: trunk/phase3/includes/api/ApiUserrights.php |
— | — | @@ -44,7 +44,7 @@ |
45 | 45 | public function execute() { |
46 | 46 | $params = $this->extractRequestParams(); |
47 | 47 | |
48 | | - $user = $this->getUser(); |
| 48 | + $user = $this->getUrUser(); |
49 | 49 | |
50 | 50 | $form = new UserrightsPage; |
51 | 51 | $r['user'] = $user->getName(); |
— | — | @@ -62,7 +62,7 @@ |
63 | 63 | /** |
64 | 64 | * @return User |
65 | 65 | */ |
66 | | - private function getUser() { |
| 66 | + private function getUrUser() { |
67 | 67 | if ( $this->mUser !== null ) { |
68 | 68 | return $this->mUser; |
69 | 69 | } |
— | — | @@ -130,7 +130,7 @@ |
131 | 131 | } |
132 | 132 | |
133 | 133 | public function getTokenSalt() { |
134 | | - return $this->getUser()->getName(); |
| 134 | + return $this->getUrUser()->getName(); |
135 | 135 | } |
136 | 136 | |
137 | 137 | public function getExamples() { |
Index: trunk/phase3/includes/api/ApiQueryBase.php |
— | — | @@ -502,8 +502,7 @@ |
503 | 503 | * @return void |
504 | 504 | */ |
505 | 505 | public function showHiddenUsersAddBlockInfo( $showBlockInfo ) { |
506 | | - global $wgUser; |
507 | | - $userCanViewHiddenUsers = $wgUser->isAllowed( 'hideuser' ); |
| 506 | + $userCanViewHiddenUsers = $this->getUser()->isAllowed( 'hideuser' ); |
508 | 507 | |
509 | 508 | if ( $showBlockInfo || !$userCanViewHiddenUsers ) { |
510 | 509 | $this->addTables( 'ipblocks' ); |
Index: trunk/phase3/includes/api/ApiQueryBlocks.php |
— | — | @@ -46,7 +46,7 @@ |
47 | 47 | } |
48 | 48 | |
49 | 49 | public function execute() { |
50 | | - global $wgUser, $wgContLang; |
| 50 | + global $wgContLang; |
51 | 51 | |
52 | 52 | $params = $this->extractRequestParams(); |
53 | 53 | $this->requireMaxOneParameter( $params, 'users', 'ip' ); |
— | — | @@ -136,7 +136,7 @@ |
137 | 137 | $this->addWhereIf( "ipb_range_end > ipb_range_start", isset( $show['range'] ) ); |
138 | 138 | } |
139 | 139 | |
140 | | - if ( !$wgUser->isAllowed( 'hideuser' ) ) { |
| 140 | + if ( !$this->getUser()->isAllowed( 'hideuser' ) ) { |
141 | 141 | $this->addWhereFld( 'ipb_deleted', 0 ); |
142 | 142 | } |
143 | 143 | |
Index: trunk/phase3/includes/api/ApiQueryFilearchive.php |
— | — | @@ -43,9 +43,9 @@ |
44 | 44 | } |
45 | 45 | |
46 | 46 | public function execute() { |
47 | | - global $wgUser; |
| 47 | + $user = $this->getUser(); |
48 | 48 | // Before doing anything at all, let's check permissions |
49 | | - if ( !$wgUser->isAllowed( 'deletedhistory' ) ) { |
| 49 | + if ( !$user->isAllowed( 'deletedhistory' ) ) { |
50 | 50 | $this->dieUsage( 'You don\'t have permission to view deleted file information', 'permissiondenied' ); |
51 | 51 | } |
52 | 52 | |
— | — | @@ -110,7 +110,7 @@ |
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
114 | | - if ( !$wgUser->isAllowed( 'suppressrevision' ) ) { |
| 114 | + if ( !$user->isAllowed( 'suppressrevision' ) ) { |
115 | 115 | // Filter out revisions that the user is not allowed to see. There |
116 | 116 | // is no way to indicate that we have skipped stuff because the |
117 | 117 | // continuation parameter is fa_name |
Index: trunk/phase3/includes/api/ApiImport.php |
— | — | @@ -41,13 +41,12 @@ |
42 | 42 | } |
43 | 43 | |
44 | 44 | public function execute() { |
45 | | - global $wgUser; |
46 | | - |
| 45 | + $user = $this->getUser(); |
47 | 46 | $params = $this->extractRequestParams(); |
48 | 47 | |
49 | 48 | $isUpload = false; |
50 | 49 | if ( isset( $params['interwikisource'] ) ) { |
51 | | - if ( !$wgUser->isAllowed( 'import' ) ) { |
| 50 | + if ( !$user->isAllowed( 'import' ) ) { |
52 | 51 | $this->dieUsageMsg( 'cantimport' ); |
53 | 52 | } |
54 | 53 | if ( !isset( $params['interwikipage'] ) ) { |
— | — | @@ -61,7 +60,7 @@ |
62 | 61 | ); |
63 | 62 | } else { |
64 | 63 | $isUpload = true; |
65 | | - if ( !$wgUser->isAllowed( 'importupload' ) ) { |
| 64 | + if ( !$user->isAllowed( 'importupload' ) ) { |
66 | 65 | $this->dieUsageMsg( 'cantimport-upload' ); |
67 | 66 | } |
68 | 67 | $source = ImportStreamSource::newFromUpload( 'xml' ); |
Index: trunk/phase3/includes/api/ApiEditPage.php |
— | — | @@ -43,7 +43,7 @@ |
44 | 44 | } |
45 | 45 | |
46 | 46 | public function execute() { |
47 | | - global $wgUser; |
| 47 | + $user = $this->getUser(); |
48 | 48 | $params = $this->extractRequestParams(); |
49 | 49 | |
50 | 50 | if ( is_null( $params['text'] ) && is_null( $params['appendtext'] ) && |
— | — | @@ -88,6 +88,7 @@ |
89 | 89 | } |
90 | 90 | |
91 | 91 | // Some functions depend on $wgTitle == $ep->mTitle |
| 92 | + // TODO: Make them not or check if they still do |
92 | 93 | global $wgTitle; |
93 | 94 | $wgTitle = $titleObj; |
94 | 95 | |
— | — | @@ -99,9 +100,9 @@ |
100 | 101 | } |
101 | 102 | |
102 | 103 | // Now let's check whether we're even allowed to do this |
103 | | - $errors = $titleObj->getUserPermissionsErrors( 'edit', $wgUser ); |
| 104 | + $errors = $titleObj->getUserPermissionsErrors( 'edit', $user ); |
104 | 105 | if ( !$titleObj->exists() ) { |
105 | | - $errors = array_merge( $errors, $titleObj->getUserPermissionsErrors( 'create', $wgUser ) ); |
| 106 | + $errors = array_merge( $errors, $titleObj->getUserPermissionsErrors( 'create', $user ) ); |
106 | 107 | } |
107 | 108 | if ( count( $errors ) ) { |
108 | 109 | $this->dieUsageMsg( $errors[0] ); |
— | — | @@ -207,7 +208,7 @@ |
208 | 209 | $reqArr['wpStarttime'] = wfTimestampNow(); // Fake wpStartime |
209 | 210 | } |
210 | 211 | |
211 | | - if ( $params['minor'] || ( !$params['notminor'] && $wgUser->getOption( 'minordefault' ) ) ) { |
| 212 | + if ( $params['minor'] || ( !$params['notminor'] && $user->getOption( 'minordefault' ) ) ) { |
212 | 213 | $reqArr['wpMinoredit'] = ''; |
213 | 214 | } |
214 | 215 | |
— | — | @@ -270,7 +271,7 @@ |
271 | 272 | $oldRequest = $wgRequest; |
272 | 273 | $wgRequest = $req; |
273 | 274 | |
274 | | - $status = $ep->internalAttemptSave( $result, $wgUser->isAllowed( 'bot' ) && $params['bot'] ); |
| 275 | + $status = $ep->internalAttemptSave( $result, $user->isAllowed( 'bot' ) && $params['bot'] ); |
275 | 276 | $wgRequest = $oldRequest; |
276 | 277 | global $wgMaxArticleSize; |
277 | 278 | |
Index: trunk/phase3/includes/api/ApiUnblock.php |
— | — | @@ -45,11 +45,11 @@ |
46 | 46 | * Unblocks the specified user or provides the reason the unblock failed. |
47 | 47 | */ |
48 | 48 | public function execute() { |
49 | | - global $wgUser; |
| 49 | + $user = $this->getUser(); |
50 | 50 | $params = $this->extractRequestParams(); |
51 | 51 | |
52 | 52 | if ( $params['gettoken'] ) { |
53 | | - $res['unblocktoken'] = $wgUser->editToken( '', $this->getMain()->getRequest() ); |
| 53 | + $res['unblocktoken'] = $user->editToken( '', $this->getMain()->getRequest() ); |
54 | 54 | $this->getResult()->addValue( null, $this->getModuleName(), $res ); |
55 | 55 | return; |
56 | 56 | } |
— | — | @@ -61,11 +61,11 @@ |
62 | 62 | $this->dieUsageMsg( 'unblock-idanduser' ); |
63 | 63 | } |
64 | 64 | |
65 | | - if ( !$wgUser->isAllowed( 'block' ) ) { |
| 65 | + if ( !$user->isAllowed( 'block' ) ) { |
66 | 66 | $this->dieUsageMsg( 'cantunblock' ); |
67 | 67 | } |
68 | 68 | # bug 15810: blocked admins should have limited access here |
69 | | - if ( $wgUser->isBlocked() ) { |
| 69 | + if ( $user->isBlocked() ) { |
70 | 70 | $status = SpecialBlock::checkUnblockSelf( $params['user'] ); |
71 | 71 | if ( $status !== true ) { |
72 | 72 | $this->dieUsageMsg( $status ); |
Index: trunk/phase3/includes/api/ApiLogin.php |
— | — | @@ -68,29 +68,32 @@ |
69 | 69 | wfSetupSession(); |
70 | 70 | } |
71 | 71 | |
72 | | - $context = $this->createContext(); |
| 72 | + $context = new DerivativeContext( $this->getContext() ); |
73 | 73 | $context->setRequest( $req ); |
| 74 | + /*$context = $this->createContext(); |
| 75 | + $context->setRequest( $req );*/ |
74 | 76 | $loginForm = new LoginForm(); |
75 | 77 | $loginForm->setContext( $context ); |
| 78 | + $user = $this->getUser(); |
76 | 79 | |
77 | | - global $wgCookiePrefix, $wgUser, $wgPasswordAttemptThrottle; |
| 80 | + global $wgCookiePrefix, $wgPasswordAttemptThrottle; |
78 | 81 | |
79 | 82 | $authRes = $loginForm->authenticateUserData(); |
80 | 83 | switch ( $authRes ) { |
81 | 84 | case LoginForm::SUCCESS: |
82 | | - $wgUser->setOption( 'rememberpassword', 1 ); |
83 | | - $wgUser->setCookies( $this->getMain()->getRequest() ); |
| 85 | + $user->setOption( 'rememberpassword', 1 ); |
| 86 | + $user->setCookies( $this->getMain()->getRequest() ); |
84 | 87 | |
85 | 88 | // Run hooks. |
86 | 89 | // @todo FIXME: Split back and frontend from this hook. |
87 | 90 | // @todo FIXME: This hook should be placed in the backend |
88 | 91 | $injected_html = ''; |
89 | | - wfRunHooks( 'UserLoginComplete', array( &$wgUser, &$injected_html ) ); |
| 92 | + wfRunHooks( 'UserLoginComplete', array( &$user, &$injected_html ) ); |
90 | 93 | |
91 | 94 | $result['result'] = 'Success'; |
92 | | - $result['lguserid'] = intval( $wgUser->getId() ); |
93 | | - $result['lgusername'] = $wgUser->getName(); |
94 | | - $result['lgtoken'] = $wgUser->getToken(); |
| 95 | + $result['lguserid'] = intval( $user->getId() ); |
| 96 | + $result['lgusername'] = $user->getName(); |
| 97 | + $result['lgtoken'] = $user->getToken(); |
95 | 98 | $result['cookieprefix'] = $wgCookiePrefix; |
96 | 99 | $result['sessionid'] = session_id(); |
97 | 100 | break; |
Index: trunk/phase3/includes/api/ApiQueryUserInfo.php |
— | — | @@ -55,47 +55,48 @@ |
56 | 56 | } |
57 | 57 | |
58 | 58 | protected function getCurrentUserInfo() { |
59 | | - global $wgUser, $wgRequest, $wgHiddenPrefs; |
| 59 | + global $wgRequest, $wgHiddenPrefs; |
| 60 | + $user = $this->getUser(); |
60 | 61 | $result = $this->getResult(); |
61 | 62 | $vals = array(); |
62 | | - $vals['id'] = intval( $wgUser->getId() ); |
63 | | - $vals['name'] = $wgUser->getName(); |
| 63 | + $vals['id'] = intval( $user->getId() ); |
| 64 | + $vals['name'] = $user->getName(); |
64 | 65 | |
65 | | - if ( $wgUser->isAnon() ) { |
| 66 | + if ( $user->isAnon() ) { |
66 | 67 | $vals['anon'] = ''; |
67 | 68 | } |
68 | 69 | |
69 | 70 | if ( isset( $this->prop['blockinfo'] ) ) { |
70 | | - if ( $wgUser->isBlocked() ) { |
71 | | - $vals['blockedby'] = User::whoIs( $wgUser->blockedBy() ); |
72 | | - $vals['blockreason'] = $wgUser->blockedFor(); |
| 71 | + if ( $user->isBlocked() ) { |
| 72 | + $vals['blockedby'] = User::whoIs( $user->blockedBy() ); |
| 73 | + $vals['blockreason'] = $user->blockedFor(); |
73 | 74 | } |
74 | 75 | } |
75 | 76 | |
76 | | - if ( isset( $this->prop['hasmsg'] ) && $wgUser->getNewtalk() ) { |
| 77 | + if ( isset( $this->prop['hasmsg'] ) && $user->getNewtalk() ) { |
77 | 78 | $vals['messages'] = ''; |
78 | 79 | } |
79 | 80 | |
80 | 81 | if ( isset( $this->prop['groups'] ) ) { |
81 | | - $autolist = ApiQueryUsers::getAutoGroups( $wgUser ); |
| 82 | + $autolist = ApiQueryUsers::getAutoGroups( $user ); |
82 | 83 | |
83 | | - $vals['groups'] = array_merge( $autolist, $wgUser->getGroups() ); |
| 84 | + $vals['groups'] = array_merge( $autolist, $user->getGroups() ); |
84 | 85 | $result->setIndexedTagName( $vals['groups'], 'g' ); // even if empty |
85 | 86 | } |
86 | 87 | |
87 | 88 | if ( isset( $this->prop['implicitgroups'] ) ) { |
88 | | - $vals['implicitgroups'] = ApiQueryUsers::getAutoGroups( $wgUser ); |
| 89 | + $vals['implicitgroups'] = ApiQueryUsers::getAutoGroups( $user ); |
89 | 90 | $result->setIndexedTagName( $vals['implicitgroups'], 'g' ); // even if empty |
90 | 91 | } |
91 | 92 | |
92 | 93 | if ( isset( $this->prop['rights'] ) ) { |
93 | 94 | // User::getRights() may return duplicate values, strip them |
94 | | - $vals['rights'] = array_values( array_unique( $wgUser->getRights() ) ); |
| 95 | + $vals['rights'] = array_values( array_unique( $user->getRights() ) ); |
95 | 96 | $result->setIndexedTagName( $vals['rights'], 'r' ); // even if empty |
96 | 97 | } |
97 | 98 | |
98 | 99 | if ( isset( $this->prop['changeablegroups'] ) ) { |
99 | | - $vals['changeablegroups'] = $wgUser->changeableGroups(); |
| 100 | + $vals['changeablegroups'] = $user->changeableGroups(); |
100 | 101 | $result->setIndexedTagName( $vals['changeablegroups']['add'], 'g' ); |
101 | 102 | $result->setIndexedTagName( $vals['changeablegroups']['remove'], 'g' ); |
102 | 103 | $result->setIndexedTagName( $vals['changeablegroups']['add-self'], 'g' ); |
— | — | @@ -103,17 +104,17 @@ |
104 | 105 | } |
105 | 106 | |
106 | 107 | if ( isset( $this->prop['options'] ) ) { |
107 | | - $vals['options'] = $wgUser->getOptions(); |
| 108 | + $vals['options'] = $user->getOptions(); |
108 | 109 | } |
109 | 110 | |
110 | 111 | if ( isset( $this->prop['preferencestoken'] ) && |
111 | 112 | is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) |
112 | 113 | ) { |
113 | | - $vals['preferencestoken'] = $wgUser->editToken( '', $this->getMain()->getRequest() ); |
| 114 | + $vals['preferencestoken'] = $user->editToken( '', $this->getMain()->getRequest() ); |
114 | 115 | } |
115 | 116 | |
116 | 117 | if ( isset( $this->prop['editcount'] ) ) { |
117 | | - $vals['editcount'] = intval( $wgUser->getEditCount() ); |
| 118 | + $vals['editcount'] = intval( $user->getEditCount() ); |
118 | 119 | } |
119 | 120 | |
120 | 121 | if ( isset( $this->prop['ratelimits'] ) ) { |
— | — | @@ -121,19 +122,19 @@ |
122 | 123 | } |
123 | 124 | |
124 | 125 | if ( isset( $this->prop['realname'] ) && !in_array( 'realname', $wgHiddenPrefs ) ) { |
125 | | - $vals['realname'] = $wgUser->getRealName(); |
| 126 | + $vals['realname'] = $user->getRealName(); |
126 | 127 | } |
127 | 128 | |
128 | 129 | if ( isset( $this->prop['email'] ) ) { |
129 | | - $vals['email'] = $wgUser->getEmail(); |
130 | | - $auth = $wgUser->getEmailAuthenticationTimestamp(); |
| 130 | + $vals['email'] = $user->getEmail(); |
| 131 | + $auth = $user->getEmailAuthenticationTimestamp(); |
131 | 132 | if ( !is_null( $auth ) ) { |
132 | 133 | $vals['emailauthenticated'] = wfTimestamp( TS_ISO_8601, $auth ); |
133 | 134 | } |
134 | 135 | } |
135 | 136 | |
136 | 137 | if ( isset( $this->prop['registrationdate'] ) ) { |
137 | | - $regDate = $wgUser->getRegistration(); |
| 138 | + $regDate = $user->getRegistration(); |
138 | 139 | if ( $regDate !== false ) { |
139 | 140 | $vals['registrationdate'] = wfTimestamp( TS_ISO_8601, $regDate ); |
140 | 141 | } |
— | — | @@ -154,25 +155,26 @@ |
155 | 156 | } |
156 | 157 | |
157 | 158 | protected function getRateLimits() { |
158 | | - global $wgUser, $wgRateLimits; |
159 | | - if ( !$wgUser->isPingLimitable() ) { |
| 159 | + global $wgRateLimits; |
| 160 | + $user = $this->getUser(); |
| 161 | + if ( !$user->isPingLimitable() ) { |
160 | 162 | return array(); // No limits |
161 | 163 | } |
162 | 164 | |
163 | 165 | // Find out which categories we belong to |
164 | 166 | $categories = array(); |
165 | | - if ( $wgUser->isAnon() ) { |
| 167 | + if ( $user->isAnon() ) { |
166 | 168 | $categories[] = 'anon'; |
167 | 169 | } else { |
168 | 170 | $categories[] = 'user'; |
169 | 171 | } |
170 | | - if ( $wgUser->isNewbie() ) { |
| 172 | + if ( $user->isNewbie() ) { |
171 | 173 | $categories[] = 'ip'; |
172 | 174 | $categories[] = 'subnet'; |
173 | | - if ( !$wgUser->isAnon() ) |
| 175 | + if ( !$user->isAnon() ) |
174 | 176 | $categories[] = 'newbie'; |
175 | 177 | } |
176 | | - $categories = array_merge( $categories, $wgUser->getGroups() ); |
| 178 | + $categories = array_merge( $categories, $user->getGroups() ); |
177 | 179 | |
178 | 180 | // Now get the actual limits |
179 | 181 | $retval = array(); |
Index: trunk/phase3/includes/api/ApiMain.php |
— | — | @@ -132,7 +132,7 @@ |
133 | 133 | private $mPrinter; |
134 | 134 | |
135 | 135 | private $mModules, $mModuleNames, $mFormats, $mFormatNames; |
136 | | - private $mResult, $mAction, $mShowVersions, $mEnableWrite, $mRequest; |
| 136 | + private $mResult, $mAction, $mShowVersions, $mEnableWrite/*, $mRequest*/; |
137 | 137 | private $mInternalMode, $mSquidMaxage, $mModule; |
138 | 138 | |
139 | 139 | private $mCacheMode = 'private'; |
— | — | @@ -141,12 +141,23 @@ |
142 | 142 | /** |
143 | 143 | * Constructs an instance of ApiMain that utilizes the module and format specified by $request. |
144 | 144 | * |
145 | | - * @param $request WebRequest - if this is an instance of FauxRequest, errors are thrown and no printing occurs |
| 145 | + * @param $context IContextSource|WebRequest - if this is an instance of FauxRequest, errors are thrown and no printing occurs |
146 | 146 | * @param $enableWrite bool should be set to true if the api may modify data |
147 | 147 | */ |
148 | | - public function __construct( $request, $enableWrite = false ) { |
149 | | - $this->mInternalMode = ( $request instanceof FauxRequest ); |
| 148 | + public function __construct( $context = null, $enableWrite = false ) { |
| 149 | + if ( $context === null ) { |
| 150 | + $context = RequestContext::getMain(); |
| 151 | + } elseif ( $context instanceof WebRequest ) { |
| 152 | + // BC for pre-1.19 |
| 153 | + $request = $context; |
| 154 | + $context = RequestContext::getMain(); |
| 155 | + $context->setRequest( $request ); |
| 156 | + } |
| 157 | + // We set a derivative context so we can change stuff later |
| 158 | + $this->setContext( new DerivativeContext( $context ) ); |
150 | 159 | |
| 160 | + $this->mInternalMode = ( $this->getRequest() instanceof FauxRequest ); |
| 161 | + |
151 | 162 | // Special handling for the main module: $parent === $this |
152 | 163 | parent::__construct( $this, $this->mInternalMode ? 'main_int' : 'main' ); |
153 | 164 | |
— | — | @@ -156,11 +167,12 @@ |
157 | 168 | // Remove all modules other than login |
158 | 169 | global $wgUser; |
159 | 170 | |
160 | | - if ( $request->getVal( 'callback' ) !== null ) { |
| 171 | + if ( $this->getRequest()->getVal( 'callback' ) !== null ) { |
161 | 172 | // JSON callback allows cross-site reads. |
162 | 173 | // For safety, strip user credentials. |
163 | 174 | wfDebug( "API: stripping user credentials for JSON callback\n" ); |
164 | 175 | $wgUser = new User(); |
| 176 | + $this->getContext()->setUser( $wgUser ); |
165 | 177 | } |
166 | 178 | } |
167 | 179 | |
— | — | @@ -175,7 +187,7 @@ |
176 | 188 | $this->mShowVersions = false; |
177 | 189 | $this->mEnableWrite = $enableWrite; |
178 | 190 | |
179 | | - $this->mRequest = &$request; |
| 191 | + //$this->mRequest = &$request; |
180 | 192 | |
181 | 193 | $this->mSquidMaxage = - 1; // flag for executeActionWithErrorHandling() |
182 | 194 | $this->mCommit = false; |
— | — | @@ -193,9 +205,9 @@ |
194 | 206 | * Return the request object that contains client's request |
195 | 207 | * @return WebRequest |
196 | 208 | */ |
197 | | - public function getRequest() { |
| 209 | + /*public function getRequest() { |
198 | 210 | return $this->mRequest; |
199 | | - } |
| 211 | + }*/ |
200 | 212 | |
201 | 213 | /** |
202 | 214 | * Get the ApiResult object associated with current request |
— | — | @@ -596,8 +608,7 @@ |
597 | 609 | if ( !isset( $moduleParams['token'] ) ) { |
598 | 610 | $this->dieUsageMsg( array( 'missingparam', 'token' ) ); |
599 | 611 | } else { |
600 | | - global $wgUser; |
601 | | - if ( !$wgUser->matchEditToken( $moduleParams['token'], $salt, $this->getRequest() ) ) { |
| 612 | + if ( !$this->getUser()->matchEditToken( $moduleParams['token'], $salt, $this->getRequest() ) ) { |
602 | 613 | $this->dieUsageMsg( 'sessionfailure' ); |
603 | 614 | } |
604 | 615 | } |
— | — | @@ -639,9 +650,9 @@ |
640 | 651 | * @param $module ApiBase An Api module |
641 | 652 | */ |
642 | 653 | protected function checkExecutePermissions( $module ) { |
643 | | - global $wgUser; |
| 654 | + $user = $this->getUser(); |
644 | 655 | if ( $module->isReadMode() && !in_array( 'read', User::getGroupPermissions( array( '*' ) ), true ) && |
645 | | - !$wgUser->isAllowed( 'read' ) ) |
| 656 | + !$user->isAllowed( 'read' ) ) |
646 | 657 | { |
647 | 658 | $this->dieUsageMsg( 'readrequired' ); |
648 | 659 | } |
— | — | @@ -649,7 +660,7 @@ |
650 | 661 | if ( !$this->mEnableWrite ) { |
651 | 662 | $this->dieUsageMsg( 'writedisabled' ); |
652 | 663 | } |
653 | | - if ( !$wgUser->isAllowed( 'writeapi' ) ) { |
| 664 | + if ( !$user->isAllowed( 'writeapi' ) ) { |
654 | 665 | $this->dieUsageMsg( 'writerequired' ); |
655 | 666 | } |
656 | 667 | if ( wfReadOnly() ) { |
— | — | @@ -665,7 +676,7 @@ |
666 | 677 | */ |
667 | 678 | protected function setupExternalResponse( $module, $params ) { |
668 | 679 | // Ignore mustBePosted() for internal calls |
669 | | - if ( $module->mustBePosted() && !$this->mRequest->wasPosted() ) { |
| 680 | + if ( $module->mustBePosted() && !$this->getRequest()->wasPosted() ) { |
670 | 681 | $this->dieUsageMsg( array( 'mustbeposted', $this->mAction ) ); |
671 | 682 | } |
672 | 683 | |
— | — | @@ -975,8 +986,7 @@ |
976 | 987 | */ |
977 | 988 | public function canApiHighLimits() { |
978 | 989 | if ( !isset( $this->mCanApiHighLimits ) ) { |
979 | | - global $wgUser; |
980 | | - $this->mCanApiHighLimits = $wgUser->isAllowed( 'apihighlimits' ); |
| 990 | + $this->mCanApiHighLimits = $this->getUser()->isAllowed( 'apihighlimits' ); |
981 | 991 | } |
982 | 992 | |
983 | 993 | return $this->mCanApiHighLimits; |
Index: trunk/phase3/includes/api/ApiEmailUser.php |
— | — | @@ -40,8 +40,6 @@ |
41 | 41 | } |
42 | 42 | |
43 | 43 | public function execute() { |
44 | | - global $wgUser; |
45 | | - |
46 | 44 | $params = $this->extractRequestParams(); |
47 | 45 | |
48 | 46 | // Validate target |
— | — | @@ -51,7 +49,7 @@ |
52 | 50 | } |
53 | 51 | |
54 | 52 | // Check permissions and errors |
55 | | - $error = SpecialEmailUser::getPermissionsError( $wgUser, $params['token'] ); |
| 53 | + $error = SpecialEmailUser::getPermissionsError( $this->getUser(), $params['token'] ); |
56 | 54 | if ( $error ) { |
57 | 55 | $this->dieUsageMsg( array( $error ) ); |
58 | 56 | } |
Index: trunk/phase3/includes/api/ApiQueryQueryPage.php |
— | — | @@ -75,12 +75,11 @@ |
76 | 76 | * @param $resultPageSet ApiPageSet |
77 | 77 | */ |
78 | 78 | public function run( $resultPageSet = null ) { |
79 | | - global $wgUser; |
80 | 79 | $params = $this->extractRequestParams(); |
81 | 80 | $result = $this->getResult(); |
82 | 81 | |
83 | 82 | $qp = new $this->qpMap[$params['page']](); |
84 | | - if ( !$qp->userCanExecute( $wgUser ) ) { |
| 83 | + if ( !$qp->userCanExecute( $this->getUser() ) ) { |
85 | 84 | $this->dieUsageMsg( 'specialpage-cantexecute' ); |
86 | 85 | } |
87 | 86 | |
Index: trunk/phase3/includes/api/ApiQueryWatchlist.php |
— | — | @@ -159,8 +159,8 @@ |
160 | 160 | |
161 | 161 | // Check permissions. |
162 | 162 | if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ) { |
163 | | - global $wgUser; |
164 | | - if ( !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol() ) { |
| 163 | + $user = $this->getUser(); |
| 164 | + if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) { |
165 | 165 | $this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' ); |
166 | 166 | } |
167 | 167 | } |
Index: trunk/phase3/includes/api/ApiBlock.php |
— | — | @@ -48,29 +48,29 @@ |
49 | 49 | * of success. If it fails, the result will specify the nature of the error. |
50 | 50 | */ |
51 | 51 | public function execute() { |
52 | | - global $wgUser; |
| 52 | + $user = $this->getUser(); |
53 | 53 | $params = $this->extractRequestParams(); |
54 | 54 | |
55 | 55 | if ( $params['gettoken'] ) { |
56 | | - $res['blocktoken'] = $wgUser->editToken( '', $this->getMain()->getRequest() ); |
| 56 | + $res['blocktoken'] = $user->editToken( '', $this->getMain()->getRequest() ); |
57 | 57 | $this->getResult()->addValue( null, $this->getModuleName(), $res ); |
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
61 | | - if ( !$wgUser->isAllowed( 'block' ) ) { |
| 61 | + if ( !$user->isAllowed( 'block' ) ) { |
62 | 62 | $this->dieUsageMsg( 'cantblock' ); |
63 | 63 | } |
64 | 64 | # bug 15810: blocked admins should have limited access here |
65 | | - if ( $wgUser->isBlocked() ) { |
| 65 | + if ( $user->isBlocked() ) { |
66 | 66 | $status = SpecialBlock::checkUnblockSelf( $params['user'] ); |
67 | 67 | if ( $status !== true ) { |
68 | 68 | $this->dieUsageMsg( array( $status ) ); |
69 | 69 | } |
70 | 70 | } |
71 | | - if ( $params['hidename'] && !$wgUser->isAllowed( 'hideuser' ) ) { |
| 71 | + if ( $params['hidename'] && !$user->isAllowed( 'hideuser' ) ) { |
72 | 72 | $this->dieUsageMsg( 'canthide' ); |
73 | 73 | } |
74 | | - if ( $params['noemail'] && !SpecialBlock::canBlockEmail( $wgUser ) ) { |
| 74 | + if ( $params['noemail'] && !SpecialBlock::canBlockEmail( $user ) ) { |
75 | 75 | $this->dieUsageMsg( 'cantblock-email' ); |
76 | 76 | } |
77 | 77 | |
Index: trunk/phase3/includes/api/ApiPatrol.php |
— | — | @@ -42,15 +42,13 @@ |
43 | 43 | * Patrols the article or provides the reason the patrol failed. |
44 | 44 | */ |
45 | 45 | public function execute() { |
46 | | - global $wgUser; |
47 | | - |
48 | 46 | $params = $this->extractRequestParams(); |
49 | 47 | |
50 | 48 | $rc = RecentChange::newFromID( $params['rcid'] ); |
51 | 49 | if ( !$rc instanceof RecentChange ) { |
52 | 50 | $this->dieUsageMsg( array( 'nosuchrcid', $params['rcid'] ) ); |
53 | 51 | } |
54 | | - $retval = $rc->doMarkPatrolled( $wgUser ); |
| 52 | + $retval = $rc->doMarkPatrolled( $this->getUser() ); |
55 | 53 | |
56 | 54 | if ( $retval ) { |
57 | 55 | $this->dieUsageMsg( reset( $retval ) ); |
Index: trunk/phase3/includes/api/ApiUndelete.php |
— | — | @@ -39,14 +39,13 @@ |
40 | 40 | } |
41 | 41 | |
42 | 42 | public function execute() { |
43 | | - global $wgUser; |
44 | 43 | $params = $this->extractRequestParams(); |
45 | 44 | |
46 | | - if ( !$wgUser->isAllowed( 'undelete' ) ) { |
| 45 | + if ( !$this->getUser()->isAllowed( 'undelete' ) ) { |
47 | 46 | $this->dieUsageMsg( 'permdenied-undelete' ); |
48 | 47 | } |
49 | 48 | |
50 | | - if ( $wgUser->isBlocked() ) { |
| 49 | + if ( $this->getUser()->isBlocked() ) { |
51 | 50 | $this->dieUsageMsg( 'blockedtext' ); |
52 | 51 | } |
53 | 52 | |
— | — | @@ -74,7 +73,7 @@ |
75 | 74 | |
76 | 75 | if ( $retval[1] ) { |
77 | 76 | wfRunHooks( 'FileUndeleteComplete', |
78 | | - array( $titleObj, array(), $wgUser, $params['reason'] ) ); |
| 77 | + array( $titleObj, array(), $this->getUser(), $params['reason'] ) ); |
79 | 78 | } |
80 | 79 | |
81 | 80 | $this->setWatch( $params['watchlist'], $titleObj ); |
Index: trunk/phase3/includes/api/ApiBase.php |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | * |
41 | 41 | * @ingroup API |
42 | 42 | */ |
43 | | -abstract class ApiBase { |
| 43 | +abstract class ApiBase extends ContextSource { |
44 | 44 | |
45 | 45 | // These constants allow modules to specify exactly how to treat incoming parameters. |
46 | 46 | |
— | — | @@ -72,6 +72,10 @@ |
73 | 73 | $this->mMainModule = $mainModule; |
74 | 74 | $this->mModuleName = $moduleName; |
75 | 75 | $this->mModulePrefix = $modulePrefix; |
| 76 | + |
| 77 | + if ( !$this->isMain() ) { |
| 78 | + $this->setContext( $this->mMainModule ); |
| 79 | + } |
76 | 80 | } |
77 | 81 | |
78 | 82 | /***************************************************************************** |
— | — | @@ -179,16 +183,11 @@ |
180 | 184 | * The object will have the WebRequest and the User object set to the ones |
181 | 185 | * used in this instance. |
182 | 186 | * |
| 187 | + * @deprecated 1.19 use getContext to get the current context |
183 | 188 | * @return RequestContext |
184 | 189 | */ |
185 | 190 | public function createContext() { |
186 | | - global $wgUser; |
187 | | - |
188 | | - $context = new RequestContext; |
189 | | - $context->setRequest( $this->getMain()->getRequest() ); |
190 | | - $context->setUser( $wgUser ); /// @todo FIXME: we should store the User object |
191 | | - |
192 | | - return $context; |
| 191 | + return $this->getContext(); |
193 | 192 | } |
194 | 193 | |
195 | 194 | /** |
— | — | @@ -674,7 +673,6 @@ |
675 | 674 | |
676 | 675 | $userWatching = $titleObj->userIsWatching(); |
677 | 676 | |
678 | | - global $wgUser; |
679 | 677 | switch ( $watchlist ) { |
680 | 678 | case 'watch': |
681 | 679 | return true; |
— | — | @@ -693,7 +691,7 @@ |
694 | 692 | ? 'watchdefault' : 'watchcreations'; |
695 | 693 | } |
696 | 694 | # Watch the article based on the user preference |
697 | | - return (bool)$wgUser->getOption( $userOption ); |
| 695 | + return (bool)$this->getUser()->getOption( $userOption ); |
698 | 696 | |
699 | 697 | case 'nochange': |
700 | 698 | return $userWatching; |
— | — | @@ -715,11 +713,11 @@ |
716 | 714 | return; |
717 | 715 | } |
718 | 716 | |
719 | | - global $wgUser; |
| 717 | + $user = $this->getUser(); |
720 | 718 | if ( $value ) { |
721 | | - WatchAction::doWatch( $titleObj, $wgUser ); |
| 719 | + WatchAction::doWatch( $titleObj, $user ); |
722 | 720 | } else { |
723 | | - WatchAction::doUnwatch( $titleObj, $wgUser ); |
| 721 | + WatchAction::doUnwatch( $titleObj, $user ); |
724 | 722 | } |
725 | 723 | } |
726 | 724 | |
— | — | @@ -767,9 +765,9 @@ |
768 | 766 | ApiBase::dieDebug( __METHOD__, "Boolean param $encParamName's default is set to '$default'" ); |
769 | 767 | } |
770 | 768 | |
771 | | - $value = $this->getMain()->getRequest()->getCheck( $encParamName ); |
| 769 | + $value = $this->getRequest()->getCheck( $encParamName ); |
772 | 770 | } else { |
773 | | - $value = $this->getMain()->getRequest()->getVal( $encParamName, $default ); |
| 771 | + $value = $this->getRequest()->getVal( $encParamName, $default ); |
774 | 772 | |
775 | 773 | if ( isset( $value ) && $type == 'namespace' ) { |
776 | 774 | $type = MWNamespace::getValidNamespaces(); |
— | — | @@ -1297,7 +1295,6 @@ |
1298 | 1296 | * @return User |
1299 | 1297 | */ |
1300 | 1298 | public function getWatchlistUser( $params ) { |
1301 | | - global $wgUser; |
1302 | 1299 | if ( !is_null( $params['owner'] ) && !is_null( $params['token'] ) ) { |
1303 | 1300 | $user = User::newFromName( $params['owner'], false ); |
1304 | 1301 | if ( !$user->getId() ) { |
— | — | @@ -1308,10 +1305,10 @@ |
1309 | 1306 | $this->dieUsage( 'Incorrect watchlist token provided -- please set a correct token in Special:Preferences', 'bad_wltoken' ); |
1310 | 1307 | } |
1311 | 1308 | } else { |
1312 | | - if ( !$wgUser->isLoggedIn() ) { |
| 1309 | + if ( !$this->getUser()->isLoggedIn() ) { |
1313 | 1310 | $this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' ); |
1314 | 1311 | } |
1315 | | - $user = $wgUser; |
| 1312 | + $user = $this->getUser(); |
1316 | 1313 | } |
1317 | 1314 | return $user; |
1318 | 1315 | } |
Index: trunk/phase3/includes/api/ApiQueryInfo.php |
— | — | @@ -619,9 +619,9 @@ |
620 | 620 | * Get information about watched status and put it in $this->watched |
621 | 621 | */ |
622 | 622 | private function getWatchedInfo() { |
623 | | - global $wgUser; |
| 623 | + $user = $this->getUser(); |
624 | 624 | |
625 | | - if ( $wgUser->isAnon() || count( $this->everything ) == 0 ) { |
| 625 | + if ( $user->isAnon() || count( $this->everything ) == 0 ) { |
626 | 626 | return; |
627 | 627 | } |
628 | 628 | |
— | — | @@ -635,7 +635,7 @@ |
636 | 636 | $this->addFields( array( 'wl_title', 'wl_namespace' ) ); |
637 | 637 | $this->addWhere( array( |
638 | 638 | $lb->constructSet( 'wl', $db ), |
639 | | - 'wl_user' => $wgUser->getID() |
| 639 | + 'wl_user' => $user->getID() |
640 | 640 | ) ); |
641 | 641 | |
642 | 642 | $res = $this->select( __METHOD__ ); |
Index: trunk/phase3/includes/api/ApiUpload.php |
— | — | @@ -46,13 +46,13 @@ |
47 | 47 | } |
48 | 48 | |
49 | 49 | public function execute() { |
50 | | - global $wgUser; |
51 | | - |
52 | 50 | // Check whether upload is enabled |
53 | 51 | if ( !UploadBase::isEnabled() ) { |
54 | 52 | $this->dieUsageMsg( 'uploaddisabled' ); |
55 | 53 | } |
56 | 54 | |
| 55 | + $user = $this->getUser(); |
| 56 | + |
57 | 57 | // Parameter handling |
58 | 58 | $this->mParams = $this->extractRequestParams(); |
59 | 59 | $request = $this->getMain()->getRequest(); |
— | — | @@ -75,7 +75,7 @@ |
76 | 76 | } |
77 | 77 | |
78 | 78 | // First check permission to upload |
79 | | - $this->checkPermissions( $wgUser ); |
| 79 | + $this->checkPermissions( $user ); |
80 | 80 | |
81 | 81 | // Fetch the file |
82 | 82 | $status = $this->mUpload->fetchFile(); |
— | — | @@ -100,7 +100,7 @@ |
101 | 101 | // (This check is irrelevant if stashing is already requested, since the errors |
102 | 102 | // can always be fixed by changing the title) |
103 | 103 | if ( ! $this->mParams['stash'] ) { |
104 | | - $permErrors = $this->mUpload->verifyTitlePermissions( $wgUser ); |
| 104 | + $permErrors = $this->mUpload->verifyTitlePermissions( $user ); |
105 | 105 | if ( $permErrors !== true ) { |
106 | 106 | $this->dieRecoverableError( $permErrors[0], 'filename' ); |
107 | 107 | } |
— | — | @@ -254,17 +254,7 @@ |
255 | 255 | $this->dieUsageMsg( 'invalid-file-key' ); |
256 | 256 | } |
257 | 257 | |
258 | | - if( class_exists( 'RequestContext' ) ) { |
259 | | - // context allows access to the current user without creating new $wgUser references |
260 | | - $context = $this->createContext(); |
261 | | - $this->mUpload = new UploadFromStash( $context->getUser() ); |
262 | | - } else { |
263 | | - // this is here to maintain 1.17 compatibility, so these changes can |
264 | | - // be merged into production |
265 | | - // remove this after we've moved to 1.18 |
266 | | - global $wgUser; |
267 | | - $this->mUpload = new UploadFromStash( $wgUser ); |
268 | | - } |
| 258 | + $this->mUpload = new UploadFromStash( $this->getUser() ); |
269 | 259 | |
270 | 260 | $this->mUpload->initialize( $this->mParams['filekey'], $this->mParams['filename'] ); |
271 | 261 | |
— | — | @@ -440,8 +430,6 @@ |
441 | 431 | * @return array |
442 | 432 | */ |
443 | 433 | protected function performUpload() { |
444 | | - global $wgUser; |
445 | | - |
446 | 434 | // Use comment as initial page text by default |
447 | 435 | if ( is_null( $this->mParams['text'] ) ) { |
448 | 436 | $this->mParams['text'] = $this->mParams['comment']; |
— | — | @@ -457,7 +445,7 @@ |
458 | 446 | |
459 | 447 | // No errors, no warnings: do the upload |
460 | 448 | $status = $this->mUpload->performUpload( $this->mParams['comment'], |
461 | | - $this->mParams['text'], $watch, $wgUser ); |
| 449 | + $this->mParams['text'], $watch, $this->getUser() ); |
462 | 450 | |
463 | 451 | if ( !$status->isGood() ) { |
464 | 452 | $error = $status->getErrorsArray(); |
Index: trunk/phase3/includes/api/ApiQueryUserContributions.php |
— | — | @@ -146,7 +146,7 @@ |
147 | 147 | // We're after the revision table, and the corresponding page |
148 | 148 | // row for anything we retrieve. We may also need the |
149 | 149 | // recentchanges row and/or tag summary row. |
150 | | - global $wgUser; |
| 150 | + $user = $this->getUser(); |
151 | 151 | $tables = array( 'page', 'revision' ); // Order may change |
152 | 152 | $this->addWhere( 'page_id=rev_page' ); |
153 | 153 | |
— | — | @@ -167,7 +167,7 @@ |
168 | 168 | ); |
169 | 169 | } |
170 | 170 | |
171 | | - if ( !$wgUser->isAllowed( 'hideuser' ) ) { |
| 171 | + if ( !$user->isAllowed( 'hideuser' ) ) { |
172 | 172 | $this->addWhere( $this->getDB()->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0' ); |
173 | 173 | } |
174 | 174 | // We only want pages by the specified users. |
— | — | @@ -216,7 +216,7 @@ |
217 | 217 | |
218 | 218 | if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) || |
219 | 219 | $this->fld_patrolled ) { |
220 | | - if ( !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol() ) { |
| 220 | + if ( !$user->useRCPatrol() && !$user->useNPPatrol() ) { |
221 | 221 | $this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' ); |
222 | 222 | } |
223 | 223 | |