Page MenuHomePhabricator

Migrate usage of Database::select to SelectQueryBuilder in PageTriage
Open, In Progress, Needs TriagePublic

Description

Now that T243051: A query builder for MediaWiki core is done, this extension should migrate away from IDatabase::select() to SelectQueryBuilder.

It would improve readability of the code, avoids mistakes by passing the wrong order of arguments, etc.

For more information check T243051 and its documentation.

Note that query builder is a different paradigm and changes should not be one-to-one. For example, avoid using joinConds().

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.

Event Timeline

Looks like the type of refactoring asked for in this ticket is to replace $dbr->select( style code with $dbr->newSelectQueryBuilder()->select( style code. The first example takes up to 6 parameters, mostly arrays, and doesn't use method chaining. The second style uses method chaining.

More info at https://www.mediawiki.org/wiki/Manual:Database_access#Wrapper_function%3A_select()

Getting around 23 search results.

PageTriage doesn't have many tests. Mass refactoring SQL functions could be a bit dangerous. Will need to be careful.

image.png (982×415 px, 84 KB)

PageTriage doesn't have many tests. Mass refactoring SQL functions could be a bit dangerous. Will need to be careful.

Agreed. We can start converting the IDatabase::select() functions in the tests themselves and then move on to other select statements, with the condition that a unit test is added.

Scardenasmolinar changed the task status from Open to In Progress.Apr 24 2023, 7:29 PM
Scardenasmolinar claimed this task.
Scardenasmolinar moved this task from Ready to In Progress on the Moderator-Tools-Team (Kanban) board.

Change 911959 had a related patch set uploaded (by Scardenasmolinar; author: Scardenasmolinar):

[mediawiki/extensions/PageTriage@master] [WIP] Change Database::select to new query builder

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

Some of the select queries I couldn't migrate because it would mean a lot of reworking. We could tackle those in a follow-up ticket.

Test wiki created on Patch demo by SCardenas (WMF) using patch(es) linked to this task:
https://patchdemo.wmflabs.org/wikis/0bf752f8c0/w