/** * Support method for fixBadQuery(). * * @param QueryGroup $query Query to fix * * @return bool|QueryGroup Fixed query, or false if no solution is found. */ protected function fixBadQueryGroup(QueryGroup $query) { $newQueries = []; $fixed = false; // Try to fix each query in the group; replace any query that needs to // be changed. foreach ($query->getQueries() as $current) { $fixedQuery = $this->fixBadQuery($current); if ($fixedQuery) { $fixed = true; $newQueries[] = $fixedQuery; } else { $newQueries[] = $current; } } // If any of the queries in the group was fixed, we'll treat the whole // group as being fixed. if ($fixed) { $query->setQueries($newQueries); return $query; } // If we got this far, nothing was changed -- report failure: return false; }