Use Skin::msg() instead.
* wfInitShellLocale() was removed (deprecated in 1.30).
* wfShellExecDisabled() was removed (deprecated in 1.30).
+* The type string for the parameter $lang of DateFormatter::getInstance is
+ removed (deprecated in 1.31).
=== Deprecations in 1.32 ===
* Use of a StartProfiler.php file is deprecated in favour of placing
return false;
}
- $cacheKey = isset( $row->old_id ) ? ( 'tt:' . $row->old_id ) : null;
+ $cacheKey = isset( $row->old_id )
+ ? SqlBlobStore::makeAddressFromTextId( $row->old_id )
+ : null;
return self::getBlobStore( $wiki )->expandBlob( $text, $flags, $cacheKey );
}
// getTextIdFromAddress() is free to insert something into the text table, so $textId
// may be a new value, not anything already contained in $blobAddress.
- $blobAddress = 'tt:' . $textId;
+ $blobAddress = SqlBlobStore::makeAddressFromTextId( $textId );
$comment = $this->failOnNull( $rev->getComment( RevisionRecord::RAW ), 'comment' );
$user = $this->failOnNull( $rev->getUser( RevisionRecord::RAW ), 'user' );
if ( isset( $row->rev_text_id ) && $row->rev_text_id > 0 ) {
$mainSlotRow->slot_content_id = $row->rev_text_id;
- $mainSlotRow->content_address = 'tt:' . $row->rev_text_id;
+ $mainSlotRow->content_address = SqlBlobStore::makeAddressFromTextId(
+ $row->rev_text_id
+ );
}
// This is used by null-revisions
? intval( $row['slot_origin'] )
: null;
$mainSlotRow->content_address = isset( $row['text_id'] )
- ? 'tt:' . intval( $row['text_id'] )
+ ? SqlBlobStore::makeAddressFromTextId( intval( $row['text_id'] ) )
: null;
$mainSlotRow->content_size = isset( $row['len'] ) ? intval( $row['len'] ) : null;
$mainSlotRow->content_sha1 = isset( $row['sha1'] ) ? strval( $row['sha1'] ) : null;
$textId = $dbw->insertId();
- return 'tt:' . $textId;
+ return self::makeAddressFromTextId( $textId );
} catch ( MWException $e ) {
throw new BlobAccessException( $e->getMessage(), 0, $e );
}
* Currently, $address must start with 'tt:' followed by a decimal integer representing
* the old_id; if $address does not start with 'tt:', null is returned. However,
* the implementation may change to insert rows into the text table on the fly.
+ * This implies that this method cannot be static.
*
* @note This method exists for use with the text table based storage schema.
* It should not be assumed that is will function with all future kinds of content addresses.
*
- * @deprecated since 1.31, so not assume that all blob addresses refer to a row in the text
+ * @deprecated since 1.31, so don't assume that all blob addresses refer to a row in the text
* table. This method should become private once the relevant refactoring in WikiPage is
* complete.
*
return $textId;
}
+ /**
+ * Returns an address referring to content stored in the text table row with the given ID.
+ * The address schema for blobs stored in the text table is "tt:" followed by an integer
+ * that corresponds to a value of the old_id field.
+ *
+ * @deprecated since 1.31. This method should become private once the relevant refactoring
+ * in WikiPage is complete.
+ *
+ * @param int $id
+ *
+ * @return string
+ */
+ public static function makeAddressFromTextId( $id ) {
+ return 'tt:' . $id;
+ }
+
/**
* Splits a blob address into three parts: the schema, the ID, and parameters/flags.
*
$tags = $params['tags'];
// Check if user can add tags
- if ( !is_null( $tags ) ) {
+ if ( $tags !== null ) {
$ableToTag = ChangeTags::canAddTagsAccompanyingChange( $tags, $pUser );
if ( !$ableToTag->isOK() ) {
$this->dieStatus( $ableToTag );
$r['user'] = $user->getName();
$r['userid'] = $user->getId();
list( $r['added'], $r['removed'] ) = $form->doSaveUserGroups(
+ // Don't pass null to doSaveUserGroups() for array params, cast to empty array
$user, (array)$add, (array)$params['remove'],
- $params['reason'], $tags, $groupExpiries
+ $params['reason'], (array)$tags, $groupExpiries
);
$result = $this->getResult();
$services = MediaWikiServices::getInstance();
$erGroup = $services->getEventRelayerGroup();
- foreach ( $params['channels'] as $action => $channel ) {
- $params['relayers'][$action] = $erGroup->getRelayer( $channel );
- $params['channels'][$action] = $channel;
+ if ( isset( $params['channels'] ) ) {
+ foreach ( $params['channels'] as $action => $channel ) {
+ $params['relayers'][$action] = $erGroup->getRelayer( $channel );
+ $params['channels'][$action] = $channel;
+ }
}
$params['cache'] = self::newFromParams( $params['store'] );
if ( isset( $params['loggroup'] ) ) {
* Defaults to the site content language
* @return DateFormatter
*/
- public static function getInstance( $lang = null ) {
+ public static function getInstance( Language $lang = null ) {
global $wgContLang, $wgMainCacheType;
- if ( is_string( $lang ) ) {
- wfDeprecated( __METHOD__ . ' with type string for $lang', '1.31' );
- }
- $lang = $lang ? wfGetLangObj( $lang ) : $wgContLang;
+ $lang = $lang ?: $wgContLang;
$cache = ObjectCache::getLocalServerInstance( $wgMainCacheType );
static $dateFormatter = false;
namespace MediaWiki\Tests\Storage;
+use InvalidArgumentException;
use Language;
use MediaWiki\MediaWikiServices;
use MediaWiki\Storage\SqlBlobStore;
$this->assertSame( $blob, $store->getBlob( $address ) );
}
+ public function provideGetTextIdFromAddress() {
+ yield [ 'tt:17', 17 ];
+ yield [ 'xy:17', null ];
+ yield [ 'xy:xyzzy', null ];
+ }
+
+ /**
+ * @dataProvider provideGetTextIdFromAddress
+ */
+ public function testGetTextIdFromAddress( $address, $textId ) {
+ $store = $this->getBlobStore();
+ $this->assertSame( $textId, $store->getTextIdFromAddress( $address ) );
+ }
+
+ public function provideGetTextIdFromAddressInvalidArgumentException() {
+ yield [ 'tt:-17' ];
+ yield [ 'tt:xy' ];
+ yield [ 'tt:0' ];
+ yield [ 'tt:' ];
+ yield [ 'xy' ];
+ yield [ '' ];
+ }
+
+ /**
+ * @dataProvider provideGetTextIdFromAddressInvalidArgumentException
+ */
+ public function testGetTextIdFromAddressInvalidArgumentException( $address ) {
+ $this->setExpectedException( InvalidArgumentException::class );
+ $store = $this->getBlobStore();
+ $store->getTextIdFromAddress( $address );
+ }
+
+ public function testMakeAddressFromTextId() {
+ $this->assertSame( 'tt:17', SqlBlobStore::makeAddressFromTextId( 17 ) );
+ }
+
}