Skip to content

Commit

Permalink
Fix for links migration: add JOIN on linktarget for notuses (#213)
Browse files Browse the repository at this point in the history
Also adds a PHPUnit tests for the notuses parameter.
  • Loading branch information
Universal-Omega authored Jan 4, 2023
1 parent 8dd8d03 commit d7336b1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -803,3 +803,7 @@ Many thanks to GreenReaper on GitHub for reporting and finding issues with core
* 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

# Version 3.5.1
* Added a fix for links migration: added a `JOIN` on `linktarget` for the `notuses` parameter
* Added a PHPUnit test for the `notuses` parameter
2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "DynamicPageList3",
"version": "3.5.0",
"version": "3.5.1",
"author": [
"'''Universal Omega'''",
"Alexia E. Smith",
Expand Down
2 changes: 1 addition & 1 deletion includes/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -2268,7 +2268,7 @@ private function _uses( $option ) {
*/
private function _notuses( $option ) {
if ( count( $option ) > 0 ) {
$where = $this->tableNames['page'] . '.page_id NOT IN (SELECT ' . $this->tableNames['templatelinks'] . '.tl_from FROM ' . $this->tableNames['templatelinks'] . ' WHERE (';
$where = $this->tableNames['page'] . '.page_id NOT IN (SELECT ' . $this->tableNames['templatelinks'] . '.tl_from FROM ' . $this->tableNames['templatelinks'] . ' INNER JOIN ' . $this->tableNames['linktarget'] . ' ON ' . $this->tableNames['linktarget'] . '.lt_id = ' . $this->tableNames['templatelinks'] . '.tl_target_id WHERE (';
$ors = [];

$linksMigration = MediaWikiServices::getInstance()->getLinksMigration();
Expand Down
11 changes: 11 additions & 0 deletions tests/phpunit/DPLQueryIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ public function testFindPagesInCategoryUsingTemplate(): void {
);
}

public function testFindPagesInCategoryNotUsingTemplate(): void {
$this->assertArrayEquals(
[ 'DPLTestArticleMultipleCategories' ],
$this->getDPLQueryResults( [
'category' => 'DPLTestOtherCategory',
'notuses' => 'Template:DPLInfobox'
] ),
true
);
}

public function testFindPagesNotInCategoryUsingTemplate(): void {
$this->assertArrayEquals(
[ 'DPLTestArticle 1' ],
Expand Down

0 comments on commit d7336b1

Please sign in to comment.