Fix compatibility with PHP 8.0 (latest XAMPP)

Solution by doctrine developers
This commit is contained in:
slawkens 2021-02-16 00:28:54 +01:00
parent 6b07d56627
commit 5bd5aa0edf
4 changed files with 30 additions and 4 deletions

View File

@ -23,6 +23,7 @@
*/
abstract class OTS_Base_DB extends PDO implements IOTS_DB
{
use OTS_DB_PDOQuery;
/**
* Tables prefix.
*
@ -74,7 +75,7 @@ abstract class OTS_Base_DB extends PDO implements IOTS_DB
return $this->fieldName($this->prefix . $name);
}
public function query($query)
private function doQuery(...$args)
{
$this->queries++;
@ -82,7 +83,7 @@ abstract class OTS_Base_DB extends PDO implements IOTS_DB
$startTime = microtime(true);
}
$ret = parent::query($query);
$ret = parent::query(...$args);;
if($this->logged) {
$totalTime = microtime(true) - $startTime;
$this->log .= round($totalTime, 4) . ' ms - ' . $query . PHP_EOL;

View File

@ -0,0 +1,25 @@
<?php
if (PHP_VERSION_ID >= 80000) {
trait OTS_DB_PDOQuery
{
/**
* @return PDOStatement
*/
public function query(?string $query = null, ?int $fetchMode = null, mixed ...$fetchModeArgs)
{
return $this->doQuery($query, $fetchMode, ...$fetchModeArgs);
}
}
} else {
trait OTS_DB_PDOQuery
{
/**
* @return PDOStatement
*/
public function query()
{
return $this->doQuery(...func_get_args());
}
}
}

View File

@ -86,7 +86,7 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
*
* @param array $properties List of object properties.
*/
public function __set_state($properties)
public static function __set_state($properties)
{
$object = new self();

View File

@ -72,7 +72,7 @@ class OTS_SpellsList implements IteratorAggregate, Countable
*
* @param array $properties List of object properties.
*/
public function __set_state($properties)
public static function __set_state($properties)
{
$object = new self();