Index: trunk/phase3/includes/api/ApiMain.php |
— | — | @@ -123,7 +123,8 @@ |
124 | 124 | |
125 | 125 | |
126 | 126 | private $mPrinter, $mModules, $mModuleNames, $mFormats, $mFormatNames; |
127 | | - private $mResult, $mAction, $mShowVersions, $mEnableWrite, $mRequest, $mInternalMode, $mSquidMaxage; |
| 127 | + private $mResult, $mAction, $mShowVersions, $mEnableWrite, $mRequest; |
| 128 | + private $mInternalMode, $mSquidMaxage, $mModule; |
128 | 129 | |
129 | 130 | /** |
130 | 131 | * Constructs an instance of ApiMain that utilizes the module and format specified by $request. |
— | — | @@ -190,6 +191,13 @@ |
191 | 192 | public function getResult() { |
192 | 193 | return $this->mResult; |
193 | 194 | } |
| 195 | + |
| 196 | + /** |
| 197 | + * Get the API module object. Only works after executeAction() |
| 198 | + */ |
| 199 | + public function getModule() { |
| 200 | + return $this->mModule; |
| 201 | + } |
194 | 202 | |
195 | 203 | /** |
196 | 204 | * Only kept for backwards compatibility |
— | — | @@ -368,6 +376,7 @@ |
369 | 377 | |
370 | 378 | // Instantiate the module requested by the user |
371 | 379 | $module = new $this->mModules[$this->mAction] ($this, $this->mAction); |
| 380 | + $this->mModule = $module; |
372 | 381 | |
373 | 382 | if( $module->shouldCheckMaxlag() && isset( $params['maxlag'] ) ) { |
374 | 383 | // Check for maxlag |
Index: trunk/phase3/api.php |
— | — | @@ -125,12 +125,19 @@ |
126 | 126 | |
127 | 127 | // Log the request |
128 | 128 | if ( $wgAPIRequestLog ) { |
129 | | - wfErrorLog( implode( ',', array( |
| 129 | + $items = array( |
130 | 130 | wfTimestamp( TS_MW ), |
131 | 131 | $endtime - $starttime, |
132 | 132 | wfGetIP(), |
133 | | - wfArrayToCGI( $wgRequest->getValues() ) |
134 | | - ) ) . "\n", $wgAPIRequestLog ); |
| 133 | + $_SERVER['HTTP_USER_AGENT'] |
| 134 | + ); |
| 135 | + $items[] = $wgRequest->wasPosted() ? 'POST' : 'GET'; |
| 136 | + if ( $processor->getModule()->mustBePosted() ) { |
| 137 | + $items[] = "action=" . $wgRequest->getVal( 'action' ); |
| 138 | + } else { |
| 139 | + $items[] = wfArrayToCGI( $wgRequest->getValues() ); |
| 140 | + } |
| 141 | + wfErrorLog( implode( ',', $items ) . "\n", $wgAPIRequestLog ); |
135 | 142 | wfDebug( "Logged API request to $wgAPIRequestLog\n" ); |
136 | 143 | } |
137 | 144 | |