X-Git-Url: https://git.cyclocoop.org/%27.%24link.%27?a=blobdiff_plain;f=includes%2Fdb%2FMWLBFactory.php;h=79f787dba4b73e26b5d7af782ab57cf9c02516e4;hb=c91a71c5f608675df6205a945bdc4be29d81d21e;hp=f0a17f7bf7ecec62e1f8e2734d20d6bb2e5bf212;hpb=312c32319d701f62d49b1509e68dd43d585f3273;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/db/MWLBFactory.php b/includes/db/MWLBFactory.php index f0a17f7bf7..79f787dba4 100644 --- a/includes/db/MWLBFactory.php +++ b/includes/db/MWLBFactory.php @@ -31,6 +31,10 @@ use Wikimedia\Rdbms\DatabaseDomain; * @ingroup Database */ abstract class MWLBFactory { + + /** @var array Cache of already-logged deprecation messages */ + private static $loggedDeprecations = []; + /** * @param array $lbConf Config for LBFactory::__construct() * @param Config $mainConfig Main config object from MediaWikiServices @@ -57,6 +61,7 @@ abstract class MWLBFactory { 'connLogger' => LoggerFactory::getInstance( 'DBConnection' ), 'perfLogger' => LoggerFactory::getInstance( 'DBPerformance' ), 'errorLogger' => [ MWExceptionHandler::class, 'logException' ], + 'deprecationLogger' => [ static::class, 'logDeprecation' ], 'cliMode' => $wgCommandLineMode, 'hostname' => wfHostname(), 'readOnlyReason' => $readOnlyMode->getReason(), @@ -203,10 +208,8 @@ abstract class MWLBFactory { return $class; } - public static function setSchemaAliases( LBFactory $lbFactory ) { - $mainLB = $lbFactory->getMainLB(); - $masterType = $mainLB->getServerType( $mainLB->getWriterIndex() ); - if ( $masterType === 'mysql' ) { + public static function setSchemaAliases( LBFactory $lbFactory, Config $config ) { + if ( $config->get( 'DBtype' ) === 'mysql' ) { /** * When SQLite indexes were introduced in r45764, it was noted that * SQLite requires index names to be unique within the whole database, @@ -228,4 +231,22 @@ abstract class MWLBFactory { ] ); } } + + /** + * Log a database deprecation warning + * @param string $msg Deprecation message + */ + public static function logDeprecation( $msg ) { + global $wgDevelopmentWarnings; + + if ( isset( self::$loggedDeprecations[$msg] ) ) { + return; + } + self::$loggedDeprecations[$msg] = true; + + if ( $wgDevelopmentWarnings ) { + trigger_error( $msg, E_USER_DEPRECATED ); + } + wfDebugLog( 'deprecated', $msg, 'private' ); + } }