*
* @file
*/
+use MediaWiki\MediaWikiServices;
class CategoryViewer extends ContextSource {
/** @var int */
$link = null;
Hooks::run( 'CategoryViewer::generateLink', [ $type, $title, $html, &$link ] );
if ( $link === null ) {
- $link = Linker::link( $title, $html );
+ $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
+ if ( $html !== null ) {
+ $html = new HtmlArmor( $html );
+ }
+ $link = $linkRenderer->makeLink( $title, $html );
}
if ( $isRedirect ) {
$link = '<span class="redirect-in-category">' . $link . '</span>';
}
function doCategoryQuery() {
- $dbr = wfGetDB( DB_SLAVE, 'category' );
+ $dbr = wfGetDB( DB_REPLICA, 'category' );
$this->nextPage = [
'page' => null,
$res = $dbr->select(
[ 'page', 'categorylinks', 'category' ],
- [ 'page_id', 'page_title', 'page_namespace', 'page_len',
- 'page_is_redirect', 'cl_sortkey', 'cat_id', 'cat_title',
- 'cat_subcats', 'cat_pages', 'cat_files',
- 'cl_sortkey_prefix', 'cl_collation' ],
+ array_merge(
+ LinkCache::getSelectFields(),
+ [
+ 'page_namespace',
+ 'page_title',
+ 'cl_sortkey',
+ 'cat_id',
+ 'cat_title',
+ 'cat_subcats',
+ 'cat_pages',
+ 'cat_files',
+ 'cl_sortkey_prefix',
+ 'cl_collation'
+ ]
+ ),
array_merge( [ 'cl_to' => $this->title->getDBkey() ], $extraConds ),
__METHOD__,
[
);
Hooks::run( 'CategoryViewer::doCategoryQuery', [ $type, $res ] );
+ $linkCache = MediaWikiServices::getInstance()->getLinkCache();
$count = 0;
foreach ( $res as $row ) {
$title = Title::newFromRow( $row );
+ $linkCache->addGoodLinkObjFromRow( $title, $row );
+
if ( $row->cl_collation === '' ) {
// Hack to make sure that while updating from 1.16 schema
// and db is inconsistent, that the sky doesn't fall.
}
/**
- * Format a list of articles chunked by letter in a three-column
- * list, ordered vertically.
+ * Format a list of articles chunked by letter in a three-column list, ordered
+ * vertically. This is used for categories with a significant number of pages.
*
* TODO: Take the headers into account when creating columns, so they're
* more visually equal.
*
* TODO: shortList and columnList are similar, need merging
*
- * @param array $articles
- * @param string[] $articles_start_char
- * @return string
+ * @param string[] $articles HTML links to each article
+ * @param string[] $articles_start_char The header characters for each article
+ * @return string HTML to output
* @private
*/
static function columnList( $articles, $articles_start_char ) {
}
/**
- * Format a list of articles chunked by letter in a bullet list.
- * @param array $articles
- * @param string[] $articles_start_char
- * @return string
+ * Format a list of articles chunked by letter in a bullet list. This is used
+ * for categories with a small number of pages (when columns aren't needed).
+ * @param string[] $articles HTML links to each article
+ * @param string[] $articles_start_char The header characters for each article
+ * @return string HTML to output
* @private
*/
static function shortList( $articles, $articles_start_char ) {