Avoid extra parsing in prepareContentForEdit()
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 14 Nov 2013 20:26:00 +0000 (12:26 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 15 Nov 2013 00:18:57 +0000 (00:18 +0000)
* WikiPage::clear() no longer resets mPreparedEdit
* Also actually made mPreparedEdit protected

bug: 57026
Change-Id: I2c34baaf8b64b204444efa1bfa6ea356e0124c54

includes/WikiPage.php
tests/phpunit/includes/ArticleTablesTest.php

index 576979c..5fc01cc 100644 (file)
@@ -48,9 +48,11 @@ class WikiPage implements Page, IDBAccessObject {
        public $mDataLoaded = false;         // !< Boolean
        public $mIsRedirect = false;         // !< Boolean
        public $mLatest = false;             // !< Integer (false means "not loaded")
-       public $mPreparedEdit = false;       // !< Array
        /**@}}*/
 
+       /** @var stdclass Map of cache fields (text, parser output, ect) for a proposed/new edit */
+       protected $mPreparedEdit = false;
+
        /**
         * @var int
         */
@@ -242,7 +244,9 @@ class WikiPage implements Page, IDBAccessObject {
                $this->mTimestamp = '';
                $this->mIsRedirect = false;
                $this->mLatest = false;
-               $this->mPreparedEdit = false;
+               // Bug 57026: do not clear mPreparedEdit since prepareTextForEdit() already checks
+               // the requested rev ID and immutable content against the cached one.
+               // Clearing it can cause extra parses on edit for no reason.
        }
 
        /**
index c749598..7f9a023 100644 (file)
@@ -24,7 +24,7 @@ class ArticleTablesTest extends MediaWikiLangTestCase {
                $templates1 = $title->getTemplateLinksFrom();
 
                $wgLang = Language::factory( 'de' );
-               $page->mPreparedEdit = false; // In order to force the rerendering of the same wikitext
+               $page = WikiPage::factory( $title ); // In order to force the rerendering of the same wikitext
 
                // We need an edit, a purge is not enough to regenerate the tables
                $page->doEditContent( new WikitextContent( '{{:{{int:history}}}}' ), 'Test code for bug 14404', EDIT_UPDATE, false, $user );