aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2021-07-02 17:45:03 +0200
committerVincent Petry <vincent@nextcloud.com>2021-08-10 13:27:58 +0200
commit4d0f0095eafe53f275e3a39b857212d89461f8e9 (patch)
treedb45c44f79c2a5f6174bd9179a8efe6e9aeecdcb /apps
parent13781b0425391655daf94067a937d92103145a7d (diff)
downloadnextcloud-server-4d0f0095eafe53f275e3a39b857212d89461f8e9.tar.gz
nextcloud-server-4d0f0095eafe53f275e3a39b857212d89461f8e9.zip
Add logging to external shares manager
Instead of just returning false, also log the exception to make debugging database issues easier. Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php3
-rw-r--r--apps/files_sharing/lib/AppInfo/Application.php3
-rw-r--r--apps/files_sharing/lib/External/Manager.php37
-rw-r--r--apps/files_sharing/lib/Hooks.php3
-rw-r--r--apps/files_sharing/tests/External/ManagerTest.php2
5 files changed, 32 insertions, 16 deletions
diff --git a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php
index 26b0288c354..d9ae9f6d733 100644
--- a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php
+++ b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php
@@ -251,7 +251,8 @@ class CloudFederationProviderFiles implements ICloudFederationProvider {
\OC::$server->getGroupManager(),
\OC::$server->getUserManager(),
$shareWith,
- \OC::$server->query(IEventDispatcher::class)
+ \OC::$server->query(IEventDispatcher::class),
+ \OC::$server->getLogger()
);
try {
diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php
index 7f234e63660..3975a8a3bde 100644
--- a/apps/files_sharing/lib/AppInfo/Application.php
+++ b/apps/files_sharing/lib/AppInfo/Application.php
@@ -98,7 +98,8 @@ class Application extends App {
$server->getGroupManager(),
$server->getUserManager(),
$uid,
- $server->query(IEventDispatcher::class)
+ $server->query(IEventDispatcher::class),
+ $server->getLogger()
);
});
diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php
index 247be47ac90..de566692d6b 100644
--- a/apps/files_sharing/lib/External/Manager.php
+++ b/apps/files_sharing/lib/External/Manager.php
@@ -14,6 +14,7 @@
* @author Robin Appelman <robin@icewind.nl>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Stefan Weil <sw@weilnetz.de>
+ * @author Vincent Petry <vincent@nextcloud.com>
*
* @license AGPL-3.0
*
@@ -44,6 +45,7 @@ use OCP\Files\Storage\IStorageFactory;
use OCP\Http\Client\IClientService;
use OCP\IDBConnection;
use OCP\IGroupManager;
+use OCP\ILogger;
use OCP\IUserManager;
use OCP\Notification\IManager;
use OCP\OCS\IDiscoveryService;
@@ -89,18 +91,24 @@ class Manager {
/** @var IEventDispatcher */
private $eventDispatcher;
- public function __construct(IDBConnection $connection,
- \OC\Files\Mount\Manager $mountManager,
- IStorageFactory $storageLoader,
- IClientService $clientService,
- IManager $notificationManager,
- IDiscoveryService $discoveryService,
- ICloudFederationProviderManager $cloudFederationProviderManager,
- ICloudFederationFactory $cloudFederationFactory,
- IGroupManager $groupManager,
- IUserManager $userManager,
- ?string $uid,
- IEventDispatcher $eventDispatcher) {
+ /** @var ILogger */
+ private $logger;
+
+ public function __construct(
+ IDBConnection $connection,
+ \OC\Files\Mount\Manager $mountManager,
+ IStorageFactory $storageLoader,
+ IClientService $clientService,
+ IManager $notificationManager,
+ IDiscoveryService $discoveryService,
+ ICloudFederationProviderManager $cloudFederationProviderManager,
+ ICloudFederationFactory $cloudFederationFactory,
+ IGroupManager $groupManager,
+ IUserManager $userManager,
+ ?string $uid,
+ IEventDispatcher $eventDispatcher,
+ ILogger $logger
+ ) {
$this->connection = $connection;
$this->mountManager = $mountManager;
$this->storageLoader = $storageLoader;
@@ -113,6 +121,7 @@ class Manager {
$this->groupManager = $groupManager;
$this->userManager = $userManager;
$this->eventDispatcher = $eventDispatcher;
+ $this->logger = $logger;
}
/**
@@ -535,6 +544,7 @@ class Manager {
$this->removeReShares($id);
} catch (\Doctrine\DBAL\Exception $ex) {
+ $this->logger->logException($ex);
return false;
}
@@ -606,6 +616,7 @@ class Manager {
$deleteResult->closeCursor();
}
} catch (\Doctrine\DBAL\Exception $ex) {
+ $this->logger->logException($ex);
return false;
}
@@ -677,7 +688,7 @@ class Manager {
}
return array_values($shares);
} catch (\Doctrine\DBAL\Exception $e) {
- // FIXME
+ $this->logger->logException($e);
return [];
}
}
diff --git a/apps/files_sharing/lib/Hooks.php b/apps/files_sharing/lib/Hooks.php
index ff4ca59339a..26e799297ff 100644
--- a/apps/files_sharing/lib/Hooks.php
+++ b/apps/files_sharing/lib/Hooks.php
@@ -43,7 +43,8 @@ class Hooks {
\OC::$server->getGroupManager(),
\OC::$server->getUserManager(),
$params['uid'],
- \OC::$server->query(IEventDispatcher::class)
+ \OC::$server->query(IEventDispatcher::class),
+ \OC::$server->getLogger()
);
$manager->removeUserShares($params['uid']);
diff --git a/apps/files_sharing/tests/External/ManagerTest.php b/apps/files_sharing/tests/External/ManagerTest.php
index 850265cb9de..b80b9d04e18 100644
--- a/apps/files_sharing/tests/External/ManagerTest.php
+++ b/apps/files_sharing/tests/External/ManagerTest.php
@@ -43,6 +43,7 @@ use OCP\Http\Client\IClientService;
use OCP\Http\Client\IResponse;
use OCP\IGroup;
use OCP\IGroupManager;
+use OCP\ILogger;
use OCP\IUserManager;
use OCP\Share\IShare;
use Test\Traits\UserTrait;
@@ -127,6 +128,7 @@ class ManagerTest extends TestCase {
$this->userManager,
$this->uid,
$this->eventDispatcher,
+ $this->createMock(ILogger::class),
]
)->setMethods(['tryOCMEndPoint'])->getMock();