X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles_versions%22%2C%22id_article=%24id_article%22%29%20.%20%22?a=blobdiff_plain;f=includes%2Fdb%2FMWLBFactory.php;h=f0a17f7bf7ecec62e1f8e2734d20d6bb2e5bf212;hb=4ccb228bde9294d96ddcb5c255565c89dbcbf879;hp=5c79117f7887b4e1339173a13f475e37a7346eb3;hpb=6e62381aaa2e0d0ee572e3827800d05d9a5c67a4;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/db/MWLBFactory.php b/includes/db/MWLBFactory.php index 5c79117f78..f0a17f7bf7 100644 --- a/includes/db/MWLBFactory.php +++ b/includes/db/MWLBFactory.php @@ -23,6 +23,7 @@ use MediaWiki\Logger\LoggerFactory; use MediaWiki\MediaWikiServices; +use Wikimedia\Rdbms\LBFactory; use Wikimedia\Rdbms\DatabaseDomain; /** @@ -201,4 +202,30 @@ abstract class MWLBFactory { return $class; } + + public static function setSchemaAliases( LBFactory $lbFactory ) { + $mainLB = $lbFactory->getMainLB(); + $masterType = $mainLB->getServerType( $mainLB->getWriterIndex() ); + if ( $masterType === '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', + ] ); + } + } }