'content' => new WikitextContent( 'GOAT' ),
'text_id' => 'someid',
],
- new MWException( "Text already stored in external store (id someid), " .
- "can't serialize content object" )
+ new MWException( 'Text already stored in external store (id someid),' )
];
yield 'with bad content object (class)' => [
[ 'content' => new stdClass() ],
- new MWException( 'content field must contain a Content object.' )
+ new MWException( 'content field must contain a Content object' )
];
yield 'with bad content object (string)' => [
[ 'content' => 'ImAGoat' ],
- new MWException( 'content field must contain a Content object.' )
+ new MWException( 'content field must contain a Content object' )
];
yield 'bad row format' => [
'imastring, not a row',
$this->testGetRevisionText( $expected, $rowData );
}
+ public function provideGetRevisionTextWithZlibExtension_badData() {
+ yield 'Generic gzip test' => [
+ 'This is a small goat of revision text.',
+ [
+ 'old_flags' => 'gzip',
+ 'old_text' => 'DEAD BEEF',
+ ],
+ ];
+ }
+
+ /**
+ * @covers Revision::getRevisionText
+ * @dataProvider provideGetRevisionTextWithZlibExtension_badData
+ */
+ public function testGetRevisionWithZlibExtension_badData( $expected, $rowData ) {
+ $this->checkPHPExtension( 'zlib' );
+ Wikimedia\suppressWarnings();
+ $this->assertFalse(
+ Revision::getRevisionText(
+ (object)$rowData
+ )
+ );
+ Wikimedia\suppressWarnings( true );
+ }
+
private function getWANObjectCache() {
return new WANObjectCache( [ 'cache' => new HashBagOStuff() ] );
}
public function testGetRevisionText_external_returnsFalseWhenNotEnoughUrlParts(
$text
) {
+ Wikimedia\suppressWarnings();
$this->assertFalse(
Revision::getRevisionText(
(object)[
]
)
);
+ Wikimedia\suppressWarnings( true );
}
/**
)
);
- $cacheKey = $cache->makeKey( 'revisiontext', 'textid', 'tt:7777' );
+ $cacheKey = $cache->makeGlobalKey(
+ 'BlobStore',
+ 'address',
+ $lb->getLocalDomainID(),
+ 'tt:7777'
+ );
$this->assertSame( 'AAAABBAAA', $cache->get( $cacheKey ) );
}