? SqlBlobStore::makeAddressFromTextId( $row->old_id )
: null;
- return self::getBlobStore( $wiki )->expandBlob( $text, $flags, $cacheKey );
+ $revisionText = self::getBlobStore( $wiki )->expandBlob( $text, $flags, $cacheKey );
+
+ if ( $revisionText === false ) {
+ if ( isset( $row->old_id ) ) {
+ wfLogWarning( __METHOD__ . ": Bad data in text row {$row->old_id}! " );
+ } else {
+ wfLogWarning( __METHOD__ . ": Bad data in text row! " );
+ }
+ return false;
+ }
+
+ return $revisionText;
}
/**
* @return string|bool Decompressed text, or false on failure
*/
public static function decompressRevisionText( $text, $flags ) {
+ if ( $text === false ) {
+ // Text failed to be fetched; nothing to do
+ return false;
+ }
+
return self::getBlobStore()->decompressData( $text, $flags );
}
$blob = $this->expandBlob( $row->old_text, $row->old_flags, $blobAddress );
if ( $blob === false ) {
- wfWarn( __METHOD__ . ": Bad data in text row $textId." );
+ wfLogWarning( __METHOD__ . ": Bad data in text row $textId." );
return false;
}
// No negative caching per BlobStore::getBlob()
$blob = ExternalStore::fetchFromURL( $url, [ 'wiki' => $this->wikiId ] );
- return $this->decompressData( $blob, $flags );
+ return $blob === false ? false : $this->decompressData( $blob, $flags );
},
[ 'pcGroup' => self::TEXT_CACHE_GROUP, 'pcTTL' => WANObjectCache::TTL_PROC_LONG ]
);
} else {
$blob = ExternalStore::fetchFromURL( $url, [ 'wiki' => $this->wikiId ] );
- return $this->decompressData( $blob, $flags );
+ return $blob === false ? false : $this->decompressData( $blob, $flags );
}
} else {
return $this->decompressData( $raw, $flags );
* @note direct use is deprecated, use getBlob() or SlotRecord::getContent() instead.
* @todo make this private, there should be no need to use this method outside this class.
*
- * @param mixed $blob Reference to a text
+ * @param string $blob Blob in compressed/encoded form.
* @param array $blobFlags Compression flags, such as 'gzip'.
* Note that not including 'utf-8' in $blobFlags will cause the data to be decoded
* according to the legacy encoding specified via setLegacyEncoding.
* @return string|bool Decompressed text, or false on failure
*/
public function decompressData( $blob, array $blobFlags ) {
- if ( $blob === false ) {
- // Text failed to be fetched; nothing to do
- return false;
- }
+ // Revision::decompressRevisionText accepted false here, so defend against that
+ Assert::parameterType( 'string', $blob, '$blob' );
if ( in_array( 'error', $blobFlags ) ) {
// Error row, return false
$blob = gzinflate( $blob );
if ( $blob === false ) {
- wfLogWarning( __METHOD__ . ': gzinflate() failed' );
+ wfWarn( __METHOD__ . ': gzinflate() failed' );
return false;
}
}