From 8f84c99e3f4455867d588eaeba29603e44ab1c31 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 5 Jul 2016 22:45:05 +0200 Subject: [PATCH 1/9] Fix undefined properties --- apps/dav/lib/CalDAV/BirthdayService.php | 6 ++++++ apps/dav/lib/CardDAV/ContactsManager.php | 2 ++ apps/dav/lib/Server.php | 6 ++++++ apps/federation/lib/DbHandler.php | 4 ++-- apps/files_external/lib/Lib/Storage/AmazonS3.php | 3 +++ apps/files_external/lib/Lib/Storage/Swift.php | 4 ++++ 6 files changed, 23 insertions(+), 2 deletions(-) diff --git a/apps/dav/lib/CalDAV/BirthdayService.php b/apps/dav/lib/CalDAV/BirthdayService.php index 26e3d22ce4..573713d2a9 100644 --- a/apps/dav/lib/CalDAV/BirthdayService.php +++ b/apps/dav/lib/CalDAV/BirthdayService.php @@ -35,6 +35,12 @@ class BirthdayService { /** @var GroupPrincipalBackend */ private $principalBackend; + /** @var CalDavBackend */ + private $calDavBackEnd; + + /** @var CardDavBackend */ + private $cardDavBackEnd; + /** * BirthdayService constructor. * diff --git a/apps/dav/lib/CardDAV/ContactsManager.php b/apps/dav/lib/CardDAV/ContactsManager.php index ad633483fd..a9f35d53d7 100644 --- a/apps/dav/lib/CardDAV/ContactsManager.php +++ b/apps/dav/lib/CardDAV/ContactsManager.php @@ -25,6 +25,8 @@ use OCP\Contacts\IManager; use OCP\IURLGenerator; class ContactsManager { + /** @var CardDavBackend */ + private $backend; /** * ContactsManager constructor. diff --git a/apps/dav/lib/Server.php b/apps/dav/lib/Server.php index 7fa1b13783..ddfd84d436 100644 --- a/apps/dav/lib/Server.php +++ b/apps/dav/lib/Server.php @@ -43,6 +43,12 @@ class Server { /** @var IRequest */ private $request; + /** @var string */ + private $baseUri; + + /** @var Connector\Sabre\Server */ + protected $server; + public function __construct(IRequest $request, $baseUri) { $this->request = $request; $this->baseUri = $baseUri; diff --git a/apps/federation/lib/DbHandler.php b/apps/federation/lib/DbHandler.php index 015a06c035..5cfbc9f021 100644 --- a/apps/federation/lib/DbHandler.php +++ b/apps/federation/lib/DbHandler.php @@ -43,7 +43,7 @@ class DbHandler { private $connection; /** @var IL10N */ - private $l; + private $IL10N; /** @var string */ private $dbTable = 'trusted_servers'; @@ -87,7 +87,7 @@ class DbHandler { return (int)$this->connection->lastInsertId('*PREFIX*'.$this->dbTable); } else { $message = 'Internal failure, Could not add ownCloud as trusted server: ' . $url; - $message_t = $this->l->t('Could not add server'); + $message_t = $this->IL10N->t('Could not add server'); throw new HintException($message, $message_t); } } diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php index 4bb4312a54..d67db9858c 100644 --- a/apps/files_external/lib/Lib/Storage/AmazonS3.php +++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php @@ -74,6 +74,9 @@ class AmazonS3 extends \OC\Files\Storage\Common { */ private $rescanDelay = 10; + /** @var string */ + private $id; + /** * @param string $path * @return string correctly encoded path diff --git a/apps/files_external/lib/Lib/Storage/Swift.php b/apps/files_external/lib/Lib/Storage/Swift.php index d015e71f9d..b7f833f9e7 100644 --- a/apps/files_external/lib/Lib/Storage/Swift.php +++ b/apps/files_external/lib/Lib/Storage/Swift.php @@ -68,6 +68,10 @@ class Swift extends \OC\Files\Storage\Common { * @var array */ private $params; + + /** @var string */ + private $id; + /** * @var array */ From f0b9eba9c2a2615ccdc53e2f36fa49473c3bbaf1 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 5 Jul 2016 23:15:41 +0200 Subject: [PATCH 2/9] dont overwrite a variable with a different type --- apps/files_sharing/lib/Controllers/ShareController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/files_sharing/lib/Controllers/ShareController.php b/apps/files_sharing/lib/Controllers/ShareController.php index 56f94b91c8..c439735c06 100644 --- a/apps/files_sharing/lib/Controllers/ShareController.php +++ b/apps/files_sharing/lib/Controllers/ShareController.php @@ -291,7 +291,7 @@ class ShareController extends Controller { $rootFolder = $share->getNode(); try { - $path = $rootFolder->get($path); + $folderNode = $rootFolder->get($path); } catch (\OCP\Files\NotFoundException $e) { $this->emitAccessShareHook($share, 404, 'Share not found'); throw new NotFoundException(); @@ -316,7 +316,7 @@ class ShareController extends Controller { // Show file list $hideFileList = false; if ($share->getNode() instanceof \OCP\Files\Folder) { - $shareTmpl['dir'] = $rootFolder->getRelativePath($path->getPath()); + $shareTmpl['dir'] = $rootFolder->getRelativePath($folderNode->getPath()); /* * The OC_Util methods require a view. This just uses the node API @@ -333,7 +333,7 @@ class ShareController extends Controller { $hideFileList = $share->getPermissions() & \OCP\Constants::PERMISSION_READ ? false : true; $folder = new Template('files', 'list', ''); - $folder->assign('dir', $rootFolder->getRelativePath($path->getPath())); + $folder->assign('dir', $rootFolder->getRelativePath($folderNode->getPath())); $folder->assign('dirToken', $token); $folder->assign('permissions', \OCP\Constants::PERMISSION_READ); $folder->assign('isPublic', true); From 951ff0897c4d8d5b234e74560c3ac4541b8784be Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 5 Jul 2016 23:17:43 +0200 Subject: [PATCH 3/9] hint global handlebars --- apps/files_external/js/statusmanager.js | 6 ++++-- apps/files_sharing/js/sharetabview.js | 2 ++ apps/files_versions/js/versionstabview.js | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/files_external/js/statusmanager.js b/apps/files_external/js/statusmanager.js index 91974f2d04..437e9178d2 100644 --- a/apps/files_external/js/statusmanager.js +++ b/apps/files_external/js/statusmanager.js @@ -12,6 +12,8 @@ * */ +/** @global Handlebars */ + if (!OCA.External) { OCA.External = {}; } @@ -502,7 +504,7 @@ OCA.External.StatusManager.Utils = { trFolder = $('#fileList tr[data-file=\"' + OCA.External.StatusManager.Utils.jqSelEscape(folder) + '\"]'); } trFolder.removeClass('externalErroredRow').removeClass('externalDisabledRow'); - tdChilds = trFolder.find("td:first-child div.thumbnail"); + var tdChilds = trFolder.find("td:first-child div.thumbnail"); tdChilds.each(function () { var thisElement = $(this); thisElement.css('background-image', thisElement.data('oldImage')); @@ -525,7 +527,7 @@ OCA.External.StatusManager.Utils = { }); } else { file = $("#fileList tr[data-file=\"" + this.jqSelEscape(filename) + "\"] > td:first-child div.thumbnail"); - parentTr = file.parents('tr:first'); + var parentTr = file.parents('tr:first'); route = OCA.External.StatusManager.Utils.getIconRoute(parentTr); parentTr.attr("data-icon", route); file.css('background-image', "url(" + route + ")").css('display', 'none').css('display', 'inline'); diff --git a/apps/files_sharing/js/sharetabview.js b/apps/files_sharing/js/sharetabview.js index e24320604f..2c7070aa3d 100644 --- a/apps/files_sharing/js/sharetabview.js +++ b/apps/files_sharing/js/sharetabview.js @@ -8,6 +8,8 @@ * */ +/* @global Handlebars */ + (function() { var TEMPLATE = '
' + diff --git a/apps/files_versions/js/versionstabview.js b/apps/files_versions/js/versionstabview.js index b9ccf03c3e..2424778b4e 100644 --- a/apps/files_versions/js/versionstabview.js +++ b/apps/files_versions/js/versionstabview.js @@ -8,6 +8,8 @@ * */ +/* @global Handlebars */ + (function() { var TEMPLATE_ITEM = '
  • ' + From 31ea10b04e5a8e52dce82f477a38bda062d70c62 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 5 Jul 2016 23:18:06 +0200 Subject: [PATCH 4/9] add missing var --- apps/files_external/js/rollingqueue.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/files_external/js/rollingqueue.js b/apps/files_external/js/rollingqueue.js index 58cb0fb22f..53e11cb121 100644 --- a/apps/files_external/js/rollingqueue.js +++ b/apps/files_external/js/rollingqueue.js @@ -70,7 +70,7 @@ var RollingQueue = function (functionList, queueWindow, callback) { throw "functionList must be an array"; } - for (i = 0; i < this.queueWindow; i++) { + for (var i = 0; i < this.queueWindow; i++) { this.launchNext(); } }; @@ -134,4 +134,4 @@ if (!OCA.External.StatusManager) { OCA.External.StatusManager.RollingQueue = RollingQueue; -})(); \ No newline at end of file +})(); From f98cb9efa042b2041ad5d7dff885b036d37e921b Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 5 Jul 2016 23:18:41 +0200 Subject: [PATCH 5/9] Fix type hinting --- apps/dav/lib/DAV/Sharing/Xml/Invite.php | 2 +- apps/dav/lib/Files/CustomPropertiesBackend.php | 2 +- apps/files_external/lib/Lib/Storage/SFTP.php | 4 ++-- apps/files_external/lib/Lib/Storage/SMB.php | 2 +- apps/files_sharing/lib/Migration.php | 3 ++- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/dav/lib/DAV/Sharing/Xml/Invite.php b/apps/dav/lib/DAV/Sharing/Xml/Invite.php index a14de7bc63..7ffe9a322c 100644 --- a/apps/dav/lib/DAV/Sharing/Xml/Invite.php +++ b/apps/dav/lib/DAV/Sharing/Xml/Invite.php @@ -50,7 +50,7 @@ class Invite implements XmlSerializable { * The organizer contains information about the person who shared the * object. * - * @var array + * @var array|null */ protected $organizer; diff --git a/apps/dav/lib/Files/CustomPropertiesBackend.php b/apps/dav/lib/Files/CustomPropertiesBackend.php index aa541f88da..41c596b961 100644 --- a/apps/dav/lib/Files/CustomPropertiesBackend.php +++ b/apps/dav/lib/Files/CustomPropertiesBackend.php @@ -58,7 +58,7 @@ class CustomPropertiesBackend implements BackendInterface { private $connection; /** - * @var IUser + * @var string */ private $user; diff --git a/apps/files_external/lib/Lib/Storage/SFTP.php b/apps/files_external/lib/Lib/Storage/SFTP.php index c058cb9848..3be7a80122 100644 --- a/apps/files_external/lib/Lib/Storage/SFTP.php +++ b/apps/files_external/lib/Lib/Storage/SFTP.php @@ -49,8 +49,8 @@ class SFTP extends \OC\Files\Storage\Common { private $auth; /** - * @var SFTP - */ + * @var \phpseclib\Net\SFTP + */ protected $client; /** diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php index 9f74aa881e..e677f8c9eb 100644 --- a/apps/files_external/lib/Lib/Storage/SMB.php +++ b/apps/files_external/lib/Lib/Storage/SMB.php @@ -221,7 +221,7 @@ class SMB extends \OC\Files\Storage\Common { /** * @param string $path * @param string $mode - * @return resource + * @return resource|false */ public function fopen($path, $mode) { $fullPath = $this->buildPath($path); diff --git a/apps/files_sharing/lib/Migration.php b/apps/files_sharing/lib/Migration.php index ad3d026d0f..b3759ea7b5 100644 --- a/apps/files_sharing/lib/Migration.php +++ b/apps/files_sharing/lib/Migration.php @@ -24,6 +24,7 @@ namespace OCA\Files_Sharing; use Doctrine\DBAL\Connection; +use OCP\ICache; use OCP\IDBConnection; use OC\Cache\CappedMemoryCache; @@ -38,7 +39,7 @@ class Migration { /** @var IDBConnection */ private $connection; - /** @var array with all shares we already saw */ + /** @var ICache with all shares we already saw */ private $shareCache; /** @var string */ From 4de7476f584051ecb017071a3c37d84eea87a6e2 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 5 Jul 2016 23:19:10 +0200 Subject: [PATCH 6/9] Allow null --- apps/federation/lib/BackgroundJob/GetSharedSecret.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/federation/lib/BackgroundJob/GetSharedSecret.php b/apps/federation/lib/BackgroundJob/GetSharedSecret.php index 5e2f80c8a9..2a7d5ad8ef 100644 --- a/apps/federation/lib/BackgroundJob/GetSharedSecret.php +++ b/apps/federation/lib/BackgroundJob/GetSharedSecret.php @@ -130,7 +130,7 @@ class GetSharedSecret extends Job{ * @param JobList $jobList * @param ILogger $logger */ - protected function parentExecute($jobList, $logger) { + protected function parentExecute($jobList, $logger = null) { parent::execute($jobList, $logger); } From 039f730700115f4595e8f12cca175af1ae630c51 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 5 Jul 2016 23:19:30 +0200 Subject: [PATCH 7/9] handle errors while getting fileinfo --- apps/files_sharing/ajax/shareinfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files_sharing/ajax/shareinfo.php b/apps/files_sharing/ajax/shareinfo.php index 002d7ab275..0b93e3d2ee 100644 --- a/apps/files_sharing/ajax/shareinfo.php +++ b/apps/files_sharing/ajax/shareinfo.php @@ -71,7 +71,7 @@ $shareManager = \OC::$server->getShareManager(); $share = $shareManager->getShareByToken($token); $sharePermissions= (int)$share->getPermissions(); -if(!($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) { +if($rootInfo === false || !($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) { OCP\JSON::error(array('data' => 'Share is not readable.')); exit(); } From d0e6fdba4d38ad7d7d7e95ec4cb752d8b609af5c Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 5 Jul 2016 23:35:32 +0200 Subject: [PATCH 8/9] combine if statements --- .../lib/Controllers/ShareController.php | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/apps/files_sharing/lib/Controllers/ShareController.php b/apps/files_sharing/lib/Controllers/ShareController.php index c439735c06..11359e5f2f 100644 --- a/apps/files_sharing/lib/Controllers/ShareController.php +++ b/apps/files_sharing/lib/Controllers/ShareController.php @@ -285,19 +285,6 @@ class ShareController extends Controller { throw $e; } - $rootFolder = null; - if ($share->getNode() instanceof \OCP\Files\Folder) { - /** @var \OCP\Files\Folder $rootFolder */ - $rootFolder = $share->getNode(); - - try { - $folderNode = $rootFolder->get($path); - } catch (\OCP\Files\NotFoundException $e) { - $this->emitAccessShareHook($share, 404, 'Share not found'); - throw new NotFoundException(); - } - } - $shareTmpl = []; $shareTmpl['displayName'] = $this->userManager->get($share->getShareOwner())->getDisplayName(); $shareTmpl['owner'] = $share->getShareOwner(); @@ -316,6 +303,16 @@ class ShareController extends Controller { // Show file list $hideFileList = false; if ($share->getNode() instanceof \OCP\Files\Folder) { + /** @var \OCP\Files\Folder $rootFolder */ + $rootFolder = $share->getNode(); + + try { + $folderNode = $rootFolder->get($path); + } catch (\OCP\Files\NotFoundException $e) { + $this->emitAccessShareHook($share, 404, 'Share not found'); + throw new NotFoundException(); + } + $shareTmpl['dir'] = $rootFolder->getRelativePath($folderNode->getPath()); /* From 6da066e7be9ad77f9591d993df92156c9f184624 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 7 Jul 2016 16:56:28 +0200 Subject: [PATCH 9/9] Fix test using private propertries --- apps/dav/lib/Server.php | 2 +- apps/dav/tests/unit/ServerTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/dav/lib/Server.php b/apps/dav/lib/Server.php index ddfd84d436..0715d39049 100644 --- a/apps/dav/lib/Server.php +++ b/apps/dav/lib/Server.php @@ -47,7 +47,7 @@ class Server { private $baseUri; /** @var Connector\Sabre\Server */ - protected $server; + private $server; public function __construct(IRequest $request, $baseUri) { $this->request = $request; diff --git a/apps/dav/tests/unit/ServerTest.php b/apps/dav/tests/unit/ServerTest.php index 83f14db88f..97c165683b 100644 --- a/apps/dav/tests/unit/ServerTest.php +++ b/apps/dav/tests/unit/ServerTest.php @@ -39,6 +39,6 @@ class ServerTest extends \Test\TestCase { $r = $this->getMockBuilder('\OCP\IRequest') ->disableOriginalConstructor()->getMock(); $s = new Server($r, '/'); - $this->assertNotNull($s->server); + $this->assertInstanceOf('OCA\DAV\Server', $s); } }