5 Jan 2024, 4:19 PM
New Zenner
- Join Date:
- Apr 2011
- Location:
- Espoo, Finland
- Posts:
- 71
- Plugin Contributions:
- 0
"Undefined variable" warning in zen_build_keyword_where_clause function
Happy New Year everyone
PHP 8 can generate "Undefined variable" and "Passing null to parameter" warnings in zen_build_keyword_where_clause function (functions_strings.php, line 211)
function zen_build_keyword_where_clause($fields, $string, $startWithWhere = false)
{
global $db, $zco_notifier;
$zco_notifier->notify('NOTIFY_BUILD_KEYWORD_SEARCH', '', $fields, $string);
if (zen_parse_search_string(stripslashes($string), $search_keywords)) [B]{[/B]
[B]$where_str =[/B] " AND (";
...
[B]}[/B]
if (substr([B]$where_str[/B], -7) === '( () )') {
return ' ';
}
return $where_str ?? ' ';
}
My quick suggestion:
if (!empty($where_str) AND substr($where_str, -7) === '( () )') {
return ' ';
}