mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-29 08:44:10 +02:00
Avoid passing null
to non-nullable arguments
This commit is contained in:
parent
3dc384fb58
commit
83567ebad2
@ -68,10 +68,16 @@ class CommentParser
|
||||
|
||||
public function dump()
|
||||
{
|
||||
$res = $this->title . "\n" . str_repeat('=', strlen($this->title)) . "\n\n";
|
||||
if ($this->title) {
|
||||
$res = $this->title . "\n" . str_repeat('=', strlen($this->title)) . "\n\n";
|
||||
} else {
|
||||
$res = '';
|
||||
}
|
||||
|
||||
foreach ($this->paragraphs as $p) {
|
||||
$res .= wordwrap($p, 72) . "\n\n";
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
@ -276,6 +276,10 @@ class Loader
|
||||
|
||||
protected function searchMatch($needle, $haystack)
|
||||
{
|
||||
if ($needle === null) {
|
||||
$needle = '';
|
||||
}
|
||||
|
||||
$this->lastSuggestions = preg_grep(sprintf('/^%s.*$/', preg_quote($needle, '/')), $haystack);
|
||||
$match = array_search($needle, $haystack, true);
|
||||
if (false !== $match) {
|
||||
|
@ -356,13 +356,13 @@ class DbQuery extends SimpleQuery
|
||||
}
|
||||
|
||||
return '(' . implode(" $operator ", $sql) . ')';
|
||||
} elseif ($sign === '=' && strpos($expression, '*') !== false) {
|
||||
} elseif ($sign === '=' && $expression !== null && strpos($expression, '*') !== false) {
|
||||
if ($expression === '*') {
|
||||
return $col . ' IS NOT NULL';
|
||||
}
|
||||
|
||||
return $col . ' LIKE ' . $this->escapeForSql($this->escapeWildcards($expression));
|
||||
} elseif ($sign === '!=' && strpos($expression, '*') !== false) {
|
||||
} elseif ($sign === '!=' && $expression !== null && strpos($expression, '*') !== false) {
|
||||
if ($expression === '*') {
|
||||
return $col . ' IS NULL';
|
||||
}
|
||||
|
@ -152,7 +152,10 @@ class FilterExpression extends Filter
|
||||
*/
|
||||
protected function strtolowerRecursive($var)
|
||||
{
|
||||
if ($var === null || is_scalar($var)) {
|
||||
if ($var === null) {
|
||||
return '';
|
||||
}
|
||||
if (is_scalar($var)) {
|
||||
return strtolower($var);
|
||||
}
|
||||
if (is_array($var)) {
|
||||
@ -206,7 +209,7 @@ class FilterExpression extends Filter
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) preg_match($pattern, $rowValue);
|
||||
return $rowValue !== null && preg_match($pattern, $rowValue);
|
||||
}
|
||||
|
||||
public function andFilter(Filter $filter)
|
||||
|
@ -378,7 +378,7 @@ class SimpleQuery implements QueryInterface, Queryable, Iterator
|
||||
$column = $this->flippedColumns[$column];
|
||||
}
|
||||
|
||||
$result = strcmp(strtolower($a->$column), strtolower($b->$column));
|
||||
$result = strcmp(strtolower($a->$column ?: ''), strtolower($b->$column ?: ''));
|
||||
if ($result === 0) {
|
||||
return $this->compare($a, $b, ++$orderIndex);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class DateFormatter
|
||||
{
|
||||
$invert = false;
|
||||
$now = time();
|
||||
$time = (float) $time;
|
||||
$time = (int) $time;
|
||||
$diff = $time - $now;
|
||||
if ($diff < 0) {
|
||||
$diff = abs($diff);
|
||||
@ -94,7 +94,7 @@ class DateFormatter
|
||||
*/
|
||||
public static function formatDate($date)
|
||||
{
|
||||
return date('Y-m-d', (float) $date);
|
||||
return date('Y-m-d', (int) $date);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,7 +141,7 @@ class DateFormatter
|
||||
*/
|
||||
public static function formatTime($time)
|
||||
{
|
||||
return date('H:i:s', (float) $time);
|
||||
return date('H:i:s', (int) $time);
|
||||
}
|
||||
|
||||
/**
|
||||
|
19
library/vendor/Zend/Db/Statement.php
vendored
19
library/vendor/Zend/Db/Statement.php
vendored
@ -135,7 +135,7 @@ abstract class Zend_Db_Statement implements Zend_Db_Statement_Interface
|
||||
$sql = $this->_stripQuoted($sql);
|
||||
|
||||
// split into text and params
|
||||
$this->_sqlSplit = preg_split('/(\?|\:[a-zA-Z0-9_]+)/',
|
||||
$this->_sqlSplit = empty($sql) ? [] : preg_split('/(\?|\:[a-zA-Z0-9_]+)/',
|
||||
$sql, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
// map params
|
||||
@ -186,14 +186,18 @@ abstract class Zend_Db_Statement implements Zend_Db_Statement_Interface
|
||||
// remove 'foo\'bar'
|
||||
if (!empty($q)) {
|
||||
$escapeChar = preg_quote($escapeChar);
|
||||
// this segfaults only after 65,000 characters instead of 9,000
|
||||
$sql = preg_replace("/$q([^$q{$escapeChar}]*|($qe)*)*$q/s", '', $sql);
|
||||
if ($sql !== null) {
|
||||
// this segfaults only after 65,000 characters instead of 9,000
|
||||
$sql = preg_replace("/$q([^$q{$escapeChar}]*|($qe)*)*$q/s", '', $sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// get a version of the SQL statement with all quoted
|
||||
// values and delimited identifiers stripped out
|
||||
// remove "foo\"bar"
|
||||
$sql = preg_replace("/\"(\\\\\"|[^\"])*\"/Us", '', $sql);
|
||||
if ($sql !== null) {
|
||||
$sql = preg_replace("/\"(\\\\\"|[^\"])*\"/Us", '', $sql);
|
||||
}
|
||||
|
||||
// get the character for delimited id quotes,
|
||||
// this is usually " but in MySQL is `
|
||||
@ -205,7 +209,10 @@ abstract class Zend_Db_Statement implements Zend_Db_Statement_Interface
|
||||
$de = substr($de, 1, 2);
|
||||
$de = preg_quote($de);
|
||||
// Note: $de and $d where never used..., now they are:
|
||||
$sql = preg_replace("/$d($de|\\\\{2}|[^$d])*$d/Us", '', $sql);
|
||||
if ($sql !== null) {
|
||||
$sql = preg_replace("/$d($de|\\\\{2}|[^$d])*$d/Us", '', $sql);
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user