Moved $wgQueryPages stuff out of the global scope and into a function
Change-Id: Ica034bdad89133bfce0b4238d62ed00865936644
This commit is contained in:
parent
2bb6da2cd0
commit
f508561f7b
6 changed files with 68 additions and 75 deletions
|
|
@ -48,6 +48,8 @@ production.
|
|||
allows more than one value of $wgLocalInterwiki to be specified and
|
||||
understood by the parser. The value of $wgLocalInterwiki is automatically
|
||||
prepended to the start of this array.
|
||||
* $wgQueryPages has been removed. Query Pages should be added to by using the
|
||||
wgQueryPages hook.
|
||||
|
||||
=== New features in 1.23 ===
|
||||
* ResourceLoader can utilize the Web Storage API to cache modules client-side.
|
||||
|
|
|
|||
|
|
@ -2916,9 +2916,9 @@ run a MediaWiki cli script.
|
|||
&$options: Associative array of options, may contain the 'php' and 'wrapper'
|
||||
keys
|
||||
|
||||
'wgQueryPages': Called when initialising $wgQueryPages, use this to add new
|
||||
query pages to be updated with maintenance/updateSpecialPages.php.
|
||||
$query: $wgQueryPages itself
|
||||
'wgQueryPages': Called when initialising list of QueryPage subclasses, use this
|
||||
to add new query pages to be updated with maintenance/updateSpecialPages.php.
|
||||
$qp: The list of QueryPages
|
||||
|
||||
'XmlDumpWriterOpenPage': Called at the end of XmlDumpWriter::openPage, to allow
|
||||
extra metadata to be added.
|
||||
|
|
|
|||
|
|
@ -21,57 +21,6 @@
|
|||
* @ingroup SpecialPage
|
||||
*/
|
||||
|
||||
/**
|
||||
* List of query page classes and their associated special pages,
|
||||
* for periodic updates.
|
||||
*
|
||||
* DO NOT CHANGE THIS LIST without testing that
|
||||
* maintenance/updateSpecialPages.php still works.
|
||||
*/
|
||||
global $wgQueryPages; // not redundant
|
||||
$wgQueryPages = array(
|
||||
// QueryPage subclass, Special page name, Limit (false for none, none for the default)
|
||||
// ----------------------------------------------------------------------------
|
||||
array( 'AncientPagesPage', 'Ancientpages' ),
|
||||
array( 'BrokenRedirectsPage', 'BrokenRedirects' ),
|
||||
array( 'DeadendPagesPage', 'Deadendpages' ),
|
||||
array( 'DoubleRedirectsPage', 'DoubleRedirects' ),
|
||||
array( 'FileDuplicateSearchPage', 'FileDuplicateSearch' ),
|
||||
array( 'LinkSearchPage', 'LinkSearch' ),
|
||||
array( 'ListredirectsPage', 'Listredirects' ),
|
||||
array( 'LonelyPagesPage', 'Lonelypages' ),
|
||||
array( 'LongPagesPage', 'Longpages' ),
|
||||
array( 'MIMEsearchPage', 'MIMEsearch' ),
|
||||
array( 'MostcategoriesPage', 'Mostcategories' ),
|
||||
array( 'MostimagesPage', 'Mostimages' ),
|
||||
array( 'MostinterwikisPage', 'Mostinterwikis' ),
|
||||
array( 'MostlinkedCategoriesPage', 'Mostlinkedcategories' ),
|
||||
array( 'MostlinkedtemplatesPage', 'Mostlinkedtemplates' ),
|
||||
array( 'MostlinkedPage', 'Mostlinked' ),
|
||||
array( 'MostrevisionsPage', 'Mostrevisions' ),
|
||||
array( 'FewestrevisionsPage', 'Fewestrevisions' ),
|
||||
array( 'ShortPagesPage', 'Shortpages' ),
|
||||
array( 'UncategorizedCategoriesPage', 'Uncategorizedcategories' ),
|
||||
array( 'UncategorizedPagesPage', 'Uncategorizedpages' ),
|
||||
array( 'UncategorizedImagesPage', 'Uncategorizedimages' ),
|
||||
array( 'UncategorizedTemplatesPage', 'Uncategorizedtemplates' ),
|
||||
array( 'UnusedCategoriesPage', 'Unusedcategories' ),
|
||||
array( 'UnusedimagesPage', 'Unusedimages' ),
|
||||
array( 'WantedCategoriesPage', 'Wantedcategories' ),
|
||||
array( 'WantedFilesPage', 'Wantedfiles' ),
|
||||
array( 'WantedPagesPage', 'Wantedpages' ),
|
||||
array( 'WantedTemplatesPage', 'Wantedtemplates' ),
|
||||
array( 'UnwatchedPagesPage', 'Unwatchedpages' ),
|
||||
array( 'UnusedtemplatesPage', 'Unusedtemplates' ),
|
||||
array( 'WithoutInterwikiPage', 'Withoutinterwiki' ),
|
||||
);
|
||||
wfRunHooks( 'wgQueryPages', array( &$wgQueryPages ) );
|
||||
|
||||
global $wgDisableCounters;
|
||||
if ( !$wgDisableCounters ) {
|
||||
$wgQueryPages[] = array( 'PopularPagesPage', 'Popularpages' );
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a class for doing query pages; since they're almost all the same,
|
||||
* we factor out some of the functionality into a superclass, and let
|
||||
|
|
@ -108,6 +57,64 @@ abstract class QueryPage extends SpecialPage {
|
|||
*/
|
||||
protected $shownavigation = true;
|
||||
|
||||
/**
|
||||
* Get a list of query page classes and their associated special pages,
|
||||
* for periodic updates.
|
||||
*
|
||||
* DO NOT CHANGE THIS LIST without testing that
|
||||
* maintenance/updateSpecialPages.php still works.
|
||||
* @return array
|
||||
*/
|
||||
public static function getPages() {
|
||||
global $wgDisableCounters;
|
||||
static $qp = null;
|
||||
|
||||
if ( $qp === null ) {
|
||||
// QueryPage subclass, Special page name
|
||||
$qp = array(
|
||||
array( 'AncientPagesPage', 'Ancientpages' ),
|
||||
array( 'BrokenRedirectsPage', 'BrokenRedirects' ),
|
||||
array( 'DeadendPagesPage', 'Deadendpages' ),
|
||||
array( 'DoubleRedirectsPage', 'DoubleRedirects' ),
|
||||
array( 'FileDuplicateSearchPage', 'FileDuplicateSearch' ),
|
||||
array( 'LinkSearchPage', 'LinkSearch' ),
|
||||
array( 'ListredirectsPage', 'Listredirects' ),
|
||||
array( 'LonelyPagesPage', 'Lonelypages' ),
|
||||
array( 'LongPagesPage', 'Longpages' ),
|
||||
array( 'MIMEsearchPage', 'MIMEsearch' ),
|
||||
array( 'MostcategoriesPage', 'Mostcategories' ),
|
||||
array( 'MostimagesPage', 'Mostimages' ),
|
||||
array( 'MostinterwikisPage', 'Mostinterwikis' ),
|
||||
array( 'MostlinkedCategoriesPage', 'Mostlinkedcategories' ),
|
||||
array( 'MostlinkedtemplatesPage', 'Mostlinkedtemplates' ),
|
||||
array( 'MostlinkedPage', 'Mostlinked' ),
|
||||
array( 'MostrevisionsPage', 'Mostrevisions' ),
|
||||
array( 'FewestrevisionsPage', 'Fewestrevisions' ),
|
||||
array( 'ShortPagesPage', 'Shortpages' ),
|
||||
array( 'UncategorizedCategoriesPage', 'Uncategorizedcategories' ),
|
||||
array( 'UncategorizedPagesPage', 'Uncategorizedpages' ),
|
||||
array( 'UncategorizedImagesPage', 'Uncategorizedimages' ),
|
||||
array( 'UncategorizedTemplatesPage', 'Uncategorizedtemplates' ),
|
||||
array( 'UnusedCategoriesPage', 'Unusedcategories' ),
|
||||
array( 'UnusedimagesPage', 'Unusedimages' ),
|
||||
array( 'WantedCategoriesPage', 'Wantedcategories' ),
|
||||
array( 'WantedFilesPage', 'Wantedfiles' ),
|
||||
array( 'WantedPagesPage', 'Wantedpages' ),
|
||||
array( 'WantedTemplatesPage', 'Wantedtemplates' ),
|
||||
array( 'UnwatchedPagesPage', 'Unwatchedpages' ),
|
||||
array( 'UnusedtemplatesPage', 'Unusedtemplates' ),
|
||||
array( 'WithoutInterwikiPage', 'Withoutinterwiki' ),
|
||||
);
|
||||
wfRunHooks( 'wgQueryPages', array( &$qp ) );
|
||||
|
||||
if ( !$wgDisableCounters ) {
|
||||
$qp[] = array( 'PopularPagesPage', 'Popularpages' );
|
||||
}
|
||||
}
|
||||
|
||||
return $qp;
|
||||
}
|
||||
|
||||
/**
|
||||
* A mutator for $this->listoutput;
|
||||
*
|
||||
|
|
|
|||
|
|
@ -34,15 +34,10 @@ class ApiQueryQueryPage extends ApiQueryGeneratorBase {
|
|||
|
||||
public function __construct( $query, $moduleName ) {
|
||||
parent::__construct( $query, $moduleName, 'qp' );
|
||||
// We need to do this to make sure $wgQueryPages is set up
|
||||
// This SUCKS
|
||||
global $IP;
|
||||
require_once "$IP/includes/QueryPage.php";
|
||||
|
||||
// Build mapping from special page names to QueryPage classes
|
||||
global $wgQueryPages, $wgAPIUselessQueryPages;
|
||||
global $wgAPIUselessQueryPages;
|
||||
$this->qpMap = array();
|
||||
foreach ( $wgQueryPages as $page ) {
|
||||
foreach ( QueryPage::getPages() as $page ) {
|
||||
if ( !in_array( $page[1], $wgAPIUselessQueryPages ) ) {
|
||||
$this->qpMap[$page[1]] = $page[0];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,16 +40,13 @@ class UpdateSpecialPages extends Maintenance {
|
|||
}
|
||||
|
||||
public function execute() {
|
||||
global $IP, $wgQueryPages, $wgQueryCacheLimit, $wgDisableQueryPageUpdate;
|
||||
global $wgQueryCacheLimit, $wgDisableQueryPageUpdate;
|
||||
|
||||
$dbw = wfGetDB( DB_MASTER );
|
||||
|
||||
$this->doSpecialPageCacheUpdates( $dbw );
|
||||
|
||||
// This is needed to initialise $wgQueryPages
|
||||
require_once "$IP/includes/QueryPage.php";
|
||||
|
||||
foreach ( $wgQueryPages as $page ) {
|
||||
foreach ( QueryPage::getPages() as $page ) {
|
||||
list( $class, $special ) = $page;
|
||||
$limit = isset( $page[2] ) ? $page[2] : null;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,13 +8,6 @@
|
|||
* @group Database
|
||||
*/
|
||||
|
||||
if ( !defined( 'MEDIAWIKI' ) ) {
|
||||
die( 1 );
|
||||
}
|
||||
|
||||
global $IP;
|
||||
require_once "$IP/includes/QueryPage.php"; // Needed to populate $wgQueryPages
|
||||
|
||||
/**
|
||||
* @covers QueryPage<extended>
|
||||
*/
|
||||
|
|
@ -41,8 +34,7 @@ class QueryAllSpecialPagesTest extends MediaWikiTestCase {
|
|||
function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
global $wgQueryPages;
|
||||
foreach ( $wgQueryPages as $page ) {
|
||||
foreach ( QueryPage::getPages() as $page ) {
|
||||
$class = $page[0];
|
||||
if ( !in_array( $class, $this->manualTest ) ) {
|
||||
$this->queryPages[$class] = new $class;
|
||||
|
|
|
|||
Loading…
Reference in a new issue