diff options
author | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-04-29 17:43:50 +0200 |
---|---|---|
committer | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-04-29 17:43:50 +0200 |
commit | 6c2e94e0b23ca2212a6b6ad510002c9594d21abb (patch) | |
tree | a02203d4933f6644bda3bea219ad81288a33df07 /lib/private | |
parent | e59ccc5fe929e63c6655c01828e6231643280b29 (diff) | |
parent | f1b6b0799c6ee3643f9bbb3e9f18e8c65c3405d2 (diff) | |
download | nextcloud-server-6c2e94e0b23ca2212a6b6ad510002c9594d21abb.tar.gz nextcloud-server-6c2e94e0b23ca2212a6b6ad510002c9594d21abb.zip |
Merge pull request #24335 from owncloud/warning-for-wrongly-done-storage-wrappers
Add a warning if a storage wrapper was registered outside of the hook
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Files/Filesystem.php | 18 | ||||
-rw-r--r-- | lib/private/util.php | 2 |
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/private/Files/Filesystem.php b/lib/private/Files/Filesystem.php index 7cd1f56071c..61319a8cbaa 100644 --- a/lib/private/Files/Filesystem.php +++ b/lib/private/Files/Filesystem.php @@ -208,12 +208,30 @@ class Filesystem { */ private static $loader; + /** @var bool */ + private static $logWarningWhenAddingStorageWrapper = true; + + /** + * @param bool $shouldLog + * @internal + */ + public static function logWarningWhenAddingStorageWrapper($shouldLog) { + self::$logWarningWhenAddingStorageWrapper = (bool) $shouldLog; + } + /** * @param string $wrapperName * @param callable $wrapper * @param int $priority */ public static function addStorageWrapper($wrapperName, $wrapper, $priority = 50) { + if (self::$logWarningWhenAddingStorageWrapper) { + \OC::$server->getLogger()->warning("Storage wrapper '{wrapper}' was not registered via the 'OC_Filesystem - preSetup' hook which could cause potential problems.", [ + 'wrapper' => $wrapperName, + 'app' => 'filesystem', + ]); + } + $mounts = self::getMountManager()->getAll(); if (!self::getLoader()->addStorageWrapper($wrapperName, $wrapper, $priority, $mounts)) { // do not re-wrap if storage with this name already existed diff --git a/lib/private/util.php b/lib/private/util.php index 7caa1efcf54..b3432470f03 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -145,6 +145,7 @@ class OC_Util { \OC\Files\Filesystem::initMountManager(); + \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); \OC\Files\Filesystem::addStorageWrapper('mount_options', function ($mountPoint, \OCP\Files\Storage $storage, \OCP\Files\Mount\IMountPoint $mount) { if ($storage->instanceOfStorage('\OC\Files\Storage\Common')) { /** @var \OC\Files\Storage\Common $storage */ @@ -195,6 +196,7 @@ class OC_Util { }); OC_Hook::emit('OC_Filesystem', 'preSetup', array('user' => $user)); + \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(true); //check if we are using an object storage $objectStore = \OC::$server->getSystemConfig()->getValue('objectstore', null); |