a redirect and its target.
* (bug 43849) ApiQueryImageInfo no longer throws exceptions with ForeignDBRepo
redirects.
+* On error, any warnings generated before that error will be shown in the result.
=== API internal changes in 1.21 ===
* For debugging only, a new global $wgDebugAPI removes many API restrictions when true.
}
}
- // Handle any kind of exception by outputing properly formatted error message.
+ // Handle any kind of exception by outputting properly formatted error message.
// If this fails, an unhandled exception should be thrown so that global error
// handler will process and log it.
if ( $this->mPrinter->getWantsHelp() || $this->mAction == 'help' ) {
ApiResult::setContent( $errMessage, $this->makeHelpMsg() );
}
-
} else {
global $wgShowSQLErrors, $wgShowExceptionDetails;
// Something is seriously wrong
ApiResult::setContent( $errMessage, $wgShowExceptionDetails ? "\n\n{$e->getTraceAsString()}\n\n" : '' );
}
+ // Remember all the warnings to re-add them later
+ $oldResult = $result->getData();
+ $warnings = isset( $oldResult['warnings'] ) ? $oldResult['warnings'] : null;
+
$result->reset();
$result->disableSizeCheck();
// Re-add the id
if ( !is_null( $requestid ) ) {
$result->addValue( null, 'requestid', $requestid );
}
-
if ( $wgShowHostnames ) {
// servedby is especially useful when debugging errors
$result->addValue( null, 'servedby', wfHostName() );
}
+ if ( $warnings !== null ) {
+ $result->addValue( null, 'warnings', $warnings );
+ }
$result->addValue( null, 'error', $errMessage );
* @dataProvider dataGetDeletionUpdates
*/
public function testDeletionUpdates( $title, $model, $text, $expectedStuff ) {
- $title = Title::newFromText( $title );
- $title->resetArticleID( 2342 ); //dummy id. fine as long as we don't try to execute the updates!
+ $ns = $this->getDefaultWikitextNS();
+ $title = Title::newFromText( $title, $ns );
$content = ContentHandler::makeContent( $text, $title, $model );
- $updates = $content->getDeletionUpdates( WikiPage::factory( $title ) );
+ $page = WikiPage::factory( $title );
+ $page->doEditContent( $content, '' );
+
+ $updates = $content->getDeletionUpdates( $page );
// make updates accessible by class name
foreach ( $updates as $update ) {
$this->assertEquals( $value, $v, "unexpected value for field $field in instance of $class" );
}
}
+
+ $page->doDeleteArticle( '' );
}
public static function provideConvert() {
* @group Database
*/
public function testGetSecondaryDataUpdates( $title, $model, $text, $expectedStuff ) {
- $title = Title::newFromText( $title );
- $title->resetArticleID( 2342 ); //dummy id. fine as long as we don't try to execute the updates!
+ $ns = $this->getDefaultWikitextNS();
+ $title = Title::newFromText( $title, $ns );
$content = ContentHandler::makeContent( $text, $title, $model );
+ $page = WikiPage::factory( $title );
+ $page->doEditContent( $content, '' );
+
$updates = $content->getSecondaryDataUpdates( $title );
// make updates accessible by class name
$this->assertEquals( $value, $v, "unexpected value for field $field in instance of $class" );
}
}
+
+ $page->doDeleteArticle( '' );
}
public static function dataGetSection() {