Page MenuHomePhabricator

ApprovedRevs: special page's orderBy clause orders by fields not in the select
Closed, ResolvedPublic

Description

This results in the following error when visiting the page:

Original exception: [ce6344b7fb59f5b775e1ea28] /wiki/Special:ApprovedRevs Wikimedia\Rdbms\DBQueryError from line 1603 of .../includes/libs/rdbms/database/Database.php: A database query error has occurred. Did you forget to run your application's database schema updater after upgrading?

Query: SELECT DISTINCT p.page_id AS id,ar.rev_id AS rev_id,p.page_latest AS latest_id FROM `wiki1approved_revs` `ar` JOIN `wiki1page` `p` ON ((ar.page_id=p.page_id)) LEFT OUTER JOIN `wiki1page_props` `pp` ON ((ar.page_id=pp_page)) WHERE (p.page_latest != ar.rev_id AND ( ( pp_propname = 'approvedrevs' AND pp_value = 'y' OR pp_propname = 'approvedrevs-approver-users' OR pp_propname = 'approvedrevs-approver-groups' ) )) ORDER BY p.page_namespace,p.page_title LIMIT 51

Function: SpecialApprovedRevs::reallyDoQuery

Error: 3065 Expression #1 of ORDER BY clause is not in SELECT list, references column 'wiki_d.p.page_namespace' which is not in SELECT list; this is incompatible with DISTINCT (10.42.27.186)

Event Timeline

Change 592717 had a related patch set uploaded (by markahershberger; owner: markahershberger):
[mediawiki/extensions/ApprovedRevs@master] Add missing fields for Special page's order by

https://gerrit.wikimedia.org/r/592717

That's very interesting. I can see how this would lead to a DB error, and yet on my wiki (MW 1.33) it doesn't - I think because the 'DISTINCT' option that's passed in seems to be getting ignored. So this might be two problems in one. What version of MediaWiki are you running, and what DB system?

I'm using Percona XtraDB Cluster 5.7.23-23-57-log which uses the MySQL 5.7 engine. There are a number of SO questions about this difference in MySQL 5.7, many of which say to disable ONLY_FULL_GROUP_BY but this Percona blog post explains how to actually address the problem.

Just ran into this again. This is not a percona problem, but an incompatibility with mysql 5.7.

Removing task assignee due to inactivity as this open task has been assigned for more than two years. See the email sent to the task assignee on August 22nd, 2022.
Please assign this task to yourself again if you still realistically [plan to] work on this task - it would be welcome!
If this task has been resolved in the meantime, or should not be worked on ("declined"), please update its task status via "Add Action… 🡒 Change Status".
Also see https://www.mediawiki.org/wiki/Bug_management/Assignee_cleanup for tips how to best manage your individual work in Phabricator. Thanks!

Change 592717 abandoned by Yaron Koren:

[mediawiki/extensions/ApprovedRevs@master] Add missing fields for Special page's order by

Reason:

This change was implemented a year later, in https://gerrit.wikimedia.org/r/c/mediawiki/extensions/ApprovedRevs/+/748785

https://gerrit.wikimedia.org/r/592717

Yaron_Koren claimed this task.

I don't know why I never approved (or even reviewed?) the original 2020 patch, or why there was another, nearly-identical patch made in 2021, but the 2021 patch was approved, thankfully:

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/ApprovedRevs/+/748785

So as far as I know, this issue was fixed back then.