diff --git a/includes/KnowledgeGraph.php b/includes/KnowledgeGraph.php index d95cf88..3133038 100644 --- a/includes/KnowledgeGraph.php +++ b/includes/KnowledgeGraph.php @@ -581,18 +581,35 @@ public static function parseParameters( $parameters, $defaultParameters ) { * @return array */ public static function articlesInCategories( $category, $limit, $offset ) { - $options = [ + $options = [ 'LIMIT' => $limit, 'OFFSET' => $offset - ]; - $dbr = wfGetDB( DB_REPLICA ); - $res = $dbr->select( 'categorylinks', - [ 'pageid' => 'cl_from' ], - [ 'cl_to' => str_replace( ' ', '_', $category ) ], - __METHOD__, - $options - ); - $ret = []; + ]; + $dbr = wfGetDB( DB_REPLICA ); + + if ( version_compare( MW_VERSION, '1.45', '>=' ) ) { + $res = $dbr->select( + [ 'categorylinks', 'linktarget' ], + [ 'pageid' => 'cl_from' ], + [ + 'lt_title' => str_replace( ' ', '_', $category ), + 'lt_namespace' => NS_CATEGORY, + ], + __METHOD__, + $options, + [ + 'linktarget' => [ 'JOIN', 'cl_target_id = lt_id' ], + ] + ); + } else { + $res = $dbr->select( 'categorylinks', + [ 'pageid' => 'cl_from' ], + [ 'cl_to' => str_replace( ' ', '_', $category ) ], + __METHOD__, + $options + ); + } + $ret = []; foreach ( $res as $row ) { $title_ = Title::newFromID( $row->pageid ); if ( $title_ ) {