X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fdb%2FMWLBFactory.php;h=5daf9ef8fcbe7e7bb0af71b8e4dc3b2bd4e9be68;hp=0c17840e4a178a132819df2014d907433b4475e1;hb=c8987d7c3e30a7d1c2e917cb6a9b0114281703e8;hpb=6162ec0f3551719420bba32fbac6e9b0e9a026fa diff --git a/includes/db/MWLBFactory.php b/includes/db/MWLBFactory.php index 0c17840e4a..5daf9ef8fc 100644 --- a/includes/db/MWLBFactory.php +++ b/includes/db/MWLBFactory.php @@ -23,7 +23,6 @@ use MediaWiki\Config\ServiceOptions; use MediaWiki\Logger\LoggerFactory; -use Wikimedia\Rdbms\LBFactory; use Wikimedia\Rdbms\DatabaseDomain; /** @@ -36,12 +35,10 @@ abstract class MWLBFactory { private static $loggedDeprecations = []; /** - * TODO Make this a const when HHVM support is dropped (T192166) - * * @var array * @since 1.34 */ - public static $applyDefaultConfigOptions = [ + public const APPLY_DEFAULT_CONFIG_OPTIONS = [ 'DBcompress', 'DBDefaultGroup', 'DBmwschema', @@ -66,7 +63,7 @@ abstract class MWLBFactory { * @param array $lbConf Config for LBFactory::__construct() * @param ServiceOptions $options * @param ConfiguredReadOnlyMode $readOnlyMode - * @param BagOStuff $srvCace + * @param BagOStuff $srvCache * @param BagOStuff $mainStash * @param WANObjectCache $wanCache * @return array @@ -76,11 +73,11 @@ abstract class MWLBFactory { array $lbConf, ServiceOptions $options, ConfiguredReadOnlyMode $readOnlyMode, - BagOStuff $srvCace, + BagOStuff $srvCache, BagOStuff $mainStash, WANObjectCache $wanCache ) { - $options->assertRequiredOptions( self::$applyDefaultConfigOptions ); + $options->assertRequiredOptions( self::APPLY_DEFAULT_CONFIG_OPTIONS ); global $wgCommandLineMode; @@ -159,7 +156,7 @@ abstract class MWLBFactory { $options->get( 'DBprefix' ) ); - $lbConf = self::injectObjectCaches( $lbConf, $srvCace, $mainStash, $wanCache ); + $lbConf = self::injectObjectCaches( $lbConf, $srvCache, $mainStash, $wanCache ); return $lbConf; } @@ -168,7 +165,7 @@ abstract class MWLBFactory { * @return array */ private static function getDbTypesWithSchemas() { - return [ 'postgres', 'mssql' ]; + return [ 'postgres' ]; } /** @@ -193,16 +190,6 @@ abstract class MWLBFactory { // Work around the reserved word usage in MediaWiki schema 'keywordTableMap' => [ 'user' => 'mwuser', 'text' => 'pagecontent' ] ]; - } elseif ( $server['type'] === 'oracle' ) { - $server += [ - // Work around the reserved word usage in MediaWiki schema - 'keywordTableMap' => [ 'user' => 'mwuser', 'text' => 'pagecontent' ] - ]; - } elseif ( $server['type'] === 'mssql' ) { - $server += [ - 'port' => $options->get( 'DBport' ), - 'useWindowsAuth' => $options->get( 'DBWindowsAuthentication' ) - ]; } if ( in_array( $server['type'], self::getDbTypesWithSchemas(), true ) ) { @@ -232,6 +219,11 @@ abstract class MWLBFactory { private static function injectObjectCaches( array $lbConf, BagOStuff $sCache, BagOStuff $mStash, WANObjectCache $wCache ) { + // Fallback if APC style caching is not an option + if ( $sCache instanceof EmptyBagOStuff ) { + $sCache = new HashBagOStuff( [ 'maxKeys' => 100 ] ); + } + // Use APC/memcached style caching, but avoids loops with CACHE_DB (T141804) if ( $sCache->getQoS( $sCache::ATTR_EMULATION ) > $sCache::QOS_EMULATION_SQL ) { $lbConf['srvCache'] = $sCache; @@ -364,35 +356,6 @@ abstract class MWLBFactory { 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( [ - 'ar_usertext_timestamp' => 'usertext_timestamp', - 'un_user_id' => 'user_id', - 'un_user_ip' => 'user_ip', - ] ); - } - } - /** * Log a database deprecation warning * @param string $msg Deprecation message