diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d2b00b..81e6f39 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,15 +4,11 @@ on: push: pull_request: workflow_dispatch: - # Every Thursday at 12:20pm UTC - schedule: - - cron: '20 12 * * 4' + jobs: ci: name: CI - # 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" + uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1 with: # set phpunit to false to prevent automatic generation of mysql phpunit jobs phpunit: false @@ -32,4 +28,3 @@ jobs: phpunit: true phpunit_suite: all - diff --git a/.github/workflows/dispatch-ci.yml b/.github/workflows/dispatch-ci.yml new file mode 100644 index 0000000..a37ad1f --- /dev/null +++ b/.github/workflows/dispatch-ci.yml @@ -0,0 +1,16 @@ +name: Dispatch CI + +on: + # At 12:20 PM UTC, only on Thursday and Friday + schedule: + - cron: '20 12 * * 4,5' + +jobs: + dispatch-ci: + name: Dispatch CI + # Only run cron on the silverstripe account + if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule') + runs-on: ubuntu-latest + steps: + - name: Dispatch CI + uses: silverstripe/gha-dispatch-ci@v1 diff --git a/_config/connectors.yml b/_config/connectors.yml index 9c1f87e..9e0a9ad 100644 --- a/_config/connectors.yml +++ b/_config/connectors.yml @@ -2,12 +2,6 @@ name: postgresqlconnectors --- SilverStripe\Core\Injector\Injector: - PostgrePDODatabase: - class: 'SilverStripe\PostgreSQL\PostgreSQLDatabase' - properties: - connector: '%$PDOConnector' - schemaManager: '%$PostgreSQLSchemaManager' - queryBuilder: '%$PostgreSQLQueryBuilder' PostgreSQLDatabase: class: 'SilverStripe\PostgreSQL\PostgreSQLDatabase' properties: diff --git a/_register_database.php b/_register_database.php index 2498a75..75c75cb 100644 --- a/_register_database.php +++ b/_register_database.php @@ -3,23 +3,6 @@ use SilverStripe\Dev\Install\DatabaseAdapterRegistry; use SilverStripe\PostgreSQL\PostgreSQLDatabaseConfigurationHelper; -// PDO Postgre database -DatabaseAdapterRegistry::register(array( - /** @skipUpgrade */ - 'class' => 'PostgrePDODatabase', - 'module' => 'postgresql', - 'title' => 'PostgreSQL 8.3+ (using PDO)', - 'helperPath' => __DIR__.'/code/PostgreSQLDatabaseConfigurationHelper.php', - 'helperClass' => PostgreSQLDatabaseConfigurationHelper::class, - 'supported' => (class_exists('PDO') && in_array('postgresql', PDO::getAvailableDrivers())), - 'missingExtensionText' => - 'Either the PDO Extension or - the SQL Server PDO Driver - are unavailable. Please install or enable these and refresh this page.' -)); - - -// PDO Postgre database DatabaseAdapterRegistry::register(array( /** @skipUpgrade */ 'class' => 'PostgreSQLDatabase', diff --git a/code/PostgreSQLConnector.php b/code/PostgreSQLConnector.php index 48cb00d..2ccfa19 100644 --- a/code/PostgreSQLConnector.php +++ b/code/PostgreSQLConnector.php @@ -72,7 +72,7 @@ class PostgreSQLConnector extends DBConnector // Note: Postgres always behaves as though $selectDB = true, ignoring // any value actually passed in. The controller passes in true for other - // connectors such as PDOConnector. + // connectors // Escape parameters $arguments = array( @@ -218,7 +218,6 @@ class PostgreSQLConnector extends DBConnector // Execute query // Unfortunately error-suppression is required in order to handle sql errors elegantly. - // Please use PDO if you can help it if (!empty($parameters)) { $result = @pg_query_params($this->dbConn, $sql, $parameters); } else { diff --git a/code/PostgreSQLDatabase.php b/code/PostgreSQLDatabase.php index 0187a33..75168ac 100644 --- a/code/PostgreSQLDatabase.php +++ b/code/PostgreSQLDatabase.php @@ -214,7 +214,7 @@ class PostgreSQLDatabase extends Database } $this->schemaOriginal = $parameters['schema']; - // Ensure that driver is available (required by PDO) + // Ensure that driver is available if (empty($parameters['driver'])) { $parameters['driver'] = $this->getDatabaseServer(); } diff --git a/code/PostgreSQLDatabaseConfigurationHelper.php b/code/PostgreSQLDatabaseConfigurationHelper.php index 235de3d..af88ae3 100644 --- a/code/PostgreSQLDatabaseConfigurationHelper.php +++ b/code/PostgreSQLDatabaseConfigurationHelper.php @@ -5,7 +5,6 @@ namespace SilverStripe\PostgreSQL; use SilverStripe\Dev\Install\DatabaseAdapterRegistry; use SilverStripe\Dev\Install\DatabaseConfigurationHelper; use Exception; -use PDO; /** * This is a helper class for the SS installer. @@ -40,10 +39,6 @@ class PostgreSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelp $connstring = "host=$server port=5432 dbname=postgres{$userPart}{$passwordPart}"; $conn = pg_connect($connstring); break; - case 'PostgrePDODatabase': - // May throw a PDOException if fails - $conn = @new PDO('postgresql:host='.$server.';dbname=postgres;port=5432', $username, $password); - break; default: $error = 'Invalid connection type: ' . $databaseConfig['type']; return null; @@ -92,8 +87,6 @@ class PostgreSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelp $conn = $this->createConnection($databaseConfig, $error); if (!$conn) { return false; - } elseif ($conn instanceof PDO) { - return $conn->getAttribute(PDO::ATTR_SERVER_VERSION); } elseif (is_resource($conn)) { $info = pg_version($conn); return $info['server']; @@ -139,11 +132,7 @@ class PostgreSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelp protected function query($conn, $sql) { $items = array(); - if ($conn instanceof PDO) { - foreach ($conn->query($sql) as $row) { - $items[] = $row[0]; - } - } elseif (is_resource($conn)) { + if (is_resource($conn)) { $result = pg_query($conn, $sql); while ($row = pg_fetch_row($result)) { $items[] = $row[0]; diff --git a/code/PostgreSQLSchemaManager.php b/code/PostgreSQLSchemaManager.php index 2a9d2b1..b21cb5b 100644 --- a/code/PostgreSQLSchemaManager.php +++ b/code/PostgreSQLSchemaManager.php @@ -849,23 +849,18 @@ class PostgreSQLSchemaManager extends DBSchemaManager $trigger['tgargs'] = stream_get_contents($trigger['tgargs']); } - if (strpos($trigger['tgargs'], "\000") !== false) { - // Option 1: output as a string (PDO) - $argList = array_filter(explode("\000", $trigger['tgargs'])); - } else { - // Option 2: hex-encoded (pg_sql non-pdo) - $bytes = str_split($trigger['tgargs'], 2); - $argList = array(); - $nextArg = ""; - foreach ($bytes as $byte) { - if ($byte == '\x') { - continue; - } elseif ($byte == "00") { - $argList[] = $nextArg; - $nextArg = ""; - } else { - $nextArg .= chr(hexdec($byte)); - } + // hex-encoded (pg_sql non-pdo) + $bytes = str_split($trigger['tgargs'], 2); + $argList = array(); + $nextArg = ""; + foreach ($bytes as $byte) { + if ($byte == '\x') { + continue; + } elseif ($byte == "00") { + $argList[] = $nextArg; + $nextArg = ""; + } else { + $nextArg .= chr(hexdec($byte)); } }