From a87989717086b114e0acf3353160063de1914114 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 14 Nov 2013 12:26:00 -0800 Subject: [PATCH] Avoid extra parsing in prepareContentForEdit() * WikiPage::clear() no longer resets mPreparedEdit * Also actually made mPreparedEdit protected bug: 57026 Change-Id: I2c34baaf8b64b204444efa1bfa6ea356e0124c54 --- includes/WikiPage.php | 8 ++++++-- tests/phpunit/includes/ArticleTablesTest.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/includes/WikiPage.php b/includes/WikiPage.php index 576979c32f..5fc01cc82f 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -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. } /** diff --git a/tests/phpunit/includes/ArticleTablesTest.php b/tests/phpunit/includes/ArticleTablesTest.php index c749598cff..7f9a023765 100644 --- a/tests/phpunit/includes/ArticleTablesTest.php +++ b/tests/phpunit/includes/ArticleTablesTest.php @@ -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 ); -- 2.20.1