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.
This commit is contained in:
Vincent Petry 2016-11-02 10:22:36 +01:00 committed by Morris Jobke
parent 2600bb2dbb
commit db8b66c546
No known key found for this signature in database
GPG Key ID: 9CE5ED29E7FCD38A
2 changed files with 6 additions and 0 deletions

View File

@ -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();

View File

@ -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;
}
/**