diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-08-02 16:28:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-02 16:28:33 +0200 |
commit | 6290ba829980c51daaeb4959c24a714223aab613 (patch) | |
tree | dc3a38818177479a42e38191ad37a080dbdc00b9 /apps | |
parent | 1a711b1e739399c053fa93fcfa3dd9c81af25d8c (diff) | |
parent | a20934227c35260e92f7978e9280b706262c4667 (diff) | |
download | nextcloud-server-6290ba829980c51daaeb4959c24a714223aab613.tar.gz nextcloud-server-6290ba829980c51daaeb4959c24a714223aab613.zip |
Merge pull request #4790 from nextcloud/fix-comparisons-in-apps
Fix comparisons in apps
Diffstat (limited to 'apps')
31 files changed, 139 insertions, 143 deletions
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index b85415e28fc..d078790b6f0 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -1158,7 +1158,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $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 d658a50437d..84e095da5f8 100644 --- a/apps/dav/lib/CalDAV/Search/SearchPlugin.php +++ b/apps/dav/lib/CalDAV/Search/SearchPlugin.php @@ -134,7 +134,7 @@ class SearchPlugin extends ServerPlugin { // 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 @@ class SearchPlugin extends ServerPlugin { $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 9dccffc022b..7c275611951 100644 --- a/apps/dav/lib/CardDAV/CardDavBackend.php +++ b/apps/dav/lib/CardDAV/CardDavBackend.php @@ -1019,7 +1019,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { } $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 1a97d896469..6fe9d26614e 100644 --- a/apps/dav/lib/Connector/Sabre/Directory.php +++ b/apps/dav/lib/Connector/Sabre/Directory.php @@ -225,7 +225,7 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node 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 63f10034ed6..478321d41f2 100644 --- a/apps/dav/lib/Connector/Sabre/File.php +++ b/apps/dav/lib/Connector/Sabre/File.php @@ -146,8 +146,8 @@ class File extends Node implements IFile { // double check if the file was fully received // compare expected and actual size if (isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['REQUEST_METHOD'] === 'PUT') { - $expected = $_SERVER['CONTENT_LENGTH']; - if ($count != $expected) { + $expected = (int) $_SERVER['CONTENT_LENGTH']; + if ($count !== $expected) { throw new BadRequest('expected filesize ' . $expected . ' got ' . $count); } } @@ -409,8 +409,8 @@ class File extends Node implements IFile { //detect aborted upload if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT') { if (isset($_SERVER['CONTENT_LENGTH'])) { - $expected = $_SERVER['CONTENT_LENGTH']; - if ($bytesWritten != $expected) { + $expected = (int) $_SERVER['CONTENT_LENGTH']; + 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 d298d6be842..3371c655f29 100644 --- a/apps/dav/lib/Connector/Sabre/ObjectTree.php +++ b/apps/dav/lib/Connector/Sabre/ObjectTree.php @@ -81,7 +81,7 @@ class ObjectTree extends \Sabre\DAV\Tree { 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 f662d8e1b80..6cc5e3b6f50 100644 --- a/apps/dav/lib/DAV/Sharing/Backend.php +++ b/apps/dav/lib/DAV/Sharing/Backend.php @@ -170,7 +170,7 @@ class Backend { '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) ]; diff --git a/apps/encryption/lib/Crypto/Crypt.php b/apps/encryption/lib/Crypto/Crypt.php index 9a9ac27b96f..6e1b7387c88 100644 --- a/apps/encryption/lib/Crypto/Crypt.php +++ b/apps/encryption/lib/Crypto/Crypt.php @@ -605,7 +605,7 @@ class Crypt { $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 1f8c8a8012e..4d20c103a5d 100644 --- a/apps/encryption/lib/Crypto/Encryption.php +++ b/apps/encryption/lib/Crypto/Encryption.php @@ -449,13 +449,13 @@ class Encryption implements IEncryptionModule { 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; } diff --git a/apps/files/ajax/download.php b/apps/files/ajax/download.php index 17a7fd8b322..7c33cdec6dd 100644 --- a/apps/files/ajax/download.php +++ b/apps/files/ajax/download.php @@ -51,7 +51,7 @@ if(isset($_GET['downloadStartSecret']) 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 d2cebce5ddc..4a5595999d2 100644 --- a/apps/files/lib/Helper.php +++ b/apps/files/lib/Helper.php @@ -227,7 +227,7 @@ class Helper { 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 da1d5deaf35..faaeb5b89c1 100644 --- a/apps/files/lib/Settings/Admin.php +++ b/apps/files/lib/Settings/Admin.php @@ -46,7 +46,7 @@ class Admin implements ISettings { * @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'); diff --git a/apps/files_external/ajax/oauth2.php b/apps/files_external/ajax/oauth2.php index db2570800af..8b257b77ef6 100644 --- a/apps/files_external/ajax/oauth2.php +++ b/apps/files_external/ajax/oauth2.php @@ -46,8 +46,8 @@ if (isset($_POST['client_id']) && isset($_POST['client_secret']) && isset($_POST $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 @@ if (isset($_POST['client_id']) && isset($_POST['client_secret']) && isset($_POST '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 96afc86ba2c..712a8851c8a 100644 --- a/apps/files_external/lib/Command/Import.php +++ b/apps/files_external/lib/Command/Import.php @@ -161,8 +161,8 @@ class Import extends Base { 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("<error>Duplicate mount (" . $mount->getMountPoint() . ")</error>"); return 1; diff --git a/apps/files_external/lib/Lib/Storage/Dropbox.php b/apps/files_external/lib/Lib/Storage/Dropbox.php index d2ba1cca751..fad85650e9b 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 @@ class Dropbox extends \OC\Files\Storage\Common { } 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 @@ class Dropbox extends \OC\Files\Storage\Common { } 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 22fe2090f30..1bbdfaba468 100644 --- a/apps/files_external/lib/Lib/Storage/FTP.php +++ b/apps/files_external/lib/Lib/Storage/FTP.php @@ -56,7 +56,7 @@ class FTP extends StreamWrapper{ $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 9669b5f3dad..34838b9891e 100644 --- a/apps/files_external/lib/Lib/Storage/OwnCloud.php +++ b/apps/files_external/lib/Lib/Storage/OwnCloud.php @@ -40,10 +40,10 @@ class OwnCloud extends \OC\Files\Storage\DAV{ // (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 a4dfea94bf7..8d489551264 100644 --- a/apps/files_external/lib/Lib/Storage/SFTP.php +++ b/apps/files_external/lib/Lib/Storage/SFTP.php @@ -102,11 +102,11 @@ class SFTP extends \OC\Files\Storage\Common { $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 @@ class SFTP extends \OC\Files\Storage\Common { // 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 @@ class SFTP extends \OC\Files\Storage\Common { 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 @@ class SFTP extends \OC\Files\Storage\Common { $id = md5('sftp:' . $path); $dirStream = array(); foreach($list as $file) { - if ($file != '.' && $file != '..') { + if ($file !== '.' && $file !== '..') { $dirStream[] = $file; } } @@ -316,11 +316,11 @@ class SFTP extends \OC\Files\Storage\Common { 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 7afdb746a98..4af6df5d84a 100644 --- a/apps/files_external/lib/Lib/Storage/SMB.php +++ b/apps/files_external/lib/Lib/Storage/SMB.php @@ -81,10 +81,10 @@ class SMB extends Common implements INotifyStorage { $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 db5b5bf6d95..57df4aa01a5 100644 --- a/apps/files_external/lib/Lib/Storage/Swift.php +++ b/apps/files_external/lib/Lib/Storage/Swift.php @@ -435,7 +435,7 @@ class Swift extends \OC\Files\Storage\Common { } $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 @@ class Swift extends \OC\Files\Storage\Common { }, $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 e463a0d3c37..1d703e0c1b3 100644 --- a/apps/files_external/templates/settings.php +++ b/apps/files_external/templates/settings.php @@ -89,7 +89,7 @@ <form data-can-create="<?php echo $canCreateMounts?'true':'false' ?>" id="files_external" class="section" data-encryption-enabled="<?php echo $_['encryptionEnabled']?'true': 'false'; ?>"> <h2 data-anchor-name="external-storage"><?php p($l->t('External storages')); ?></h2> - <?php if (isset($_['dependencies']) and ($_['dependencies']<>'') and $canCreateMounts) print_unescaped(''.$_['dependencies'].''); ?> + <?php if (isset($_['dependencies']) and ($_['dependencies'] !== '') and $canCreateMounts) print_unescaped(''.$_['dependencies'].''); ?> <table id="externalStorage" class="grid" data-admin='<?php print_unescaped(json_encode($_['visibilityType'] === BackendService::VISIBILITY_ADMIN)); ?>'> <thead> <tr> @@ -169,10 +169,10 @@ <?php if ($_['visibilityType'] === BackendService::VISIBILITY_ADMIN): ?> <input type="checkbox" name="allowUserMounting" id="allowUserMounting" class="checkbox" - value="1" <?php if ($_['allowUserMounting'] == 'yes') print_unescaped(' checked="checked"'); ?> /> + value="1" <?php if ($_['allowUserMounting'] === 'yes') print_unescaped(' checked="checked"'); ?> /> <label for="allowUserMounting"><?php p($l->t('Allow users to mount external storage')); ?></label> <span id="userMountingMsg" class="msg"></span> - <p id="userMountingBackends"<?php if ($_['allowUserMounting'] != 'yes'): ?> class="hidden"<?php endif; ?>> + <p id="userMountingBackends"<?php if ($_['allowUserMounting'] !== 'yes'): ?> class="hidden"<?php endif; ?>> <?php p($l->t('Allow users to mount the following external storage')); ?><br /> <?php $userBackends = array_filter($_['backends'], function($backend) { diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index df6f379d119..14fc8d63381 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -514,7 +514,7 @@ class ShareController extends Controller { $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 a659da9292f..c8f46fa8132 100644 --- a/apps/files_sharing/lib/Helper.php +++ b/apps/files_sharing/lib/Helper.php @@ -132,7 +132,7 @@ class Helper { 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 @@ class Helper { $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 aecb63c60e4..83474546581 100644 --- a/apps/files_sharing/lib/ShareBackend/File.php +++ b/apps/files_sharing/lib/ShareBackend/File.php @@ -123,7 +123,7 @@ class File implements \OCP\Share_Backend_File_Dependent { } 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 @@ class File implements \OCP\Share_Backend_File_Dependent { '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 @@ class File implements \OCP\Share_Backend_File_Dependent { $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 07e353cc6a6..55c2eff6fe0 100644 --- a/apps/files_sharing/lib/ShareBackend/Folder.php +++ b/apps/files_sharing/lib/ShareBackend/Folder.php @@ -83,7 +83,7 @@ class Folder extends File implements \OCP\Share_Backend_Collection { $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 @@ class Folder extends File implements \OCP\Share_Backend_Collection { 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 36b4dcdbe1c..f8d056ef93c 100644 --- a/apps/files_sharing/templates/public.php +++ b/apps/files_sharing/templates/public.php @@ -75,7 +75,7 @@ $maxUploadFilesize = min($upload_max_filesize, $post_max_size); <?php if (isset($_['folder'])): ?> <?php print_unescaped($_['folder']); ?> <?php else: ?> - <?php if ($_['previewEnabled'] && substr($_['mimetype'], 0, strpos($_['mimetype'], '/')) == 'video'): ?> + <?php if ($_['previewEnabled'] && substr($_['mimetype'], 0, strpos($_['mimetype'], '/')) === 'video'): ?> <div id="imgframe"> <video tabindex="0" controls="" preload="none" style="max-width: <?php p($_['previewMaxX']); ?>px; max-height: <?php p($_['previewMaxY']); ?>px"> <source src="<?php p($_['downloadURL']); ?>" type="<?php p($_['mimetype']); ?>" /> diff --git a/apps/files_trashbin/lib/Storage.php b/apps/files_trashbin/lib/Storage.php index e3fe648281c..fdc7081b137 100644 --- a/apps/files_trashbin/lib/Storage.php +++ b/apps/files_trashbin/lib/Storage.php @@ -206,7 +206,7 @@ class Storage extends Wrapper { return false; } - if ($this->userManager->userExists($parts[1]) && $parts[2] == 'files') { + if ($this->userManager->userExists($parts[1]) && $parts[2] === 'files') { return true; } diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index 88d23cee711..0d336664e38 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -95,7 +95,7 @@ class Trashbin { return [null, null]; } 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_versions/lib/Hooks.php b/apps/files_versions/lib/Hooks.php index 3753d8b5016..a9ebb153eff 100644 --- a/apps/files_versions/lib/Hooks.php +++ b/apps/files_versions/lib/Hooks.php @@ -57,7 +57,7 @@ class Hooks { 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 @@ class Hooks { 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 @@ class Hooks { */ 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 @@ class Hooks { 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 @@ class Hooks { 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 6e6b6aebb6d..5e3f87b3646 100644 --- a/apps/files_versions/lib/Storage.php +++ b/apps/files_versions/lib/Storage.php @@ -102,7 +102,7 @@ class Storage { $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,41 +161,39 @@ class Storage { * store a new version of a file. */ public static function store($filename) { - 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 - $ext = pathinfo($filename, PATHINFO_EXTENSION); - if ($ext === 'part') { - $filename = substr($filename, 0, strlen($filename) - 5); - } + // if the file gets streamed we need to remove the .part extension + // to get the right target + $ext = pathinfo($filename, PATHINFO_EXTENSION); + if ($ext === 'part') { + $filename = substr($filename, 0, strlen($filename) - 5); + } - // we only handle existing files - if (! Filesystem::file_exists($filename) || Filesystem::is_dir($filename)) { - return false; - } + // we only handle existing files + if (! Filesystem::file_exists($filename) || Filesystem::is_dir($filename)) { + return false; + } - list($uid, $filename) = self::getUidAndFilename($filename); + list($uid, $filename) = self::getUidAndFilename($filename); - $files_view = new View('/'.$uid .'/files'); - $users_view = new View('/'.$uid); + $files_view = new View('/'.$uid .'/files'); + $users_view = new View('/'.$uid); - // no use making versions for empty files - if ($files_view->filesize($filename) === 0) { - return false; - } + // no use making versions for empty files + if ($files_view->filesize($filename) === 0) { + return false; + } - // create all parent folders - self::createMissingDirectories($filename, $users_view); + // create all parent folders + self::createMissingDirectories($filename, $users_view); - self::scheduleExpire($uid, $filename); + self::scheduleExpire($uid, $filename); - // store a new version of a file - $mtime = $users_view->filemtime('files/' . $filename); - $users_view->copy('files/' . $filename, 'files_versions/' . $filename . '.v' . $mtime); - // call getFileInfo to enforce a file cache entry for the new version - $users_view->getFileInfo('files_versions/' . $filename . '.v' . $mtime); - } + // store a new version of a file + $mtime = $users_view->filemtime('files/' . $filename); + $users_view->copy('files/' . $filename, 'files_versions/' . $filename . '.v' . $mtime); + // call getFileInfo to enforce a file cache entry for the new version + $users_view->getFileInfo('files_versions/' . $filename . '.v' . $mtime); } @@ -320,61 +318,60 @@ class Storage { */ public static function rollback($file, $revision) { - if(\OC::$server->getConfig()->getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { - // add expected leading slash - $file = '/' . ltrim($file, '/'); - list($uid, $filename) = self::getUidAndFilename($file); - if ($uid === null || trim($filename, '/') === '') { - return false; - } + // add expected leading slash + $file = '/' . ltrim($file, '/'); + list($uid, $filename) = self::getUidAndFilename($file); + if ($uid === null || trim($filename, '/') === '') { + return false; + } - $users_view = new View('/'.$uid); - $files_view = new View('/'. User::getUser().'/files'); + $users_view = new View('/'.$uid); + $files_view = new View('/'. User::getUser().'/files'); - $versionCreated = false; + $versionCreated = false; - $fileInfo = $files_view->getFileInfo($file); + $fileInfo = $files_view->getFileInfo($file); - // check if user has the permissions to revert a version - if (!$fileInfo->isUpdateable()) { - return false; - } + // check if user has the permissions to revert a version + if (!$fileInfo->isUpdateable()) { + return false; + } - //first create a new version - $version = 'files_versions'.$filename.'.v'.$users_view->filemtime('files'.$filename); - if (!$users_view->file_exists($version)) { - $users_view->copy('files'.$filename, 'files_versions'.$filename.'.v'.$users_view->filemtime('files'.$filename)); - $versionCreated = true; - } + //first create a new version + $version = 'files_versions'.$filename.'.v'.$users_view->filemtime('files'.$filename); + if (!$users_view->file_exists($version)) { + $users_view->copy('files'.$filename, 'files_versions'.$filename.'.v'.$users_view->filemtime('files'.$filename)); + $versionCreated = true; + } - $fileToRestore = 'files_versions' . $filename . '.v' . $revision; - - // Restore encrypted version of the old file for the newly restored file - // This has to happen manually here since the file is manually copied below - $oldVersion = $users_view->getFileInfo($fileToRestore)->getEncryptedVersion(); - $oldFileInfo = $users_view->getFileInfo($fileToRestore); - $cache = $fileInfo->getStorage()->getCache(); - $cache->update( - $fileInfo->getId(), [ - 'encrypted' => $oldVersion, - 'encryptedVersion' => $oldVersion, - 'size' => $oldFileInfo->getSize() - ] - ); - - // rollback - if (self::copyFileContents($users_view, $fileToRestore, 'files' . $filename)) { - $files_view->touch($file, $revision); - Storage::scheduleExpire($uid, $file); - \OC_Hook::emit('\OCP\Versions', 'rollback', array( - 'path' => $filename, - 'revision' => $revision, - )); - return true; - } else if ($versionCreated) { - self::deleteVersion($users_view, $version); - } + $fileToRestore = 'files_versions' . $filename . '.v' . $revision; + + // Restore encrypted version of the old file for the newly restored file + // This has to happen manually here since the file is manually copied below + $oldVersion = $users_view->getFileInfo($fileToRestore)->getEncryptedVersion(); + $oldFileInfo = $users_view->getFileInfo($fileToRestore); + $cache = $fileInfo->getStorage()->getCache(); + $cache->update( + $fileInfo->getId(), [ + 'encrypted' => $oldVersion, + 'encryptedVersion' => $oldVersion, + 'size' => $oldFileInfo->getSize() + ] + ); + + // rollback + if (self::copyFileContents($users_view, $fileToRestore, 'files' . $filename)) { + $files_view->touch($file, $revision); + Storage::scheduleExpire($uid, $file); + \OC_Hook::emit('\OCP\Versions', 'rollback', array( + 'path' => $filename, + 'revision' => $revision, + )); + return true; + } else if ($versionCreated) { + self::deleteVersion($users_view, $version); } + return false; } @@ -629,7 +626,7 @@ class Storage { $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 +641,7 @@ class Storage { 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 +656,7 @@ class Storage { $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']; @@ -698,10 +695,9 @@ class Storage { * @return bool|int|null */ public static function expire($filename, $uid) { - $config = \OC::$server->getConfig(); $expiration = self::getExpiration(); - if($config->getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' && $expiration->isEnabled()) { + if ($expiration->isEnabled()) { // get available disk space for user $user = \OC::$server->getUserManager()->get($uid); if (is_null($user)) { diff --git a/apps/user_ldap/lib/Wizard.php b/apps/user_ldap/lib/Wizard.php index dfbde31314e..f6b78208fd2 100644 --- a/apps/user_ldap/lib/Wizard.php +++ b/apps/user_ldap/lib/Wizard.php @@ -905,7 +905,7 @@ class Wizard extends LDAPUtility { $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 . ')'; |