(bug 41042) Regression: API action=parse with nonexistent page
Changeset Iec98e472 changed the behavior of action=parse&page=... when passed a page that does not exist: previously, it would return a "missingtitle" error instead of assuming an empty page. As some people had been depending on this old behavior, restore the error checking. Change-Id: I4c76ce458ceb01e233c6074cd9251879013ec143
This commit is contained in:
parent
42ff119e8a
commit
3756f810bc
3 changed files with 33 additions and 0 deletions
|
|
@ -47,6 +47,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 ===
|
||||
|
||||
|
|
|
|||
|
|
@ -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'] ) ) {
|
||||
|
|
|
|||
29
tests/phpunit/includes/api/ApiParseTest.php
Normal file
29
tests/phpunit/includes/api/ApiParseTest.php
Normal file
|
|
@ -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 ) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue