PHP 8 fix: adding explicit cast for comparing DB-version to a float major number

This commit is contained in:
Ralf Becker 2021-03-31 13:31:42 +02:00
parent 11d441e689
commit 37e5e12c3c
5 changed files with 8 additions and 8 deletions

View File

@ -419,7 +419,7 @@ class Sql extends Api\Storage
);
$columns = implode(', ', $group);
if ($this->db->Type == 'mysql' && $this->db->ServerInfo['version'] >= 4.0)
if ($this->db->Type == 'mysql' && (float)$this->db->ServerInfo['version'] >= 4.0)
{
$mysql_calc_rows = 'SQL_CALC_FOUND_ROWS ';
}

View File

@ -538,7 +538,7 @@ class Db
$this->set_capabilities($Type,$this->ServerInfo['version']);
// switch off MySQL 5.7+ ONLY_FULL_GROUP_BY sql_mode
if (substr($this->Type, 0, 5) == 'mysql' && $this->ServerInfo['version'] >= 5.7 && $this->ServerInfo['version'] < 10.0)
if (substr($this->Type, 0, 5) == 'mysql' && (float)$this->ServerInfo['version'] >= 5.7 && (float)$this->ServerInfo['version'] < 10.0)
{
$this->query("SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''))", __LINE__, __FILE__);
}
@ -661,7 +661,7 @@ class Db
case 'maxdb': // if Lim ever changes it to maxdb ;-)
case 'sapdb':
$this->capabilities[self::CAPABILITY_DISTINCT_ON_TEXT] = false;
$this->capabilities[self::CAPABILITY_LIKE_ON_TEXT] = $db_version >= 7.6;
$this->capabilities[self::CAPABILITY_LIKE_ON_TEXT] = (float)$db_version >= 7.6;
$this->capabilities[self::CAPABILITY_ORDER_ON_TEXT] = false;
break;
}
@ -1228,7 +1228,7 @@ class Db
break;
case 'pgsql': // requires for Postgresql < 8.4 to have a custom ARRAY_AGG method installed!
if ($this->Type == 'pgsql' && $this->ServerInfo['version'] < 8.4)
if ($this->Type == 'pgsql' && (float)$this->ServerInfo['version'] < 8.4)
{
return false;
}

View File

@ -105,7 +105,7 @@ class Pdo
case 'mysql':
$dsn .= ';charset=utf8';
// switch off MySQL 5.7+ ONLY_FULL_GROUP_BY sql_mode
if ($egw_db->ServerInfo['version'] >= 5.7 && $egw_db->ServerInfo['version'] < 10.0)
if ((float)$egw_db->ServerInfo['version'] >= 5.7 && (float)$egw_db->ServerInfo['version'] < 10.0)
{
$query = "SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''))";
}

View File

@ -1002,7 +1002,7 @@ class Base
// running the union query now
if ($start !== false) // need to get the total too, saved in $this->total
{
if ($this->db->Type == 'mysql' && $this->db->ServerInfo['version'] >= 4.0)
if ($this->db->Type == 'mysql' && (float)$this->db->ServerInfo['version'] >= 4.0)
{
$union[0]['cols'] = ($mysql_calc_rows = 'SQL_CALC_FOUND_ROWS ').$union[0]['cols'];
}
@ -1021,7 +1021,7 @@ class Base
{
if ($start !== false) // need to get the total too, saved in $this->total
{
if ($this->db->Type == 'mysql' && $this->db->ServerInfo['version'] >= 4.0)
if ($this->db->Type == 'mysql' && (float)$this->db->ServerInfo['version'] >= 4.0)
{
$mysql_calc_rows = 'SQL_CALC_FOUND_ROWS ';
}

View File

@ -946,7 +946,7 @@ class infolog_so
$sql_query = "FROM $this->info_table main $join WHERE ($filtermethod $pid $sql_query) $link_extra";
#error_log("infolog.so.search:\n" . print_r($sql_query, true));
if ($this->db->Type == 'mysql' && $this->db->ServerInfo['version'] >= 4.0)
if ($this->db->Type == 'mysql' && (float)$this->db->ServerInfo['version'] >= 4.0)
{
$mysql_calc_rows = 'SQL_CALC_FOUND_ROWS ';
unset($query['total']);