RecentChangesUpdateJob: Fix GROUP BY
authorBrad Jorsch <bjorsch@wikimedia.org>
Fri, 16 Aug 2019 18:02:56 +0000 (14:02 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Fri, 16 Aug 2019 18:02:56 +0000 (14:02 -0400)
When a column specified in GROUP BY is both a table column and a
SELECT-field, MySQL and PostgreSQL both interpret it as the table column
rather than the SELECT-field.

In PostgreSQL this raises an error, which is good since it lets us know
it needs fixing. But MySQL goes ahead and groups by the table field
which gives us the wrong result.

Bug: T230618
Change-Id: Id500556b2795b86849329eece3b651b08e29a7f7

includes/jobqueue/jobs/RecentChangesUpdateJob.php

index 2d4ce34..63e6da4 100644 (file)
@@ -168,7 +168,7 @@ class RecentChangesUpdateJob extends Job {
                        ],
                        __METHOD__,
                        [
-                               'GROUP BY' => [ 'rc_user_text' ],
+                               'GROUP BY' => [ $actorQuery['fields']['rc_user_text'] ],
                                'ORDER BY' => 'NULL' // avoid filesort
                        ],
                        $actorQuery['joins']