diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index dba01c4d961e872ac2162ee06002c18e50cbacb0..48485cf2e86eb24b783a669de229040a951fbbba 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -131,7 +131,7 @@ class Util {
 			$this->userId = $this->publicShareKeyId;
 
 			// only handle for files_sharing app
-			if ($GLOBALS['app'] === 'files_sharing') {
+			if (isset($GLOBALS['app']) && $GLOBALS['app'] === 'files_sharing') {
 				$this->userDir = '/' . $GLOBALS['fileOwner'];
 				$this->fileFolderName = 'files';
 				$this->userFilesDir = '/' . $GLOBALS['fileOwner'] . '/'