diff options
-rw-r--r-- | apps/files_trashbin/lib/Controller/PreviewController.php | 2 | ||||
-rw-r--r-- | lib/private/DB/AdapterPgSql.php | 23 | ||||
-rw-r--r-- | lib/private/Log/Syslog.php | 2 | ||||
-rw-r--r-- | lib/private/Server.php | 3 | ||||
-rw-r--r-- | lib/private/legacy/util.php | 4 |
5 files changed, 28 insertions, 6 deletions
diff --git a/apps/files_trashbin/lib/Controller/PreviewController.php b/apps/files_trashbin/lib/Controller/PreviewController.php index ace3d10bf98..5f4419b3e50 100644 --- a/apps/files_trashbin/lib/Controller/PreviewController.php +++ b/apps/files_trashbin/lib/Controller/PreviewController.php @@ -103,7 +103,7 @@ class PreviewController extends Controller { } $pathParts = pathinfo($file->getName()); - $extension = $pathParts['extension']; + $extension = $pathParts['extension'] ?? ''; $fileName = $pathParts['filename']; /* * Files in the root of the trashbin are timetamped. diff --git a/lib/private/DB/AdapterPgSql.php b/lib/private/DB/AdapterPgSql.php index af1978d051c..42e57cd45f7 100644 --- a/lib/private/DB/AdapterPgSql.php +++ b/lib/private/DB/AdapterPgSql.php @@ -24,7 +24,11 @@ namespace OC\DB; +use Doctrine\DBAL\DBALException; + class AdapterPgSql extends Adapter { + protected $compatModePre9_5 = null; + public function lastInsertId($table) { return $this->conn->fetchColumn('SELECT lastval()'); } @@ -40,12 +44,29 @@ class AdapterPgSql extends Adapter { * @suppress SqlInjectionChecker */ public function insertIgnoreConflict(string $table,array $values) : int { + if($this->isPre9_5CompatMode() === true) { + return parent::insertIgnoreConflict($table, $values); + } + + // "upsert" is only available since PgSQL 9.5, but the generic way + // would leave error logs in the DB. $builder = $this->conn->getQueryBuilder(); $builder->insert($table); - foreach($values as $key => $value) { + foreach ($values as $key => $value) { $builder->setValue($key, $builder->createNamedParameter($value)); } $queryString = $builder->getSQL() . ' ON CONFLICT DO NOTHING'; return $this->conn->executeUpdate($queryString, $builder->getParameters(), $builder->getParameterTypes()); } + + protected function isPre9_5CompatMode(): bool { + if($this->compatModePre9_5 !== null) { + return $this->compatModePre9_5; + } + + $version = $this->conn->fetchColumn('SHOW SERVER_VERSION'); + $this->compatModePre9_5 = version_compare($version, '9.5', '<'); + + return $this->compatModePre9_5; + } } diff --git a/lib/private/Log/Syslog.php b/lib/private/Log/Syslog.php index b8fba34d62b..fc536fbd7fc 100644 --- a/lib/private/Log/Syslog.php +++ b/lib/private/Log/Syslog.php @@ -40,7 +40,7 @@ class Syslog extends LogDetails implements IWriter { public function __construct(SystemConfig $config) { parent::__construct($config); - openlog($config->getSystemValue('syslog_tag', 'Nextcloud'), LOG_PID | LOG_CONS, LOG_USER); + openlog($config->getValue('syslog_tag', 'Nextcloud'), LOG_PID | LOG_CONS, LOG_USER); } public function __destruct() { diff --git a/lib/private/Server.php b/lib/private/Server.php index c25808a9ccc..f919e0b4efb 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -449,9 +449,10 @@ class Server extends ServerContainer implements IServerContainer { $this->registerAlias('AllConfig', \OC\AllConfig::class); $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); - $this->registerService('SystemConfig', function ($c) use ($config) { + $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) { return new \OC\SystemConfig($config); }); + $this->registerAlias('SystemConfig', \OC\SystemConfig::class); $this->registerService(\OC\AppConfig::class, function (Server $c) { return new \OC\AppConfig($c->getDatabaseConnection()); diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php index 32069053257..810f22fb9e5 100644 --- a/lib/private/legacy/util.php +++ b/lib/private/legacy/util.php @@ -978,9 +978,9 @@ class OC_Util { $data = $result->fetchRow(); if (isset($data['server_version'])) { $version = $data['server_version']; - if (version_compare($version, '9.5.0', '<')) { + if (version_compare($version, '9.0.0', '<')) { $errors[] = array( - 'error' => $l->t('PostgreSQL >= 9.5 required'), + 'error' => $l->t('PostgreSQL >= 9 required'), 'hint' => $l->t('Please upgrade your database version') ); } |