);
$class = MWLBFactory::getLBFactoryClass( $lbConf );
- $instance = new $class( $lbConf );
- MWLBFactory::setSchemaAliases( $instance, $mainConfig->get( 'DBtype' ) );
-
- return $instance;
+ return new $class( $lbConf );
},
'EventRelayerGroup' => function ( MediaWikiServices $services ) : EventRelayerGroup {
}
if ( $this->getParameter( 'curtimestamp' ) ) {
- $result->addValue( null, 'curtimestamp', wfTimestamp( TS_ISO_8601, time() ),
- ApiResult::NO_SIZE_CHECK );
+ $result->addValue( null, 'curtimestamp', wfTimestamp( TS_ISO_8601 ), ApiResult::NO_SIZE_CHECK );
}
if ( $this->getParameter( 'responselanginfo' ) ) {
use MediaWiki\Config\ServiceOptions;
use MediaWiki\Logger\LoggerFactory;
-use Wikimedia\Rdbms\LBFactory;
use Wikimedia\Rdbms\DatabaseDomain;
/**
return $class;
}
- /**
- * @param LBFactory $lbFactory
- * @param string $dbType 'mysql', 'sqlite', etc.
- * @internal For use with service wiring
- */
- public static function setSchemaAliases( LBFactory $lbFactory, $dbType ) {
- if ( $dbType === 'mysql' ) {
- /**
- * When SQLite indexes were introduced in r45764, it was noted that
- * SQLite requires index names to be unique within the whole database,
- * not just within a schema. As discussed in CR r45819, to avoid the
- * need for a schema change on existing installations, the indexes
- * were implicitly mapped from the new names to the old names.
- *
- * This mapping can be removed if DB patches are introduced to alter
- * the relevant tables in existing installations. Note that because
- * this index mapping applies to table creation, even new installations
- * of MySQL have the old names (except for installations created during
- * a period where this mapping was inappropriately removed, see
- * T154872).
- */
- $lbFactory->setIndexAliases( [
- 'un_user_id' => 'user_id',
- 'un_user_ip' => 'user_ip',
- ] );
- }
- }
-
/**
* Log a database deprecation warning
* @param string $msg Deprecation message
'patch-drop-archive-ar_usertext_timestamp.sql' ],
[ 'dropIndex', 'archive', 'usertext_timestamp', 'patch-drop-archive-usertext_timestamp.sql' ],
[ 'dropField', 'logging', 'log_user', 'patch-drop-user-fields.sql' ],
+ [ 'addIndex', 'user_newtalk', 'un_user_ip', 'patch-rename-mysql-user_newtalk-indexes.sql' ],
];
}
--- /dev/null
+-- T233240: The indexes on `user_newtalk` may be named `un_user_id`/`un_user_ip`
+-- or `user_id`/`user_ip`. At least it won't be both or mixed. Rename them to
+-- the former.
+
+-- Do not use the /*i*/ hack here!
+ALTER TABLE /*_*/user_newtalk
+ DROP INDEX user_id,
+ DROP INDEX user_ip,
+ ADD INDEX un_user_id (user_id),
+ ADD INDEX un_user_ip (user_ip);
use Wikimedia\Rdbms\DBQueryError;
use Wikimedia\TestingAccessWrapper;
+use Wikimedia\Timestamp\ConvertibleTimestamp;
/**
* @group API
}
public function testAddRequestedFieldsCurTimestamp() {
+ // Fake timestamp for better testability, CI can sometimes take
+ // unreasonably long to run the simple test request here.
+ $reset = ConvertibleTimestamp::setFakeTime( '20190102030405' );
+
$req = new FauxRequest( [
'action' => 'query',
'meta' => 'siteinfo',
$api = new ApiMain( $req );
$api->execute();
$timestamp = $api->getResult()->getResultData()['curtimestamp'];
- $this->assertLessThanOrEqual( 1, abs( strtotime( $timestamp ) - time() ) );
+ $this->assertSame( '2019-01-02T03:04:05Z', $timestamp );
}
public function testAddRequestedFieldsResponseLangInfo() {
}
public function testContinuation() {
- // We make lots and lots of URL protocols that are each 100 bytes
+ // Use $wgUrlProtocols to forge the size of the API query
global $wgAPIMaxResultSize, $wgUrlProtocols;
- $this->setMwGlobals( 'wgUrlProtocols', [] );
+ $protocol = 'foo://';
- // Just under the limit
- $chunks = $wgAPIMaxResultSize / 100 - 1;
-
- for ( $i = 0; $i < $chunks; $i++ ) {
- $wgUrlProtocols[] = substr( str_repeat( "$i ", 50 ), 0, 100 );
- }
+ $this->setMwGlobals( 'wgUrlProtocols', [ $protocol ] );
+ $this->setMwGlobals( 'wgAPIMaxResultSize', strlen( $protocol ) );
$res = $this->doApiRequest( [
'action' => 'query',