Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert helper classes #63

Merged
merged 19 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/mediawiki-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ jobs:
- mw: 'REL1_36'
php: 7.3
php-docker: 73
experimental: false
experimental: true
stage: composer-test

runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -708,3 +708,7 @@ Many thanks to GreenReaper on GitHub for reporting and finding issues with core
* Numerous bug fixes
* Now requires MediaWiki 1.36.0 or later
* 1.37.0 support

# Version 3.3.7
* Revert helper classes added in version 3.3.6, as it had negative performance impact
* Fix adduser
4 changes: 1 addition & 3 deletions extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "DynamicPageList3",
"version": "3.3.6",
"version": "3.3.7",
"author": [
"Alexia E. Smith",
"[https://meta.miraheze.org/wiki/User:Universal_Omega Universal Omega]",
Expand Down Expand Up @@ -57,8 +57,6 @@
"DPL\\Query": "includes/Query.php",
"DPL\\UpdateArticle": "includes/UpdateArticle.php",
"DPL\\Variables": "includes/Variables.php",
"DPL\\RevisionJoinBuilder": "includes/RevisionJoinBuilder.php",
"DPL\\UserQueryBuilder": "includes/UserQueryBuilder.php",
"DPL\\DynamicPageListHooks": "includes/DynamicPageListHooks.php",
"DPL\\DPLIntegrationTestCase": "tests/phpunit/DPLIntegrationTestCase.php"
},
Expand Down
43 changes: 29 additions & 14 deletions includes/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class Article {
/**
* Name of editor (first/last, depending on user's request) or contributions if not registered.
*
* @var string
* @var string|null
*/
public $mUser = null;

Expand All @@ -144,7 +144,7 @@ class Article {
*
* @var string
*/
public $mComment = null;
public $mComment = '';

/**
* Number of bytes changed.
Expand Down Expand Up @@ -196,10 +196,18 @@ public function __construct( Title $title, $namespace ) {
public static function newFromRow( $row, Parameters $parameters, Title $title, $pageNamespace, $pageTitle ) {
global $wgLang;

$contentLanguage = MediaWikiServices::getInstance()->getContentLanguage();
$services = MediaWikiServices::getInstance();

$contentLanguage = $services->getContentLanguage();
$userFactory = $services->getUserFactory();

$article = new Article( $title, $pageNamespace );

$revActorName = null;
if ( isset( $row['revactor_actor'] ) ) {
$revActorName = $userFactory->newFromActorId( $row['revactor_actor'] )->getName();
}

$titleText = $title->getText();
if ( $parameters->getParameter( 'shownamespace' ) === true ) {
$titleText = $title->getPrefixedText();
Expand Down Expand Up @@ -274,19 +282,20 @@ public static function newFromRow( $row, Parameters $parameters, Title $title, $
if ( $parameters->getParameter( 'goal' ) != 'categories' ) {
// REVISION SPECIFIED
if ( $parameters->getParameter( 'lastrevisionbefore' ) || $parameters->getParameter( 'allrevisionsbefore' ) || $parameters->getParameter( 'firstrevisionsince' ) || $parameters->getParameter( 'allrevisionssince' ) ) {
$article->mRevision = $row['rev_id'];
$article->mUser = $row['rev_user_text'];
$article->mDate = $row['rev_timestamp'];
$article->mComment = $row['rev_comment'];
$article->mRevision = $row['revactor_rev'];
$article->mUser = $revActorName;
$article->mDate = $row['revactor_timestamp'];

// $article->mComment = $row['rev_comment'];
}

// SHOW "PAGE_TOUCHED" DATE, "FIRSTCATEGORYDATE" OR (FIRST/LAST) EDIT DATE
if ( $parameters->getParameter( 'addpagetoucheddate' ) ) {
$article->mDate = $row['page_touched'];
} elseif ( $parameters->getParameter( 'addfirstcategorydate' ) ) {
$article->mDate = $row['cl_timestamp'];
} elseif ( $parameters->getParameter( 'addeditdate' ) && isset( $row['rev_timestamp'] ) ) {
$article->mDate = $row['rev_timestamp'];
} elseif ( $parameters->getParameter( 'addeditdate' ) && isset( $row['revactor_timestamp'] ) ) {
$article->mDate = $row['revactor_timestamp'];
} elseif ( $parameters->getParameter( 'addeditdate' ) && isset( $row['page_touched'] ) ) {
$article->mDate = $row['page_touched'];
}
Expand All @@ -304,16 +313,18 @@ public static function newFromRow( $row, Parameters $parameters, Title $title, $
// CONTRIBUTION, CONTRIBUTOR
if ( $parameters->getParameter( 'addcontribution' ) ) {
$article->mContribution = $row['contribution'];
$article->mContributor = $row['contributor'];

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

$article->mContrib = substr( '*****************', 0, (int)round( log( $row['contribution'] ) ) );
}

// USER/AUTHOR(S)
// because we are going to do a recursive parse at the end of the output phase
// we have to generate wiki syntax for linking to a user´s homepage
if ( $parameters->getParameter( 'adduser' ) || $parameters->getParameter( 'addauthor' ) || $parameters->getParameter( 'addlasteditor' ) ) {
$article->mUserLink = '[[User:' . $row['rev_user_text'] . '|' . $row['rev_user_text'] . ']]';
$article->mUser = $row['rev_user_text'];
$article->mUserLink = '[[User:' . $revActorName . '|' . $revActorName . ']]';
$article->mUser = $revActorName;
}

// CATEGORY LINKS FROM CURRENT PAGE
Expand All @@ -337,11 +348,15 @@ public static function newFromRow( $row, Parameters $parameters, Title $title, $
} else {
$article->mParentHLink = '[[:Category:' . $row['cl_to'] . '|' . str_replace( '_', ' ', $row['cl_to'] ) . ']]';
}

break;
case 'user':
self::$headings[$row['rev_user_text']] = ( isset( self::$headings[$row['rev_user_text']] ) ? self::$headings[$row['rev_user_text']] + 1 : 1 );
if ( $revActorName ) {
self::$headings[$revActorName] = ( isset( self::$headings[$revActorName] ) ? self::$headings[$revActorName] + 1 : 1 );

$article->mParentHLink = '[[User:' . $revActorName . '|' . $revActorName . ']]';
}

$article->mParentHLink = '[[User:' . $row['rev_user_text'] . '|' . $row['rev_user_text'] . ']]';
break;
}
}
Expand Down
5 changes: 1 addition & 4 deletions includes/Parse.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace DPL;

use ActorMigration;
use DPL\Heading\Heading;
use DPL\Lister\Lister;
use ExtVariables;
Expand Down Expand Up @@ -216,9 +215,7 @@ public function parse( $input, Parser $parser, &$reset, &$eliminate, $isParserTa
/* Query */
/*********/
try {
$actorMigration = ActorMigration::newMigration();
$commentStore = MediaWikiServices::getInstance()->getCommentStore();
$query = new Query( $this->parameters, $actorMigration, $commentStore );
$query = new Query( $this->parameters );
$result = $query->buildAndSelect( $calcRows );
} catch ( MWException $e ) {
$this->logger->addMessage( DynamicPageListHooks::FATAL_SQLBUILDERROR, $e->getMessage() );
Expand Down
Loading