PortableInfobox/includes/querypage/AllInfoboxesQueryPage.php

85 lines
1.8 KiB
PHP
Raw Normal View History

<?php
use MediaWiki\MediaWikiServices;
2021-09-12 16:42:37 +00:00
class AllInfoboxesQueryPage extends PageQueryPage {
2021-09-10 02:52:19 +00:00
private const ALL_INFOBOXES_TYPE = 'AllInfoboxes';
2021-09-10 02:52:19 +00:00
public function __construct() {
parent::__construct( self::ALL_INFOBOXES_TYPE );
}
2021-09-10 02:52:19 +00:00
public function getQueryInfo() {
$query = [
'tables' => [ 'page', 'page_props' ],
2018-08-03 08:49:28 +00:00
'fields' => [
'namespace' => 'page_namespace',
'title' => 'page_title',
'value' => 'page_id',
'infoboxes' => 'pp_value'
2018-08-03 08:49:28 +00:00
],
'conds' => [
'page_is_redirect' => 0,
'page_namespace' => NS_TEMPLATE,
'pp_value IS NOT NULL',
'pp_value != \'\''
],
'join_conds' => [
'page_props' => [
'INNER JOIN',
'page_id = pp_page AND pp_propname = "infoboxes"'
]
2018-08-03 08:49:28 +00:00
]
];
2022-12-07 00:19:24 +00:00
$dbr = $this->getDBLoadBalancer()->getConnection( DB_REPLICA );
2021-09-10 02:52:19 +00:00
$subpagesBlacklist = $this->getConfig()->get( 'AllInfoboxesSubpagesBlacklist' );
foreach ( $subpagesBlacklist as $subpage ) {
$query['conds'][] = 'page_title NOT ' . $dbr->buildLike( "/{$subpage}" );
}
return $query;
}
/**
* Update the querycache table
*
2018-08-06 13:16:36 +00:00
* @see QueryPage::recache
*
* @param bool $limit Limit for SQL statement
2018-08-06 13:16:36 +00:00
* @param bool $ignoreErrors Whether to ignore database errors
*
* @return int number of rows updated
*/
public function recache( $limit = false, $ignoreErrors = true ) {
$res = parent::recache( $limit, $ignoreErrors );
$hookContainer = MediaWikiServices::getInstance()->getHookContainer();
$hookContainer->run( 'AllInfoboxesQueryRecached' );
2018-08-03 08:49:28 +00:00
return $res;
}
2021-09-10 02:52:19 +00:00
public function isExpensive() {
return true;
}
protected function getOrderFields() {
return [ 'title' ];
}
protected function getCacheOrderFields() {
return $this->getOrderFields();
}
protected function sortDescending() {
return false;
}
protected function getGroupName() {
return 'pages';
}
}