Page MenuHomePhabricator

"Title::newFromTitle: $text must be a string" from PrefixSearch
Closed, ResolvedPublicPRODUCTION ERROR

Description

Looking in logstash for channel:T76305 to find these hits.

Warning: Title::newFromTitle: $text must be a string
from
PrefixSearch->searchWithVariants/PrefixSearch->search/PrefixSearch->searchBackend/PrefixSearch->defaultSearchBackend/Title::newFromText

Note that Title::newFromText already throws for objects and tolerates null. So this must be a primitive non-null, non-string value being passed somehow.

Event Timeline

Krinkle raised the priority of this task from to Medium.
Krinkle updated the task description. (Show Details)
Krinkle added subscribers: Krinkle, Reedy.

I wasn't able to reproduce this in plain MediaWiki. I suspect this is coming from a CirrusSearch hook, namely https://github.com/wikimedia/mediawiki-extensions-CirrusSearch/blob/2a22965d0463bd498bed1834d01573abc63a13cc/includes/Searcher.php#L1589. That call to substr looks very suspicious, I imagine it could easily return false if the right string is passed in.

I wonder if someone with Vagrant+CirrusSearch could have a play around with this?

This task is effectively a dupe of T109975 and should have been fixed by https://gerrit.wikimedia.org/r/#/c/235675. Seems like that got reverted in b7f078c75e75c57aa06c4f61f0427bd5ffcf219a for some reason.

got reverted in b7f078c75e75c57aa06c4f61f0427bd5ffcf219a for some reason.

From the commit message:

PrefixSearch: Follows-up 337b1e2e. null is already handled. If other types are passed, we want to find these.

Function documentation:

/*  @param string $search

The original patch was for fixing null, not false. Where is false coming from? That should be handled by the caller. This function doesn't support other types. Doing a type check in between this and Title::newFromText seems inappropriate.

I wonder if this is happening anymore, as the code was refactored so that normally PrefixSearch is not used unless searching for Special: etc. @Krinkle, could you check if it is still an issue? I've looked at https://logstash.wikimedia.org/ and found no instances lately but I'm not sure if I did it right.

Deskana added a subscriber: Deskana.

Let's assume this one is resolved, then. @Krinkle or anyone else can reopen if we are mistaken, and we can continue investigations.

mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:11 PM