Page MenuHomePhabricator

SearchEngine.php uses count() on non-countable SearchSuggestionSet, producing warning in PHP 7.2
Closed, ResolvedPublic

Description

Error log:

[Mon Jan 15 21:23:13.214568 2018] [fcgid:warn] [pid 2505:tid 140496450066176] [client <IP>:13644] mod_fcgid: stderr: PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /includes/search/SearchEngine.php on line 546, referer: <URL>

Details

Related Gerrit Patches:

Event Timeline

Restricted Application added projects: Discovery, Discovery-Search. · View Herald TranscriptJan 15 2018, 4:44 PM
EBjune added a subscriber: EBjune.Jan 16 2018, 6:42 PM

Shouldn't be too hard, moving to up next

EBjune triaged this task as Medium priority.Jan 16 2018, 6:42 PM
EBjune moved this task from needs triage to Up Next on the Discovery-Search board.
Smalyshev added a subscriber: Smalyshev.

@RazeSoldier do you have any info about what actions has caused this to happen?

RazeSoldier added a comment.EditedJan 16 2018, 8:46 PM

@RazeSoldier do you have any info about what actions has caused this to happen?

After testing, I think this error will appear when I search the page (like: https://www.mediawiki.org/w/index.php?search=MediaWiki&title=Special:Search&profile=default&fulltext=1), if I search something out. Repeat the search for the same keyword, the error will only show the first time.

So, I think the condition of this error is:

  • There are search results
  • This search is the first time

I think there's a more generic bug here:

	$fallbackLimit -= count( $fallbackSearchResult );

$fallbackSearchResult is SearchSuggestionSet which does not implement Countable. It's just before 7.2 PHP did not warn about it. But I think it should be $fallbackSearchResult->getSize() instead.

Smalyshev renamed this task from Search part of MW is not fully compatible with PHP 7.2 to SearchEngine.php uses count() on non-countable SearchSuggestionSet, producing warning in PHP 7.2.Jan 16 2018, 9:48 PM
RazeSoldier added a comment.EditedJan 19 2018, 12:37 PM

I think there's a more generic bug here:

	$fallbackLimit -= count( $fallbackSearchResult );

$fallbackSearchResult is SearchSuggestionSet which does not implement Countable. It's just before 7.2 PHP did not warn about it. But I think it should be $fallbackSearchResult->getSize() instead.

I think this problem has been solved on my wiki.

Change 405757 had a related patch set uploaded (by Smalyshev; owner: Smalyshev):
[mediawiki/core@master] Use getSize since SearchSuggestionSet does not implement Countable

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

Change 405757 merged by jenkins-bot:
[mediawiki/core@master] Use getSize since SearchSuggestionSet does not implement Countable

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

RazeSoldier closed this task as Resolved.Jan 30 2018, 5:17 AM
RazeSoldier claimed this task.
RazeSoldier removed RazeSoldier as the assignee of this task.
RazeSoldier removed a project: Patch-For-Review.
mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:09 PM