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

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

Change 672591 had a related patch set uploaded (by Tobias Andersson; owner: Guergana Tzatchkova):
[mediawiki/extensions/Wikibase@REL1_35] Fix limit not applied in case of language fallback

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

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

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