mirror of
https://github.com/silverstripe/silverstripe-sqlite3
synced 2024-10-22 17:05:37 +02:00
PHP 8.1 compatibility
This commit is contained in:
parent
c95b0105f5
commit
f9dfa9f34c
@ -411,7 +411,7 @@ class SQLite3Database extends Database
|
|||||||
$queries[$class]->setFrom('"'.DataObject::getSchema()->baseDataTable($class).'"');
|
$queries[$class]->setFrom('"'.DataObject::getSchema()->baseDataTable($class).'"');
|
||||||
$queries[$class]->setSelect(array());
|
$queries[$class]->setSelect(array());
|
||||||
foreach ($select[$class] as $clause) {
|
foreach ($select[$class] as $clause) {
|
||||||
if (preg_match('/^(.*) +AS +"?([^"]*)"?/i', $clause, $matches)) {
|
if (preg_match('/^(.*) +AS +"?([^"]*)"?/i', $clause ?? '', $matches)) {
|
||||||
$queries[$class]->selectField($matches[1], $matches[2]);
|
$queries[$class]->selectField($matches[1], $matches[2]);
|
||||||
} else {
|
} else {
|
||||||
$queries[$class]->selectField(str_replace('"', '', $clause));
|
$queries[$class]->selectField(str_replace('"', '', $clause));
|
||||||
@ -672,7 +672,7 @@ class SQLite3Database extends Database
|
|||||||
|
|
||||||
public function formattedDatetimeClause($date, $format)
|
public function formattedDatetimeClause($date, $format)
|
||||||
{
|
{
|
||||||
preg_match_all('/%(.)/', $format, $matches);
|
preg_match_all('/%(.)/', $format ?? '', $matches);
|
||||||
foreach ($matches[1] as $match) {
|
foreach ($matches[1] as $match) {
|
||||||
if (array_search($match, array('Y', 'm', 'd', 'H', 'i', 's', 'U')) === false) {
|
if (array_search($match, array('Y', 'm', 'd', 'H', 'i', 's', 'U')) === false) {
|
||||||
user_error('formattedDatetimeClause(): unsupported format character %' . $match, E_USER_WARNING);
|
user_error('formattedDatetimeClause(): unsupported format character %' . $match, E_USER_WARNING);
|
||||||
@ -694,9 +694,9 @@ class SQLite3Database extends Database
|
|||||||
$modifiers[] = 'localtime';
|
$modifiers[] = 'localtime';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('/^now$/i', $date)) {
|
if (preg_match('/^now$/i', $date ?? '')) {
|
||||||
$date = "'now'";
|
$date = "'now'";
|
||||||
} elseif (preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/i', $date)) {
|
} elseif (preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/i', $date ?? '')) {
|
||||||
$date = "'$date'";
|
$date = "'$date'";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -711,9 +711,9 @@ class SQLite3Database extends Database
|
|||||||
$modifiers[] = 'localtime';
|
$modifiers[] = 'localtime';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('/^now$/i', $date)) {
|
if (preg_match('/^now$/i', $date ?? '')) {
|
||||||
$date = "'now'";
|
$date = "'now'";
|
||||||
} elseif (preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/i', $date)) {
|
} elseif (preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/i', $date ?? '')) {
|
||||||
$date = "'$date'";
|
$date = "'$date'";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -733,15 +733,15 @@ class SQLite3Database extends Database
|
|||||||
$modifiers2[] = 'localtime';
|
$modifiers2[] = 'localtime';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('/^now$/i', $date1)) {
|
if (preg_match('/^now$/i', $date1 ?? '')) {
|
||||||
$date1 = "'now'";
|
$date1 = "'now'";
|
||||||
} elseif (preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/i', $date1)) {
|
} elseif (preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/i', $date1 ?? '')) {
|
||||||
$date1 = "'$date1'";
|
$date1 = "'$date1'";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('/^now$/i', $date2)) {
|
if (preg_match('/^now$/i', $date2 ?? '')) {
|
||||||
$date2 = "'now'";
|
$date2 = "'now'";
|
||||||
} elseif (preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/i', $date2)) {
|
} elseif (preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/i', $date2 ?? '')) {
|
||||||
$date2 = "'$date2'";
|
$date2 = "'$date2'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ class SQLite3SchemaManager extends DBSchemaManager
|
|||||||
if (self::$vacuum) {
|
if (self::$vacuum) {
|
||||||
$this->query('VACUUM', E_USER_NOTICE);
|
$this->query('VACUUM', E_USER_NOTICE);
|
||||||
$message = $this->database->getConnector()->getLastError();
|
$message = $this->database->getConnector()->getLastError();
|
||||||
if (preg_match('/authoriz/', $message)) {
|
if (preg_match('/authoriz/', $message ?? '')) {
|
||||||
$this->alterationMessage("VACUUM | $message", "error");
|
$this->alterationMessage("VACUUM | $message", "error");
|
||||||
} else {
|
} else {
|
||||||
$this->alterationMessage("VACUUMing", "repaired");
|
$this->alterationMessage("VACUUMing", "repaired");
|
||||||
@ -371,7 +371,7 @@ class SQLite3SchemaManager extends DBSchemaManager
|
|||||||
if ($sqlCreate && $sqlCreate['sql']) {
|
if ($sqlCreate && $sqlCreate['sql']) {
|
||||||
preg_match(
|
preg_match(
|
||||||
'/^[\s]*CREATE[\s]+TABLE[\s]+[\'"]?[a-zA-Z0-9_\\\]+[\'"]?[\s]*\((.+)\)[\s]*$/ims',
|
'/^[\s]*CREATE[\s]+TABLE[\s]+[\'"]?[a-zA-Z0-9_\\\]+[\'"]?[\s]*\((.+)\)[\s]*$/ims',
|
||||||
$sqlCreate['sql'],
|
$sqlCreate['sql'] ?? '',
|
||||||
$matches
|
$matches
|
||||||
);
|
);
|
||||||
$fields = isset($matches[1])
|
$fields = isset($matches[1])
|
||||||
|
Loading…
Reference in New Issue
Block a user