From db8b66c54649f35b19b6f771876c7859a63533b0 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Wed, 2 Nov 2016 10:22:36 +0100 Subject: [PATCH 1/2] Hack to prevent warning for read-only wrapper in public links Storage wrappers should normally always be registered inside a presetup hook. However in the public link scenario this is not possible and there is currently no good alternative with the current architecture. Instead of logging a warning every time, this fix prevents the warning to be shown but also adds a FIXME in the code for the future. This is ok because this app is already using private/internal APIs at the moment and should be reworked properly in the future. --- apps/dav/appinfo/v1/publicwebdav.php | 3 +++ lib/private/Files/Filesystem.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/apps/dav/appinfo/v1/publicwebdav.php b/apps/dav/appinfo/v1/publicwebdav.php index b88c5847ab..864ff6fd10 100644 --- a/apps/dav/appinfo/v1/publicwebdav.php +++ b/apps/dav/appinfo/v1/publicwebdav.php @@ -76,9 +76,12 @@ $server = $serverFactory->createServer($baseuri, $requestUri, $authBackend, func return false; } + // FIXME: should not add storage wrappers outside of preSetup, need to find a better way + $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); \OC\Files\Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) { return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE)); }); + \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog); OC_Util::setupFS($owner); $ownerView = \OC\Files\Filesystem::getView(); diff --git a/lib/private/Files/Filesystem.php b/lib/private/Files/Filesystem.php index d835fea7f4..e55d383579 100644 --- a/lib/private/Files/Filesystem.php +++ b/lib/private/Files/Filesystem.php @@ -213,10 +213,13 @@ class Filesystem { /** * @param bool $shouldLog + * @return bool previous value * @internal */ public static function logWarningWhenAddingStorageWrapper($shouldLog) { + $previousValue = self::$logWarningWhenAddingStorageWrapper; self::$logWarningWhenAddingStorageWrapper = (bool) $shouldLog; + return $previousValue; } /** From fcb6386b04cb9ce862056ddfe17827e0bc887745 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Mon, 14 Nov 2016 16:13:05 +0100 Subject: [PATCH 2/2] only use one kind of hack for the storage wrappers of the sharing code Signed-off-by: Morris Jobke --- apps/files_sharing/ajax/shareinfo.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/files_sharing/ajax/shareinfo.php b/apps/files_sharing/ajax/shareinfo.php index 75d6e6081e..a32b0a0732 100644 --- a/apps/files_sharing/ajax/shareinfo.php +++ b/apps/files_sharing/ajax/shareinfo.php @@ -63,9 +63,12 @@ $path = $data['realPath']; $isWritable = $share->getPermissions() & (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_CREATE); if (!$isWritable) { + // FIXME: should not add storage wrappers outside of preSetup, need to find a better way + $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); \OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) { return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_SHARE)); }); + \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog); } $rootInfo = \OC\Files\Filesystem::getFileInfo($path);