magnusmanske/petscan_rs

Breaking change: Flagged pages is broken

Closed this issue · 4 comments

Example and reason on the following link:
https://phabricator.wikimedia.org/T367966

Here's a copy of the linked phab ticket:

PetScan query fails with the following error:

Server(ServerError { code: 1356, message: "View 'huwiki_p.flaggedpage_pending' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them", state: "HY000" })

A search of the codebase for flaggedpage_pending reveals this. This is probably the code that needs updating:

match self.params.last_edit_flagged.as_str() {
"yes" => sql.0 +=
" AND NOT EXISTS (SELECT * FROM flaggedpage_pending WHERE p.page_id=fpp_page_id)",
"no" => {
sql.0 +=
" AND EXISTS (SELECT * FROM flaggedpage_pending WHERE p.page_id=fpp_page_id)"
}
_ => {}
}

Afaik, this would work with same logic than SQL query with flaggedpage_pending.

"yes" => sql.0 +=
" AND NOT EXISTS (SELECT * FROM flaggedpages WHERE fp_pending_since IS NOT NULL AND fp_page_id=p.page_id )",
"no" => {
sql.0 +=
" AND EXISTS (SELECT * FROM flaggedpages WHERE fp_pending_since IS NOT NULL AND fp_page_id=p.page_id )"
}

Description of the change:

Get rid of flaggedpage_pending table

This table was useful when we had several quality tiers but not anymore.

As it's written in documentation of the table:

Basically the same as flaggedpages, without the rows where fp_pending_since
is NULL. Was more useful in the past when there were multiple quality tiers.

Refactor the one place it actually makes the query (for updating stats)
and Special:PendingChanges if you provide levels (which we don't)