Skip to content

Commit 63ca25b

Browse files
committed
Merge branch '3.0' into 3
2 parents fe42614 + 0a1085a commit 63ca25b

File tree

8 files changed

+33
-62
lines changed

8 files changed

+33
-62
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ on:
44
push:
55
pull_request:
66
workflow_dispatch:
7-
# Every Thursday at 12:20pm UTC
8-
schedule:
9-
- cron: '20 12 * * 4'
7+
108
jobs:
119
ci:
1210
name: CI
13-
# Only run cron on the silverstripe account
14-
if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule')
15-
uses: "silverstripe/gha-ci/.github/workflows/ci.yml@v1"
11+
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1
1612
with:
1713
# set phpunit to false to prevent automatic generation of mysql phpunit jobs
1814
phpunit: false
@@ -32,4 +28,3 @@ jobs:
3228
phpunit: true
3329
phpunit_suite: all
3430
35-

.github/workflows/dispatch-ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Dispatch CI
2+
3+
on:
4+
# At 12:20 PM UTC, only on Thursday and Friday
5+
schedule:
6+
- cron: '20 12 * * 4,5'
7+
8+
jobs:
9+
dispatch-ci:
10+
name: Dispatch CI
11+
# Only run cron on the silverstripe account
12+
if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule')
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Dispatch CI
16+
uses: silverstripe/gha-dispatch-ci@v1

_config/connectors.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
name: postgresqlconnectors
33
---
44
SilverStripe\Core\Injector\Injector:
5-
PostgrePDODatabase:
6-
class: 'SilverStripe\PostgreSQL\PostgreSQLDatabase'
7-
properties:
8-
connector: '%$PDOConnector'
9-
schemaManager: '%$PostgreSQLSchemaManager'
10-
queryBuilder: '%$PostgreSQLQueryBuilder'
115
PostgreSQLDatabase:
126
class: 'SilverStripe\PostgreSQL\PostgreSQLDatabase'
137
properties:

_register_database.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,6 @@
33
use SilverStripe\Dev\Install\DatabaseAdapterRegistry;
44
use SilverStripe\PostgreSQL\PostgreSQLDatabaseConfigurationHelper;
55

