Issue #1847978 by cpliakas: Fixed undefined variable and logic error when determining whether the query has phrases.