Using getDateFormat instead of mDateFormat in ParserOptions::optionsHash. This was causing parser cache misses when using ApiParse

This commit is contained in:
Priyanka Dhanda 2010-11-01 23:00:53 +00:00
parent fdf5e56d17
commit 3d0db4ad13
2 changed files with 36 additions and 1 deletions

View file

@ -284,7 +284,7 @@ class ParserOptions {
$confstr .= '!*' ;
if ( in_array( 'dateformat', $forOptions ) )
$confstr .= '!' . $this->mDateFormat;
$confstr .= '!' . $this->getDateFormat();
if ( in_array( 'numberheadings', $forOptions ) )
$confstr .= '!' . ( $this->mNumberHeadings ? '1' : '' );

View file

@ -0,0 +1,35 @@
<?php
class ParserOptionsTest extends PHPUnit_Framework_TestCase {
private $popts;
private $pcache;
function setUp() {
ParserTest::setUp(); //reuse setup from parser tests
global $wgContLang, $wgUser;
$wgContLang = new StubContLang;
$this->popts = new ParserOptions( $wgUser );
$this->pcache = ParserCache::singleton();
}
function tearDown() {
parent::tearDown();
}
/*
* ParserOptions::optionsHash was not giving consistent results when $wgUseDynamicDates was set
*/
function testGetParserCacheKeyWithDynamicDates() {
global $wgUseDynamicDates;
$wgUseDynamicDates = true;
$title = Title::newFromText( "Some test article" );
$article = new Article( $title );
$pcacheKeyBefore = $this->pcache->getKey( $article, $this->popts );
$this->assertNotNull( $this->popts->getDateFormat() );
$pcacheKeyAfter = $this->pcache->getKey( $article, $this->popts );
$this->assertEquals( $pcacheKeyBefore, $pcacheKeyAfter );
}
}