diff --git a/includes/HookHandlers/RelatedArticles.php b/includes/HookHandlers/RelatedArticles.php index a19e3e7..3df0c9f 100644 --- a/includes/HookHandlers/RelatedArticles.php +++ b/includes/HookHandlers/RelatedArticles.php @@ -5,8 +5,8 @@ use Config; use ExtensionRegistry; use MediaWiki\MediaWikiServices; -use Title; use MediaWiki\Page\PageStoreRecord; +use Title; use Wikimedia\Rdbms\DBConnRef; use Wikimedia\Rdbms\ILoadBalancer; use Wikimedia\Rdbms\SelectQueryBuilder; @@ -139,7 +139,7 @@ private function makeTitlesFromHereSQL( Title $title, DBConnRef $dbr, $targetNam // Hide redirects 'rd_from' => null, ] ) - ->fields( self::getSelectFields() ) + ->fields( self::getSelectFields() ) ->getSQL(); } @@ -173,7 +173,7 @@ private function makeRedirectedTitlesFromHereSQL( Title $title, DBConnRef $dbr, // Only redirects 'rd_from != 0', ] ) - ->fields( self::getSelectFields( 'target' ) ) + ->fields( self::getSelectFields( 'target' ) ) ->getSQL(); } @@ -203,7 +203,7 @@ private function makeTitlesToHereSQL( Title $title, DBConnRef $dbr, $targetNames ->conds( $targetNamespaces ? [ 'page_namespace' => $targetNamespaces, ] : [] ) - ->fields( self::getSelectFields() ) + ->fields( self::getSelectFields() ) ->getSQL(); } @@ -245,6 +245,10 @@ private function makeTitlesToRedirectsOfHereSQL( Title $title, DBConnRef $dbr, $ ->getSQL(); } + /** + * @param string|null $table + * @return array + */ public static function getSelectFields( $table = null ) { $pageLanguageUseDB = MediaWikiServices::getInstance()->getMainConfig()->get( 'PageLanguageUseDB' ); @@ -262,7 +266,8 @@ public static function getSelectFields( $table = null ) { } if ( $table ) { - foreach( $fields as $f ) { + $fieldMap = []; + foreach ( $fields as $f ) { $fieldMap[$f] = "$table.$f"; } return $fieldMap;