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)
1  2 
RELEASE-NOTES-1.21
includes/api/ApiParse.php

diff --combined RELEASE-NOTES-1.21
@@@ -26,15 -26,6 +26,15 @@@ production
  * jQuery UI upgraded from 1.8.23 to 1.8.24.
  * Added separate fa_sha1 field to filearchive table. This allows sha1
    searches with the api in miser mode for deleted files.
 +* Add initial and programmatic sorting for tablesorter.
 +* Add the event "sortEnd.tablesorter", triggered after sorting has completed.
 +* The Job system was refactored to allow for different backing stores for queues
 +  as well as cross-wiki access to queues, among other things. The schema for the
 +  DB queue was changed to support better concurrency and reduce deadlock errors.
 +* Added ApiQueryORM class to facilitate creation of query API modules based on
 +  tables that have a corresponding ORMTable class.
 +* (bug 40876) Icon for PSD (Adobe Photoshop) file types.
 +* (bug 40641) Implemented Special:Version/Credits with a list of contributors.
  
  === Bug fixes in 1.21 ===
  * (bug 40353) SpecialDoubleRedirect should support interwiki redirects.
    compatibility. This also works with Squid in reverse-proxy mode. If you wish 
    to support Squid configured in forward-proxy mode, set 
    $wgSquidPurgeUseHostHeader to false.
 +* (bug 37020) sql.php with readline eats semicolon
 +* (bug 11748) Properly handle optionally-closed HTML tags when Tidy is
 +  disabled, and don't wrap HTML-syntax definition lists in paragraphs.
 +* (bug 41409) Diffs while editing an old revision should again diff against the
 +  current revision.
  
  === API changes in 1.21 ===
  * prop=revisions can now report the contentmodel and contentformat, see docs/contenthandler.txt
@@@ -61,6 -47,7 +61,7 @@@
    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 ===
  
@@@ -114,7 -114,7 +114,7 @@@ class ApiParse extends ApiBase 
                                        }
  
                                        // Should we save old revision parses to the parser cache?
 -                                      $p_result = $this->content->getParserOutput( $titleObj, $popts );
 +                                      $p_result = $this->content->getParserOutput( $titleObj, $rev->getId(), $popts );
                                }
                        } else { // Not $oldid, but $pageid or $page
                                if ( $params['redirects'] ) {
  
                                $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'] ) ) {
                                        $oldid = $pageObj->getLatest();
                                }
  
 -
                                $popts = $pageObj->makeParserOptions( $this->getContext() );
                                $popts->enableLimitReport( !$params['disablepp'] );
  
                        if ( !$titleObj ) {
                                $this->dieUsageMsg( array( 'invalidtitle', $title ) );
                        }
 +                      if ( !$titleObj->canExist() ) {
 +                              $this->dieUsage( "Namespace doesn't allow actual pages", 'pagecannotexist' );
 +                      }
                        $wgTitle = $titleObj;
                        $pageObj = WikiPage::factory( $titleObj );
  
  
                        // Not cached (save or load)
                        if ( $params['pst'] ) {
 -                              $p_result = $this->pstContent->getParserOutput( $titleObj, $popts );
 +                              $p_result = $this->pstContent->getParserOutput( $titleObj, null, $popts );
                        } else {
 -                              $p_result = $this->content->getParserOutput( $titleObj, $popts );
 +                              $p_result = $this->content->getParserOutput( $titleObj, null, $popts );
                        }
                }
  
        private function getParsedContent( WikiPage $page, $popts, $pageId = null, $getWikitext = false ) {
                $this->content = $page->getContent( Revision::RAW ); //XXX: really raw?
  
 -              if ( $this->section !== false ) {
 +              if ( $this->section !== false && $this->content !== null ) {
                        $this->content = $this->getSectionContent(
                                $this->content,
                                !is_null( $pageId ) ? 'page id ' . $pageId : $page->getTitle()->getText() );
  
                        // Not cached (save or load)
 -                      return $this->content->getParserOutput( $page->getTitle(), $popts );
 +                      return $this->content->getParserOutput( $page->getTitle(), null, $popts );
                } else {
                        // Try the parser cache first
                        // getParserOutput will save to Parser cache if able
                        array( 'invalidtitle', 'title' ),
                        array( 'code' => 'parseerror', 'info' => 'Failed to parse the given text.' ),
                        array( 'code' => 'notwikitext', 'info' => 'The requested operation is only supported on wikitext content.' ),
 +                      array( 'code' => 'pagecannotexist', 'info' => "Namespace doesn't allow actual pages" ),
                ) );
        }