Index: trunk/phase3/includes/api/ApiEditPage.php |
— | — | @@ -350,11 +350,9 @@ |
351 | 351 | array( 'nosuchrevid', 'undo' ), |
352 | 352 | array( 'nosuchrevid', 'undoafter' ), |
353 | 353 | array( 'revwrongpage', 'id', 'text' ), |
354 | | - array( 'revwrongpage', 'id', 'text' ), |
355 | 354 | array( 'undo-failure' ), |
356 | 355 | array( 'hashcheckfailed' ), |
357 | 356 | array( 'hookaborted' ), |
358 | | - array( 'hookaborted' ), |
359 | 357 | array( 'noimageredirect-anon' ), |
360 | 358 | array( 'noimageredirect-logged' ), |
361 | 359 | array( 'spamdetected', 'spam' ), |
Index: trunk/phase3/includes/api/ApiMain.php |
— | — | @@ -339,54 +339,54 @@ |
340 | 340 | */ |
341 | 341 | protected function substituteResultWithError( $e ) { |
342 | 342 | |
343 | | - // Printer may not be initialized if the extractRequestParams() fails for the main module |
344 | | - if ( !isset ( $this->mPrinter ) ) { |
345 | | - // The printer has not been created yet. Try to manually get formatter value. |
346 | | - $value = $this->getRequest()->getVal( 'format', self::API_DEFAULT_FORMAT ); |
347 | | - if ( !in_array( $value, $this->mFormatNames ) ) |
348 | | - $value = self::API_DEFAULT_FORMAT; |
| 343 | + // Printer may not be initialized if the extractRequestParams() fails for the main module |
| 344 | + if ( !isset ( $this->mPrinter ) ) { |
| 345 | + // The printer has not been created yet. Try to manually get formatter value. |
| 346 | + $value = $this->getRequest()->getVal( 'format', self::API_DEFAULT_FORMAT ); |
| 347 | + if ( !in_array( $value, $this->mFormatNames ) ) |
| 348 | + $value = self::API_DEFAULT_FORMAT; |
349 | 349 | |
350 | | - $this->mPrinter = $this->createPrinterByName( $value ); |
351 | | - if ( $this->mPrinter->getNeedsRawData() ) |
352 | | - $this->getResult()->setRawMode(); |
353 | | - } |
| 350 | + $this->mPrinter = $this->createPrinterByName( $value ); |
| 351 | + if ( $this->mPrinter->getNeedsRawData() ) |
| 352 | + $this->getResult()->setRawMode(); |
| 353 | + } |
354 | 354 | |
355 | | - if ( $e instanceof UsageException ) { |
356 | | - // |
357 | | - // User entered incorrect parameters - print usage screen |
358 | | - // |
359 | | - $errMessage = $e->getMessageArray(); |
| 355 | + if ( $e instanceof UsageException ) { |
| 356 | + // |
| 357 | + // User entered incorrect parameters - print usage screen |
| 358 | + // |
| 359 | + $errMessage = $e->getMessageArray(); |
360 | 360 | |
361 | | - // Only print the help message when this is for the developer, not runtime |
362 | | - if ( $this->mPrinter->getWantsHelp() || $this->mAction == 'help' ) |
363 | | - ApiResult :: setContent( $errMessage, $this->makeHelpMsg() ); |
| 361 | + // Only print the help message when this is for the developer, not runtime |
| 362 | + if ( $this->mPrinter->getWantsHelp() || $this->mAction == 'help' ) |
| 363 | + ApiResult :: setContent( $errMessage, $this->makeHelpMsg() ); |
364 | 364 | |
| 365 | + } else { |
| 366 | + global $wgShowSQLErrors, $wgShowExceptionDetails; |
| 367 | + // |
| 368 | + // Something is seriously wrong |
| 369 | + // |
| 370 | + if ( ( $e instanceof DBQueryError ) && !$wgShowSQLErrors ) { |
| 371 | + $info = "Database query error"; |
365 | 372 | } else { |
366 | | - global $wgShowSQLErrors, $wgShowExceptionDetails; |
367 | | - // |
368 | | - // Something is seriously wrong |
369 | | - // |
370 | | - if ( ( $e instanceof DBQueryError ) && !$wgShowSQLErrors ) { |
371 | | - $info = "Database query error"; |
372 | | - } else { |
373 | | - $info = "Exception Caught: {$e->getMessage()}"; |
374 | | - } |
375 | | - |
376 | | - $errMessage = array ( |
377 | | - 'code' => 'internal_api_error_' . get_class( $e ), |
378 | | - 'info' => $info, |
379 | | - ); |
380 | | - ApiResult :: setContent( $errMessage, $wgShowExceptionDetails ? "\n\n{$e->getTraceAsString()}\n\n" : "" ); |
| 373 | + $info = "Exception Caught: {$e->getMessage()}"; |
381 | 374 | } |
382 | 375 | |
383 | | - $this->getResult()->reset(); |
384 | | - $this->getResult()->disableSizeCheck(); |
385 | | - // Re-add the id |
386 | | - $requestid = $this->getParameter( 'requestid' ); |
387 | | - if ( !is_null( $requestid ) ) |
388 | | - $this->getResult()->addValue( null, 'requestid', $requestid ); |
389 | | - $this->getResult()->addValue( null, 'error', $errMessage ); |
| 376 | + $errMessage = array ( |
| 377 | + 'code' => 'internal_api_error_' . get_class( $e ), |
| 378 | + 'info' => $info, |
| 379 | + ); |
| 380 | + ApiResult :: setContent( $errMessage, $wgShowExceptionDetails ? "\n\n{$e->getTraceAsString()}\n\n" : "" ); |
| 381 | + } |
390 | 382 | |
| 383 | + $this->getResult()->reset(); |
| 384 | + $this->getResult()->disableSizeCheck(); |
| 385 | + // Re-add the id |
| 386 | + $requestid = $this->getParameter( 'requestid' ); |
| 387 | + if ( !is_null( $requestid ) ) |
| 388 | + $this->getResult()->addValue( null, 'requestid', $requestid ); |
| 389 | + $this->getResult()->addValue( null, 'error', $errMessage ); |
| 390 | + |
391 | 391 | return $errMessage['code']; |
392 | 392 | } |
393 | 393 | |