Use a maintenance database connection to call fieldExists

IndexPager::$mDb is documented as IDatabase, that interface does not
implement fieldExists. To use the correct static types get a
IMaintainableDatabase instead from the load balancer and call
fieldExists

Bug: T343495
Change-Id: I6a07ff2115de781e26f272126a72a9fbdef30223
This commit is contained in:
Umherirrender 2023-08-04 11:56:02 +02:00
parent 35a88c7816
commit 7009ca8390

View file

@ -128,12 +128,13 @@ class LintErrorsPager extends TablePager {
if ( $this->categoryId !== null ) {
$conds[ 'linter_cat' ] = $this->categoryId;
}
$mwServices = MediaWikiServices::getInstance();
$config = $mwServices->getMainConfig();
$dbMaintenance = $mwServices->getDBLoadBalancer()->getMaintenanceConnectionRef( DB_REPLICA );
if ( $this->namespace !== null ) {
$comp_op = $this->invertNamespace ? '!=' : '=';
$mwServices = MediaWikiServices::getInstance();
$config = $mwServices->getMainConfig();
$enableUseNamespaceColumnStage = $config->get( 'LinterUseNamespaceColumnStage' );
$fieldExists = $this->mDb->fieldExists( 'linter', 'linter_namespace', __METHOD__ );
$fieldExists = $dbMaintenance->fieldExists( 'linter', 'linter_namespace', __METHOD__ );
if ( !$enableUseNamespaceColumnStage || !$fieldExists ) {
$conds[] = "page_namespace $comp_op " . $this->mDb->addQuotes( $this->namespace );
} else {
@ -148,10 +149,8 @@ class LintErrorsPager extends TablePager {
$conds[] = 'page_title' . $this->mDb->buildLike( $this->title, $this->mDb->anyString() );
}
$mwServices = MediaWikiServices::getInstance();
$config = $mwServices->getMainConfig();
$enableUserInterfaceTagAndTemplateStage = $config->get( 'LinterUserInterfaceTagAndTemplateStage' );
$fieldTagExists = $this->mDb->fieldExists( 'linter', 'linter_tag', __METHOD__ );
$fieldTagExists = $dbMaintenance->fieldExists( 'linter', 'linter_tag', __METHOD__ );
if ( $enableUserInterfaceTagAndTemplateStage && $fieldTagExists ) {
switch ( $this->throughTemplate ) {
case 'with':