r100927 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100926‎ | r100927 | r100928 >
Date:01:13, 27 October 2011
Author:johnduhart
Status:resolved (Comments)
Tags:
Comment:
Followup r100905, cleanup per CR and fixes the overriding of the main RequestContext
Modified paths:
  • /trunk/phase3/includes/api/ApiMain.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiMain.php
@@ -151,11 +151,14 @@
152152 // BC for pre-1.19
153153 $request = $context;
154154 $context = RequestContext::getMain();
155 - $context->setRequest( $request );
156155 }
157156 // We set a derivative context so we can change stuff later
158157 $this->setContext( new DerivativeContext( $context ) );
159158
 159+ if ( isset( $request ) ) {
 160+ $context->setRequest( $request );
 161+ }
 162+
160163 $this->mInternalMode = ( $this->getRequest() instanceof FauxRequest );
161164
162165 // Special handling for the main module: $parent === $this
@@ -187,8 +190,6 @@
188191 $this->mShowVersions = false;
189192 $this->mEnableWrite = $enableWrite;
190193
191 - //$this->mRequest = &$request;
192 -
193194 $this->mSquidMaxage = - 1; // flag for executeActionWithErrorHandling()
194195 $this->mCommit = false;
195196 }
@@ -202,14 +203,6 @@
203204 }
204205
205206 /**
206 - * Return the request object that contains client's request
207 - * @return WebRequest
208 - */
209 - /*public function getRequest() {
210 - return $this->mRequest;
211 - }*/
212 -
213 - /**
214207 * Get the ApiResult object associated with current request
215208 *
216209 * @return ApiResult

Follow-up revisions

RevisionCommit summaryAuthorDate
r101273Followup r100927 and r100905, when setting a FauxRequest use the NEW contextjohnduhart16:14, 29 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r100905Adding context to the API...johnduhart23:27, 26 October 2011

Comments

#Comment by Catrope (talk | contribs)   11:11, 29 October 2011
+		if ( isset( $request ) ) {
+			$context->setRequest( $request );
+		}

As MaxSem points out on r100905 CR this is still wrong. You need to call setRequest() on $this->getContext() (the derivative context you created) not on $context (the original global context).

Status & tagging log