Page MenuHomePhabricator

Fix footgun DB query in RevisionStore::getTimestampFromId
Closed, ResolvedPublic

Description

It seems this method (unintentionally?) accepts a null value, leading to a strange and confusing query:

SELECT rev_timestamp FROM `revision` WHERE rev_id IS NULL LIMIT 1

This was uncovered in https://gerrit.wikimedia.org/r/c/mediawiki/core/+/620918 by patching high-level Skin code.

I think this should either be made impossible with a strict parameter type that disallows non-integer values, or it needs to be explicitly supported with a test and possibly an inline optimisation for the null case so that this logic does not reside in the Skin layer.

Event Timeline

Change 657554 had a related patch set uploaded (by Ammarpad; owner: Ammarpad):
[mediawiki/core@master] RevisionStore: Prevent useless DB query

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

Change 657554 merged by jenkins-bot:
[mediawiki/core@master] RevisionStore: Prevent useless DB query

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

Ammarpad claimed this task.