mirror of
https://github.com/Universal-Omega/DynamicPageList3
synced 2024-11-23 15:56:50 +00:00
Support MediaWiki 1.39 for actor and templatelinks migration (#188)
This adds support for 1.39, and drops support for older versions, since 1.39 is the current LTS release.
This commit is contained in:
parent
afb60b4105
commit
8dd8d03d61
160
.github/workflows/mediawiki-tests.yml
vendored
160
.github/workflows/mediawiki-tests.yml
vendored
|
@ -13,41 +13,13 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
# Latest stable MediaWiki - PHP 7.3 (phan)
|
||||
- mw: 'REL1_36'
|
||||
php: 7.3
|
||||
php-docker: 73
|
||||
experimental: false
|
||||
stage: phan
|
||||
|
||||
# Latest stable MediaWiki - PHP 7.4 (phan)
|
||||
- mw: 'REL1_36'
|
||||
- mw: 'REL1_39'
|
||||
php: 7.4
|
||||
php-docker: 74
|
||||
experimental: false
|
||||
stage: phan
|
||||
|
||||
# Latest MediaWiki release branch - PHP 7.3 (phan)
|
||||
- mw: 'REL1_37'
|
||||
php: 7.3
|
||||
php-docker: 73
|
||||
experimental: true
|
||||
stage: phan
|
||||
|
||||
# Latest MediaWiki release branch - PHP 7.4 (phan)
|
||||
- mw: 'REL1_37'
|
||||
php: 7.4
|
||||
php-docker: 74
|
||||
experimental: true
|
||||
stage: phan
|
||||
|
||||
# Latest MediaWiki master - PHP 7.3 (phan)
|
||||
- mw: 'master'
|
||||
php: 7.3
|
||||
php-docker: 73
|
||||
experimental: true
|
||||
stage: phan
|
||||
|
||||
# Latest MediaWiki master - PHP 7.4 (phan)
|
||||
- mw: 'master'
|
||||
php: 7.4
|
||||
|
@ -55,62 +27,20 @@ jobs:
|
|||
experimental: true
|
||||
stage: phan
|
||||
|
||||
# Latest stable MediaWiki - PHP 7.3 (coverage)
|
||||
- mw: 'REL1_36'
|
||||
php: 7.3
|
||||
php-docker: 73
|
||||
experimental: false
|
||||
stage: coverage
|
||||
|
||||
# Latest MediaWiki release branch - PHP 7.3 (coverage)
|
||||
- mw: 'REL1_37'
|
||||
php: 7.3
|
||||
php-docker: 73
|
||||
experimental: false
|
||||
stage: coverage
|
||||
|
||||
# Latest MediaWiki master - PHP 7.3 (coverage)
|
||||
# Latest MediaWiki master - PHP 7.4 (coverage)
|
||||
- mw: 'master'
|
||||
php: 7.3
|
||||
php-docker: 73
|
||||
php: 7.4
|
||||
php-docker: 74
|
||||
experimental: false
|
||||
stage: coverage
|
||||
|
||||
# Latest stable MediaWiki - PHP 7.3 (phpunit-unit)
|
||||
- mw: 'REL1_36'
|
||||
php: 7.3
|
||||
php-docker: 73
|
||||
experimental: false
|
||||
stage: phpunit-unit
|
||||
|
||||
# Latest stable MediaWiki - PHP 7.4 (phpunit-unit)
|
||||
- mw: 'REL1_36'
|
||||
- mw: 'REL1_39'
|
||||
php: 7.4
|
||||
php-docker: 74
|
||||
experimental: false
|
||||
stage: phpunit-unit
|
||||
|
||||
# Latest MediaWiki release branch - PHP 7.3 (phpunit-unit)
|
||||
- mw: 'REL1_37'
|
||||
php: 7.3
|
||||
php-docker: 73
|
||||
experimental: false
|
||||
stage: phpunit-unit
|
||||
|
||||
# Latest MediaWiki release branch - PHP 7.4 (phpunit-unit)
|
||||
- mw: 'REL1_37'
|
||||
php: 7.4
|
||||
php-docker: 74
|
||||
experimental: false
|
||||
stage: phpunit-unit
|
||||
|
||||
# Latest MediaWiki master - PHP 7.3 (phpunit-unit)
|
||||
- mw: 'master'
|
||||
php: 7.3
|
||||
php-docker: 73
|
||||
experimental: false
|
||||
stage: phpunit-unit
|
||||
|
||||
# Latest MediaWiki master - PHP 7.4 (phpunit-unit)
|
||||
- mw: 'master'
|
||||
php: 7.4
|
||||
|
@ -118,41 +48,13 @@ jobs:
|
|||
experimental: false
|
||||
stage: phpunit-unit
|
||||
|
||||
# Latest stable MediaWiki - PHP 7.3 (phpunit)
|
||||
- mw: 'REL1_36'
|
||||
php: 7.3
|
||||
php-docker: 73
|
||||
experimental: false
|
||||
stage: phpunit
|
||||
|
||||
# Latest stable MediaWiki - PHP 7.4 (phpunit)
|
||||
- mw: 'REL1_36'
|
||||
- mw: 'REL1_39'
|
||||
php: 7.4
|
||||
php-docker: 74
|
||||
experimental: false
|
||||
stage: phpunit
|
||||
|
||||
# Latest MediaWiki release branch - PHP 7.3 (phpunit)
|
||||
- mw: 'REL1_37'
|
||||
php: 7.3
|
||||
php-docker: 73
|
||||
experimental: false
|
||||
stage: phpunit
|
||||
|
||||
# Latest MediaWiki release branch - PHP 7.4 (phpunit)
|
||||
- mw: 'REL1_37'
|
||||
php: 7.4
|
||||
php-docker: 74
|
||||
experimental: false
|
||||
stage: phpunit
|
||||
|
||||
# Latest MediaWiki master - PHP 7.3 (phpunit)
|
||||
- mw: 'master'
|
||||
php: 7.3
|
||||
php-docker: 73
|
||||
experimental: false
|
||||
stage: phpunit
|
||||
|
||||
# Latest MediaWiki master - PHP 7.4 (phpunit)
|
||||
- mw: 'master'
|
||||
php: 7.4
|
||||
|
@ -160,52 +62,38 @@ jobs:
|
|||
experimental: false
|
||||
stage: phpunit
|
||||
|
||||
# Latest stable MediaWiki - PHP 7.3 (selenium)
|
||||
- mw: 'REL1_36'
|
||||
php: 7.3
|
||||
php-docker: 73
|
||||
# Latest stable MediaWiki - PHP 7.4 (selenium)
|
||||
- mw: 'REL1_39'
|
||||
php: 7.4
|
||||
php-docker: 74
|
||||
experimental: false
|
||||
stage: selenium
|
||||
|
||||
# Latest MediaWiki release branch - PHP 7.3 (selenium)
|
||||
- mw: 'REL1_37'
|
||||
php: 7.3
|
||||
php-docker: 73
|
||||
experimental: false
|
||||
stage: selenium
|
||||
|
||||
# Latest MediaWiki master - PHP 7.3 (selenium)
|
||||
# Latest MediaWiki master - PHP 7.4 (selenium)
|
||||
- mw: 'master'
|
||||
php: 7.3
|
||||
php-docker: 73
|
||||
php: 7.4
|
||||
php-docker: 74
|
||||
experimental: false
|
||||
stage: selenium
|
||||
|
||||
# Latest stable MediaWiki - PHP 7.3 (qunit)
|
||||
- mw: 'REL1_36'
|
||||
php: 7.3
|
||||
php-docker: 73
|
||||
# Latest stable MediaWiki - PHP 7.4 (qunit)
|
||||
- mw: 'REL1_39'
|
||||
php: 7.4
|
||||
php-docker: 74
|
||||
experimental: false
|
||||
stage: qunit
|
||||
|
||||
# Latest MediaWiki release branch - PHP 7.3 (qunit)
|
||||
- mw: 'REL1_37'
|
||||
php: 7.3
|
||||
php-docker: 73
|
||||
experimental: false
|
||||
stage: qunit
|
||||
|
||||
# Latest MediaWiki master - PHP 7.3 (qunit)
|
||||
# Latest MediaWiki master - PHP 7.4 (qunit)
|
||||
- mw: 'master'
|
||||
php: 7.3
|
||||
php-docker: 73
|
||||
php: 7.4
|
||||
php-docker: 74
|
||||
experimental: false
|
||||
stage: qunit
|
||||
|
||||
# Latest stable MediaWiki - PHP 7.3 (composer-test)
|
||||
- mw: 'REL1_37'
|
||||
php: 7.3
|
||||
php-docker: 73
|
||||
# Latest stable MediaWiki - PHP 7.4 (composer-test)
|
||||
- mw: 'REL1_39'
|
||||
php: 7.4
|
||||
php-docker: 74
|
||||
experimental: false
|
||||
stage: composer-test
|
||||
|
||||
|
|
16
CHANGELOG.md
16
CHANGELOG.md
|
@ -787,3 +787,19 @@ Many thanks to GreenReaper on GitHub for reporting and finding issues with core
|
|||
* Updated CreateTemplate to mention DPL3, not DPL
|
||||
* Used database update maintenance script for creating VIEW
|
||||
* Added additional isset check for mTemplatePath
|
||||
|
||||
# Version 3.5.0
|
||||
* Dropped `revision_actor_temp` support and completed actor migration
|
||||
* Added support for `templatelinks` migration
|
||||
* Added support for MediaWiki 1.39 and dropped support for older MediaWiki versions (before 1.39.0)
|
||||
* Dropped official support for PHP versions before PHP 7.4.3, because MediaWiki 1.39 does not support older PHP versions anymore
|
||||
* Fixed installing via composer version 2.2.1 and later
|
||||
* Fixed using imagecontainer with openreferences
|
||||
* Replaced usages of `intval()` with `(int)` in Query.php and Parse.php
|
||||
* Swapped order of mapping for `Query::addTables()` from `[ alias => table ]` to `[ table => alias ]`
|
||||
* Replaced usages of deprecated `wfGetDB()`
|
||||
* Replaced usages of deprecated `Parser::getTitle()`
|
||||
* Replaced usage of deprecated `Title::isProtected()`
|
||||
* Replaced usage of deprecated `User::matchEditToken()`
|
||||
* Replaced usage of deprecated `Article::doDelete()`
|
||||
* Added `null` checks on `Parser::getPage()` and `ParserOutput` before using to avoid fatals
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "DynamicPageList3",
|
||||
"version": "3.4.6",
|
||||
"version": "3.5.0",
|
||||
"author": [
|
||||
"'''Universal Omega'''",
|
||||
"Alexia E. Smith",
|
||||
|
@ -11,7 +11,7 @@
|
|||
"license-name": "GPL-3.0-or-later",
|
||||
"type": "parserhook",
|
||||
"requires": {
|
||||
"MediaWiki": ">= 1.35.3"
|
||||
"MediaWiki": ">= 1.39.0"
|
||||
},
|
||||
"GroupPermissions": {
|
||||
"sysop": {
|
||||
|
|
|
@ -210,8 +210,8 @@ class Article {
|
|||
$article = new self( $title, $pageNamespace );
|
||||
|
||||
$revActorName = null;
|
||||
if ( isset( $row->revactor_actor ) ) {
|
||||
$revActorName = $userFactory->newFromActorId( $row->revactor_actor )->getName();
|
||||
if ( isset( $row->rev_actor ) ) {
|
||||
$revActorName = $userFactory->newFromActorId( $row->rev_actor )->getName();
|
||||
}
|
||||
|
||||
$titleText = $title->getText();
|
||||
|
@ -286,9 +286,9 @@ class Article {
|
|||
if ( $parameters->getParameter( 'goal' ) != 'categories' ) {
|
||||
// REVISION SPECIFIED
|
||||
if ( $parameters->getParameter( 'lastrevisionbefore' ) || $parameters->getParameter( 'allrevisionsbefore' ) || $parameters->getParameter( 'firstrevisionsince' ) || $parameters->getParameter( 'allrevisionssince' ) ) {
|
||||
$article->mRevision = $row->revactor_rev;
|
||||
$article->mRevision = $row->rev_id;
|
||||
$article->mUser = $revActorName;
|
||||
$article->mDate = $row->revactor_timestamp;
|
||||
$article->mDate = $row->rev_timestamp;
|
||||
|
||||
// $article->mComment = $row->rev_comment;
|
||||
}
|
||||
|
@ -298,8 +298,8 @@ class Article {
|
|||
$article->mDate = $row->page_touched;
|
||||
} elseif ( $parameters->getParameter( 'addfirstcategorydate' ) ) {
|
||||
$article->mDate = $row->cl_timestamp;
|
||||
} elseif ( $parameters->getParameter( 'addeditdate' ) && isset( $row->revactor_timestamp ) ) {
|
||||
$article->mDate = $row->revactor_timestamp;
|
||||
} elseif ( $parameters->getParameter( 'addeditdate' ) && isset( $row->rev_timestamp ) ) {
|
||||
$article->mDate = $row->rev_timestamp;
|
||||
} elseif ( $parameters->getParameter( 'addeditdate' ) && isset( $row->page_touched ) ) {
|
||||
$article->mDate = $row->page_touched;
|
||||
}
|
||||
|
|
|
@ -278,7 +278,7 @@ class Hooks {
|
|||
// @phan-suppress-next-line PhanPluginMixedKeyNoKey
|
||||
$parser->getPreprocessor()->preprocessToObj( $dplresult, 1 ),
|
||||
'isLocalObj' => true,
|
||||
'title' => $parser->getTitle()
|
||||
'title' => $parser->getPage()
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -45,8 +45,6 @@ class LST {
|
|||
* @param Parser $parser
|
||||
* @param string $part1
|
||||
* @return bool
|
||||
*
|
||||
* @suppress PhanUndeclaredProperty Use of Parser::mTemplatePath
|
||||
*/
|
||||
public static function open( $parser, $part1 ) {
|
||||
// Infinite loop test
|
||||
|
@ -70,8 +68,6 @@ class LST {
|
|||
*
|
||||
* @param Parser $parser
|
||||
* @param string $part1
|
||||
*
|
||||
* @suppress PhanUndeclaredProperty Use of Parser::mTemplatePath
|
||||
*/
|
||||
public static function close( $parser, $part1 ) {
|
||||
// Infinite loop test
|
||||
|
@ -111,7 +107,7 @@ class LST {
|
|||
|
||||
// Handle recursion here, so we can break cycles.
|
||||
if ( $recursionCheck == false ) {
|
||||
$text = $parser->preprocess( $text, $parser->getTitle(), $parser->getOptions() );
|
||||
$text = $parser->preprocess( $text, $parser->getPage(), $parser->getOptions() );
|
||||
self::close( $parser, $part1 );
|
||||
}
|
||||
|
||||
|
@ -124,7 +120,8 @@ class LST {
|
|||
return $text;
|
||||
}
|
||||
} else {
|
||||
return "[[" . $parser->getTitle()->getPrefixedText() . "]]" . "<!-- WARNING: LST loop detected -->";
|
||||
$title = Title::castFromPageReference( $parser->getPage() );
|
||||
return "[[" . $title->getPrefixedText() . "]]" . "<!-- WARNING: LST loop detected -->";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -708,7 +705,7 @@ class LST {
|
|||
}
|
||||
} else {
|
||||
// put a red link into the output
|
||||
$output[0] = $parser->preprocess( '{{' . $defaultTemplate . '|%PAGE%=' . $page . '|%TITLE%=' . $title->getText() . '|%DATE%=' . $date . '|%USER%=' . $user . '}}', $parser->getTitle(), $parser->getOptions() );
|
||||
$output[0] = $parser->preprocess( '{{' . $defaultTemplate . '|%PAGE%=' . $page . '|%TITLE%=' . $title->getText() . '|%DATE%=' . $date . '|%USER%=' . $user . '}}', $parser->getPage(), $parser->getOptions() );
|
||||
}
|
||||
|
||||
unset( $title );
|
||||
|
@ -757,7 +754,7 @@ class LST {
|
|||
}
|
||||
|
||||
$argChain .= '|%DATE%=' . $date . '|%USER%=' . $user . '|%ARGS%=' . str_replace( '|', '§', preg_replace( '/[}]+/', '}', preg_replace( '/[{]+/', '{', substr( $invocation, strlen( $template2 ) + 2 ) ) ) ) . '}}';
|
||||
$output[++$n] = $parser->preprocess( $argChain, $parser->getTitle(), $parser->getOptions() );
|
||||
$output[++$n] = $parser->preprocess( $argChain, $parser->getPage(), $parser->getOptions() );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -98,8 +98,6 @@ class Parse {
|
|||
* @param array &$eliminate
|
||||
* @param bool $isParserTag
|
||||
* @return string
|
||||
*
|
||||
* @suppress PhanUndeclaredProperty Use of Parser::mTemplatePath
|
||||
*/
|
||||
public function parse( $input, Parser $parser, &$reset, &$eliminate, $isParserTag = false ) {
|
||||
$dplStartTime = microtime( true );
|
||||
|
@ -107,17 +105,20 @@ class Parse {
|
|||
// Reset headings when being ran more than once in the same page load.
|
||||
Article::resetHeadings();
|
||||
|
||||
$title = Title::castFromPageReference( $parser->getPage() );
|
||||
|
||||
// Check that we are not in an infinite transclusion loop
|
||||
if ( isset( $parser->mTemplatePath[$parser->getTitle()->getPrefixedText()] ) ) {
|
||||
$this->logger->addMessage( Hooks::WARN_TRANSCLUSIONLOOP, $parser->getTitle()->getPrefixedText() );
|
||||
if ( isset( $parser->mTemplatePath[$title->getPrefixedText()] ) ) {
|
||||
$this->logger->addMessage( Hooks::WARN_TRANSCLUSIONLOOP, $title->getPrefixedText() );
|
||||
|
||||
return $this->getFullOutput();
|
||||
}
|
||||
|
||||
$restrictionStore = MediaWikiServices::getInstance()->getRestrictionStore();
|
||||
// Check if DPL shall only be executed from protected pages.
|
||||
if ( Config::getSetting( 'runFromProtectedPagesOnly' ) === true && !$parser->getTitle()->isProtected( 'edit' ) ) {
|
||||
if ( Config::getSetting( 'runFromProtectedPagesOnly' ) === true && $title && !$restrictionStore->isProtected( $title, 'edit' ) ) {
|
||||
// Ideally we would like to allow using a DPL query if the query istelf is coded on a template page which is protected. Then there would be no need for the article to be protected. However, how can one find out from which wiki source an extension has been invoked???
|
||||
$this->logger->addMessage( Hooks::FATAL_NOTPROTECTED, $parser->getTitle()->getPrefixedText() );
|
||||
$this->logger->addMessage( Hooks::FATAL_NOTPROTECTED, $title->getPrefixedText() );
|
||||
|
||||
return $this->getFullOutput();
|
||||
}
|
||||
|
@ -203,7 +204,7 @@ class Parse {
|
|||
|
||||
$foundRows = null;
|
||||
$profilingContext = '';
|
||||
$currentTitle= $parser->getTitle();
|
||||
$currentTitle = $parser->getPage();
|
||||
if ( $currentTitle instanceof Title ) {
|
||||
$profilingContext
|
||||
= str_replace( [ '*', '/' ], '-', $currentTitle->getPrefixedDBkey() );
|
||||
|
@ -405,7 +406,7 @@ class Parse {
|
|||
}
|
||||
|
||||
$title = Title::makeTitle( $pageNamespace, $pageTitle );
|
||||
$thisTitle = $parser->getTitle();
|
||||
$thisTitle = Title::castFromPageReference( $parser->getPage() );
|
||||
|
||||
// Block recursion from happening by seeing if this result row is the page the DPL query was ran from.
|
||||
if ( $this->parameters->getParameter( 'skipthispage' ) && $thisTitle->equals( $title ) ) {
|
||||
|
@ -590,7 +591,7 @@ class Parse {
|
|||
* @return mixed Type to use: 'results', 'oneresult', or 'noresults'. False if invalid or none should be used.
|
||||
*/
|
||||
private function getHeaderFooterType( $position, $count ) {
|
||||
$count = intval( $count );
|
||||
$count = (int)$count;
|
||||
|
||||
if ( $position != 'header' && $position != 'footer' ) {
|
||||
return false;
|
||||
|
@ -714,7 +715,7 @@ class Parse {
|
|||
|
||||
// No more than one type of date at a time!
|
||||
// @TODO: Can this be fixed to allow all three later after fixing the article class?
|
||||
if ( ( intval( $this->parameters->getParameter( 'addpagetoucheddate' ) ) + intval( $this->parameters->getParameter( 'addfirstcategorydate' ) ) + intval( $this->parameters->getParameter( 'addeditdate' ) ) ) > 1 ) {
|
||||
if ( ( (int)$this->parameters->getParameter( 'addpagetoucheddate' ) + (int)$this->parameters->getParameter( 'addfirstcategorydate' ) + (int)$this->parameters->getParameter( 'addeditdate' ) ) > 1 ) {
|
||||
$this->logger->addMessage( Hooks::FATAL_MORETHAN1TYPEOFDATE );
|
||||
|
||||
return false;
|
||||
|
@ -906,7 +907,9 @@ class Parse {
|
|||
global $wgHooks;
|
||||
|
||||
$localParser = MediaWikiServices::getInstance()->getParserFactory()->create();
|
||||
$parserOutput = $localParser->parse( $output, $parser->getTitle(), $parser->getOptions() );
|
||||
|
||||
$page = $parser->getPage();
|
||||
$parserOutput = $page ? $localParser->parse( $output, $page, $parser->getOptions() ) : null;
|
||||
|
||||
if ( !is_array( $reset ) ) {
|
||||
$reset = [];
|
||||
|
@ -967,7 +970,7 @@ class Parse {
|
|||
$wgHooks['ParserAfterTidy'][] = 'MediaWiki\\Extension\\DynamicPageList3\\Hooks::endEliminate';
|
||||
}
|
||||
|
||||
if ( isset( $eliminate['links'] ) && $eliminate['links'] ) {
|
||||
if ( $parserOutput && isset( $eliminate['links'] ) && $eliminate['links'] ) {
|
||||
// Trigger the mediawiki parser to find links, images, categories etc. which are contained in the DPL output. This allows us to remove these links from the link list later. If the article containing the DPL statement itself uses one of these links they will be thrown away!
|
||||
Hooks::$createdLinks[0] = [];
|
||||
|
||||
|
@ -976,7 +979,7 @@ class Parse {
|
|||
}
|
||||
}
|
||||
|
||||
if ( isset( $eliminate['templates'] ) && $eliminate['templates'] ) {
|
||||
if ( $parserOutput && isset( $eliminate['templates'] ) && $eliminate['templates'] ) {
|
||||
Hooks::$createdLinks[1] = [];
|
||||
|
||||
foreach ( $parserOutput->getTemplates() as $nsp => $tpl ) {
|
||||
|
@ -984,11 +987,11 @@ class Parse {
|
|||
}
|
||||
}
|
||||
|
||||
if ( isset( $eliminate['categories'] ) && $eliminate['categories'] ) {
|
||||
if ( $parserOutput && isset( $eliminate['categories'] ) && $eliminate['categories'] ) {
|
||||
Hooks::$createdLinks[2] = $parserOutput->mCategories;
|
||||
}
|
||||
|
||||
if ( isset( $eliminate['images'] ) && $eliminate['images'] ) {
|
||||
if ( $parserOutput && isset( $eliminate['images'] ) && $eliminate['images'] ) {
|
||||
Hooks::$createdLinks[3] = $parserOutput->mImages;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ class Query {
|
|||
|
||||
$this->tableNames = self::getTableNames();
|
||||
|
||||
$this->dbr = wfGetDB( DB_REPLICA, 'dpl' );
|
||||
$this->dbr = MediaWikiServices::getInstance()->getDBLoadBalancer()->getConnection( DB_REPLICA, 'dpl' );
|
||||
|
||||
$this->userFactory = MediaWikiServices::getInstance()->getUserFactory();
|
||||
}
|
||||
|
@ -440,7 +440,7 @@ class Query {
|
|||
* @return array
|
||||
*/
|
||||
public static function getTableNames() {
|
||||
$dbr = wfGetDB( DB_REPLICA, 'dpl' );
|
||||
$dbr = MediaWikiServices::getInstance()->getDBLoadBalancer()->getConnection( DB_REPLICA, 'dpl' );
|
||||
|
||||
$tables = [
|
||||
'categorylinks',
|
||||
|
@ -448,11 +448,11 @@ class Query {
|
|||
'externallinks',
|
||||
'flaggedpages',
|
||||
'imagelinks',
|
||||
'linktarget',
|
||||
'page',
|
||||
'pagelinks',
|
||||
'recentchanges',
|
||||
'revision',
|
||||
'revision_actor_temp',
|
||||
'templatelinks'
|
||||
];
|
||||
|
||||
|
@ -492,10 +492,10 @@ class Query {
|
|||
/**
|
||||
* Add multiple tables to the output.
|
||||
*
|
||||
* @param array $tablesByAlias
|
||||
* @param array $tablesByAlias [ table => alias ]
|
||||
*/
|
||||
public function addTables( array $tablesByAlias ) {
|
||||
foreach ( $tablesByAlias as $alias => $table ) {
|
||||
foreach ( $tablesByAlias as $table => $alias ) {
|
||||
$this->addTable( $table, $alias );
|
||||
}
|
||||
}
|
||||
|
@ -648,7 +648,7 @@ class Query {
|
|||
*/
|
||||
public function setLimit( $limit ) {
|
||||
if ( is_numeric( $limit ) ) {
|
||||
$this->limit = intval( $limit );
|
||||
$this->limit = (int)$limit;
|
||||
} else {
|
||||
$this->limit = false;
|
||||
}
|
||||
|
@ -664,7 +664,7 @@ class Query {
|
|||
*/
|
||||
public function setOffset( $offset ) {
|
||||
if ( is_numeric( $offset ) ) {
|
||||
$this->offset = intval( $offset );
|
||||
$this->offset = (int)$offset;
|
||||
} else {
|
||||
$this->offset = false;
|
||||
}
|
||||
|
@ -710,7 +710,7 @@ class Query {
|
|||
* @return array
|
||||
*/
|
||||
public static function getSubcategories( $categoryName, $depth = 1 ) {
|
||||
$dbr = wfGetDB( DB_REPLICA, 'dpl' );
|
||||
$dbr = MediaWikiServices::getInstance()->getDBLoadBalancer()->getConnection( DB_REPLICA, 'dpl' );
|
||||
|
||||
if ( $depth > 2 ) {
|
||||
// Hard constrain depth because lots of recursion is bad.
|
||||
|
@ -722,7 +722,7 @@ class Query {
|
|||
[ 'page', 'categorylinks' ],
|
||||
[ 'page_title' ],
|
||||
[
|
||||
'page_namespace' => intval( NS_CATEGORY ),
|
||||
'page_namespace' => NS_CATEGORY,
|
||||
'cl_to' => str_replace( ' ', '_', $categoryName )
|
||||
],
|
||||
__METHOD__,
|
||||
|
@ -802,11 +802,11 @@ class Query {
|
|||
private function _addauthor( $option ) {
|
||||
// Addauthor can not be used with addlasteditor.
|
||||
if ( !isset( $this->parametersProcessed['addlasteditor'] ) || !$this->parametersProcessed['addlasteditor'] ) {
|
||||
$this->addTable( 'revision_actor_temp', 'rev' );
|
||||
$this->addTable( 'revision', 'rev' );
|
||||
$this->addWhere(
|
||||
[
|
||||
$this->tableNames['page'] . '.page_id = rev.revactor_page',
|
||||
'rev.revactor_timestamp = (SELECT MIN(rev_aux_min.revactor_timestamp) FROM ' . $this->tableNames['revision_actor_temp'] . ' AS rev_aux_min WHERE rev_aux_min.revactor_page = rev.revactor_page)'
|
||||
$this->tableNames['page'] . '.page_id = rev.rev_page',
|
||||
'rev.rev_timestamp = (SELECT MIN(rev_aux_min.rev_timestamp) FROM ' . $this->tableNames['revision'] . ' AS rev_aux_min WHERE rev_aux_min.rev_page = rev.rev_page)'
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -868,12 +868,12 @@ class Query {
|
|||
* @param mixed $option
|
||||
*/
|
||||
private function _addeditdate( $option ) {
|
||||
$this->addTable( 'revision_actor_temp', 'rev' );
|
||||
$this->addSelect( [ 'rev.revactor_timestamp' ] );
|
||||
$this->addTable( 'revision', 'rev' );
|
||||
$this->addSelect( [ 'rev.rev_timestamp' ] );
|
||||
|
||||
$this->addWhere(
|
||||
[
|
||||
$this->tableNames['page'] . '.page_id = rev.revactor_page',
|
||||
$this->tableNames['page'] . '.page_id = rev.rev_page',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -900,12 +900,12 @@ class Query {
|
|||
private function _addlasteditor( $option ) {
|
||||
// Addlasteditor can not be used with addauthor.
|
||||
if ( !isset( $this->parametersProcessed['addauthor'] ) || !$this->parametersProcessed['addauthor'] ) {
|
||||
$this->addTable( 'revision_actor_temp', 'rev' );
|
||||
$this->addTable( 'revision', 'rev' );
|
||||
|
||||
$this->addWhere(
|
||||
[
|
||||
$this->tableNames['page'] . '.page_id = rev.revactor_page',
|
||||
'rev.revactor_timestamp = (SELECT MAX(rev_aux_max.revactor_timestamp) FROM ' . $this->tableNames['revision_actor_temp'] . ' AS rev_aux_max WHERE rev_aux_max.revactor_page = rev.revactor_page)'
|
||||
$this->tableNames['page'] . '.page_id = rev.rev_page',
|
||||
'rev.rev_timestamp = (SELECT MAX(rev_aux_max.rev_timestamp) FROM ' . $this->tableNames['revision'] . ' AS rev_aux_max WHERE rev_aux_max.rev_page = rev.rev_page)'
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -976,7 +976,7 @@ class Query {
|
|||
|
||||
$this->addSelect(
|
||||
[
|
||||
$tableAlias . 'revactor_actor',
|
||||
$tableAlias . 'rev_actor',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -987,21 +987,21 @@ class Query {
|
|||
* @param mixed $option
|
||||
*/
|
||||
private function _allrevisionsbefore( $option ) {
|
||||
$this->addTable( 'revision_actor_temp', 'rev' );
|
||||
$this->addTable( 'revision', 'rev' );
|
||||
$this->addSelect(
|
||||
[
|
||||
'rev.revactor_rev',
|
||||
'rev.revactor_timestamp'
|
||||
'rev.rev_id',
|
||||
'rev.rev_timestamp'
|
||||
]
|
||||
);
|
||||
|
||||
$this->addOrderBy( 'rev.revactor_rev' );
|
||||
$this->addOrderBy( 'rev.rev_id' );
|
||||
$this->setOrderDir( 'DESC' );
|
||||
|
||||
$this->addWhere(
|
||||
[
|
||||
$this->tableNames['page'] . '.page_id = rev.revactor_page',
|
||||
'rev.revactor_timestamp < ' . $this->convertTimestamp( $option )
|
||||
$this->tableNames['page'] . '.page_id = rev.rev_page',
|
||||
'rev.rev_timestamp < ' . $this->convertTimestamp( $option )
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -1012,21 +1012,21 @@ class Query {
|
|||
* @param mixed $option
|
||||
*/
|
||||
private function _allrevisionssince( $option ) {
|
||||
$this->addTable( 'revision_actor_temp', 'rev' );
|
||||
$this->addTable( 'revision', 'rev' );
|
||||
$this->addSelect(
|
||||
[
|
||||
'rev.revactor_rev',
|
||||
'rev.revactor_timestamp'
|
||||
'rev.rev_id',
|
||||
'rev.rev_timestamp'
|
||||
]
|
||||
);
|
||||
|
||||
$this->addOrderBy( 'rev.revactor_rev' );
|
||||
$this->addOrderBy( 'rev.rev_id' );
|
||||
$this->setOrderDir( 'DESC' );
|
||||
|
||||
$this->addWhere(
|
||||
[
|
||||
$this->tableNames['page'] . '.page_id = rev.revactor_page',
|
||||
'rev.revactor_timestamp >= ' . $this->convertTimestamp( $option )
|
||||
$this->tableNames['page'] . '.page_id = rev.rev_page',
|
||||
'rev.rev_timestamp >= ' . $this->convertTimestamp( $option )
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -1047,11 +1047,11 @@ class Query {
|
|||
*/
|
||||
private function _categoriesminmax( $option ) {
|
||||
if ( is_numeric( $option[0] ) ) {
|
||||
$this->addWhere( intval( $option[0] ) . ' <= (SELECT count(*) FROM ' . $this->tableNames['categorylinks'] . ' WHERE ' . $this->tableNames['categorylinks'] . '.cl_from=page_id)' );
|
||||
$this->addWhere( (int)$option[0] . ' <= (SELECT count(*) FROM ' . $this->tableNames['categorylinks'] . ' WHERE ' . $this->tableNames['categorylinks'] . '.cl_from=page_id)' );
|
||||
}
|
||||
|
||||
if ( isset( $option[1] ) && is_numeric( $option[1] ) ) {
|
||||
$this->addWhere( intval( $option[1] ) . ' >= (SELECT count(*) FROM ' . $this->tableNames['categorylinks'] . ' WHERE ' . $this->tableNames['categorylinks'] . '.cl_from=page_id)' );
|
||||
$this->addWhere( (int)$option[1] . ' >= (SELECT count(*) FROM ' . $this->tableNames['categorylinks'] . ' WHERE ' . $this->tableNames['categorylinks'] . '.cl_from=page_id)' );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1150,13 +1150,12 @@ class Query {
|
|||
*/
|
||||
private function _createdby( $option ) {
|
||||
$this->addTable( 'revision', 'creation_rev' );
|
||||
$this->addTable( 'revision_actor_temp', 'creation_rev_actor' );
|
||||
$this->_adduser( null, 'creation_rev_actor' );
|
||||
$this->_adduser( null, 'creation_rev' );
|
||||
|
||||
$this->addWhere(
|
||||
[
|
||||
$this->dbr->addQuotes( $this->userFactory->newFromName( $option )->getActorId() ) . ' = creation_rev_actor.revactor_actor',
|
||||
'creation_rev_actor.revactor_page = page_id',
|
||||
$this->dbr->addQuotes( $this->userFactory->newFromName( $option )->getActorId() ) . ' = creation_rev.rev_actor',
|
||||
'creation_rev.rev_page = page_id',
|
||||
'creation_rev.rev_parent_id = 0'
|
||||
]
|
||||
);
|
||||
|
@ -1181,26 +1180,26 @@ class Query {
|
|||
* @param mixed $option
|
||||
*/
|
||||
private function _firstrevisionsince( $option ) {
|
||||
$this->addTable( 'revision_actor_temp', 'rev' );
|
||||
$this->addTable( 'revision', 'rev' );
|
||||
$this->addSelect(
|
||||
[
|
||||
'rev.revactor_rev',
|
||||
'rev.revactor_timestamp'
|
||||
'rev.rev_id',
|
||||
'rev.rev_timestamp'
|
||||
]
|
||||
);
|
||||
|
||||
// tell the query optimizer not to look at rows that the following subquery will filter out anyway
|
||||
$this->addWhere(
|
||||
[
|
||||
$this->tableNames['page'] . '.page_id = rev.revactor_page',
|
||||
'rev.revactor_timestamp >= ' . $this->dbr->addQuotes( $option )
|
||||
$this->tableNames['page'] . '.page_id = rev.rev_page',
|
||||
'rev.rev_timestamp >= ' . $this->dbr->addQuotes( $option )
|
||||
]
|
||||
);
|
||||
|
||||
$this->addWhere(
|
||||
[
|
||||
$this->tableNames['page'] . '.page_id = rev.revactor_page',
|
||||
'rev.revactor_timestamp = (SELECT MIN(rev_aux_snc.revactor_timestamp) FROM ' . $this->tableNames['revision_actor_temp'] . ' AS rev_aux_snc WHERE rev_aux_snc.revactor_page=rev.revactor_page AND rev_aux_snc.revactor_timestamp >= ' . $this->convertTimestamp( $option ) . ')'
|
||||
$this->tableNames['page'] . '.page_id = rev.rev_page',
|
||||
'rev.rev_timestamp = (SELECT MIN(rev_aux_snc.rev_timestamp) FROM ' . $this->tableNames['revision'] . ' AS rev_aux_snc WHERE rev_aux_snc.rev_page=rev.rev_page AND rev_aux_snc.rev_timestamp >= ' . $this->convertTimestamp( $option ) . ')'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -1243,7 +1242,7 @@ class Query {
|
|||
|
||||
if ( !$this->parameters->getParameter( 'openreferences' ) ) {
|
||||
$where = [
|
||||
"{$this->tableNames['page']}.page_namespace = " . intval( NS_FILE ),
|
||||
"{$this->tableNames['page']}.page_namespace = " . NS_FILE,
|
||||
"{$this->tableNames['page']}.page_title = ic.il_to"
|
||||
];
|
||||
}
|
||||
|
@ -1305,7 +1304,7 @@ class Query {
|
|||
* @param mixed $option
|
||||
*/
|
||||
private function _lastmodifiedby( $option ) {
|
||||
$this->addWhere( $this->dbr->addQuotes( $this->userFactory->newFromName( $option )->getActorId() ) . ' = (SELECT revactor_actor FROM ' . $this->tableNames['revision_actor_temp'] . ' WHERE ' . $this->tableNames['revision_actor_temp'] . '.revactor_page=page_id ORDER BY ' . $this->tableNames['revision_actor_temp'] . '.revactor_timestamp DESC LIMIT 1)' );
|
||||
$this->addWhere( $this->dbr->addQuotes( $this->userFactory->newFromName( $option )->getActorId() ) . ' = (SELECT rev_actor FROM ' . $this->tableNames['revision'] . ' WHERE ' . $this->tableNames['revision'] . '.rev_page=page_id ORDER BY ' . $this->tableNames['revision'] . '.rev_timestamp DESC LIMIT 1)' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1314,21 +1313,21 @@ class Query {
|
|||
* @param mixed $option
|
||||
*/
|
||||
private function _lastrevisionbefore( $option ) {
|
||||
$this->addTable( 'revision_actor_temp', 'rev' );
|
||||
$this->addSelect( [ 'rev.revactor_rev', 'rev.revactor_timestamp' ] );
|
||||
$this->addTable( 'revision', 'rev' );
|
||||
$this->addSelect( [ 'rev.rev_id', 'rev.rev_timestamp' ] );
|
||||
|
||||
// tell the query optimizer not to look at rows that the following subquery will filter out anyway
|
||||
$this->addWhere(
|
||||
[
|
||||
$this->tableNames['page'] . '.page_id = rev.revactor_page',
|
||||
'rev.revactor_timestamp < ' . $this->convertTimestamp( $option )
|
||||
$this->tableNames['page'] . '.page_id = rev.rev_page',
|
||||
'rev.rev_timestamp < ' . $this->convertTimestamp( $option )
|
||||
]
|
||||
);
|
||||
|
||||
$this->addWhere(
|
||||
[
|
||||
$this->tableNames['page'] . '.page_id = rev.revactor_page',
|
||||
'rev.revactor_timestamp = (SELECT MAX(rev_aux_bef.revactor_timestamp) FROM ' . $this->tableNames['revision_actor_temp'] . ' AS rev_aux_bef WHERE rev_aux_bef.revactor_page=rev.revactor_page AND rev_aux_bef.revactor_timestamp < ' . $this->convertTimestamp( $option ) . ')'
|
||||
$this->tableNames['page'] . '.page_id = rev.rev_page',
|
||||
'rev.rev_timestamp = (SELECT MAX(rev_aux_bef.rev_timestamp) FROM ' . $this->tableNames['revision'] . ' AS rev_aux_bef WHERE rev_aux_bef.rev_page=rev.rev_page AND rev_aux_bef.rev_timestamp < ' . $this->convertTimestamp( $option ) . ')'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -1403,7 +1402,7 @@ class Query {
|
|||
$ors = [];
|
||||
|
||||
foreach ( $linkGroup as $link ) {
|
||||
$_or = '(pl.pl_namespace=' . intval( $link->getNamespace() );
|
||||
$_or = '(pl.pl_namespace=' . (int)$link->getNamespace();
|
||||
if ( strpos( $link->getDBkey(), '%' ) >= 0 ) {
|
||||
$operator = 'LIKE';
|
||||
} else {
|
||||
|
@ -1426,7 +1425,7 @@ class Query {
|
|||
$ors = [];
|
||||
|
||||
foreach ( $linkGroup as $link ) {
|
||||
$_or = '(' . $this->tableNames['pagelinks'] . '.pl_namespace=' . intval( $link->getNamespace() );
|
||||
$_or = '(' . $this->tableNames['pagelinks'] . '.pl_namespace=' . (int)$link->getNamespace();
|
||||
if ( strpos( $link->getDBkey(), '%' ) >= 0 ) {
|
||||
$operator = 'LIKE';
|
||||
} else {
|
||||
|
@ -1466,7 +1465,7 @@ class Query {
|
|||
$ands = [];
|
||||
foreach ( $option as $linkGroup ) {
|
||||
foreach ( $linkGroup as $link ) {
|
||||
$ands[] = 'pl_from <> ' . intval( $link->getArticleID() ) . ' ';
|
||||
$ands[] = 'pl_from <> ' . (int)$link->getArticleID() . ' ';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1477,7 +1476,7 @@ class Query {
|
|||
|
||||
foreach ( $option as $linkGroup ) {
|
||||
foreach ( $linkGroup as $link ) {
|
||||
$ors[] = $this->tableNames['pagelinks'] . '.pl_from = ' . intval( $link->getArticleID() );
|
||||
$ors[] = $this->tableNames['pagelinks'] . '.pl_from = ' . (int)$link->getArticleID();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1503,7 +1502,7 @@ class Query {
|
|||
|
||||
foreach ( $option as $linkGroup ) {
|
||||
foreach ( $linkGroup as $link ) {
|
||||
$_or = '(' . $this->tableNames['pagelinks'] . '.pl_namespace=' . intval( $link->getNamespace() );
|
||||
$_or = '(' . $this->tableNames['pagelinks'] . '.pl_namespace=' . (int)$link->getNamespace();
|
||||
if ( strpos( $link->getDBkey(), '%' ) >= 0 ) {
|
||||
$operator = 'LIKE';
|
||||
} else {
|
||||
|
@ -1573,7 +1572,7 @@ class Query {
|
|||
* @param mixed $option
|
||||
*/
|
||||
private function _maxrevisions( $option ) {
|
||||
$this->addWhere( "((SELECT count(rev_aux3.revactor_page) FROM {$this->tableNames['revision_actor_temp']} AS rev_aux3 WHERE rev_aux3.revactor_page = {$this->tableNames['page']}.page_id) <= {$option})" );
|
||||
$this->addWhere( "((SELECT count(rev_aux3.rev_page) FROM {$this->tableNames['revision']} AS rev_aux3 WHERE rev_aux3.rev_page = {$this->tableNames['page']}.page_id) <= {$option})" );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1594,7 +1593,7 @@ class Query {
|
|||
* @param mixed $option
|
||||
*/
|
||||
private function _minrevisions( $option ) {
|
||||
$this->addWhere( "((SELECT count(rev_aux2.revactor_page) FROM {$this->tableNames['revision_actor_temp']} AS rev_aux2 WHERE rev_aux2.revactor_page = {$this->tableNames['page']}.page_id) >= {$option})" );
|
||||
$this->addWhere( "((SELECT count(rev_aux2.rev_page) FROM {$this->tableNames['revision']} AS rev_aux2 WHERE rev_aux2.rev_page = {$this->tableNames['page']}.page_id) >= {$option})" );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1603,9 +1602,9 @@ class Query {
|
|||
* @param mixed $option
|
||||
*/
|
||||
private function _modifiedby( $option ) {
|
||||
$this->addTable( 'revision_actor_temp', 'change_rev' );
|
||||
$this->addTable( 'revision', 'change_rev' );
|
||||
|
||||
$this->addWhere( $this->dbr->addQuotes( $this->userFactory->newFromName( $option )->getActorId() ) . ' = change_rev.revactor_actor AND change_rev.revactor_page = page_id' );
|
||||
$this->addWhere( $this->dbr->addQuotes( $this->userFactory->newFromName( $option )->getActorId() ) . ' = change_rev.rev_actor AND change_rev.rev_page = page_id' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1638,9 +1637,8 @@ class Query {
|
|||
*/
|
||||
private function _notcreatedby( $option ) {
|
||||
$this->addTable( 'revision', 'no_creation_rev' );
|
||||
$this->addTable( 'revision_actor_temp', 'no_creation_rev_actor' );
|
||||
|
||||
$this->addWhere( $this->dbr->addQuotes( $this->userFactory->newFromName( $option )->getActorId() ) . ' != no_creation_rev_actor.revactor_actor AND no_creation_rev_actor.revactor_page = page_id AND no_creation_rev.rev_parent_id = 0' );
|
||||
$this->addWhere( $this->dbr->addQuotes( $this->userFactory->newFromName( $option )->getActorId() ) . ' != no_creation_rev.rev_actor AND no_creation_rev.rev_page = page_id AND no_creation_rev.rev_parent_id = 0' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1649,7 +1647,7 @@ class Query {
|
|||
* @param mixed $option
|
||||
*/
|
||||
private function _notlastmodifiedby( $option ) {
|
||||
$this->addWhere( $this->dbr->addQuotes( $this->userFactory->newFromName( $option )->getActorId() ) . ' != (SELECT revactor_actor FROM ' . $this->tableNames['revision_actor_temp'] . ' WHERE ' . $this->tableNames['revision_actor_temp'] . '.revactor_page=page_id ORDER BY ' . $this->tableNames['revision_actor_temp'] . '.revactor_timestamp DESC LIMIT 1)' );
|
||||
$this->addWhere( $this->dbr->addQuotes( $this->userFactory->newFromName( $option )->getActorId() ) . ' != (SELECT rev_actor FROM ' . $this->tableNames['revision'] . ' WHERE ' . $this->tableNames['revision'] . '.rev_page=page_id ORDER BY ' . $this->tableNames['revision'] . '.rev_timestamp DESC LIMIT 1)' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1658,7 +1656,7 @@ class Query {
|
|||
* @param mixed $option
|
||||
*/
|
||||
private function _notmodifiedby( $option ) {
|
||||
$this->addWhere( 'NOT EXISTS (SELECT 1 FROM ' . $this->tableNames['revision_actor_temp'] . ' WHERE ' . $this->tableNames['revision_actor_temp'] . '.revactor_page=page_id AND ' . $this->tableNames['revision_actor_temp'] . '.revactor_actor = ' . $this->dbr->addQuotes( $this->userFactory->newFromName( $option )->getActorId() ) . ' LIMIT 1)' );
|
||||
$this->addWhere( 'NOT EXISTS (SELECT 1 FROM ' . $this->tableNames['revision'] . ' WHERE ' . $this->tableNames['revision'] . '.rev_page=page_id AND ' . $this->tableNames['revision'] . '.rev_actor = ' . $this->dbr->addQuotes( $this->userFactory->newFromName( $option )->getActorId() ) . ' LIMIT 1)' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1764,7 +1762,7 @@ class Query {
|
|||
$_namespaceIdToText = "CASE {$this->tableNames['page']}.page_namespace";
|
||||
|
||||
foreach ( $namespaces as $id => $name ) {
|
||||
$_namespaceIdToText .= ' WHEN ' . intval( $id ) . ' THEN ' . $this->dbr->addQuotes( $name . ':' );
|
||||
$_namespaceIdToText .= ' WHEN ' . (int)$id . ' THEN ' . $this->dbr->addQuotes( $name . ':' );
|
||||
}
|
||||
|
||||
$_namespaceIdToText .= ' END';
|
||||
|
@ -1835,20 +1833,20 @@ class Query {
|
|||
}
|
||||
break;
|
||||
case 'firstedit':
|
||||
$this->addOrderBy( 'rev.revactor_timestamp' );
|
||||
$this->addTable( 'revision_actor_temp', 'rev' );
|
||||
$this->addOrderBy( 'rev.rev_timestamp' );
|
||||
$this->addTable( 'revision', 'rev' );
|
||||
|
||||
$this->addSelect(
|
||||
[
|
||||
'rev.revactor_timestamp'
|
||||
'rev.rev_timestamp'
|
||||
]
|
||||
);
|
||||
|
||||
if ( !$this->revisionAuxWhereAdded ) {
|
||||
$this->addWhere(
|
||||
[
|
||||
"{$this->tableNames['page']}.page_id = rev.revactor_page",
|
||||
"rev.revactor_timestamp = (SELECT MIN(rev_aux.revactor_timestamp) FROM {$this->tableNames['revision_actor_temp']} AS rev_aux WHERE rev_aux.revactor_page=rev.revactor_page)"
|
||||
"{$this->tableNames['page']}.page_id = rev.rev_page",
|
||||
"rev.rev_timestamp = (SELECT MIN(rev_aux.rev_timestamp) FROM {$this->tableNames['revision']} AS rev_aux WHERE rev_aux.rev_page=rev.rev_page)"
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -1864,15 +1862,15 @@ class Query {
|
|||
]
|
||||
);
|
||||
} else {
|
||||
$this->addOrderBy( 'rev.revactor_timestamp' );
|
||||
$this->addTable( 'revision_actor_temp', 'rev' );
|
||||
$this->addSelect( [ 'rev.revactor_timestamp' ] );
|
||||
$this->addOrderBy( 'rev.rev_timestamp' );
|
||||
$this->addTable( 'revision', 'rev' );
|
||||
$this->addSelect( [ 'rev.rev_timestamp' ] );
|
||||
|
||||
if ( !$this->revisionAuxWhereAdded ) {
|
||||
$this->addWhere(
|
||||
[
|
||||
"{$this->tableNames['page']}.page_id = rev.revactor_page",
|
||||
"rev.revactor_timestamp = (SELECT MAX(rev_aux.revactor_timestamp) FROM {$this->tableNames['revision_actor_temp']} AS rev_aux WHERE rev_aux.revactor_page = rev.revactor_page)"
|
||||
"{$this->tableNames['page']}.page_id = rev.rev_page",
|
||||
"rev.rev_timestamp = (SELECT MAX(rev_aux.rev_timestamp) FROM {$this->tableNames['revision']} AS rev_aux WHERE rev_aux.rev_page = rev.rev_page)"
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -1962,8 +1960,8 @@ class Query {
|
|||
}
|
||||
break;
|
||||
case 'user':
|
||||
$this->addOrderBy( 'rev.revactor_actor' );
|
||||
$this->addTable( 'revision_actor_temp', 'rev' );
|
||||
$this->addOrderBy( 'rev.rev_actor' );
|
||||
$this->addTable( 'revision', 'rev' );
|
||||
|
||||
$this->_adduser( null, 'rev' );
|
||||
break;
|
||||
|
@ -2196,22 +2194,29 @@ class Query {
|
|||
|
||||
foreach ( $option as $linkGroup ) {
|
||||
foreach ( $linkGroup as $link ) {
|
||||
$ors[] = 'tpl_from = ' . intval( $link->getArticleID() );
|
||||
$ors[] = 'tpl_from = ' . (int)$link->getArticleID();
|
||||
}
|
||||
}
|
||||
|
||||
$where = '(' . implode( ' OR ', $ors ) . ')';
|
||||
} else {
|
||||
$this->addTable( 'templatelinks', 'tpl' );
|
||||
$this->addTable( 'page', 'tplsrc' );
|
||||
$this->addTables( [
|
||||
'linktarget' => 'lt',
|
||||
'page' => 'tplsrc',
|
||||
'templatelinks' => 'tpl',
|
||||
] );
|
||||
|
||||
$linksMigration = MediaWikiServices::getInstance()->getLinksMigration();
|
||||
list( $nsField, $titleField ) = $linksMigration->getTitleFields( 'templatelinks' );
|
||||
|
||||
$this->addSelect( [ 'tpl_sel_title' => 'tplsrc.page_title', 'tpl_sel_ns' => 'tplsrc.page_namespace' ] );
|
||||
$where = $this->tableNames['page'] . '.page_namespace = tpl.tl_namespace AND ' .
|
||||
$this->tableNames['page'] . '.page_title = tpl.tl_title AND tplsrc.page_id = tpl.tl_from AND ';
|
||||
$where = $this->tableNames['page'] . '.page_namespace = lt.' . $nsField . ' AND ' .
|
||||
$this->tableNames['page'] . '.page_title = lt.' . $titleField . ' AND tplsrc.page_id = tpl.tl_from AND ';
|
||||
$ors = [];
|
||||
|
||||
foreach ( $option as $linkGroup ) {
|
||||
foreach ( $linkGroup as $link ) {
|
||||
$ors[] = 'tpl.tl_from = ' . intval( $link->getArticleID() );
|
||||
$ors[] = 'tpl.tl_from = ' . (int)$link->getArticleID();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2227,18 +2232,25 @@ class Query {
|
|||
* @param mixed $option
|
||||
*/
|
||||
private function _uses( $option ) {
|
||||
$this->addTable( 'templatelinks', 'tl' );
|
||||
$where = $this->tableNames['page'] . '.page_id=tl.tl_from AND (';
|
||||
$this->addTables( [
|
||||
'linktarget' => 'lt',
|
||||
'templatelinks' => 'tl',
|
||||
] );
|
||||
|
||||
$where = $this->tableNames['page'] . '.page_id=tl.tl_from AND lt.lt_id = tl.tl_target_id AND (';
|
||||
$ors = [];
|
||||
|
||||
$linksMigration = MediaWikiServices::getInstance()->getLinksMigration();
|
||||
list( $nsField, $titleField ) = $linksMigration->getTitleFields( 'templatelinks' );
|
||||
|
||||
foreach ( $option as $linkGroup ) {
|
||||
foreach ( $linkGroup as $link ) {
|
||||
$_or = '(tl.tl_namespace=' . intval( $link->getNamespace() );
|
||||
$_or = '(lt.' . $nsField . '=' . (int)$link->getNamespace();
|
||||
|
||||
if ( $this->parameters->getParameter( 'ignorecase' ) ) {
|
||||
$_or .= ' AND LOWER(CAST(tl.tl_title AS char)) = LOWER(' . $this->dbr->addQuotes( $link->getDBkey() ) . '))';
|
||||
$_or .= ' AND LOWER(CAST(lt.' . $titleField . ' AS char)) = LOWER(' . $this->dbr->addQuotes( $link->getDBkey() ) . '))';
|
||||
} else {
|
||||
$_or .= ' AND tl.tl_title = ' . $this->dbr->addQuotes( $link->getDBkey() ) . ')';
|
||||
$_or .= ' AND ' . $titleField . ' = ' . $this->dbr->addQuotes( $link->getDBkey() ) . ')';
|
||||
}
|
||||
|
||||
$ors[] = $_or;
|
||||
|
@ -2259,14 +2271,17 @@ class Query {
|
|||
$where = $this->tableNames['page'] . '.page_id NOT IN (SELECT ' . $this->tableNames['templatelinks'] . '.tl_from FROM ' . $this->tableNames['templatelinks'] . ' WHERE (';
|
||||
$ors = [];
|
||||
|
||||
$linksMigration = MediaWikiServices::getInstance()->getLinksMigration();
|
||||
list( $nsField, $titleField ) = $linksMigration->getTitleFields( 'templatelinks' );
|
||||
|
||||
foreach ( $option as $linkGroup ) {
|
||||
foreach ( $linkGroup as $link ) {
|
||||
$_or = '(' . $this->tableNames['templatelinks'] . '.tl_namespace=' . intval( $link->getNamespace() );
|
||||
$_or = '(' . $this->tableNames['linktarget'] . '.' . $nsField . '=' . (int)$link->getNamespace();
|
||||
|
||||
if ( $this->parameters->getParameter( 'ignorecase' ) ) {
|
||||
$_or .= ' AND LOWER(CAST(' . $this->tableNames['templatelinks'] . '.tl_title AS char)) = LOWER(' . $this->dbr->addQuotes( $link->getDBkey() ) . '))';
|
||||
$_or .= ' AND LOWER(CAST(' . $this->tableNames['linktarget'] . '.' . $titleField . ' AS char)) = LOWER(' . $this->dbr->addQuotes( $link->getDBkey() ) . '))';
|
||||
} else {
|
||||
$_or .= ' AND ' . $this->tableNames['templatelinks'] . '.tl_title = ' . $this->dbr->addQuotes( $link->getDBkey() ) . ')';
|
||||
$_or .= ' AND ' . $this->tableNames['linktarget'] . '.' . $titleField . ' = ' . $this->dbr->addQuotes( $link->getDBkey() ) . ')';
|
||||
}
|
||||
$ors[] = $_or;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ use MediaWiki\Revision\SlotRecord;
|
|||
use ReadOnlyError;
|
||||
use RequestContext;
|
||||
use Title;
|
||||
use WikiPage;
|
||||
|
||||
class UpdateArticle {
|
||||
/**
|
||||
|
@ -311,7 +310,8 @@ class UpdateArticle {
|
|||
$form .= "<input type='hidden' " . $hide . " />";
|
||||
}
|
||||
|
||||
$form .= "<input type='hidden' name='wpEditToken' value='{$user->getEditToken()}'/>";
|
||||
$csrfTokenSet = RequestContext::getMain()->getCsrfTokenSet();
|
||||
$form .= "<input type='hidden' name='wpEditToken' value='{$csrfTokenSet->getToken()}'/>";
|
||||
foreach ( $preview as $prev ) {
|
||||
$form .= "<input type='submit' " . $prev . " /> ";
|
||||
}
|
||||
|
@ -393,11 +393,10 @@ class UpdateArticle {
|
|||
*/
|
||||
private static function doUpdateArticle( $title, $text, $summary ) {
|
||||
$context = RequestContext::getMain();
|
||||
$request = $context->getRequest();
|
||||
$out = $context->getOutput();
|
||||
$user = $context->getUser();
|
||||
|
||||
if ( !$user->matchEditToken( $request->getVal( 'wpEditToken' ) ) ) {
|
||||
if ( !$context->getCsrfTokenSet()->matchTokenField( 'wpEditToken' ) ) {
|
||||
$out->addWikiMsg( 'sessionfailure' );
|
||||
|
||||
return 'session failure';
|
||||
|
@ -408,14 +407,8 @@ class UpdateArticle {
|
|||
|
||||
if ( count( $permission_errors ) == 0 ) {
|
||||
$services = MediaWikiServices::getInstance();
|
||||
// MW 1.36+
|
||||
if ( method_exists( $services, 'getWikiPageFactory' ) ) {
|
||||
$wikiPageFactory = $services->getWikiPageFactory();
|
||||
$page = $wikiPageFactory->newFromTitle( $titleX );
|
||||
} else {
|
||||
// @phan-suppress-next-line PhanDeprecatedFunction
|
||||
$page = WikiPage::factory( $titleX );
|
||||
}
|
||||
$wikiPageFactory = $services->getWikiPageFactory();
|
||||
$page = $wikiPageFactory->newFromTitle( $titleX );
|
||||
|
||||
$updater = $page->newPageUpdater( $user );
|
||||
$content = $page->getContentHandler()->makeContent( $text, $titleX );
|
||||
|
@ -768,8 +761,14 @@ class UpdateArticle {
|
|||
} elseif ( $isReadOnly ) {
|
||||
throw new ReadOnlyError;
|
||||
} else {
|
||||
$articleX = new Article( $titleX );
|
||||
$articleX->doDelete( $reason );
|
||||
$wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
|
||||
$deletePageFactory = MediaWikiServices::getInstance()->getDeletePageFactory();
|
||||
$deletePage = $deletePageFactory->newDeletePage(
|
||||
$wikiPageFactory->newFromTitle( $titleX ),
|
||||
$user
|
||||
);
|
||||
|
||||
$deletePage->deleteIfAllowed( $reason );
|
||||
}
|
||||
} else {
|
||||
$message .= "set 'exec yes' to delete     <big>'''$title'''</big>\n";
|
||||
|
|
|
@ -8,7 +8,6 @@ use MediaWiki\MediaWikiServices;
|
|||
use MediaWiki\Revision\SlotRecord;
|
||||
use Title;
|
||||
use User;
|
||||
use WikiPage;
|
||||
|
||||
$IP = getenv( 'MW_INSTALL_PATH' );
|
||||
if ( $IP === false ) {
|
||||
|
@ -54,14 +53,9 @@ class CreateTemplate extends LoggedUpdateMaintenance {
|
|||
// Make sure template does not already exist
|
||||
if ( !$title->exists() ) {
|
||||
$services = MediaWikiServices::getInstance();
|
||||
// MW 1.36+
|
||||
if ( method_exists( $services, 'getWikiPageFactory' ) ) {
|
||||
$wikiPageFactory = $services->getWikiPageFactory();
|
||||
$page = $wikiPageFactory->newFromTitle( $title );
|
||||
} else {
|
||||
// @phan-suppress-next-line PhanDeprecatedFunction
|
||||
$page = WikiPage::factory( $title );
|
||||
}
|
||||
$wikiPageFactory = $services->getWikiPageFactory();
|
||||
$page = $wikiPageFactory->newFromTitle( $title );
|
||||
|
||||
$updater = $page->newPageUpdater( User::newSystemUser( 'DynamicPageList3 extension' ) );
|
||||
$content = $page->getContentHandler()->makeContent( '<noinclude>This page was automatically created. It serves as an anchor page for all \'\'\'[[Special:WhatLinksHere/Template:Extension_DPL|invocations]]\'\'\' of [https://www.mediawiki.org/wiki/Special:MyLanguage/Extension:DynamicPageList3 Extension:DynamicPageList3].</noinclude>', $title );
|
||||
$updater->setContent( SlotRecord::MAIN, $content );
|
||||
|
|
|
@ -88,12 +88,7 @@ abstract class DPLIntegrationTestCase extends MediaWikiIntegrationTestCase {
|
|||
$source = new ImportStreamSource( $seedDataFile );
|
||||
$services = MediaWikiServices::getInstance();
|
||||
|
||||
if ( $services->hasService( 'WikiImporterFactory' ) ) {
|
||||
return $services->getWikiImporterFactory()->getWikiImporter( $source );
|
||||
}
|
||||
|
||||
// MW 1.36
|
||||
return new WikiImporter( $source, $services->getMainConfig() );
|
||||
return $services->getWikiImporterFactory()->getWikiImporter( $source );
|
||||
}
|
||||
|
||||
private function getAuthManager(): AuthManager {
|
||||
|
@ -155,6 +150,7 @@ abstract class DPLIntegrationTestCase extends MediaWikiIntegrationTestCase {
|
|||
$parserOptions = ParserOptions::newCanonical(
|
||||
RequestContext::getMain()
|
||||
);
|
||||
|
||||
$parserOutput = $parser->parse( $invocation, $title, $parserOptions );
|
||||
|
||||
return $parserOutput->getText();
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<sitename>MediaWiki</sitename>
|
||||
<dbname>mwdev</dbname>
|
||||
<base>http://localhost:8080/wiki/Main_Page</base>
|
||||
<generator>MediaWiki 1.37.0-alpha</generator>
|
||||
<generator>MediaWiki 1.39.0</generator>
|
||||
<case>first-letter</case>
|
||||
<namespaces>
|
||||
<namespace key="-2" case="first-letter">Media</namespace>
|
||||
|
@ -252,12 +252,27 @@
|
|||
</revision>
|
||||
<revision>
|
||||
<id>28</id>
|
||||
<timestamp>2021-09-04T03:01:00Z</timestamp>
|
||||
<timestamp>2021-09-04T03:01:14Z</timestamp>
|
||||
<contributor>
|
||||
<username>DPLTestUser</username>
|
||||
<id>2</id>
|
||||
</contributor>
|
||||
<comment>Page edited</comment>
|
||||
<origin>27</origin>
|
||||
<origin>28</origin>
|
||||
<model>wikitext</model>
|
||||
<format>text/x-wiki</format>
|
||||
<text xml:space="preserve">Uncategorized test page edit</text>
|
||||
<sha1 />
|
||||
</revision>
|
||||
<revision>
|
||||
<id>29</id>
|
||||
<timestamp>2021-09-04T03:01:26Z</timestamp>
|
||||
<contributor>
|
||||
<username>DPLTestAdmin</username>
|
||||
<id>1</id>
|
||||
</contributor>
|
||||
<comment>Page edited</comment>
|
||||
<origin>29</origin>
|
||||
<model>wikitext</model>
|
||||
<format>text/x-wiki</format>
|
||||
<text xml:space="preserve">Uncategorized test page edit</text>
|
||||
|
@ -267,16 +282,16 @@
|
|||
<page>
|
||||
<title>DPLTestOpenReferences</title>
|
||||
<ns>0</ns>
|
||||
<id>29</id>
|
||||
<id>30</id>
|
||||
<revision>
|
||||
<id>29</id>
|
||||
<id>30</id>
|
||||
<timestamp>2021-09-04T04:00:00Z</timestamp>
|
||||
<contributor>
|
||||
<username>DPLTestUser</username>
|
||||
<id>2</id>
|
||||
</contributor>
|
||||
<comment>Create test page with red link</comment>
|
||||
<origin>29</origin>
|
||||
<origin>30</origin>
|
||||
<model>wikitext</model>
|
||||
<format>text/x-wiki</format>
|
||||
<text xml:space="preserve">[[DPLTestArticle 1]][[DPLTestArticle 2]][[RedLink]][[DPLTestArticle 3]]</text>
|
||||
|
|
Loading…
Reference in a new issue