+
+ /**
+ * Regression test for T218918
+ */
+ public function testLoadFromDB_fetchLatestRevision() {
+ // Create three revisions of the same message page.
+ // Must be an existing message key.
+ $key = 'Log';
+ $this->makePage( $key, 'de', 'Test eins' );
+ $this->makePage( $key, 'de', 'Test zwei' );
+ $r3 = $this->makePage( $key, 'de', 'Test drei' );
+
+ // Create an out-of-sequence revision by importing a
+ // revision with an old timestamp. Hacky.
+ $importRevision = new WikiRevision( new HashConfig() );
+ $importRevision->setTitle( $r3->getTitle() );
+ $importRevision->setComment( 'Imported edit' );
+ $importRevision->setTimestamp( '19991122334455' );
+ $importRevision->setText( 'IMPORTED OLD TEST' );
+ $importRevision->setUsername( 'Alan Smithee' );
+
+ $importer = MediaWikiServices::getInstance()->getWikiRevisionOldRevisionImporterNoUpdates();
+ $importer->import( $importRevision );
+
+ // Now, load the message from the wiki page
+ MessageCache::destroyInstance();
+ $messageCache = MessageCache::singleton();
+ $messageCache->enable();
+ $messageCache = TestingAccessWrapper::newFromObject( $messageCache );
+
+ $cache = $messageCache->loadFromDB( 'de' );
+
+ $this->assertArrayHasKey( $key, $cache );
+
+ // Text in the cache has an extra space in front!
+ $this->assertSame( ' ' . 'Test drei', $cache[$key] );
+ }
+