WikiImporter now uses NaiveImportTitleFactory, which in turn uses Title::makeTitleSafe,
bypassing the internal title cache. To avoid (potentially cached) Title objects obtained
via Title::newFromText getting out of sync, WikiImporter now clears the title
cache in addition to clearing the LinkCache.
NOTE: a test for this is provided by I2be12fa7d439b.
Bug: T89307
Change-Id: Ib50c48d4797fc21c62090c0be69e87f7e7d07428
}
// avoid memory leak...?
- $linkCache = LinkCache::singleton();
- $linkCache->clear();
+ Title::clearCaches();
$page = WikiPage::factory( $this->title );
$page->loadPageData( 'fromdbmaster' );
$this->mIsBigDeletion = null;
}
+ public static function clearCaches() {
+ $linkCache = LinkCache::singleton();
+ $linkCache->clear();
+
+ $titleCache = self::getTitleCache();
+ $titleCache->clear();
+ }
+
/**
* Capitalize a text string for a title if it belongs to a namespace that capitalizes
*
$title = Title::newFromText( $text );
$this->assertEquals( $expected, $title->getOtherPage()->getPrefixedText() );
}
+
+ public function testClearCaches() {
+ $linkCache = LinkCache::singleton();
+
+ $title1 = Title::newFromText( 'Foo' );
+ $linkCache->addGoodLinkObj( 23, $title1 );
+
+ Title::clearCaches();
+
+ $title2 = Title::newFromText( 'Foo' );
+ $this->assertNotSame( $title1, $title2, 'title cache should be empty' );
+ $this->assertEquals( 0, $linkCache->getGoodLinkID( 'Foo' ), 'link cache should be empty' );
+ }
}