Skip to content

USEREDITCNTNS compatibility with MW1.39 #234

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

Merged
merged 2 commits into from
Aug 14, 2024
Merged
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
26 changes: 19 additions & 7 deletions src/PropertyAnnotators/UserEditCountPerNsPropertyAnnotator.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,25 @@ public static function container( DIWikiPage $subject, $ns, $edits ): DIContaine
*/
private function getEditsPerNs( $id, $ip ): array {
$db = $this->appFactory->getConnection();

if ( version_compare( MW_VERSION, "1.39", ">=" ) ) {
$queryTables = [ 'revision', 'actor', 'page' ];
$joinConditions = [
'page' => [ 'INNER JOIN', [ 'page.page_id=revision.rev_page' ] ],
'actor' => [ 'INNER JOIN', [ 'actor.actor_id=revision.rev_actor' ] ]
];
} else {
$queryTables = [ 'revision', 'revision_actor_temp', 'actor', 'page' ];
$joinConditions = [
'page' => [ 'INNER JOIN', [ 'page.page_id=revision.rev_page' ] ],
'revision_actor_temp' => [ 'INNER JOIN', [ 'revision_actor_temp.revactor_rev=revision.rev_id' ] ],
'actor' => [ 'INNER JOIN', [ 'actor.actor_id=revision_actor_temp.revactor_actor' ] ]
];
}

$result = $db->select(
// FROM.
[ 'revision', 'revision_actor_temp', 'actor', 'page' ],
// FROM.
$queryTables,
// SELECT.
[ 'ns' => 'page.page_namespace', 'edits' => 'COUNT(revision.rev_id)' ],
// WHERE.
Expand All @@ -126,11 +142,7 @@ private function getEditsPerNs( $id, $ip ): array {
// GROUP BY.
[ 'GROUP BY' => [ 'page.page_namespace' ] ],
// JOIN conditions.
[
'page' => [ 'INNER JOIN', [ 'page.page_id=revision.rev_page' ] ],
'revision_actor_temp' => [ 'INNER JOIN', [ 'revision_actor_temp.revactor_rev=revision.rev_id' ] ],
'actor' => [ 'INNER JOIN', [ 'actor.actor_id=revision_actor_temp.revactor_actor' ] ]
]
$joinConditions
);
$records = [];
foreach ( $result as $row ) {
Expand Down
Loading