summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-07-30 12:32:22 +0200
committerLukas Reschke <lukas@owncloud.com>2015-07-30 12:32:22 +0200
commite95bc68ac75222bdb839d2fb062abc9d4a8e1911 (patch)
tree1e5f6624322af7dc94620898cb99a4659e2e1411 /lib
parent4d672ded244e5e8a242d649588879979bdde1bb6 (diff)
downloadnextcloud-server-e95bc68ac75222bdb839d2fb062abc9d4a8e1911.tar.gz
nextcloud-server-e95bc68ac75222bdb839d2fb062abc9d4a8e1911.zip
Check for PDO instead of removed function for PHP 7 compatibility
Diffstat (limited to 'lib')
-rw-r--r--lib/private/setup.php30
1 files changed, 22 insertions, 8 deletions
diff --git a/lib/private/setup.php b/lib/private/setup.php
index afc88256da4..8f1ae389e45 100644
--- a/lib/private/setup.php
+++ b/lib/private/setup.php
@@ -89,7 +89,7 @@ class Setup {
* @param string $name
* @return bool
*/
- public function class_exists($name) {
+ protected function class_exists($name) {
return class_exists($name);
}
@@ -98,11 +98,20 @@ class Setup {
* @param string $name
* @return bool
*/
- public function is_callable($name) {
+ protected function is_callable($name) {
return is_callable($name);
}
/**
+ * Wrapper around \PDO::getAvailableDrivers
+ *
+ * @return array
+ */
+ protected function getAvailableDbDriversForPdo() {
+ return \PDO::getAvailableDrivers();
+ }
+
+ /**
* Get the available and supported databases of this instance
*
* @param bool $allowAllDatabases
@@ -117,8 +126,8 @@ class Setup {
'name' => 'SQLite'
),
'mysql' => array(
- 'type' => 'function',
- 'call' => 'mysql_connect',
+ 'type' => 'pdo',
+ 'call' => 'mysql',
'name' => 'MySQL/MariaDB'
),
'pgsql' => array(
@@ -147,10 +156,15 @@ class Setup {
foreach($configuredDatabases as $database) {
if(array_key_exists($database, $availableDatabases)) {
$working = false;
- if($availableDatabases[$database]['type'] === 'class') {
- $working = $this->class_exists($availableDatabases[$database]['call']);
- } elseif ($availableDatabases[$database]['type'] === 'function') {
- $working = $this->is_callable($availableDatabases[$database]['call']);
+ $type = $availableDatabases[$database]['type'];
+ $call = $availableDatabases[$database]['call'];
+
+ if($type === 'class') {
+ $working = $this->class_exists($call);
+ } elseif ($type === 'function') {
+ $working = $this->is_callable($call);
+ } elseif($type === 'pdo') {
+ $working = in_array($call, $this->getAvailableDbDriversForPdo(), TRUE);
}
if($working) {
$supportedDatabases[$database] = $availableDatabases[$database]['name'];