Compare commits

...

4 Commits

Author SHA1 Message Date
Sabina Talipova
83feb62e63
ENH Add CMS5 compatibility and re-enable builds (#69) 2023-03-03 10:50:02 +13:00
Steve Boyd
d45ec79b07 Merge branch '2' into 3 2023-02-03 11:11:29 +13:00
Sabina Talipova
b614fb6133
API Remove deprecated code (#67) 2023-01-25 13:50:21 +13:00
Sabina Talipova
25304fa8aa
DEP PHP Support in CMS5 (#66) 2023-01-10 13:33:07 +13:00
8 changed files with 41 additions and 51 deletions

View File

@ -14,3 +14,21 @@ jobs:
# Only run cron on the silverstripe account
if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule')
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1
with:
# set phpunit to false to prevent automatic generation of mysql phpunit jobs
phpunit: false
preserve_vendor_tests: true
extra_jobs: |
- php: 8.1
db: sqlite3
composer_args: --prefer-lowest
phpunit: true
phpunit_suite: all
- php: 8.1
db: sqlite3
phpunit: true
phpunit_suite: all
- php: 8.2
db: sqlite3
phpunit: true
phpunit_suite: all

View File

@ -1 +0,0 @@
<?php

0
_config/config.yml Normal file
View File

View File

@ -5,7 +5,6 @@ namespace SilverStripe\SQLite;
use SilverStripe\Assets\File;
use SilverStripe\Core\Config\Configurable;
use SilverStripe\Core\Convert;
use SilverStripe\Dev\Deprecation;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\Connect\Database;
use SilverStripe\ORM\DataList;
@ -120,16 +119,6 @@ class SQLite3Database extends Database
*/
public function connect($parameters)
{
if (!empty($parameters['memory'])) {
Deprecation::notice(
'1.4.0',
"\$databaseConfig['memory'] is deprecated. Use \$databaseConfig['path'] = ':memory:' instead.",
Deprecation::SCOPE_GLOBAL
);
unset($parameters['memory']);
$parameters['path'] = ':memory:';
}
//We will store these connection parameters for use elsewhere (ie, unit tests)
$this->parameters = $parameters;
$this->schemaManager->flushCache();
@ -540,7 +529,7 @@ class SQLite3Database extends Database
return $this->transactionNesting;
}
public function transactionEnd($chain = false)
public function transactionEnd(): bool|null
{
// Fail if transaction isn't available
if (!$this->transactionDepth()) {
@ -556,10 +545,6 @@ class SQLite3Database extends Database
$this->resetTransactionNesting();
}
if ($chain) {
$this->transactionStart();
}
return true;
}
@ -622,16 +607,6 @@ class SQLite3Database extends Database
return parent::preparedQuery($sql, $parameters, $errorLevel);
}
/**
* Inspect a SQL query prior to execution
* @deprecated 2.2.0:3.0.0
* @param string $sql
*/
protected function inspectQuery($sql)
{
// no-op
}
public function clearTable($table)
{
$this->query("DELETE FROM \"$table\"");
@ -652,9 +627,9 @@ class SQLite3Database extends Database
// GLOB uses asterisks as wildcards.
// Replace them in search string, without replacing escaped percetage signs.
$comp = 'GLOB';
$value = preg_replace('/^%([^\\\\])/', '*$1', $value);
$value = preg_replace('/([^\\\\])%$/', '$1*', $value);
$value = preg_replace('/([^\\\\])%/', '$1*', $value);
$value = preg_replace('/^%([^\\\\])/', '*$1', $value ?? '');
$value = preg_replace('/([^\\\\])%$/', '$1*', $value ?? '');
$value = preg_replace('/([^\\\\])%/', '$1*', $value ?? '');
} else {
$comp = 'LIKE';
}

View File

@ -4,6 +4,7 @@ namespace SilverStripe\SQLite;
use SilverStripe\ORM\Connect\Query;
use SQLite3Result;
use Traversable;
/**
* A result-set from a SQLite3 database.
@ -43,16 +44,6 @@ class SQLite3Query extends Query
}
}
public function seek($row)
{
$this->handle->reset();
$i=0;
while ($i <= $row && $result = @$this->handle->fetchArray(SQLITE3_ASSOC)) {
$i++;
}
return $result;
}
/**
* @todo This looks terrible but there is no SQLite3::get_num_rows() implementation
*/
@ -72,12 +63,10 @@ class SQLite3Query extends Query
return $c;
}
public function nextRecord()
public function getIterator(): Traversable
{
if ($data = $this->handle->fetchArray(SQLITE3_ASSOC)) {
return $data;
} else {
return false;
while ($data = $this->handle->fetchArray(SQLITE3_ASSOC)) {
yield $data;
}
}
}

View File

@ -692,7 +692,7 @@ class SQLite3SchemaManager extends DBSchemaManager
return (bool)$this->preparedQuery(
'SELECT "name" FROM "sqlite_master" WHERE "type" = ? AND "name" = ?',
array('table', $tableName)
)->first();
)->record();
}
/**
@ -715,7 +715,7 @@ class SQLite3SchemaManager extends DBSchemaManager
$classnameinfo = $this->preparedQuery(
"SELECT EnumList FROM SQLiteEnums WHERE TableColumn = ?",
array($tablefield)
)->first();
)->record();
if ($classnameinfo) {
$valueList = $classnameinfo['EnumList'];
$this->enum_map[$tablefield] = $valueList;

View File

@ -14,11 +14,12 @@
}
],
"require": {
"silverstripe/framework": "~4.0",
"silverstripe/vendor-plugin": "^1.0"
"silverstripe/framework": "^5",
"silverstripe/vendor-plugin": "^2"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3"
"squizlabs/php_codesniffer": "^3",
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {

8
phpunit.xml.dist Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/silverstripe/framework/tests/bootstrap.php" colors="true">
<testsuites>
<testsuite name="framework">
<directory>vendor/silverstripe/framework/tests/php</directory>
</testsuite>
</testsuites>
</phpunit>