diff options
author | Joas Schilling <coding@schilljs.com> | 2022-04-07 15:08:37 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-04-07 15:08:37 +0300 |
commit | a06ba8850243b93295e9c49ab820c0c46d9b220a (patch) | |
tree | 8c333d355de2bff158377fb871cefd2c176a1db8 /lib | |
parent | 0e29dc8c76a379b7f34f63303ae831e52bb62801 (diff) |
Fix \OC_App::getCurrentApp() when being called from CLI or phpunit
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/legacy/OC_App.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php index ca01e91216b..245bfe76d98 100644 --- a/lib/private/legacy/OC_App.php +++ b/lib/private/legacy/OC_App.php @@ -629,11 +629,20 @@ class OC_App { * @return string */ public static function getCurrentApp(): string { + if (\OC::$CLI) { + return ''; + } + $request = \OC::$server->getRequest(); $script = substr($request->getScriptName(), strlen(OC::$WEBROOT) + 1); $topFolder = substr($script, 0, strpos($script, '/') ?: 0); if (empty($topFolder)) { - $path_info = $request->getPathInfo(); + try { + $path_info = $request->getPathInfo(); + } catch (Exception $e) { + // Can happen from unit tests because the script name is `./vendor/bin/phpunit` or something a like then. + return ''; + } if ($path_info) { $topFolder = substr($path_info, 1, strpos($path_info, '/', 1) - 1); } |