PortableInfobox/includes/querypage/AllinfoboxesQueryPage.php

81 lines
1.8 KiB
PHP
Raw Normal View History

<?php
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.page_namespace',
'title' => 'page.page_title',
'value' => 'page.page_id',
'infoboxes' => 'page_props.pp_value'
2018-08-03 08:49:28 +00:00
],
'conds' => [
'page.page_is_redirect' => 0,
'page.page_namespace' => NS_TEMPLATE,
'page_props.pp_value IS NOT NULL',
'page_props.pp_value != \'\''
],
'join_conds' => [
'page_props' => [
'INNER JOIN',
'page.page_id = page_props.pp_page AND page_props.pp_propname = "infoboxes"'
]
2018-08-03 08:49:28 +00:00
]
];
2021-09-10 02:52:19 +00:00
$dbr = $this->getDBLoadBalancer()->getConnectionRef( DB_REPLICA );
$subpagesBlacklist = $this->getConfig()->get( 'AllInfoboxesSubpagesBlacklist' );
foreach ( $subpagesBlacklist as $subpage ) {
2021-09-10 02:52:19 +00:00
$query['conds'][] = 'page.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 );
2017-07-12 12:21:06 +00:00
Hooks::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';
}
}