From c3c50fb481318c5f2ab3b554dd12c84983b916e8 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Wed, 8 Apr 2015 13:55:10 +0200 Subject: [PATCH] Fix language level incompatibilties Arbitrary expressions in empty are allowed in PHP 5.5 ands upwards. Seems to only affect master. Fixed https://github.com/owncloud/core/issues/15463 --- apps/files_external/lib/sftp_key.php | 9 +++++++-- apps/files_external/service/globalstoragesservice.php | 11 +++++++++-- apps/files_external/service/storagesservice.php | 6 ++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/apps/files_external/lib/sftp_key.php b/apps/files_external/lib/sftp_key.php index c460d81b8f0..d9bcadb9eb7 100644 --- a/apps/files_external/lib/sftp_key.php +++ b/apps/files_external/lib/sftp_key.php @@ -135,11 +135,16 @@ class SFTP_Key extends \OC\Files\Storage\SFTP { } public function test() { - if (empty($this->getHost())) { + + // FIXME: Use as expression in empty once PHP 5.4 support is dropped + $host = $this->getHost(); + if (empty($host)) { \OC::$server->getLogger()->warning('Hostname has not been specified'); return false; } - if (empty($this->getUser())) { + // FIXME: Use as expression in empty once PHP 5.4 support is dropped + $user = $this->getUser(); + if (empty($user)) { \OC::$server->getLogger()->warning('Username has not been specified'); return false; } diff --git a/apps/files_external/service/globalstoragesservice.php b/apps/files_external/service/globalstoragesservice.php index 011730390b0..7df0f73f652 100644 --- a/apps/files_external/service/globalstoragesservice.php +++ b/apps/files_external/service/globalstoragesservice.php @@ -101,6 +101,7 @@ class GlobalStoragesService extends StoragesService { * @param string $signal signal to trigger */ protected function triggerHooks(StorageConfig $storage, $signal) { + // FIXME: Use as expression in empty once PHP 5.4 support is dropped $applicableUsers = $storage->getApplicableUsers(); $applicableGroups = $storage->getApplicableGroups(); if (empty($applicableUsers) && empty($applicableGroups)) { @@ -149,8 +150,11 @@ class GlobalStoragesService extends StoragesService { $groupAdditions = array_diff($newStorage->getApplicableGroups(), $oldStorage->getApplicableGroups()); $groupDeletions = array_diff($oldStorage->getApplicableGroups(), $newStorage->getApplicableGroups()); + // FIXME: Use as expression in empty once PHP 5.4 support is dropped // if no applicable were set, raise a signal for "all" - if (empty($oldStorage->getApplicableUsers()) && empty($oldStorage->getApplicableGroups())) { + $oldApplicableUsers = $oldStorage->getApplicableUsers(); + $oldApplicableGroups = $oldStorage->getApplicableGroups(); + if (empty($oldApplicableUsers) && empty($oldApplicableGroups)) { $this->triggerApplicableHooks( Filesystem::signal_delete_mount, $oldStorage->getMountPoint(), @@ -191,8 +195,11 @@ class GlobalStoragesService extends StoragesService { $groupAdditions ); + // FIXME: Use as expression in empty once PHP 5.4 support is dropped // if no applicable, raise a signal for "all" - if (empty($newStorage->getApplicableUsers()) && empty($newStorage->getApplicableGroups())) { + $newApplicableUsers = $newStorage->getApplicableUsers(); + $newApplicableGroups = $newStorage->getApplicableGroups(); + if (empty($newApplicableUsers) && empty($newApplicableGroups)) { $this->triggerApplicableHooks( Filesystem::signal_create_mount, $newStorage->getMountPoint(), diff --git a/apps/files_external/service/storagesservice.php b/apps/files_external/service/storagesservice.php index 399a56677bf..51eb4abcc00 100644 --- a/apps/files_external/service/storagesservice.php +++ b/apps/files_external/service/storagesservice.php @@ -227,8 +227,10 @@ abstract class StoragesService { if (!is_null($storageConfig->getPriority())) { $options['priority'] = $storageConfig->getPriority(); } - if (!empty($storageConfig->getMountOptions())) { - $options['mountOptions'] = $storageConfig->getMountOptions(); + + $mountOptions = $storageConfig->getMountOptions(); + if (!empty($mountOptions)) { + $options['mountOptions'] = $mountOptions; } $mountPoints[$mountType][$applicable][$rootMountPoint] = $options; -- 2.39.5