mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Miscellaneous fixes, mostly undefined variables (#14432)
* Miscellaneous fixes, mostly undefined variables * Update phpstan-baseline.neon
This commit is contained in:
@@ -140,7 +140,7 @@ class QueryBuilderFluentParser extends QueryBuilderParser
|
||||
$op = $rule['operator'];
|
||||
|
||||
$value = $rule['value'];
|
||||
if (! is_array($value) && Str::startsWith($value, '`') && Str::endsWith($value, '`')) {
|
||||
if (! is_array($value) && is_string($value) && Str::startsWith($value, '`') && Str::endsWith($value, '`')) {
|
||||
$value = DB::raw($this->expandMacro(trim($value, '`')));
|
||||
}
|
||||
|
||||
|
@@ -171,8 +171,12 @@ class QueryBuilderParser implements \JsonSerializable
|
||||
$split = array_chunk(preg_split('/(&&|\|\|)/', $query, -1, PREG_SPLIT_DELIM_CAPTURE), 2);
|
||||
|
||||
foreach ($split as $chunk) {
|
||||
if (count($chunk) < 2 && empty($chunk[0])) {
|
||||
continue; // likely the ending && or ||
|
||||
if (count($chunk) < 2) {
|
||||
if (empty($chunk[0])) {
|
||||
continue; // likely the ending && or ||
|
||||
}
|
||||
|
||||
$chunk[1] = '';
|
||||
}
|
||||
|
||||
@[$rule_text, $rule_operator] = $chunk;
|
||||
@@ -181,8 +185,11 @@ class QueryBuilderParser implements \JsonSerializable
|
||||
$condition = ($rule_operator == '||' ? 'OR' : 'AND');
|
||||
}
|
||||
|
||||
@[$field, $op, $value] = preg_split('/ *([!=<>~]{1,2}) */', trim($rule_text), 2, PREG_SPLIT_DELIM_CAPTURE);
|
||||
$field = ltrim($field, '%');
|
||||
$rule_split = preg_split('/ *([!=<>~]{1,2}) */', trim($rule_text), 2, PREG_SPLIT_DELIM_CAPTURE);
|
||||
|
||||
$field = ltrim($rule_split[0], '%');
|
||||
$op = $rule_split[1] ?? null;
|
||||
$value = $rule_split[2] ?? null;
|
||||
|
||||
// for rules missing values just use '= 1'
|
||||
$operator = isset(self::$legacy_operators[$op]) ? self::$legacy_operators[$op] : 'equal';
|
||||
|
Reference in New Issue
Block a user