Merge "Improved some thumb.php error messages."
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 23 Jan 2013 21:05:45 +0000 (21:05 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 23 Jan 2013 21:05:45 +0000 (21:05 +0000)
RELEASE-NOTES-1.21
includes/api/ApiMain.php
tests/phpunit/includes/content/TextContentTest.php
tests/phpunit/includes/content/WikitextContentTest.php

index 01ff993..a34cd17 100644 (file)
@@ -187,6 +187,7 @@ production.
   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.
index 3f82d3c..70c31c1 100644 (file)
@@ -384,7 +384,7 @@ class ApiMain extends ApiBase {
                                }
                        }
 
-                       // 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.
 
@@ -622,7 +622,6 @@ class ApiMain extends ApiBase {
                        if ( $this->mPrinter->getWantsHelp() || $this->mAction == 'help' ) {
                                ApiResult::setContent( $errMessage, $this->makeHelpMsg() );
                        }
-
                } else {
                        global $wgShowSQLErrors, $wgShowExceptionDetails;
                        // Something is seriously wrong
@@ -639,6 +638,10 @@ class ApiMain extends ApiBase {
                        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
@@ -646,11 +649,13 @@ class ApiMain extends ApiBase {
                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 );
 
index 3501aec..ca387a2 100644 (file)
@@ -349,12 +349,15 @@ class TextContentTest extends MediaWikiLangTestCase {
         * @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 ) {
@@ -377,6 +380,8 @@ class TextContentTest extends MediaWikiLangTestCase {
                                $this->assertEquals( $value, $v, "unexpected value for field $field in instance of $class" );
                        }
                }
+
+               $page->doDeleteArticle( '' );
        }
 
        public static function provideConvert() {
index b76e9aa..7cf473e 100644 (file)
@@ -69,11 +69,14 @@ more stuff
         * @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
@@ -92,6 +95,8 @@ more stuff
                                $this->assertEquals( $value, $v, "unexpected value for field $field in instance of $class" );
                        }
                }
+
+               $page->doDeleteArticle( '' );
        }
 
        public static function dataGetSection() {