diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index 35f1472ba0..fe02408eaa 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -512,8 +512,10 @@ public function getSettingsFile(string $type, string $token, string $category, s ] ); } catch (NotFoundException $e) { + $this->logger->info('Settings file not found', ['type' => $type, 'category' => $category, 'name' => $name, 'exception' => $e]); return new DataDisplayResponse('File not found.', 404); } catch (\Exception $e) { + $this->logger->error('Error fetching settings file', ['exception' => $e]); return new DataDisplayResponse('Something went wrong', 500); } } diff --git a/lib/TemplateManager.php b/lib/TemplateManager.php index 1c6e52beec..56e27066b5 100644 --- a/lib/TemplateManager.php +++ b/lib/TemplateManager.php @@ -107,6 +107,51 @@ public function setUserId(?string $userId): void { $this->userId = $userId; } + private function debugStorage($file) { + $storage = $file->getStorage(); + + while ($storage) { + $class = get_class($storage); + $this->logger->warning( + 'DEBUG: storage unwrap {fullPath} ({internalPath}) {className} with permissions {permissions}, double-check is it readable: {isReadable}', + [ + 'app' => Application::APPNAME, + 'fullPath' => $file->getPath(), + 'internalPath' => $file->getInternalPath(), + 'permissions' => $storage->getPermissions($file->getInternalPath()), + 'isReadable' => $storage->isReadable($file->getInternalPath()), + 'className' => $class, + ] + ); + if ($storage instanceof \OC\Files\Storage\Wrapper\Wrapper) { + $storage = $storage->getWrapperStorage(); + } else { + $storage = null; + } + } + + $cache = $file->getStorage()->getCache(); + + while ($cache) { + $class = get_class($cache); + $this->logger->warning( + 'DEBUG: cache unwrap {fullPath} ({internalPath}) {className} with permissions {permissions}', + [ + 'app' => Application::APPNAME, + 'fullPath' => $file->getPath(), + 'internalPath' => $file->getInternalPath(), + 'permissions' => $cache->get($file->getInternalPath())->getPermissions(), + 'className' => $class, + ] + ); + if ($cache instanceof \OC\Files\Cache\Wrapper\CacheWrapper) { + $cache = $cache->getCache(); + } else { + $cache = null; + } + } + } + /** * Get template ISimpleFile|Node * @@ -119,6 +164,18 @@ public function get(int $fileId) { foreach ($files as $file) { if ($file->getId() === $fileId) { + $this->logger->warning( + 'DEBUG: found template in empty_templates dir: {fullPath} ({internalPath}) with permissions {permissions}, double-check is it readable: {isReadable}', + [ + 'app' => Application::APPNAME, + 'fullPath' => $file->getPath(), + 'internalPath' => $file->getInternalPath(), + 'permissions' => $file->getPermissions(), + 'isReadable' => $file->isReadable(), + ] + ); + $this->debugStorage($file); + return $file; } } @@ -132,6 +189,17 @@ public function get(int $fileId) { foreach ($files as $file) { if ($file->getId() === $fileId) { + $this->logger->warning( + 'DEBUG: found template in system templates dir: {fullPath} ({internalPath}) with permissions {permissions}, double-check is it readable: {isReadable}', + [ + 'app' => Application::APPNAME, + 'fullPath' => $file->getPath(), + 'internalPath' => $file->getInternalPath(), + 'permissions' => $file->getPermissions(), + 'isReadable' => $file->isReadable(), + ] + ); + $this->debugStorage($file); return $file; } } @@ -140,6 +208,17 @@ public function get(int $fileId) { // finally get the template file $file = $templateDir->getFirstNodeById($fileId); if ($file !== null) { + $this->logger->warning( + 'DEBUG: found template in user templates dir: {fullPath} ({internalPath}) with permissions {permissions}, double-check is it readable: {isReadable}', + [ + 'app' => Application::APPNAME, + 'fullPath' => $file->getPath(), + 'internalPath' => $file->getInternalPath(), + 'permissions' => $file->getPermissions(), + 'isReadable' => $file->isReadable(), + ] + ); + $this->debugStorage($file); return $file; }