Merge "(bug 41042) Regression: API action=parse with nonexistent page"
authorCatrope <roan.kattouw@gmail.com>
Mon, 29 Oct 2012 20:03:16 +0000 (20:03 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 29 Oct 2012 20:03:16 +0000 (20:03 +0000)
RELEASE-NOTES-1.21
includes/api/ApiParse.php
tests/phpunit/includes/api/ApiParseTest.php [new file with mode: 0644]

index 7b9e101..74ff05b 100644 (file)
@@ -61,6 +61,7 @@ production.
   page content; See docs/contenthandler.txt for details.
 * (bug 35693) ApiQueryImageInfo now suppresses errors when unserializing metadata.
 * (bug 40111) Disable minor edit for page/section creation by API
+* (bug 41042) Revert change to action=parse&page=... behavior when the page does not exist.
 
 === Languages updated in 1.21 ===
 
index fae8e69..2c8349f 100644 (file)
@@ -147,6 +147,9 @@ class ApiParse extends ApiBase {
 
                                $pageObj = $this->getTitleOrPageId( $pageParams, 'fromdb' );
                                $titleObj = $pageObj->getTitle();
+                               if ( !$titleObj || !$titleObj->exists() ) {
+                                       $this->dieUsage( "The page you specified doesn't exist", 'missingtitle' );
+                               }
                                $wgTitle = $titleObj;
 
                                if ( isset( $prop['revid'] ) ) {
diff --git a/tests/phpunit/includes/api/ApiParseTest.php b/tests/phpunit/includes/api/ApiParseTest.php
new file mode 100644 (file)
index 0000000..b5dabf0
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+
+/**
+ * @group API
+ * @group Database
+ */
+class ApiParseTest extends ApiTestCase {
+
+       protected function setUp() {
+               parent::setUp();
+               $this->doLogin();
+       }
+
+       function testParseNonexistentPage() {
+               $somePage = mt_rand();
+
+               try {
+                       $data = $this->doApiRequest( array(
+                               'action' => 'parse',
+                               'page' => $somePage ) );
+
+                       $this->fail( "API did not return an error when parsing a nonexistent page" );
+               } catch(UsageException $ex){
+                       $this->assertEquals( 'missingtitle', $ex->getCodeString(),
+                               "Parse request for nonexistent page must give 'missingtitle' error: " . var_export( $ex->getMessageArray(), true ) );
+               }
+       }
+
+}