6-
// PDO Postgre database
7-
DatabaseAdapterRegistry::register(array(
8-
/** @skipUpgrade */
9-
'class' => 'PostgrePDODatabase',
10-
'module' => 'postgresql',
11-
'title' => 'PostgreSQL 8.3+ (using PDO)',
12-
'helperPath' => __DIR__.'/code/PostgreSQLDatabaseConfigurationHelper.php',
13-
'helperClass' => PostgreSQLDatabaseConfigurationHelper::class,
14-
'supported' => (class_exists('PDO') && in_array('postgresql', PDO::getAvailableDrivers())),
15-
'missingExtensionText' =>
16-
'Either the <a href="http://www.php.net/manual/en/book.pdo.php">PDO Extension</a> or
17-
the <a href="http://www.php.net/manual/en/ref.pdo-sqlsrv.php">SQL Server PDO Driver</a>
18-
are unavailable. Please install or enable these and refresh this page.'
19-
));
20-
21-
22-
// PDO Postgre database
236
DatabaseAdapterRegistry::register(array(
247
/** @skipUpgrade */
258
'class' => 'PostgreSQLDatabase',

code/PostgreSQLConnector.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function connect($parameters, $selectDB = false)
7272

7373
// Note: Postgres always behaves as though $selectDB = true, ignoring
7474
// any value actually passed in. The controller passes in true for other
75-
// connectors such as PDOConnector.
75+
// connectors
7676

7777
// Escape parameters
7878
$arguments = array(
@@ -218,7 +218,6 @@ public function preparedQuery($sql, $parameters, $errorLevel = E_USER_ERROR)
218218

219219
// Execute query
220220
// Unfortunately error-suppression is required in order to handle sql errors elegantly.
221-
// Please use PDO if you can help it
222221
if (!empty($parameters)) {
223222
$result = @pg_query_params($this->dbConn, $sql, $parameters);
224223
} else {

code/PostgreSQLDatabase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public function connect($parameters)
214214
}
215215
$this->schemaOriginal = $parameters['schema'];
216216

217-
// Ensure that driver is available (required by PDO)
217+
// Ensure that driver is available
218218
if (empty($parameters['driver'])) {
219219
$parameters['driver'] = $this->getDatabaseServer();
220220
}

code/PostgreSQLDatabaseConfigurationHelper.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use SilverStripe\Dev\Install\DatabaseAdapterRegistry;
66
use SilverStripe\Dev\Install\DatabaseConfigurationHelper;
77
use Exception;
8-
use PDO;
98

109
/**
1110
* This is a helper class for the SS installer.
@@ -40,10 +39,6 @@ protected function createConnection($databaseConfig, &$error)
4039
$connstring = "host=$server port=5432 dbname=postgres{$userPart}{$passwordPart}";
4140
$conn = pg_connect($connstring);
4241
break;
43-
case 'PostgrePDODatabase':
44-
// May throw a PDOException if fails
45-
$conn = @new PDO('postgresql:host='.$server.';dbname=postgres;port=5432', $username, $password);
46-
break;
4742
default:
4843
$error = 'Invalid connection type: ' . $databaseConfig['type'];
4944
return null;
@@ -92,8 +87,6 @@ public function getDatabaseVersion($databaseConfig)
9287
$conn = $this->createConnection($databaseConfig, $error);
9388
if (!$conn) {
9489
return false;
95-
} elseif ($conn instanceof PDO) {
96-
return $conn->getAttribute(PDO::ATTR_SERVER_VERSION);
9790
} elseif (is_resource($conn)) {
9891
$info = pg_version($conn);
9992
return $info['server'];
@@ -139,11 +132,7 @@ public function requireDatabaseVersion($databaseConfig)
139132
protected function query($conn, $sql)
140133
{
141134
$items = array();
142-
if ($conn instanceof PDO) {
143-
foreach ($conn->query($sql) as $row) {
144-
$items[] = $row[0];
145-
}
146-
} elseif (is_resource($conn)) {
135+
if (is_resource($conn)) {
147136
$result = pg_query($conn, $sql);
148137
while ($row = pg_fetch_row($result)) {
149138
$items[] = $row[0];

code/PostgreSQLSchemaManager.php

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -849,23 +849,18 @@ protected function extractTriggerColumns($triggerName, $table)
849849
$trigger['tgargs'] = stream_get_contents($trigger['tgargs']);
850850
}
851851

852-
if (strpos($trigger['tgargs'], "\000") !== false) {
853-
// Option 1: output as a string (PDO)
854-
$argList = array_filter(explode("\000", $trigger['tgargs']));
855-
} else {
856-
// Option 2: hex-encoded (pg_sql non-pdo)
857-
$bytes = str_split($trigger['tgargs'], 2);
858-
$argList = array();
859-
$nextArg = "";
860-
foreach ($bytes as $byte) {
861-
if ($byte == '\x') {
862-
continue;
863-
} elseif ($byte == "00") {
864-
$argList[] = $nextArg;
865-
$nextArg = "";
866-
} else {
867-
$nextArg .= chr(hexdec($byte));
868-
}
852+
// hex-encoded (pg_sql non-pdo)
853+
$bytes = str_split($trigger['tgargs'], 2);
854+
$argList = array();
855+
$nextArg = "";
856+
foreach ($bytes as $byte) {
857+
if ($byte == '\x') {
858+
continue;
859+
} elseif ($byte == "00") {
860+
$argList[] = $nextArg;
861+
$nextArg = "";
862+
} else {
863+
$nextArg .= chr(hexdec($byte));
869864
}
870865
}
871866

0 commit comments

Comments
 (0)