Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8aaa8d2
Use namespaced ConfigException
Universal-Omega Feb 13, 2025
2bac492
Fix Heading's attribute setters (hlistattr, hitemattr may be null) (#…
alex4401 Mar 5, 2025
da82ff3
Fix tests
Universal-Omega Mar 25, 2025
59feaf9
Bump version to 3.6.2
Universal-Omega Mar 25, 2025
bd275b7
Update CHANGELOG for 3.6.2
Universal-Omega Mar 25, 2025
097c9ac
Fix tense
Universal-Omega Mar 25, 2025
650b304
Fix branch
Universal-Omega Apr 11, 2025
26b9e96
Apply some performance improvements from downstream (#327)
Universal-Omega Apr 11, 2025
2430655
Update branches
Universal-Omega Apr 13, 2025
1d503ef
Fix dataProvider method names
Universal-Omega May 6, 2025
0862b59
Update mediawiki/mediawiki-codesniffer requirement from 46.0.0 to 47.…
dependabot[bot] May 6, 2025
be0e14f
Localisation updates from https://translatewiki.net.
translatewiki May 15, 2025
b694220
Pass unquoted table name to RDBMS (#334)
xtexx Jun 21, 2025
03aa26f
Show raw query exception if the request is not made (#333)
xtexx Jun 21, 2025
1ead265
Fix compatability with upstream backported Rdbms changes
Universal-Omega Jul 8, 2025
c68fc91
Release version 3.6.3
Universal-Omega Jul 8, 2025
efc66ea
Fix PHP warning in Parameters::_nottitleregexp (uninitialised array/k…
alex4401 Jul 8, 2025
8bef7e3
Some cleanup
Universal-Omega Jul 8, 2025
c571e1c
Remove unused variable
Universal-Omega Jul 8, 2025
10453b0
Update mediawiki/mediawiki-phan-config requirement from 0.15.1 to 0.1…
dependabot[bot] Jul 8, 2025
ba64d28
Security: fix hiding usernames for hidden users
Universal-Omega Jul 9, 2025
18fffff
Fix PHPCS
Universal-Omega Jul 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ name: Codacy Security Scan

on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
branches: [ main ]
schedule:
- cron: '31 7 * * 0'

Expand Down
34 changes: 24 additions & 10 deletions .github/workflows/mediawiki-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Quibble and Phan

on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
branches: [ master ]
branches: [ main ]

jobs:
test:
Expand All @@ -13,33 +13,47 @@ jobs:
strategy:
matrix:
include:
# Latest stable MediaWiki - PHP 8.1 (phan)
# Latest MediaWiki LTS - PHP 8.1 (phan)
- mw: 'REL1_43'
php: 8.1
php-docker: 81
experimental: false
stage: phan

# Latest stable MediaWiki - PHP 8.1 (phan)
- mw: 'REL1_44'
php: 8.1
php-docker: 81
experimental: true
stage: phan

# Latest MediaWiki master - PHP 8.1 (phan)
- mw: 'master'
php: 8.1
php-docker: 81
experimental: true
stage: phan

# Latest MediaWiki master - PHP 7.4 (coverage)
# Latest MediaWiki master - PHP 8.1 (coverage)
- mw: 'master'
php: 7.4
php-docker: 74
php: 8.1
php-docker: 81
experimental: false
stage: coverage

# Latest stable MediaWiki - PHP 8.1 (phpunit)
# Latest MediaWiki LTS - PHP 8.1 (phpunit)
- mw: 'REL1_43'
php: 8.1
php-docker: 81
experimental: false
stage: phpunit

# Latest stable MediaWiki - PHP 8.1 (phpunit)
- mw: 'REL1_44'
php: 8.1
php-docker: 81
experimental: false
stage: phpunit

# Latest MediaWiki master - PHP 8.1 (phpunit)
- mw: 'master'
Expand Down Expand Up @@ -74,8 +88,8 @@ jobs:
env:
DOCKER_REGISTRY: docker-registry.wikimedia.org
DOCKER_ORG: releng
QUIBBLE_DOCKER_IMAGE: quibble-buster-php${{ matrix.php-docker }}
COVERAGE_DOCKER_IMAGE: quibble-buster-php${{ matrix.php-docker }}-coverage
QUIBBLE_DOCKER_IMAGE: quibble-bullseye-php${{ matrix.php-docker }}
COVERAGE_DOCKER_IMAGE: quibble-bullseye-php${{ matrix.php-docker }}-coverage
PHAN_DOCKER_IMAGE: mediawiki-phan-php${{ matrix.php-docker }}
MEDIAWIKI_VERSION: ${{ matrix.mw }}

Expand Down Expand Up @@ -121,7 +135,7 @@ jobs:
curl -sL https://raw.githubusercontent.com/wikimedia/integration-config/master/zuul/dependencies.yaml -o dependencies.yaml
curl -sL https://raw.githubusercontent.com/wikimedia/integration-config/master/zuul/phan_dependencies.yaml -o phan_dependencies.yaml
curl -sL https://raw.githubusercontent.com/wikimedia/integration-config/master/zuul/parameter_functions.py -o pf.py
curl -sL https://raw.githubusercontent.com/miraheze/ci-scripts/master/mediawiki/resolve_dependencies.py -o rd.py
curl -sL https://raw.githubusercontent.com/miraheze/ci-scripts/main/mediawiki/resolve_dependencies.py -o rd.py
if [ -e dependencies ]; then
echo "DEPENDENCIES=$(python3 rd.py dependencies)" >> $GITHUB_ENV
fi
Expand Down
2 changes: 2 additions & 0 deletions .phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

$cfg = require __DIR__ . '/../vendor/mediawiki/mediawiki-phan-config/src/config.php';

$cfg['minimum_target_php_version'] = '8.1';

$cfg['directory_list'] = array_merge(
$cfg['directory_list'], [
'../../extensions/Variables',
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -838,3 +838,22 @@ Many thanks to GreenReaper on GitHub for reporting and finding issues with core
* Replaced the deprecated `ExtVariables::VERSION` with using `ExtensionRegistry` to check if the Variables extension is installed.
* Replaced usages of `intval()` with `(int)` in all remaining places within this extension. This was started in version 3.5.0 and completed in this version.
* Replaced usages of `boolval()` with `(bool)` throughout the entire extension.

# Version 3.6.2
* Fixed Heading's attribute setters (hlistattr, hitemattr may be null).
* Restored partial support for `linkstoexternal` and introduced replacement via `linkstoexternaldomain` and `linkstoexternalpath`.
* Fixed type mismatch between what is returned by `getLinkList` (list of arrays that contained non-serializable TitleValue) and what is expected by ParserOutput.

# Version 3.6.3
* Applied some performance improvements to LST from downstream (which added the new configuration option `$wgDplSettings['recursivePreprocess']`).
* Now shows raw query exception if the request is not made.
* Fixed CI compatibility with PHP 8.1 (which upstream MediaWiki master now requires).
* Added REL1_44 to CI.
* Fixed tests, replacing `ParserOutput::getText` with `ParserOutput::getContentHolderText`.
* Removed `Query::getTableNames` and associated properties, replacing calls with `$this->dbr->tableName`.
* Fixed compatability with upstream backported changes to use raw table names where necessary (by passing the second parameter of `$this->dbr->tableName` as `'raw'` where needed).

# Version 3.6.4
* Fixed a PHP warning in `nottitleregexp` (uninitialised array/key).
* Removed some unused parameters, methods, and variables.
* SECURITY: Fixed leakage of hidden/suppressed usernames ([GHSA-7pgw-q3qp-6pgq](https://github.com/Universal-Omega/DynamicPageList3/security/advisories/GHSA-7pgw-q3qp-6pgq)).
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ These are DPL3's configuration settings and along with their default values. To
| $wgDplSettings['maxCategoryCount'] | 4 | Maximum number of categories to allow in queries. |
| $wgDplSettings['minCategoryCount'] | 0 | Minimum number of categories to allow in queries. |
| $wgDplSettings['maxResultCount'] | 500 | Maximum number of results to return from a query. |
| $wgDplSettings['recursiveTagParse'] | false | Do recursive tag parsing on <dpl> parser tags converting tags and functions such as magic words like {{PAGENAME}}. This is similar to the {{#dpl}} parser function call, but may not work exactly the same in all cases. |
| $wgDplSettings['recursiveTagParse'] | false | Do recursive tag parsing on <dpl> parser tags converting tags and functions such as magic words like {{PAGENAME}}. This is similar to the {{#dpl}} parser function call, but may not work exactly the same in all cases. |
| $wgDplSettings['recursivePreprocess'] | false | Use `Parser::recursivePreprocess()` to improve performance by preserving the internal cache, reducing redundant template parsing. |
| $wgDplSettings['runFromProtectedPagesOnly'] | false | Set this to true to allow DPL3 to run from protected pages only. This is recommend if wiki administrators are having issues with malicious users creating computationally intensive queries. |
| $wgDplSettings['handleSectionTag'] | false | Set this to true to have DPL3 handle <section> tags outside of the parser tags provided by DPL3. |
| $wgDplSettings['maxQueryTime'] | 10000 | Maximum allowed time for database queries in milliseconds. |
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"composer/installers": ">=1.0.1"
},
"require-dev": {
"mediawiki/mediawiki-codesniffer": "46.0.0",
"mediawiki/mediawiki-phan-config": "0.15.1",
"mediawiki/mediawiki-codesniffer": "47.0.0",
"mediawiki/mediawiki-phan-config": "0.16.0",
"mediawiki/minus-x": "1.1.3",
"php-parallel-lint/php-console-highlighter": "1.0.0",
"php-parallel-lint/php-parallel-lint": "1.4.0"
Expand Down
3 changes: 2 additions & 1 deletion extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "DynamicPageList3",
"version": "3.6.1",
"version": "3.6.4",
"author": [
"'''Universal Omega'''",
"Alexia E. Smith",
Expand Down Expand Up @@ -58,6 +58,7 @@
"minCategoryCount": 0,
"maxResultCount": 500,
"recursiveTagParse": false,
"recursivePreprocess": false,
"runFromProtectedPagesOnly": false,
"handleSectionTag": false,
"alwaysCacheResults": false,
Expand Down
1 change: 1 addition & 0 deletions i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"Justman10000",
"Magiczocker",
"MarkusRost",
"Talex42",
"TomatoCake"
]
},
Expand Down
15 changes: 10 additions & 5 deletions includes/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use MediaWiki\Context\RequestContext;
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Title\Title;
use MediaWiki\User\ActorStore;
use stdClass;
Expand Down Expand Up @@ -211,8 +212,11 @@ public static function newFromRow(
$article = new self( $title, $pageNamespace );

$revActorName = ActorStore::UNKNOWN_USER_NAME;
if ( isset( $row->rev_actor ) && $row->rev_actor !== '0' ) {
$revActorName = $userFactory->newFromActorId( $row->rev_actor )->getName();
if ( isset( $row->rev_actor ) && (int)$row->rev_actor !== 0 ) {
$revUser = $userFactory->newFromActorId( $row->rev_actor );
$revUserDeleted = $row->rev_deleted & RevisionRecord::DELETED_USER;
$revActorName = $revUser->isHidden() || $revUserDeleted ?
wfMessage( 'rev-deleted-user' )->escaped() : $revUser->getName();
}

$titleText = $title->getText();
Expand Down Expand Up @@ -342,9 +346,10 @@ public static function newFromRow(
// CONTRIBUTION, CONTRIBUTOR
if ( $parameters->getParameter( 'addcontribution' ) ) {
$article->mContribution = $row->contribution;

$article->mContributor = $userFactory->newFromActorId( $row->contributor )->getName();

$contribUser = $userFactory->newFromActorId( $row->contributor );
$contribUserDeleted = $row->contrib_deleted & RevisionRecord::DELETED_USER;
$article->mContributor = $contribUser->isHidden() || $contribUserDeleted ?
wfMessage( 'rev-deleted-user' )->escaped() : $contribUser->getName();
$article->mContrib = substr( '*****************', 0, (int)round( log( $row->contribution ) ) );
}

Expand Down
2 changes: 1 addition & 1 deletion includes/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace MediaWiki\Extension\DynamicPageList3;

use ConfigException;
use MediaWiki\Config\ConfigException;

class Config {
/**
Expand Down
10 changes: 4 additions & 6 deletions includes/ExternalDomainPatternParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,24 @@

namespace MediaWiki\Extension\DynamicPageList3;

use MediaWiki\Extension\DynamicPageList3\Tests\DPLExternalDomainPatternParserTest;

trait ExternalDomainPatternParser {
/**
* We provide:
* * full support for "standalone" wildcard usage (eg. `%.fandom.com`)
* * partial support for wildcard usage when it is not separated by `.` (eg. `%fandom.com would match starwars.fandom-suffix.com)
* * protocols followed by the `://` are supported, like `http://` or `https://` (`mailto:` on the other hand is not supported)
*
* @See DPLExternalDomainPatternParserTest for example cases
* @see DPLExternalDomainPatternParserTest for example cases
*/
private function parseDomainPattern( string $pattern ): string {
$protocol = false;
// Protocol is specified. Strip it
if ( str_contains( $pattern, '://' ) ) {
[$protocol, $pattern] = explode( '://', $pattern );
[ $protocol, $pattern ] = explode( '://', $pattern );
}

// Previous step will strip protocol if it was specified
[$domainPattern, ] = explode( '/', $pattern, 2 );
[ $domainPattern, ] = explode( '/', $pattern, 2 );
$parts = explode( '.', $domainPattern );
$reversed = array_reverse( $parts );
foreach ( $reversed as &$part ) {
Expand All @@ -30,7 +28,7 @@ private function parseDomainPattern( string $pattern ): string {
}
if ( str_starts_with( $part, '%' ) ) {
$part .= '%';
} else if ( str_ends_with( $part, '%' ) ) {
} elseif ( str_ends_with( $part, '%' ) ) {
$part = '%' . $part;
}
}
Expand Down
5 changes: 0 additions & 5 deletions includes/Heading/Heading.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ public function format( $articles, Lister $lister ) {
$rowSize = $this->getParameters()->getParameter( 'rowsize' );
$rowColFormat = $this->getParameters()->getParameter( 'rowcolformat' );

$count = 0;

$headings = Article::getHeadings();
$output = '';

Expand Down Expand Up @@ -212,7 +210,6 @@ public function format( $articles, Lister $lister ) {
$output .= $this->getListStart();
$nstart = 0;
$greml = $nsize;
$g = 0;
$offset = 0;
foreach ( $headings as $headingCount ) {
$headingStart = $nstart - $offset;
Expand Down Expand Up @@ -247,8 +244,6 @@ public function format( $articles, Lister $lister ) {
$output .= "\n|-\n|\n";
}

++$g;

if ( $nstart + $nsize > $count ) {
$nsize = $count - $nstart;
}
Expand Down
18 changes: 8 additions & 10 deletions includes/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public static function dplTag( $input, array $args, Parser $parser, PPFrame $fra
* The callback function wrapper for converting the input text to HTML output
*
* @param string $input
* @param array $args
* @param array $args @phan-unused-param
* @param Parser $parser
* @param PPFrame $frame
* @return string
Expand Down Expand Up @@ -308,7 +308,7 @@ public static function dplNumParserFunction( $parser, $text = '' ) {
$parser->addTrackingCategory( 'dplnum-parserfunc-tracking-category' );

$num = str_replace( '&#160;', ' ', $text );
$num = str_replace( '&nbsp;', ' ', $text );
$num = str_replace( '&nbsp;', ' ', $num );
$num = preg_replace( '/([0-9])([.])([0-9][0-9]?[^0-9,])/', '\1,\3', $num );
$num = preg_replace( '/([0-9.]+),([0-9][0-9][0-9])\s*Mrd/', '\1\2 000000 ', $num );
$num = preg_replace( '/([0-9.]+),([0-9][0-9])\s*Mrd/', '\1\2 0000000 ', $num );
Expand Down Expand Up @@ -420,7 +420,7 @@ public static function dplChapterParserFunction(
) {
$parser->addTrackingCategory( 'dplchapter-parserfunc-tracking-category' );
$output = LST::extractHeadingFromText(
$parser, $page, '?title?', $text, $heading, '',
$parser, $page, $text, $heading, '',
$sectionHeading, true, $maxLength, $link, $trim
);
return $output[0];
Expand Down Expand Up @@ -514,8 +514,7 @@ public static function dplMatrixParserFunction(

foreach ( $targets as $to => $toName ) {
$targets[$to] = "[[$to|$toName]]";

foreach ( $sources as $from => $fromName ) {
foreach ( $sources as $from => $_ ) {
if ( array_key_exists( $to, $m[$from] ) ) {
$targets[$to] .= "\n|$yes";
} else {
Expand All @@ -534,8 +533,7 @@ public static function dplMatrixParserFunction(

foreach ( $sources as $from => $fromName ) {
$sources[$from] = "[[$from|$fromName]]";

foreach ( $targets as $to => $toName ) {
foreach ( $targets as $to => $_ ) {
if ( array_key_exists( $to, $m[$from] ) ) {
$sources[$from] .= "\n|$yes";
} else {
Expand Down Expand Up @@ -581,7 +579,7 @@ public static function getDebugLevel() {
* Reset everything; some categories may have been fixed, however via fixcategory=
*
* @param Parser $parser
* @param string $text
* @param string $text @phan-unused-param
*/
public static function endReset( $parser, $text ) {
if ( !self::$createdLinks['resetdone'] ) {
Expand Down Expand Up @@ -622,7 +620,7 @@ public static function endEliminate( $parser, &$text ) {
if ( self::$createdLinks ) {
if ( array_key_exists( 0, self::$createdLinks ) ) {
$parserLinks = $parser->getOutput()->mLinks;
foreach ( $parserLinks as $nsp => $link ) {
foreach ( $parserLinks as $nsp => $_ ) {
if ( !array_key_exists( $nsp, self::$createdLinks[0] ) ) {
continue;
}
Expand All @@ -641,7 +639,7 @@ public static function endEliminate( $parser, &$text ) {

if ( array_key_exists( 1, self::$createdLinks ) ) {
$parserTemplates = $parser->getOutput()->mTemplates;
foreach ( $parserTemplates as $nsp => $tpl ) {
foreach ( $parserTemplates as $nsp => $_ ) {
if ( !array_key_exists( $nsp, self::$createdLinks[1] ) ) {
continue;
}
Expand Down
Loading