Page MenuHomePhabricator

Fix possible bug in MatchingTermsLookupSearchInteractor
Closed, ResolvedPublic

Description

The sonar code health analysis has surfaced a strange piece of code:

MatchingTermsLookupSearchInteractor.php
if ( count( $matchedTermIndexEntries ) > $limit ) {
	array_slice( $matchedTermIndexEntries, 0, $limit, true );
}

PHP's array_slice does not mutate its arguments but instead returns a value. That returned value is not used here, so something is wrong.

  • Figure out what is going on. Do we actually have a bug here that can be somehow seen in production?
  • Try to understand why there are no tests failing (are there none for that feature?)
  • Fix it (either remove it if it is not used or fix it and write a test for it if it is an actual bug in prod)

Event Timeline

Michael created this task.Jul 1 2020, 2:47 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 1 2020, 2:47 PM
Maintenance_bot moved this task from incoming to in progress on the Wikidata board.Jul 1 2020, 3:15 PM

Change 611340 had a related patch set uploaded (by Guergana Tzatchkova; owner: Guergana Tzatchkova):
[mediawiki/extensions/Wikibase@master] Fix bug in MatchingTermsLookupSearchInteractor

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

Change 611340 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Fix limit not applied in case of language fallback

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

Addshore updated the task description. (Show Details)Jul 16 2020, 7:13 AM