Fix safeguard for empty condition list in WikiPageEntityMetaDataLookup
Closed, ResolvedPublic

Description

WikiPageEntityMetaDataLookup::getWhere has a special guard against an empty condition list for the query:

		if ( empty( $where ) ) {
			// If we skipped all entity IDs, select nothing, not everything.
			return '0';
		}

However, Database::selectSQLText actually interprets that '0' as “no conditions” (same as []), which results in a query without WHERE clause. Make sure we return something better. ([ false ]?)

Part of https://wikitech.wikimedia.org/wiki/Incident_documentation/20180226-WikibaseQualityConstraints.

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptFeb 26 2018, 8:31 PM

By the way, the safeguard was introduced by @daniel in Ie2e0b4d096 “Protected against unknown entity namespace”. (Not intended as blame, just for notification.)

I think [ false ] would result in WHERE (), which is a syntax error. I'd probably go for '1=2'.

Change 415064 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] DNM: add test without fixing bug

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

Change 415064 abandoned by Lucas Werkmeister (WMDE):
DNM: add test without fixing bug

Reason:
Nevermind, I got a working setup now. And it’ll look better on the task if I abandon this change and upload a new one instead of updating this one… I didn’t think this through :)

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

Change 415071 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Fix empty condition list in metadata lookup

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

Change 415071 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Fix empty condition list in metadata lookup

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

Change 415319 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@wmf/1.31.0-wmf.23] Fix empty condition list in metadata lookup

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

Change 415319 merged by Hashar:
[mediawiki/extensions/Wikibase@wmf/1.31.0-wmf.23] Fix empty condition list in metadata lookup

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

Mentioned in SAL (#wikimedia-operations) [2018-03-05T20:02:00Z] <hashar@tin> Synchronized php-1.31.0-wmf.23/extensions/Wikibase: Fix empty condition list in metadata lookup - T188313 (duration: 01m 58s)