From 0ebdf871e02653bf7e65bf5bdefaec7f92d3c677 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 10 May 2017 13:58:15 +0200 Subject: [PATCH 01/11] Fix comparisons in encryption app Signed-off-by: Joas Schilling --- apps/encryption/lib/Crypto/Crypt.php | 2 +- apps/encryption/lib/Crypto/Encryption.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/encryption/lib/Crypto/Crypt.php b/apps/encryption/lib/Crypto/Crypt.php index 9a9ac27b96fec..6e1b7387c88e1 100644 --- a/apps/encryption/lib/Crypto/Crypt.php +++ b/apps/encryption/lib/Crypto/Crypt.php @@ -605,7 +605,7 @@ protected function parseHeader($data) { $element = array_shift($exploded); - while ($element != self::HEADER_END) { + while ($element !== self::HEADER_END) { $result[$element] = array_shift($exploded); $element = array_shift($exploded); } diff --git a/apps/encryption/lib/Crypto/Encryption.php b/apps/encryption/lib/Crypto/Encryption.php index 1f8c8a8012ece..4d20c103a5de5 100644 --- a/apps/encryption/lib/Crypto/Encryption.php +++ b/apps/encryption/lib/Crypto/Encryption.php @@ -449,13 +449,13 @@ public function shouldEncrypt($path) { return false; } - if ($parts[2] == 'files') { + if ($parts[2] === 'files') { return true; } - if ($parts[2] == 'files_versions') { + if ($parts[2] === 'files_versions') { return true; } - if ($parts[2] == 'files_trashbin') { + if ($parts[2] === 'files_trashbin') { return true; } From 89238164e12ba8532cdefed16a789cbd4e4efde5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 10 May 2017 14:03:14 +0200 Subject: [PATCH 02/11] Fix comparisons in the dav app Signed-off-by: Joas Schilling --- apps/dav/lib/CalDAV/CalDavBackend.php | 2 +- apps/dav/lib/CalDAV/Search/SearchPlugin.php | 4 ++-- apps/dav/lib/CardDAV/CardDavBackend.php | 2 +- apps/dav/lib/Connector/Sabre/Directory.php | 2 +- apps/dav/lib/Connector/Sabre/File.php | 4 ++-- apps/dav/lib/Connector/Sabre/ObjectTree.php | 2 +- apps/dav/lib/DAV/Sharing/Backend.php | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index b85415e28fc6e..d078790b6f0ca 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -1158,7 +1158,7 @@ function calendarQuery($calendarId, array $filters) { $requirePostFilter = false; } // There was a time-range filter - if ($componentType == 'VEVENT' && isset($filters['comp-filters'][0]['time-range'])) { + if ($componentType === 'VEVENT' && isset($filters['comp-filters'][0]['time-range'])) { $timeRange = $filters['comp-filters'][0]['time-range']; // If start time OR the end time is not specified, we can do a diff --git a/apps/dav/lib/CalDAV/Search/SearchPlugin.php b/apps/dav/lib/CalDAV/Search/SearchPlugin.php index d658a50437d8e..84e095da5f877 100644 --- a/apps/dav/lib/CalDAV/Search/SearchPlugin.php +++ b/apps/dav/lib/CalDAV/Search/SearchPlugin.php @@ -134,7 +134,7 @@ private function calendarSearch($report) { // If we're dealing with the calendar home, the calendar home itself is // responsible for the calendar-query - if ($node instanceof CalendarHome && $depth == 2) { + if ($node instanceof CalendarHome && $depth === 2) { $nodePaths = $node->calendarSearch($report->filters, $report->limit, $report->offset); @@ -156,4 +156,4 @@ private function calendarSearch($report) { $this->server->generateMultiStatus($result, $prefer['return'] === 'minimal')); } -} \ No newline at end of file +} diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php index 9dccffc022baf..7c275611951e4 100644 --- a/apps/dav/lib/CardDAV/CardDavBackend.php +++ b/apps/dav/lib/CardDAV/CardDavBackend.php @@ -1019,7 +1019,7 @@ protected function updateProperties($addressBookId, $cardUri, $vCardSerialized) } $preferred = 0; foreach($property->parameters as $parameter) { - if ($parameter->name == 'TYPE' && strtoupper($parameter->getValue()) == 'PREF') { + if ($parameter->name === 'TYPE' && strtoupper($parameter->getValue()) === 'PREF') { $preferred = 1; break; } diff --git a/apps/dav/lib/Connector/Sabre/Directory.php b/apps/dav/lib/Connector/Sabre/Directory.php index 1a97d89646966..6fe9d26614e79 100644 --- a/apps/dav/lib/Connector/Sabre/Directory.php +++ b/apps/dav/lib/Connector/Sabre/Directory.php @@ -225,7 +225,7 @@ public function getChild($name, $info = null) { throw new \Sabre\DAV\Exception\NotFound('File with name ' . $path . ' could not be located'); } - if ($info['mimetype'] == 'httpd/unix-directory') { + if ($info['mimetype'] === 'httpd/unix-directory') { $node = new \OCA\DAV\Connector\Sabre\Directory($this->fileView, $info, $this->tree, $this->shareManager); } else { $node = new \OCA\DAV\Connector\Sabre\File($this->fileView, $info, $this->shareManager); diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php index 63f10034ed689..9803beabe37de 100644 --- a/apps/dav/lib/Connector/Sabre/File.php +++ b/apps/dav/lib/Connector/Sabre/File.php @@ -147,7 +147,7 @@ public function put($data) { // compare expected and actual size if (isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['REQUEST_METHOD'] === 'PUT') { $expected = $_SERVER['CONTENT_LENGTH']; - if ($count != $expected) { + if ($count !== $expected) { throw new BadRequest('expected filesize ' . $expected . ' got ' . $count); } } @@ -410,7 +410,7 @@ private function createFileChunked($data) { if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT') { if (isset($_SERVER['CONTENT_LENGTH'])) { $expected = $_SERVER['CONTENT_LENGTH']; - if ($bytesWritten != $expected) { + if ($bytesWritten !== $expected) { $chunk_handler->remove($info['index']); throw new BadRequest( 'expected filesize ' . $expected . ' got ' . $bytesWritten); diff --git a/apps/dav/lib/Connector/Sabre/ObjectTree.php b/apps/dav/lib/Connector/Sabre/ObjectTree.php index d298d6be842bc..3371c655f29d6 100644 --- a/apps/dav/lib/Connector/Sabre/ObjectTree.php +++ b/apps/dav/lib/Connector/Sabre/ObjectTree.php @@ -81,7 +81,7 @@ private function resolveChunkFile($path) { if (isset($_SERVER['HTTP_OC_CHUNKED'])) { // resolve to real file name to find the proper node list($dir, $name) = \Sabre\Uri\split($path); - if ($dir == '/' || $dir == '.') { + if ($dir === '/' || $dir === '.') { $dir = ''; } diff --git a/apps/dav/lib/DAV/Sharing/Backend.php b/apps/dav/lib/DAV/Sharing/Backend.php index f662d8e1b80a5..6cc5e3b6f509a 100644 --- a/apps/dav/lib/DAV/Sharing/Backend.php +++ b/apps/dav/lib/DAV/Sharing/Backend.php @@ -170,7 +170,7 @@ public function getShares($resourceId) { 'href' => "principal:${row['principaluri']}", 'commonName' => isset($p['{DAV:}displayname']) ? $p['{DAV:}displayname'] : '', 'status' => 1, - 'readOnly' => ($row['access'] == self::ACCESS_READ), + 'readOnly' => ((int) $row['access'] === self::ACCESS_READ), '{http://owncloud.org/ns}principal' => $row['principaluri'], '{http://owncloud.org/ns}group-share' => is_null($p) ]; From 1e2de86c3ada8599cf6999abc1b1223d2d886430 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 10 May 2017 14:05:14 +0200 Subject: [PATCH 03/11] Fix comparisons in the versions app Signed-off-by: Joas Schilling --- apps/files_versions/lib/Hooks.php | 10 +++++----- apps/files_versions/lib/Storage.php | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/files_versions/lib/Hooks.php b/apps/files_versions/lib/Hooks.php index 3753d8b501648..a9ebb153efff8 100644 --- a/apps/files_versions/lib/Hooks.php +++ b/apps/files_versions/lib/Hooks.php @@ -57,7 +57,7 @@ public static function write_hook( $params ) { if (\OCP\App::isEnabled('files_versions')) { $path = $params[\OC\Files\Filesystem::signal_param_path]; - if($path<>'') { + if($path !== '') { Storage::store($path); } } @@ -75,7 +75,7 @@ public static function remove_hook($params) { if (\OCP\App::isEnabled('files_versions')) { $path = $params[\OC\Files\Filesystem::signal_param_path]; - if($path<>'') { + if($path !== '') { Storage::delete($path); } } @@ -87,7 +87,7 @@ public static function remove_hook($params) { */ public static function pre_remove_hook($params) { $path = $params[\OC\Files\Filesystem::signal_param_path]; - if($path<>'') { + if($path !== '') { Storage::markDeletedFile($path); } } @@ -104,7 +104,7 @@ public static function rename_hook($params) { if (\OCP\App::isEnabled('files_versions')) { $oldpath = $params['oldpath']; $newpath = $params['newpath']; - if($oldpath<>'' && $newpath<>'') { + if($oldpath !== '' && $newpath !== '') { Storage::renameOrCopy($oldpath, $newpath, 'rename'); } } @@ -122,7 +122,7 @@ public static function copy_hook($params) { if (\OCP\App::isEnabled('files_versions')) { $oldpath = $params['oldpath']; $newpath = $params['newpath']; - if($oldpath<>'' && $newpath<>'') { + if($oldpath !== '' && $newpath !== '') { Storage::renameOrCopy($oldpath, $newpath, 'copy'); } } diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php index 6e6b6aebb6d02..ff73b81f57475 100644 --- a/apps/files_versions/lib/Storage.php +++ b/apps/files_versions/lib/Storage.php @@ -102,7 +102,7 @@ public static function getUidAndFilename($filename) { $uid = User::getUser(); } Filesystem::initMountPoints($uid); - if ( $uid != User::getUser() ) { + if ( $uid !== User::getUser() ) { $info = Filesystem::getFileInfo($filename); $ownerView = new View('/'.$uid.'/files'); try { @@ -161,7 +161,7 @@ private static function getVersionsSize($user) { * store a new version of a file. */ public static function store($filename) { - if(\OC::$server->getConfig()->getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { + if(\OC::$server->getConfig()->getSystemValue('files_versions', Storage::DEFAULTENABLED) === 'true') { // if the file gets streamed we need to remove the .part extension // to get the right target @@ -320,7 +320,7 @@ public static function renameOrCopy($sourcePath, $targetPath, $operation) { */ public static function rollback($file, $revision) { - if(\OC::$server->getConfig()->getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { + if(\OC::$server->getConfig()->getSystemValue('files_versions', Storage::DEFAULTENABLED) === 'true') { // add expected leading slash $file = '/' . ltrim($file, '/'); list($uid, $filename) = self::getUidAndFilename($file); @@ -629,7 +629,7 @@ protected static function getAutoExpireList($time, $versions) { $interval = 1; $step = Storage::$max_versions_per_interval[$interval]['step']; - if (Storage::$max_versions_per_interval[$interval]['intervalEndsAfter'] == -1) { + if (Storage::$max_versions_per_interval[$interval]['intervalEndsAfter'] === -1) { $nextInterval = -1; } else { $nextInterval = $time - Storage::$max_versions_per_interval[$interval]['intervalEndsAfter']; @@ -644,7 +644,7 @@ protected static function getAutoExpireList($time, $versions) { foreach ($versions as $key => $version) { $newInterval = true; while ($newInterval) { - if ($nextInterval == -1 || $prevTimestamp > $nextInterval) { + if ($nextInterval === -1 || $prevTimestamp > $nextInterval) { if ($version['version'] > $nextVersion) { //distance between two version too small, mark to delete $toDelete[$key] = $version['path'] . '.v' . $version['version']; @@ -659,7 +659,7 @@ protected static function getAutoExpireList($time, $versions) { $interval++; $step = Storage::$max_versions_per_interval[$interval]['step']; $nextVersion = $prevTimestamp - $step; - if (Storage::$max_versions_per_interval[$interval]['intervalEndsAfter'] == -1) { + if (Storage::$max_versions_per_interval[$interval]['intervalEndsAfter'] === -1) { $nextInterval = -1; } else { $nextInterval = $time - Storage::$max_versions_per_interval[$interval]['intervalEndsAfter']; @@ -701,7 +701,7 @@ public static function expire($filename, $uid) { $config = \OC::$server->getConfig(); $expiration = self::getExpiration(); - if($config->getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' && $expiration->isEnabled()) { + if($config->getSystemValue('files_versions', Storage::DEFAULTENABLED) === 'true' && $expiration->isEnabled()) { // get available disk space for user $user = \OC::$server->getUserManager()->get($uid); if (is_null($user)) { From 45e2c415d4ff066d579ab133be4f15453c07b242 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 10 May 2017 14:06:01 +0200 Subject: [PATCH 04/11] Fix comparison in the ldap app Signed-off-by: Joas Schilling --- apps/user_ldap/lib/Wizard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/user_ldap/lib/Wizard.php b/apps/user_ldap/lib/Wizard.php index dfbde31314edc..f6b78208fd24c 100644 --- a/apps/user_ldap/lib/Wizard.php +++ b/apps/user_ldap/lib/Wizard.php @@ -905,7 +905,7 @@ private function composeLdapFilter($filterType) { $er = $this->ldap->firstEntry($cr, $rr); $attrs = $this->ldap->getAttributes($cr, $er); $dn = $this->ldap->getDN($cr, $er); - if ($dn == false || $dn === '') { + if ($dn === false || $dn === '') { continue; } $filterPart = '(memberof=' . $dn . ')'; From e30287cf814bca99b01561df0e60fb00c59ade42 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 10 May 2017 14:07:58 +0200 Subject: [PATCH 05/11] Fix comparisons in the files app Signed-off-by: Joas Schilling --- apps/files/ajax/download.php | 2 +- apps/files/lib/Helper.php | 2 +- apps/files/lib/Settings/Admin.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/files/ajax/download.php b/apps/files/ajax/download.php index 17a7fd8b32290..7c33cdec6dd7e 100644 --- a/apps/files/ajax/download.php +++ b/apps/files/ajax/download.php @@ -51,7 +51,7 @@ setcookie('ocDownloadStarted', $_GET['downloadStartSecret'], time() + 20, '/'); } -$server_params = array( 'head' => \OC::$server->getRequest()->getMethod() == 'HEAD' ); +$server_params = array( 'head' => \OC::$server->getRequest()->getMethod() === 'HEAD' ); /** * Http range requests support diff --git a/apps/files/lib/Helper.php b/apps/files/lib/Helper.php index d2cebce5ddcd7..4a5595999d216 100644 --- a/apps/files/lib/Helper.php +++ b/apps/files/lib/Helper.php @@ -227,7 +227,7 @@ public static function populateTags(array $fileList, $fileIdentifier = 'fileid') foreach ($filesById as $key => $fileWithTags) { foreach($fileList as $key2 => $file){ - if( $file[$fileIdentifier] == $key){ + if( $file[$fileIdentifier] === $key){ $fileList[$key2] = $fileWithTags; } } diff --git a/apps/files/lib/Settings/Admin.php b/apps/files/lib/Settings/Admin.php index da1d5deaf35b6..faaeb5b89c114 100644 --- a/apps/files/lib/Settings/Admin.php +++ b/apps/files/lib/Settings/Admin.php @@ -46,7 +46,7 @@ public function __construct(IniGetWrapper $iniWrapper, IRequest $request) { * @return TemplateResponse */ public function getForm() { - $htaccessWorking = (getenv('htaccessWorking') == 'true'); + $htaccessWorking = (getenv('htaccessWorking') === 'true'); $htaccessWritable = is_writable(\OC::$SERVERROOT.'/.htaccess'); $userIniWritable = is_writable(\OC::$SERVERROOT.'/.user.ini'); From 7a62fbd205874355abb3b551b182bc61b9c3d3e1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 10 May 2017 14:12:58 +0200 Subject: [PATCH 06/11] Fix comparisons in the files external app Signed-off-by: Joas Schilling --- apps/files_external/ajax/oauth2.php | 6 +++--- apps/files_external/lib/Command/Import.php | 4 ++-- apps/files_external/lib/Lib/Storage/Dropbox.php | 8 ++++---- apps/files_external/lib/Lib/Storage/FTP.php | 2 +- apps/files_external/lib/Lib/Storage/OwnCloud.php | 4 ++-- apps/files_external/lib/Lib/Storage/SFTP.php | 14 +++++++------- apps/files_external/lib/Lib/Storage/SMB.php | 4 ++-- apps/files_external/lib/Lib/Storage/Swift.php | 4 ++-- apps/files_external/templates/settings.php | 6 +++--- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/apps/files_external/ajax/oauth2.php b/apps/files_external/ajax/oauth2.php index db2570800af3d..8b257b77ef6a6 100644 --- a/apps/files_external/ajax/oauth2.php +++ b/apps/files_external/ajax/oauth2.php @@ -46,8 +46,8 @@ $client->setApprovalPrompt('force'); $client->setAccessType('offline'); if (isset($_POST['step'])) { - $step = $_POST['step']; - if ($step == 1) { + $step = (int) $_POST['step']; + if ($step === 1) { try { $authUrl = $client->createAuthUrl(); OCP\JSON::success(array('data' => array( @@ -58,7 +58,7 @@ 'message' => $l->t('Step 1 failed. Exception: %s', array($exception->getMessage())) ))); } - } else if ($step == 2 && isset($_POST['code'])) { + } else if ($step === 2 && isset($_POST['code'])) { try { $token = $client->authenticate((string)$_POST['code']); OCP\JSON::success(array('data' => array( diff --git a/apps/files_external/lib/Command/Import.php b/apps/files_external/lib/Command/Import.php index 96afc86ba2c9c..712a8851c8abe 100644 --- a/apps/files_external/lib/Command/Import.php +++ b/apps/files_external/lib/Command/Import.php @@ -161,8 +161,8 @@ protected function execute(InputInterface $input, OutputInterface $output) { if ( $existingMount->getMountPoint() === $mount->getMountPoint() && $existingMount->getApplicableGroups() === $mount->getApplicableGroups() && - $existingMount->getApplicableUsers() == $mount->getApplicableUsers() && - $existingMount->getBackendOptions() == $mount->getBackendOptions() + $existingMount->getApplicableUsers() === $mount->getApplicableUsers() && + $existingMount->getBackendOptions() === $mount->getBackendOptions() ) { $output->writeln("Duplicate mount (" . $mount->getMountPoint() . ")"); return 1; diff --git a/apps/files_external/lib/Lib/Storage/Dropbox.php b/apps/files_external/lib/Lib/Storage/Dropbox.php index d2ba1cca7510f..fad85650e9b44 100644 --- a/apps/files_external/lib/Lib/Storage/Dropbox.php +++ b/apps/files_external/lib/Lib/Storage/Dropbox.php @@ -47,7 +47,7 @@ class Dropbox extends \OC\Files\Storage\Common { private $oauth; public function __construct($params) { - if (isset($params['configured']) && $params['configured'] == 'true' + if (isset($params['configured']) && $params['configured'] === 'true' && isset($params['app_key']) && isset($params['app_secret']) && isset($params['token']) @@ -187,12 +187,12 @@ public function stat($path) { } public function filetype($path) { - if ($path == '' || $path == '/') { + if ($path === '' || $path === '/') { return 'dir'; } else { $metaData = $this->getDropBoxMetaData($path); if ($metaData) { - if ($metaData['is_dir'] == 'true') { + if ($metaData['is_dir'] === 'true') { return 'dir'; } else { return 'file'; @@ -203,7 +203,7 @@ public function filetype($path) { } public function file_exists($path) { - if ($path == '' || $path == '/') { + if ($path === '' || $path === '/') { return true; } if ($this->getDropBoxMetaData($path)) { diff --git a/apps/files_external/lib/Lib/Storage/FTP.php b/apps/files_external/lib/Lib/Storage/FTP.php index 22fe2090f305d..1bbdfaba468bb 100644 --- a/apps/files_external/lib/Lib/Storage/FTP.php +++ b/apps/files_external/lib/Lib/Storage/FTP.php @@ -56,7 +56,7 @@ public function __construct($params) { $this->secure = false; } $this->root=isset($params['root'])?$params['root']:'/'; - if ( ! $this->root || $this->root[0]!='/') { + if ( ! $this->root || $this->root[0]!=='/') { $this->root='/'.$this->root; } if (substr($this->root, -1) !== '/') { diff --git a/apps/files_external/lib/Lib/Storage/OwnCloud.php b/apps/files_external/lib/Lib/Storage/OwnCloud.php index 9669b5f3dad07..34838b9891e18 100644 --- a/apps/files_external/lib/Lib/Storage/OwnCloud.php +++ b/apps/files_external/lib/Lib/Storage/OwnCloud.php @@ -40,10 +40,10 @@ public function __construct($params) { // (owncloud install path on host) $host = $params['host']; // strip protocol - if (substr($host, 0, 8) == "https://") { + if (substr($host, 0, 8) === "https://") { $host = substr($host, 8); $params['secure'] = true; - } else if (substr($host, 0, 7) == "http://") { + } else if (substr($host, 0, 7) === "http://") { $host = substr($host, 7); $params['secure'] = false; } diff --git a/apps/files_external/lib/Lib/Storage/SFTP.php b/apps/files_external/lib/Lib/Storage/SFTP.php index a4dfea94bf707..8d48955126404 100644 --- a/apps/files_external/lib/Lib/Storage/SFTP.php +++ b/apps/files_external/lib/Lib/Storage/SFTP.php @@ -102,11 +102,11 @@ public function __construct($params) { $this->root = isset($params['root']) ? $this->cleanPath($params['root']) : '/'; - if ($this->root[0] != '/') { + if ($this->root[0] !== '/') { $this->root = '/' . $this->root; } - if (substr($this->root, -1, 1) != '/') { + if (substr($this->root, -1, 1) !== '/') { $this->root .= '/'; } } @@ -128,7 +128,7 @@ public function getConnection() { // The SSH Host Key MUST be verified before login(). $currentHostKey = $this->client->getServerPublicHostKey(); if (array_key_exists($this->host, $hostKeys)) { - if ($hostKeys[$this->host] != $currentHostKey) { + if ($hostKeys[$this->host] !== $currentHostKey) { throw new \Exception('Host public key does not match known key'); } } else { @@ -248,7 +248,7 @@ protected function readHostKeys() { if ($lines) { foreach ($lines as $line) { $hostKeyArray = explode("::", $line, 2); - if (count($hostKeyArray) == 2) { + if (count($hostKeyArray) === 2) { $hosts[] = $hostKeyArray[0]; $keys[] = $hostKeyArray[1]; } @@ -300,7 +300,7 @@ public function opendir($path) { $id = md5('sftp:' . $path); $dirStream = array(); foreach($list as $file) { - if ($file != '.' && $file != '..') { + if ($file !== '.' && $file !== '..') { $dirStream[] = $file; } } @@ -316,11 +316,11 @@ public function opendir($path) { public function filetype($path) { try { $stat = $this->getConnection()->stat($this->absPath($path)); - if ($stat['type'] == NET_SFTP_TYPE_REGULAR) { + if ((int) $stat['type'] === NET_SFTP_TYPE_REGULAR) { return 'file'; } - if ($stat['type'] == NET_SFTP_TYPE_DIRECTORY) { + if ((int) $stat['type'] === NET_SFTP_TYPE_DIRECTORY) { return 'dir'; } } catch (\Exception $e) { diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php index 7afdb746a9856..4af6df5d84ad0 100644 --- a/apps/files_external/lib/Lib/Storage/SMB.php +++ b/apps/files_external/lib/Lib/Storage/SMB.php @@ -81,10 +81,10 @@ public function __construct($params) { $this->share = $this->server->getShare(trim($params['share'], '/')); $this->root = isset($params['root']) ? $params['root'] : '/'; - if (!$this->root || $this->root[0] != '/') { + if (!$this->root || $this->root[0] !== '/') { $this->root = '/' . $this->root; } - if (substr($this->root, -1, 1) != '/') { + if (substr($this->root, -1, 1) !== '/') { $this->root .= '/'; } } else { diff --git a/apps/files_external/lib/Lib/Storage/Swift.php b/apps/files_external/lib/Lib/Storage/Swift.php index db5b5bf6d95b4..57df4aa01a52b 100644 --- a/apps/files_external/lib/Lib/Storage/Swift.php +++ b/apps/files_external/lib/Lib/Storage/Swift.php @@ -435,7 +435,7 @@ public function touch($path, $mtime = null) { } $metadata = array('timestamp' => $mtime); if ($this->file_exists($path)) { - if ($this->is_dir($path) && $path != '.') { + if ($this->is_dir($path) && $path !== '.') { $path .= '/'; } @@ -640,7 +640,7 @@ public function hasUpdated($path, $time) { }, $cachedContent); sort($cachedNames); sort($content); - return $cachedNames != $content; + return $cachedNames !== $content; } /** diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php index e463a0d3c37d3..1d703e0c1b30f 100644 --- a/apps/files_external/templates/settings.php +++ b/apps/files_external/templates/settings.php @@ -89,7 +89,7 @@ function writeParameterInput($parameter, $options, $classes = []) {

t('External storages')); ?>

- '') and $canCreateMounts) print_unescaped(''.$_['dependencies'].''); ?> + '> @@ -169,10 +169,10 @@ function writeParameterInput($parameter, $options, $classes = []) { /> + value="1" /> -

class="hidden"> +

class="hidden"> t('Allow users to mount the following external storage')); ?>
Date: Wed, 10 May 2017 14:16:22 +0200 Subject: [PATCH 07/11] Fix comparisons in the sharing app Signed-off-by: Joas Schilling --- apps/files_sharing/lib/Controller/ShareController.php | 2 +- apps/files_sharing/lib/Helper.php | 4 ++-- apps/files_sharing/lib/ShareBackend/File.php | 8 ++++---- apps/files_sharing/lib/ShareBackend/Folder.php | 4 ++-- apps/files_sharing/templates/public.php | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index df6f379d11948..14fc8d6338109 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -514,7 +514,7 @@ public function downloadShare($token, $files = null, $path = '', $downloadStartS $this->emitAccessShareHook($share); - $server_params = array( 'head' => $this->request->getMethod() == 'HEAD' ); + $server_params = array( 'head' => $this->request->getMethod() === 'HEAD' ); /** * Http range requests support diff --git a/apps/files_sharing/lib/Helper.php b/apps/files_sharing/lib/Helper.php index a659da9292fee..c8f46fa8132bd 100644 --- a/apps/files_sharing/lib/Helper.php +++ b/apps/files_sharing/lib/Helper.php @@ -132,7 +132,7 @@ public static function getSharesFromItem($target) { Filesystem::initMountPoints($owner); $info = Filesystem::getFileInfo($target); $ownerView = new View('/'.$owner.'/files'); - if ( $owner != User::getUser() ) { + if ( $owner !== User::getUser() ) { $path = $ownerView->getPath($info['fileid']); } else { $path = $target; @@ -183,7 +183,7 @@ public static function getUidAndFilename($filename) { $uid = User::getUser(); } Filesystem::initMountPoints($uid); - if ( $uid != User::getUser() ) { + if ( $uid !== User::getUser() ) { $info = Filesystem::getFileInfo($filename); $ownerView = new View('/'.$uid.'/files'); try { diff --git a/apps/files_sharing/lib/ShareBackend/File.php b/apps/files_sharing/lib/ShareBackend/File.php index aecb63c60e41d..8347454658182 100644 --- a/apps/files_sharing/lib/ShareBackend/File.php +++ b/apps/files_sharing/lib/ShareBackend/File.php @@ -123,7 +123,7 @@ public function generateTarget($filePath, $shareWith, $exclude = null) { } public function formatItems($items, $format, $parameters = null) { - if ($format == self::FORMAT_SHARED_STORAGE) { + if ($format === self::FORMAT_SHARED_STORAGE) { // Only 1 item should come through for this format call $item = array_shift($items); return array( @@ -133,7 +133,7 @@ public function formatItems($items, $format, $parameters = null) { 'permissions' => $item['permissions'], 'uid_owner' => $item['uid_owner'], ); - } else if ($format == self::FORMAT_GET_FOLDER_CONTENTS) { + } else if ($format === self::FORMAT_GET_FOLDER_CONTENTS) { $files = array(); foreach ($items as $item) { $file = array(); @@ -156,13 +156,13 @@ public function formatItems($items, $format, $parameters = null) { $files[] = $file; } return $files; - } else if ($format == self::FORMAT_OPENDIR) { + } else if ($format === self::FORMAT_OPENDIR) { $files = array(); foreach ($items as $item) { $files[] = basename($item['file_target']); } return $files; - } else if ($format == self::FORMAT_GET_ALL) { + } else if ($format === self::FORMAT_GET_ALL) { $ids = array(); foreach ($items as $item) { $ids[] = $item['file_source']; diff --git a/apps/files_sharing/lib/ShareBackend/Folder.php b/apps/files_sharing/lib/ShareBackend/Folder.php index 07e353cc6a684..55c2eff6fe080 100644 --- a/apps/files_sharing/lib/ShareBackend/Folder.php +++ b/apps/files_sharing/lib/ShareBackend/Folder.php @@ -83,7 +83,7 @@ public function getChildren($itemSource) { $query = \OCP\DB::prepare('SELECT `id` FROM `*PREFIX*mimetypes` WHERE `mimetype` = ?'); $result = $query->execute(array('httpd/unix-directory')); if ($row = $result->fetchRow()) { - $mimetype = $row['id']; + $mimetype = (int) $row['id']; } else { $mimetype = -1; } @@ -96,7 +96,7 @@ public function getChildren($itemSource) { while ($file = $result->fetchRow()) { $children[] = array('source' => $file['fileid'], 'file_path' => $file['name']); // If a child folder is found look inside it - if ($file['mimetype'] == $mimetype) { + if ((int) $file['mimetype'] === $mimetype) { $parents[] = $file['fileid']; } } diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php index 36b4dcdbe1c11..f8d056ef93ca6 100644 --- a/apps/files_sharing/templates/public.php +++ b/apps/files_sharing/templates/public.php @@ -75,7 +75,7 @@ - +