diff options
114 files changed, 658 insertions, 797 deletions
diff --git a/.mention-bot b/.mention-bot index b342edbd214..449cf7d1c68 100644 --- a/.mention-bot +++ b/.mention-bot @@ -7,5 +7,5 @@ "files": ["apps/dav/**"] } ], - "userBlacklist": ["owncloud-bot"] + "userBlacklist": ["owncloud-bot", "scrutinizer-auto-fixer"] } diff --git a/3rdparty b/3rdparty -Subproject c11e8afdaafc9975cffe5b61e43f21d8fa82927 +Subproject a5b2a3cdb03cbf5a7246c6185cd4d473f697803 diff --git a/README.md b/README.md index 1e8f6e828a8..c1a9043ce70 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,14 @@ https://doc.owncloud.org/server/9.0/developer_manual/app/index.html ## Contribution Guidelines https://owncloud.org/contribute/ +## Support +Learn about the diffrent ways you can get support for ownCloud: https://owncloud.org/support/ + ## Get in touch * :clipboard: [Forum](https://forum.owncloud.org) * :envelope: [Mailing list](https://mailman.owncloud.org/mailman/listinfo) -* :busts_in_silhouette: [IRC channel](https://webchat.freenode.net/?channels=owncloud) +* :hash: [IRC channel](https://webchat.freenode.net/?channels=owncloud) +* :busts_in_silhouette: [Facebook] (https://facebook.com/ownclouders) * :hatching_chick: [Twitter](https://twitter.com/ownClouders) ## Important notice on translations diff --git a/apps/dav/lib/connector/sabre/file.php b/apps/dav/lib/connector/sabre/file.php index c66f627c0a3..6a0a39d04e7 100644 --- a/apps/dav/lib/connector/sabre/file.php +++ b/apps/dav/lib/connector/sabre/file.php @@ -329,7 +329,7 @@ class File extends Node implements IFile { if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PROPFIND') { return $mimeType; } - return \OC_Helper::getSecureMimeType($mimeType); + return \OC::$server->getMimeTypeDetector()->getSecureMimeType($mimeType); } /** diff --git a/apps/encryption/tests/lib/MigrationTest.php b/apps/encryption/tests/lib/MigrationTest.php index fc3d014345b..6df72ac1bf6 100644 --- a/apps/encryption/tests/lib/MigrationTest.php +++ b/apps/encryption/tests/lib/MigrationTest.php @@ -43,15 +43,18 @@ class MigrationTest extends \Test\TestCase { public static function setUpBeforeClass() { parent::setUpBeforeClass(); - \OC_User::createUser(self::TEST_ENCRYPTION_MIGRATION_USER1, 'foo'); - \OC_User::createUser(self::TEST_ENCRYPTION_MIGRATION_USER2, 'foo'); - \OC_User::createUser(self::TEST_ENCRYPTION_MIGRATION_USER3, 'foo'); + \OC::$server->getUserManager()->createUser(self::TEST_ENCRYPTION_MIGRATION_USER1, 'foo'); + \OC::$server->getUserManager()->createUser(self::TEST_ENCRYPTION_MIGRATION_USER2, 'foo'); + \OC::$server->getUserManager()->createUser(self::TEST_ENCRYPTION_MIGRATION_USER3, 'foo'); } public static function tearDownAfterClass() { - \OC_User::deleteUser(self::TEST_ENCRYPTION_MIGRATION_USER1); - \OC_User::deleteUser(self::TEST_ENCRYPTION_MIGRATION_USER2); - \OC_User::deleteUser(self::TEST_ENCRYPTION_MIGRATION_USER3); + $user = \OC::$server->getUserManager()->get(self::TEST_ENCRYPTION_MIGRATION_USER1); + if ($user !== null) { $user->delete(); } + $user = \OC::$server->getUserManager()->get(self::TEST_ENCRYPTION_MIGRATION_USER2); + if ($user !== null) { $user->delete(); } + $user = \OC::$server->getUserManager()->get(self::TEST_ENCRYPTION_MIGRATION_USER3); + if ($user !== null) { $user->delete(); } parent::tearDownAfterClass(); } diff --git a/apps/files/appinfo/register_command.php b/apps/files/appinfo/register_command.php index 3042c259872..7e541ca26f2 100644 --- a/apps/files/appinfo/register_command.php +++ b/apps/files/appinfo/register_command.php @@ -20,5 +20,5 @@ * */ -$application->add(new OCA\Files\Command\Scan(OC_User::getManager())); +$application->add(new OCA\Files\Command\Scan(\OC::$server->getUserManager())); $application->add(new OCA\Files\Command\DeleteOrphanedFiles(\OC::$server->getDatabaseConnection())); diff --git a/apps/files/download.php b/apps/files/download.php index b0628e394be..b058f0ebf5b 100644 --- a/apps/files/download.php +++ b/apps/files/download.php @@ -39,7 +39,7 @@ if(!\OC\Files\Filesystem::file_exists($filename)) { exit; } -$ftype=\OC_Helper::getSecureMimeType(\OC\Files\Filesystem::getMimeType( $filename )); +$ftype=\OC::$server->getMimeTypeDetector()->getSecureMimeType(\OC\Files\Filesystem::getMimeType( $filename )); header('Content-Type:'.$ftype); OCP\Response::setContentDispositionHeader(basename($filename), 'attachment'); diff --git a/apps/files/l10n/es.js b/apps/files/l10n/es.js index aefcef734aa..4b0ddbb7265 100644 --- a/apps/files/l10n/es.js +++ b/apps/files/l10n/es.js @@ -99,6 +99,7 @@ OC.L10N.register( "Maximum upload size" : "Tamaño máximo de subida", "max. possible: " : "máx. posible:", "Save" : "Guardar", + "Missing permissions to edit from here." : "Faltan permisos para poder editar desde aquí.", "Settings" : "Ajustes", "WebDAV" : "WebDAV", "Use this address to <a href=\"%s\" target=\"_blank\">access your Files via WebDAV</a>" : "Use esta URL <a href=\"%s\" target=\"_blank\">para acceder via WebDAV</a>", diff --git a/apps/files/l10n/es.json b/apps/files/l10n/es.json index 3c89e59a8c1..09411bc5b2a 100644 --- a/apps/files/l10n/es.json +++ b/apps/files/l10n/es.json @@ -97,6 +97,7 @@ "Maximum upload size" : "Tamaño máximo de subida", "max. possible: " : "máx. posible:", "Save" : "Guardar", + "Missing permissions to edit from here." : "Faltan permisos para poder editar desde aquí.", "Settings" : "Ajustes", "WebDAV" : "WebDAV", "Use this address to <a href=\"%s\" target=\"_blank\">access your Files via WebDAV</a>" : "Use esta URL <a href=\"%s\" target=\"_blank\">para acceder via WebDAV</a>", diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php index 9a4e8d59786..4f960518839 100644 --- a/apps/files/lib/helper.php +++ b/apps/files/lib/helper.php @@ -66,15 +66,15 @@ class Helper { */ public static function determineIcon($file) { if($file['type'] === 'dir') { - $icon = \OC_Helper::mimetypeIcon('dir'); + $icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon('dir'); // TODO: move this part to the client side, using mountType if ($file->isShared()) { - $icon = \OC_Helper::mimetypeIcon('dir-shared'); + $icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon('dir-shared'); } elseif ($file->isMounted()) { - $icon = \OC_Helper::mimetypeIcon('dir-external'); + $icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon('dir-external'); } }else{ - $icon = \OC_Helper::mimetypeIcon($file->getMimetype()); + $icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon($file->getMimetype()); } return substr($icon, 0, -3) . 'svg'; diff --git a/apps/files/tests/service/tagservice.php b/apps/files/tests/service/tagservice.php index 36da3edc61e..b93dedd0efd 100644 --- a/apps/files/tests/service/tagservice.php +++ b/apps/files/tests/service/tagservice.php @@ -54,7 +54,7 @@ class TagServiceTest extends \Test\TestCase { protected function setUp() { parent::setUp(); $this->user = $this->getUniqueId('user'); - \OC_User::createUser($this->user, 'test'); + \OC::$server->getUserManager()->createUser($this->user, 'test'); \OC_User::setUserId($this->user); \OC_Util::setupFS($this->user); /** @@ -82,7 +82,8 @@ class TagServiceTest extends \Test\TestCase { protected function tearDown() { \OC_User::setUserId(''); - \OC_User::deleteUser($this->user); + $user = \OC::$server->getUserManager()->get($this->user); + if ($user !== null) { $user->delete(); } } public function testUpdateFileTags() { diff --git a/apps/files_external/l10n/es.js b/apps/files_external/l10n/es.js index 804e75526bd..5aaa3884fd0 100644 --- a/apps/files_external/l10n/es.js +++ b/apps/files_external/l10n/es.js @@ -1,8 +1,8 @@ OC.L10N.register( "files_external", { - "Fetching request tokens failed. Verify that your app key and secret are correct." : "Fallo al acceder a los tokens solicitados. Verfique que su clave de app y la clave secreta son correctas.", - "Fetching access tokens failed. Verify that your app key and secret are correct." : "Fallo al acceder a los tokens solicitados. Verfique que su clave de app y la clave secreta son correctas.", + "Fetching request tokens failed. Verify that your app key and secret are correct." : "Falló al acceder a los tokens solicitados. Verifique que su clave de app y la clave secreta sean correctas.", + "Fetching access tokens failed. Verify that your app key and secret are correct." : "Falló al acceder a los tokens solicitados. Verifique que su clave de app y la clave secreta sean correctas.", "Please provide a valid app key and secret." : "Por favor facilite una clave de app y una clave secreta válidas.", "Step 1 failed. Exception: %s" : "El paso 1 falló. Excepción: %s", "Step 2 failed. Exception: %s" : "El paso 2 falló. Excepción: %s", @@ -101,6 +101,7 @@ OC.L10N.register( "Add storage" : "Añadir almacenamiento", "Advanced settings" : "Configuración avanzada", "Delete" : "Eliminar", + "Allow users to mount external storage" : "Permitir a los usuarios montar un almacenamiento externo", "Allow users to mount the following external storage" : "Permitir a los usuarios montar el siguiente almacenamiento externo" }, "nplurals=2; plural=(n != 1);"); diff --git a/apps/files_external/l10n/es.json b/apps/files_external/l10n/es.json index 86148cf3b0c..60722de1f41 100644 --- a/apps/files_external/l10n/es.json +++ b/apps/files_external/l10n/es.json @@ -1,6 +1,6 @@ { "translations": { - "Fetching request tokens failed. Verify that your app key and secret are correct." : "Fallo al acceder a los tokens solicitados. Verfique que su clave de app y la clave secreta son correctas.", - "Fetching access tokens failed. Verify that your app key and secret are correct." : "Fallo al acceder a los tokens solicitados. Verfique que su clave de app y la clave secreta son correctas.", + "Fetching request tokens failed. Verify that your app key and secret are correct." : "Falló al acceder a los tokens solicitados. Verifique que su clave de app y la clave secreta sean correctas.", + "Fetching access tokens failed. Verify that your app key and secret are correct." : "Falló al acceder a los tokens solicitados. Verifique que su clave de app y la clave secreta sean correctas.", "Please provide a valid app key and secret." : "Por favor facilite una clave de app y una clave secreta válidas.", "Step 1 failed. Exception: %s" : "El paso 1 falló. Excepción: %s", "Step 2 failed. Exception: %s" : "El paso 2 falló. Excepción: %s", @@ -99,6 +99,7 @@ "Add storage" : "Añadir almacenamiento", "Advanced settings" : "Configuración avanzada", "Delete" : "Eliminar", + "Allow users to mount external storage" : "Permitir a los usuarios montar un almacenamiento externo", "Allow users to mount the following external storage" : "Permitir a los usuarios montar el siguiente almacenamiento externo" },"pluralForm" :"nplurals=2; plural=(n != 1);" }
\ No newline at end of file diff --git a/apps/files_external/l10n/ja.js b/apps/files_external/l10n/ja.js index dc31bdb1807..30731fe91fa 100644 --- a/apps/files_external/l10n/ja.js +++ b/apps/files_external/l10n/ja.js @@ -39,6 +39,7 @@ OC.L10N.register( "Empty response from the server" : "サーバーから空の応答がありました", "Couldn't access. Please logout and login to activate this mount point" : "アクセス出来ませんでした。このマウントポイントを有効にするには一度ログアウトしてからログインしてください。", "There was an error with message: " : "メッセージ付きのエラーが発生しました:", + "External mount error" : "外部マウントエラー", "goto-external-storage" : "外部ストレージに行く", "Access key" : "アクセスキー", "Secret key" : "シークレットキー", diff --git a/apps/files_external/l10n/ja.json b/apps/files_external/l10n/ja.json index 6e7f00d6a57..0c251601a78 100644 --- a/apps/files_external/l10n/ja.json +++ b/apps/files_external/l10n/ja.json @@ -37,6 +37,7 @@ "Empty response from the server" : "サーバーから空の応答がありました", "Couldn't access. Please logout and login to activate this mount point" : "アクセス出来ませんでした。このマウントポイントを有効にするには一度ログアウトしてからログインしてください。", "There was an error with message: " : "メッセージ付きのエラーが発生しました:", + "External mount error" : "外部マウントエラー", "goto-external-storage" : "外部ストレージに行く", "Access key" : "アクセスキー", "Secret key" : "シークレットキー", diff --git a/apps/files_sharing/api/local.php b/apps/files_sharing/api/local.php index aaafafb269f..5b2f2e06e75 100644 --- a/apps/files_sharing/api/local.php +++ b/apps/files_sharing/api/local.php @@ -64,9 +64,10 @@ class Local { if ($shares === false) { return new \OC_OCS_Result(null, 404, 'could not get shares'); } else { + $mimetypeDetector = \OC::$server->getMimeTypeDetector(); foreach ($shares as &$share) { if ($share['item_type'] === 'file' && isset($share['path'])) { - $share['mimetype'] = \OC_Helper::getFileNameMimeType($share['path']); + $share['mimetype'] = $mimetypeDetector->detectPath($share['path']); if (\OC::$server->getPreviewManager()->isMimeSupported($share['mimetype'])) { $share['isPreviewAvailable'] = true; } @@ -227,9 +228,10 @@ class Local { private static function getFilesSharedWithMe() { try { $shares = \OCP\Share::getItemsSharedWith('file'); + $mimetypeDetector = \OC::$server->getMimeTypeDetector(); foreach ($shares as &$share) { if ($share['item_type'] === 'file') { - $share['mimetype'] = \OC_Helper::getFileNameMimeType($share['file_target']); + $share['mimetype'] = $mimetypeDetector->detectPath($share['file_target']); if (\OC::$server->getPreviewManager()->isMimeSupported($share['mimetype'])) { $share['isPreviewAvailable'] = true; } diff --git a/apps/files_sharing/l10n/es.js b/apps/files_sharing/l10n/es.js index 650fb5c524a..e77c4b974f7 100644 --- a/apps/files_sharing/l10n/es.js +++ b/apps/files_sharing/l10n/es.js @@ -52,6 +52,7 @@ OC.L10N.register( "Shared by %2$s" : "Compartido por %2$s", "Shared via public link" : "Compartido vía enlace público", "Shares" : "Compartidos", + "You received %2$s as a remote share from %1$s" : "Ha recibido %2$s como un recurso compartido de %1$s", "Accept" : "Aceptar", "Decline" : "Denegar", "Share with me through my #ownCloud Federated Cloud ID, see %s" : "Compartirlo conmigo a través de mi ID Nube Federada #ownCloud, ver %s", diff --git a/apps/files_sharing/l10n/es.json b/apps/files_sharing/l10n/es.json index 6f963ab8fee..96fb368f76b 100644 --- a/apps/files_sharing/l10n/es.json +++ b/apps/files_sharing/l10n/es.json @@ -50,6 +50,7 @@ "Shared by %2$s" : "Compartido por %2$s", "Shared via public link" : "Compartido vía enlace público", "Shares" : "Compartidos", + "You received %2$s as a remote share from %1$s" : "Ha recibido %2$s como un recurso compartido de %1$s", "Accept" : "Aceptar", "Decline" : "Denegar", "Share with me through my #ownCloud Federated Cloud ID, see %s" : "Compartirlo conmigo a través de mi ID Nube Federada #ownCloud, ver %s", diff --git a/apps/files_sharing/l10n/ja.js b/apps/files_sharing/l10n/ja.js index e40acc0104a..e3427ea1f7b 100644 --- a/apps/files_sharing/l10n/ja.js +++ b/apps/files_sharing/l10n/ja.js @@ -3,6 +3,7 @@ OC.L10N.register( { "Server to server sharing is not enabled on this server" : "このサーバーでは、サーバー間の共有が有効ではありません", "The mountpoint name contains invalid characters." : "マウントポイント名 に不正な文字列が含まれています。", + "Not allowed to create a federated share with the same user server" : "同じユーザーのサーバーでフェデレーション共有を作成することは出来ません", "Invalid or untrusted SSL certificate" : "無効または信頼できないSSL証明書", "Could not authenticate to remote share, password might be wrong" : "リモート共有が認証できませんでした,パスワードが間違っているかもしれません", "Storage not valid" : "ストレージが無効です", diff --git a/apps/files_sharing/l10n/ja.json b/apps/files_sharing/l10n/ja.json index 989a723b2a8..9dc64e2b3ec 100644 --- a/apps/files_sharing/l10n/ja.json +++ b/apps/files_sharing/l10n/ja.json @@ -1,6 +1,7 @@ { "translations": { "Server to server sharing is not enabled on this server" : "このサーバーでは、サーバー間の共有が有効ではありません", "The mountpoint name contains invalid characters." : "マウントポイント名 に不正な文字列が含まれています。", + "Not allowed to create a federated share with the same user server" : "同じユーザーのサーバーでフェデレーション共有を作成することは出来ません", "Invalid or untrusted SSL certificate" : "無効または信頼できないSSL証明書", "Could not authenticate to remote share, password might be wrong" : "リモート共有が認証できませんでした,パスワードが間違っているかもしれません", "Storage not valid" : "ストレージが無効です", diff --git a/apps/files_sharing/l10n/nl.js b/apps/files_sharing/l10n/nl.js index 7b31b7c73e2..523213f6d9b 100644 --- a/apps/files_sharing/l10n/nl.js +++ b/apps/files_sharing/l10n/nl.js @@ -3,6 +3,7 @@ OC.L10N.register( { "Server to server sharing is not enabled on this server" : "Server met server delen is niet geactiveerd op deze server", "The mountpoint name contains invalid characters." : "De naam van het mountpoint bevat ongeldige karakters.", + "Not allowed to create a federated share with the same user server" : "Het is niet toegestaan om een gefedereerde share met dezelfde gebruikersserver te maken", "Invalid or untrusted SSL certificate" : "Ongeldig of onvertrouwd SSL-certificaat", "Could not authenticate to remote share, password might be wrong" : "Kon niet authenticeren bij externe share, misschien verkeerd wachtwoord", "Storage not valid" : "Opslag ongeldig", diff --git a/apps/files_sharing/l10n/nl.json b/apps/files_sharing/l10n/nl.json index 92ba1c04268..e6501e874ea 100644 --- a/apps/files_sharing/l10n/nl.json +++ b/apps/files_sharing/l10n/nl.json @@ -1,6 +1,7 @@ { "translations": { "Server to server sharing is not enabled on this server" : "Server met server delen is niet geactiveerd op deze server", "The mountpoint name contains invalid characters." : "De naam van het mountpoint bevat ongeldige karakters.", + "Not allowed to create a federated share with the same user server" : "Het is niet toegestaan om een gefedereerde share met dezelfde gebruikersserver te maken", "Invalid or untrusted SSL certificate" : "Ongeldig of onvertrouwd SSL-certificaat", "Could not authenticate to remote share, password might be wrong" : "Kon niet authenticeren bij externe share, misschien verkeerd wachtwoord", "Storage not valid" : "Opslag ongeldig", diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php index 046f954106a..aa1f926ea35 100644 --- a/apps/files_sharing/templates/public.php +++ b/apps/files_sharing/templates/public.php @@ -41,7 +41,7 @@ $thumbSize = 1024; <input type="hidden" name="filename" value="<?php p($_['filename']) ?>" id="filename"> <input type="hidden" name="mimetype" value="<?php p($_['mimetype']) ?>" id="mimetype"> <input type="hidden" name="previewSupported" value="<?php p($_['previewSupported'] ? 'true' : 'false'); ?>" id="previewSupported"> -<input type="hidden" name="mimetypeIcon" value="<?php p(OC_Helper::mimetypeIcon($_['mimetype'])); ?>" id="mimetypeIcon"> +<input type="hidden" name="mimetypeIcon" value="<?php p(\OC::$server->getMimeTypeDetector()->mimeTypeIcon($_['mimetype'])); ?>" id="mimetypeIcon"> <input type="hidden" name="filesize" value="<?php p($_['nonHumanFileSize']); ?>" id="filesize"> <input type="hidden" name="maxSizeAnimateGif" value="<?php p($_['maxSizeAnimateGif']); ?>" id="maxSizeAnimateGif"> diff --git a/apps/files_sharing/tests/controller/sharecontroller.php b/apps/files_sharing/tests/controller/sharecontroller.php index 168488f5613..398538f0943 100644 --- a/apps/files_sharing/tests/controller/sharecontroller.php +++ b/apps/files_sharing/tests/controller/sharecontroller.php @@ -78,7 +78,7 @@ class ShareControllerTest extends \Test\TestCase { // Create a dummy user $this->user = \OC::$server->getSecureRandom()->getLowStrengthGenerator()->generate(12, ISecureRandom::CHAR_LOWER); - \OC_User::createUser($this->user, $this->user); + \OC::$server->getUserManager()->createUser($this->user, $this->user); \OC_Util::tearDownFS(); $this->loginAsUser($this->user); @@ -98,7 +98,8 @@ class ShareControllerTest extends \Test\TestCase { \OC_Util::tearDownFS(); \OC_User::setUserId(''); Filesystem::tearDown(); - \OC_User::deleteUser($this->user); + $user = \OC::$server->getUserManager()->get($this->user); + if ($user !== null) { $user->delete(); } \OC_User::setIncognitoMode(false); \OC::$server->getSession()->set('public_link_authenticated', ''); diff --git a/apps/files_sharing/tests/testcase.php b/apps/files_sharing/tests/testcase.php index a74ee83c25b..c4037c7c42e 100644 --- a/apps/files_sharing/tests/testcase.php +++ b/apps/files_sharing/tests/testcase.php @@ -117,9 +117,12 @@ abstract class TestCase extends \Test\TestCase { public static function tearDownAfterClass() { // cleanup users - \OC_User::deleteUser(self::TEST_FILES_SHARING_API_USER1); - \OC_User::deleteUser(self::TEST_FILES_SHARING_API_USER2); - \OC_User::deleteUser(self::TEST_FILES_SHARING_API_USER3); + $user = \OC::$server->getUserManager()->get(self::TEST_FILES_SHARING_API_USER1); + if ($user !== null) { $user->delete(); } + $user = \OC::$server->getUserManager()->get(self::TEST_FILES_SHARING_API_USER2); + if ($user !== null) { $user->delete(); } + $user = \OC::$server->getUserManager()->get(self::TEST_FILES_SHARING_API_USER3); + if ($user !== null) { $user->delete(); } // delete group \OC_Group::deleteGroup(self::TEST_FILES_SHARING_API_GROUP1); @@ -149,7 +152,7 @@ abstract class TestCase extends \Test\TestCase { } if ($create) { - \OC_User::createUser($user, $password); + \OC::$server->getUserManager()->createUser($user, $password); \OC_Group::createGroup('group'); \OC_Group::addToGroup($user, 'group'); } diff --git a/apps/files_trashbin/ajax/preview.php b/apps/files_trashbin/ajax/preview.php index 49d6d93f574..ecb4971253f 100644 --- a/apps/files_trashbin/ajax/preview.php +++ b/apps/files_trashbin/ajax/preview.php @@ -62,7 +62,7 @@ try{ $fileName = substr($fileName, 0, $i); } } - $mimetype = \OC_Helper::getFileNameMimeType($fileName); + $mimetype = \OC::$server->getMimeTypeDetector()->detectPath($fileName); } $preview->setMimetype($mimetype); $preview->setMaxX($maxX); diff --git a/apps/files_trashbin/lib/helper.php b/apps/files_trashbin/lib/helper.php index d14e97285c5..0ccf15cd2bc 100644 --- a/apps/files_trashbin/lib/helper.php +++ b/apps/files_trashbin/lib/helper.php @@ -87,7 +87,7 @@ class Helper $i = array( 'name' => $id, 'mtime' => $timestamp, - 'mimetype' => $view->is_dir($dir . '/' . $entryName) ? 'httpd/unix-directory' : \OC_Helper::getFileNameMimeType($id), + 'mimetype' => $view->is_dir($dir . '/' . $entryName) ? 'httpd/unix-directory' : \OC::$server->getMimeTypeDetector()->detectPath($id), 'type' => $view->is_dir($dir . '/' . $entryName) ? 'dir' : 'file', 'directory' => ($dir === '/') ? '' : $dir, 'size' => $size, diff --git a/apps/files_trashbin/tests/storage.php b/apps/files_trashbin/tests/storage.php index 387bb20c6d4..30735fe7bc3 100644 --- a/apps/files_trashbin/tests/storage.php +++ b/apps/files_trashbin/tests/storage.php @@ -75,7 +75,8 @@ class Storage extends \Test\TestCase { protected function tearDown() { \OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin'); $this->logout(); - \OC_User::deleteUser($this->user); + $user = \OC::$server->getUserManager()->get($this->user); + if ($user !== null) { $user->delete(); } \OC_Hook::clear(); parent::tearDown(); } diff --git a/apps/files_trashbin/tests/trashbin.php b/apps/files_trashbin/tests/trashbin.php index db7e7e6e840..9c19b67a904 100644 --- a/apps/files_trashbin/tests/trashbin.php +++ b/apps/files_trashbin/tests/trashbin.php @@ -88,7 +88,8 @@ class Test_Trashbin extends \Test\TestCase { public static function tearDownAfterClass() { // cleanup test user - \OC_User::deleteUser(self::TEST_TRASHBIN_USER1); + $user = \OC::$server->getUserManager()->get(self::TEST_TRASHBIN_USER1); + if ($user !== null) { $user->delete(); } \OC::$server->getConfig()->setSystemValue('trashbin_retention_obligation', self::$rememberRetentionObligation); @@ -636,7 +637,7 @@ class Test_Trashbin extends \Test\TestCase { public static function loginHelper($user, $create = false) { if ($create) { try { - \OC_User::createUser($user, $user); + \OC::$server->getUserManager()->createUser($user, $user); } catch(\Exception $e) { // catch username is already being used from previous aborted runs } diff --git a/apps/files_versions/ajax/preview.php b/apps/files_versions/ajax/preview.php index 0da518f3eaa..f21911abc9b 100644 --- a/apps/files_versions/ajax/preview.php +++ b/apps/files_versions/ajax/preview.php @@ -48,7 +48,7 @@ if($maxX === 0 || $maxY === 0) { try { list($user, $file) = \OCA\Files_Versions\Storage::getUidAndFilename($file); $preview = new \OC\Preview($user, 'files_versions', $file.'.v'.$version); - $mimetype = \OC_Helper::getFileNameMimeType($file); + $mimetype = \OC::$server->getMimeTypeDetector()->detectPath($file); $preview->setMimetype($mimetype); $preview->setMaxX($maxX); $preview->setMaxY($maxY); diff --git a/apps/files_versions/download.php b/apps/files_versions/download.php index 22a218f472a..d3c38f3d4e1 100644 --- a/apps/files_versions/download.php +++ b/apps/files_versions/download.php @@ -35,7 +35,7 @@ $versionName = '/'.$uid.'/files_versions/'.$filename.'.v'.$revision; $view = new OC\Files\View('/'); -$ftype = \OC_Helper::getSecureMimeType($view->getMimeType('/'.$uid.'/files/'.$filename)); +$ftype = \OC::$server->getMimeTypeDetector()->getSecureMimeType($view->getMimeType('/'.$uid.'/files/'.$filename)); header('Content-Type:'.$ftype); OCP\Response::setContentDispositionHeader(basename($filename), 'attachment'); diff --git a/apps/files_versions/tests/versions.php b/apps/files_versions/tests/versions.php index ffc98c2e98c..ee4978ff784 100644 --- a/apps/files_versions/tests/versions.php +++ b/apps/files_versions/tests/versions.php @@ -61,8 +61,10 @@ class Test_Files_Versioning extends \Test\TestCase { public static function tearDownAfterClass() { // cleanup test user - \OC_User::deleteUser(self::TEST_VERSIONS_USER); - \OC_User::deleteUser(self::TEST_VERSIONS_USER2); + $user = \OC::$server->getUserManager()->get(self::TEST_VERSIONS_USER); + if ($user !== null) { $user->delete(); } + $user = \OC::$server->getUserManager()->get(self::TEST_VERSIONS_USER2); + if ($user !== null) { $user->delete(); } parent::tearDownAfterClass(); } diff --git a/core/command/status.php b/core/command/status.php index 2eb58525d3e..c2a28ff822f 100644 --- a/core/command/status.php +++ b/core/command/status.php @@ -39,7 +39,7 @@ class Status extends Base { protected function execute(InputInterface $input, OutputInterface $output) { $values = array( 'installed' => (bool) \OC::$server->getConfig()->getSystemValue('installed', false), - 'version' => implode('.', \OC_Util::getVersion()), + 'version' => implode('.', \OCP\Util::getVersion()), 'versionstring' => \OC_Util::getVersionString(), 'edition' => \OC_Util::getEditionString(), ); diff --git a/core/js/config.php b/core/js/config.php index e51ae903729..c975c6db2dc 100644 --- a/core/js/config.php +++ b/core/js/config.php @@ -138,7 +138,7 @@ $array = array( array( 'session_lifetime' => min(\OCP\Config::getSystemValue('session_lifetime', OC::$server->getIniWrapper()->getNumeric('session.gc_maxlifetime')), OC::$server->getIniWrapper()->getNumeric('session.gc_maxlifetime')), 'session_keepalive' => \OCP\Config::getSystemValue('session_keepalive', true), - 'version' => implode('.', OC_Util::getVersion()), + 'version' => implode('.', \OCP\Util::getVersion()), 'versionstring' => OC_Util::getVersionString(), 'enable_avatars' => \OC::$server->getConfig()->getSystemValue('enable_avatars', true), 'lost_password_link'=> \OC::$server->getConfig()->getSystemValue('lost_password_link', null), diff --git a/core/l10n/es.js b/core/l10n/es.js index 2967d07b3d0..3e9bd71239f 100644 --- a/core/l10n/es.js +++ b/core/l10n/es.js @@ -119,6 +119,7 @@ OC.L10N.register( "Your PHP version ({version}) is no longer <a href=\"{phpLink}\">supported by PHP</a>. We encourage you to upgrade your PHP version to take advantage of performance and security updates provided by PHP." : "Su versión PHP ({version}) ya no es <a href=\"{phpLink}\">respaldada por PHP</a>. Recomendamos actualizar su versión de PHP para aprovechar las actualizaciones de rendimiento y seguridad proporcionadas por PHP.", "The reverse proxy headers configuration is incorrect, or you are accessing ownCloud from a trusted proxy. If you are not accessing ownCloud from a trusted proxy, this is a security issue and can allow an attacker to spoof their IP address as visible to ownCloud. Further information can be found in our <a href=\"{docLink}\">documentation</a>." : "La configuración de las cabeceras inversas del proxy son incorrectas, o está accediendo a ownCloud desde un proxy confiable. Si no está accediendo a ownCloud desde un proxy certificado y confiable, este es un problema de seguridad y puede permitirle a un hacker camuflar su dirección IP a ownCloud. Más información puede ser encontrada en nuestra <a href=\"{docLink}\">documentación</a>.", "Memcached is configured as distributed cache, but the wrong PHP module \"memcache\" is installed. \\OC\\Memcache\\Memcached only supports \"memcached\" and not \"memcache\". See the <a href=\"{wikiLink}\">memcached wiki about both modules</a>." : "memcached es un sistema de cache distribuido. pero ha sido instalado por error el modulo PHP memcache.\nConsulte <a href=\"{wikiLink}\">memcached wiki acerca de ambos modulos</a>", + "Some files have not passed the integrity check. Further information on how to resolve this issue can be found in our <a href=\"{docLink}\">documentation</a>. (<a href=\"{codeIntegrityDownloadEndpoint}\">List of invalid files…</a> / <a href=\"{rescanEndpoint}\">Rescan…</a>)" : "Algunos archivos no han superado la comprobación de integridad. Para más información sobre cómo resolver este inconveniente consulte nuestra <a href=\"{docLink}\">documentación</a>. (<a href=\"{codeIntegrityDownloadEndpoint}\">Lista de archivos inválidos…</a> / <a href=\"{rescanEndpoint}\">Reescanear…</a>)", "Error occurred while checking server setup" : "Ha ocurrido un error al revisar la configuración del servidor", "The \"{header}\" HTTP header is not configured to equal to \"{expected}\". This is a potential security or privacy risk and we recommend adjusting this setting." : "La \"{header}\" cabecera HTTP no está configurado para ser igual a \"{expected}\". Esto puede suponer un riesgo para la seguridad o la privacidad, por lo que se recomienda ajustar esta opción.", "The \"Strict-Transport-Security\" HTTP header is not configured to least \"{seconds}\" seconds. For enhanced security we recommend enabling HSTS as described in our <a href=\"{docUrl}\">security tips</a>." : "La cabecera HTTP \"Strict-Transport-Security\" no está configurada en al menos \"{segundos}\" segundos. Para una mejor seguridad recomendamos que habilite HSTS como es descripta en nuestros <a href=\"{docUrl}\">consejos de seguridad</a>.", diff --git a/core/l10n/es.json b/core/l10n/es.json index d7350cc3333..492cfbf05df 100644 --- a/core/l10n/es.json +++ b/core/l10n/es.json @@ -117,6 +117,7 @@ "Your PHP version ({version}) is no longer <a href=\"{phpLink}\">supported by PHP</a>. We encourage you to upgrade your PHP version to take advantage of performance and security updates provided by PHP." : "Su versión PHP ({version}) ya no es <a href=\"{phpLink}\">respaldada por PHP</a>. Recomendamos actualizar su versión de PHP para aprovechar las actualizaciones de rendimiento y seguridad proporcionadas por PHP.", "The reverse proxy headers configuration is incorrect, or you are accessing ownCloud from a trusted proxy. If you are not accessing ownCloud from a trusted proxy, this is a security issue and can allow an attacker to spoof their IP address as visible to ownCloud. Further information can be found in our <a href=\"{docLink}\">documentation</a>." : "La configuración de las cabeceras inversas del proxy son incorrectas, o está accediendo a ownCloud desde un proxy confiable. Si no está accediendo a ownCloud desde un proxy certificado y confiable, este es un problema de seguridad y puede permitirle a un hacker camuflar su dirección IP a ownCloud. Más información puede ser encontrada en nuestra <a href=\"{docLink}\">documentación</a>.", "Memcached is configured as distributed cache, but the wrong PHP module \"memcache\" is installed. \\OC\\Memcache\\Memcached only supports \"memcached\" and not \"memcache\". See the <a href=\"{wikiLink}\">memcached wiki about both modules</a>." : "memcached es un sistema de cache distribuido. pero ha sido instalado por error el modulo PHP memcache.\nConsulte <a href=\"{wikiLink}\">memcached wiki acerca de ambos modulos</a>", + "Some files have not passed the integrity check. Further information on how to resolve this issue can be found in our <a href=\"{docLink}\">documentation</a>. (<a href=\"{codeIntegrityDownloadEndpoint}\">List of invalid files…</a> / <a href=\"{rescanEndpoint}\">Rescan…</a>)" : "Algunos archivos no han superado la comprobación de integridad. Para más información sobre cómo resolver este inconveniente consulte nuestra <a href=\"{docLink}\">documentación</a>. (<a href=\"{codeIntegrityDownloadEndpoint}\">Lista de archivos inválidos…</a> / <a href=\"{rescanEndpoint}\">Reescanear…</a>)", "Error occurred while checking server setup" : "Ha ocurrido un error al revisar la configuración del servidor", "The \"{header}\" HTTP header is not configured to equal to \"{expected}\". This is a potential security or privacy risk and we recommend adjusting this setting." : "La \"{header}\" cabecera HTTP no está configurado para ser igual a \"{expected}\". Esto puede suponer un riesgo para la seguridad o la privacidad, por lo que se recomienda ajustar esta opción.", "The \"Strict-Transport-Security\" HTTP header is not configured to least \"{seconds}\" seconds. For enhanced security we recommend enabling HSTS as described in our <a href=\"{docUrl}\">security tips</a>." : "La cabecera HTTP \"Strict-Transport-Security\" no está configurada en al menos \"{segundos}\" segundos. Para una mejor seguridad recomendamos que habilite HSTS como es descripta en nuestros <a href=\"{docUrl}\">consejos de seguridad</a>.", diff --git a/core/templates/internalmail.php b/core/templates/internalmail.php index 0e73a601857..c2d84184d38 100644 --- a/core/templates/internalmail.php +++ b/core/templates/internalmail.php @@ -4,7 +4,7 @@ <tr> <td bgcolor="<?php p($theme->getMailHeaderColor());?>" width="20px"> </td> <td bgcolor="<?php p($theme->getMailHeaderColor());?>"> -<img src="<?php p(OC_Helper::makeURLAbsolute(image_path('', 'logo-mail.gif'))); ?>" alt="<?php p($theme->getName()); ?>"/> +<img src="<?php p(\OC::$server->getURLGenerator()->getAbsoluteURL(image_path('', 'logo-mail.gif'))); ?>" alt="<?php p($theme->getName()); ?>"/> </td> </tr> <tr><td colspan="2"> </td></tr> diff --git a/core/templates/mail.php b/core/templates/mail.php index 0e73a601857..c2d84184d38 100644 --- a/core/templates/mail.php +++ b/core/templates/mail.php @@ -4,7 +4,7 @@ <tr> <td bgcolor="<?php p($theme->getMailHeaderColor());?>" width="20px"> </td> <td bgcolor="<?php p($theme->getMailHeaderColor());?>"> -<img src="<?php p(OC_Helper::makeURLAbsolute(image_path('', 'logo-mail.gif'))); ?>" alt="<?php p($theme->getName()); ?>"/> +<img src="<?php p(\OC::$server->getURLGenerator()->getAbsoluteURL(image_path('', 'logo-mail.gif'))); ?>" alt="<?php p($theme->getName()); ?>"/> </td> </tr> <tr><td colspan="2"> </td></tr> diff --git a/core/templates/untrustedDomain.php b/core/templates/untrustedDomain.php index 361495636cd..46bad216822 100644 --- a/core/templates/untrustedDomain.php +++ b/core/templates/untrustedDomain.php @@ -10,7 +10,7 @@ <?php p($l->t('Depending on your configuration, as an administrator you might also be able to use the button below to trust this domain.')); ?> <br><br> <p style="text-align:center;"> - <a href="<?php print_unescaped(OC_Helper::makeURLAbsolute(\OCP\Util::linkToRoute('settings_admin'))); ?>?trustDomain=<?php p($_['domain']); ?>" class="button"> + <a href="<?php print_unescaped(\OC::$server->getURLGenerator()->getAbsoluteURL(\OCP\Util::linkToRoute('settings_admin'))); ?>?trustDomain=<?php p($_['domain']); ?>" class="button"> <?php p($l->t('Add "%s" as trusted domain', array($_['domain']))); ?> </a> </p> diff --git a/lib/base.php b/lib/base.php index 038c259ecf6..ce4546e8fa3 100644 --- a/lib/base.php +++ b/lib/base.php @@ -113,6 +113,11 @@ class OC { public static $server = null; /** + * @var \OC\Config + */ + private static $config = null; + + /** * @throws \RuntimeException when the 3rdparty directory is missing or * the app path list is empty or contains an invalid path */ @@ -124,7 +129,7 @@ class OC { } else { self::$configDir = OC::$SERVERROOT . '/config/'; } - OC_Config::$object = new \OC\Config(self::$configDir); + self::$config = new \OC\Config(self::$configDir); OC::$SUBURI = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen(OC::$SERVERROOT))); /** @@ -137,7 +142,7 @@ class OC { 'SCRIPT_FILENAME' => $_SERVER['SCRIPT_FILENAME'], ], ]; - $fakeRequest = new \OC\AppFramework\Http\Request($params, null, new \OC\AllConfig(new \OC\SystemConfig())); + $fakeRequest = new \OC\AppFramework\Http\Request($params, null, new \OC\AllConfig(new \OC\SystemConfig(self::$config))); $scriptName = $fakeRequest->getScriptName(); if (substr($scriptName, -1) == '/') { $scriptName .= 'index.php'; @@ -152,7 +157,7 @@ class OC { if (OC::$CLI) { - OC::$WEBROOT = OC_Config::getValue('overwritewebroot', ''); + OC::$WEBROOT = self::$config->getValue('overwritewebroot', ''); } else { if (substr($scriptName, 0 - strlen(OC::$SUBURI)) === OC::$SUBURI) { OC::$WEBROOT = substr($scriptName, 0, 0 - strlen(OC::$SUBURI)); @@ -165,7 +170,7 @@ class OC { // This most likely means that we are calling from CLI. // However some cron jobs still need to generate // a web URL, so we use overwritewebroot as a fallback. - OC::$WEBROOT = OC_Config::getValue('overwritewebroot', ''); + OC::$WEBROOT = self::$config->getValue('overwritewebroot', ''); } // Resolve /owncloud to /owncloud/ to ensure to always have a trailing @@ -178,8 +183,8 @@ class OC { } // search the 3rdparty folder - OC::$THIRDPARTYROOT = OC_Config::getValue('3rdpartyroot', null); - OC::$THIRDPARTYWEBROOT = OC_Config::getValue('3rdpartyurl', null); + OC::$THIRDPARTYROOT = self::$config->getValue('3rdpartyroot', null); + OC::$THIRDPARTYWEBROOT = self::$config->getValue('3rdpartyurl', null); if (empty(OC::$THIRDPARTYROOT) && empty(OC::$THIRDPARTYWEBROOT)) { if (file_exists(OC::$SERVERROOT . '/3rdparty')) { @@ -197,7 +202,7 @@ class OC { } // search the apps folder - $config_paths = OC_Config::getValue('apps_paths', array()); + $config_paths = self::$config->getValue('apps_paths', array()); if (!empty($config_paths)) { foreach ($config_paths as $paths) { if (isset($paths['url']) && isset($paths['path'])) { @@ -372,7 +377,7 @@ class OC { // check whether this is a core update or apps update $installedVersion = $systemConfig->getValue('version', '0.0.0'); - $currentVersion = implode('.', OC_Util::getVersion()); + $currentVersion = implode('.', \OCP\Util::getVersion()); $appManager = \OC::$server->getAppManager(); @@ -387,7 +392,7 @@ class OC { } // get third party apps - $ocVersion = OC_Util::getVersion(); + $ocVersion = \OCP\Util::getVersion(); $tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion)); $tmpl->assign('incompatibleAppsList', $appManager->getIncompatibleApps($ocVersion)); $tmpl->assign('productName', 'ownCloud'); // for now @@ -517,7 +522,7 @@ class OC { } // setup the basic server - self::$server = new \OC\Server(\OC::$WEBROOT); + self::$server = new \OC\Server(\OC::$WEBROOT, self::$config); \OC::$server->getEventLogger()->log('autoloader', 'Autoloader', $loaderStart, $loaderEnd); \OC::$server->getEventLogger()->start('boot', 'Initialize'); @@ -875,7 +880,7 @@ class OC { // Handle redirect URL for logged in users if (isset($_REQUEST['redirect_url']) && OC_User::isLoggedIn()) { - $location = OC_Helper::makeURLAbsolute(urldecode($_REQUEST['redirect_url'])); + $location = \OC::$server->getURLGenerator()->getAbsoluteURL(urldecode($_REQUEST['redirect_url'])); // Deny the redirect if the URL contains a @ // This prevents unvalidated redirects like ?redirect_url=:user@domain.com diff --git a/lib/l10n/es.js b/lib/l10n/es.js index 8f554001cfd..b37631114a0 100644 --- a/lib/l10n/es.js +++ b/lib/l10n/es.js @@ -147,6 +147,8 @@ OC.L10N.register( "Data directory (%s) is invalid" : "El directorio de datos (%s) no es válido", "Please check that the data directory contains a file \".ocdata\" in its root." : "Verifique que el directorio de datos contiene un archivo \".ocdata\" en su directorio raíz.", "Could not obtain lock type %d on \"%s\"." : "No se pudo realizar el bloqueo %d en \"%s\".", + "Storage unauthorized. %s" : "Almacenamiento no autorizado. %s", + "Storage incomplete configuration. %s" : "Configuración de almacenamiento incompleta. %s", "Storage not available" : "Almacenamiento no disponible" }, "nplurals=2; plural=(n != 1);"); diff --git a/lib/l10n/es.json b/lib/l10n/es.json index 94ff1d3db2c..9be893bbb60 100644 --- a/lib/l10n/es.json +++ b/lib/l10n/es.json @@ -145,6 +145,8 @@ "Data directory (%s) is invalid" : "El directorio de datos (%s) no es válido", "Please check that the data directory contains a file \".ocdata\" in its root." : "Verifique que el directorio de datos contiene un archivo \".ocdata\" en su directorio raíz.", "Could not obtain lock type %d on \"%s\"." : "No se pudo realizar el bloqueo %d en \"%s\".", + "Storage unauthorized. %s" : "Almacenamiento no autorizado. %s", + "Storage incomplete configuration. %s" : "Configuración de almacenamiento incompleta. %s", "Storage not available" : "Almacenamiento no disponible" },"pluralForm" :"nplurals=2; plural=(n != 1);" }
\ No newline at end of file diff --git a/lib/l10n/ja.js b/lib/l10n/ja.js index b21abe31b4e..a0619055f3a 100644 --- a/lib/l10n/ja.js +++ b/lib/l10n/ja.js @@ -96,6 +96,7 @@ OC.L10N.register( "Sharing %s failed, because %s is not a member of the group %s" : "%s を共有できませんでした。%s は、グループ %s のメンバーではありません。", "You need to provide a password to create a public link, only protected links are allowed" : "公開用リンクの作成にはパスワードの設定が必要です", "Sharing %s failed, because sharing with links is not allowed" : "%s を共有できませんでした。リンクでの共有は許可されていません。", + "Not allowed to create a federated share with the same user" : "同じユーザーでフェデレーション共有を作成することは出来ません", "Sharing %s failed, could not find %s, maybe the server is currently unreachable." : "%s を共有できませんでした。%s が見つかりませんでした。現在サーバーに接続できないようです。", "Share type %s is not valid for %s" : "%s の共有方法は、%s には適用できません。", "Setting permissions for %s failed, because the permissions exceed permissions granted to %s" : "%s を共有できませんでした。%s に許可されている権限を越えています。", diff --git a/lib/l10n/ja.json b/lib/l10n/ja.json index acc09118592..681b479ff23 100644 --- a/lib/l10n/ja.json +++ b/lib/l10n/ja.json @@ -94,6 +94,7 @@ "Sharing %s failed, because %s is not a member of the group %s" : "%s を共有できませんでした。%s は、グループ %s のメンバーではありません。", "You need to provide a password to create a public link, only protected links are allowed" : "公開用リンクの作成にはパスワードの設定が必要です", "Sharing %s failed, because sharing with links is not allowed" : "%s を共有できませんでした。リンクでの共有は許可されていません。", + "Not allowed to create a federated share with the same user" : "同じユーザーでフェデレーション共有を作成することは出来ません", "Sharing %s failed, could not find %s, maybe the server is currently unreachable." : "%s を共有できませんでした。%s が見つかりませんでした。現在サーバーに接続できないようです。", "Share type %s is not valid for %s" : "%s の共有方法は、%s には適用できません。", "Setting permissions for %s failed, because the permissions exceed permissions granted to %s" : "%s を共有できませんでした。%s に許可されている権限を越えています。", diff --git a/lib/l10n/nl.js b/lib/l10n/nl.js index f4201778f7e..bb3bd551841 100644 --- a/lib/l10n/nl.js +++ b/lib/l10n/nl.js @@ -96,6 +96,7 @@ OC.L10N.register( "Sharing %s failed, because %s is not a member of the group %s" : "Delen van %s is mislukt, omdat %s geen lid is van groep %s", "You need to provide a password to create a public link, only protected links are allowed" : "U moet een wachtwoord verstrekken om een openbare koppeling te maken, alleen beschermde links zijn toegestaan", "Sharing %s failed, because sharing with links is not allowed" : "Delen van %s is mislukt, omdat het delen met links niet is toegestaan", + "Not allowed to create a federated share with the same user" : "Het is niet toegestaan om een gefedereerde share met dezelfde gebruikersserver te maken", "Sharing %s failed, could not find %s, maybe the server is currently unreachable." : "Delen van %s mislukt, kon %s niet vinden, misschien is de server niet bereikbaar.", "Share type %s is not valid for %s" : "Delen van type %s is niet geldig voor %s", "Setting permissions for %s failed, because the permissions exceed permissions granted to %s" : "Instellen van de permissies voor %s is mislukt, omdat de permissies hoger zijn dan de aan %s toegekende permissies", diff --git a/lib/l10n/nl.json b/lib/l10n/nl.json index c8981f8fd4c..8388c0a502e 100644 --- a/lib/l10n/nl.json +++ b/lib/l10n/nl.json @@ -94,6 +94,7 @@ "Sharing %s failed, because %s is not a member of the group %s" : "Delen van %s is mislukt, omdat %s geen lid is van groep %s", "You need to provide a password to create a public link, only protected links are allowed" : "U moet een wachtwoord verstrekken om een openbare koppeling te maken, alleen beschermde links zijn toegestaan", "Sharing %s failed, because sharing with links is not allowed" : "Delen van %s is mislukt, omdat het delen met links niet is toegestaan", + "Not allowed to create a federated share with the same user" : "Het is niet toegestaan om een gefedereerde share met dezelfde gebruikersserver te maken", "Sharing %s failed, could not find %s, maybe the server is currently unreachable." : "Delen van %s mislukt, kon %s niet vinden, misschien is de server niet bereikbaar.", "Share type %s is not valid for %s" : "Delen van type %s is niet geldig voor %s", "Setting permissions for %s failed, because the permissions exceed permissions granted to %s" : "Instellen van de permissies voor %s is mislukt, omdat de permissies hoger zijn dan de aan %s toegekende permissies", diff --git a/lib/private/app.php b/lib/private/app.php index e8cc9219224..5f6ca9596c8 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -96,7 +96,7 @@ class OC_App { * if $types is set, only apps of those types will be loaded */ public static function loadApps($types = null) { - if (OC_Config::getValue('maintenance', false)) { + if (\OC::$server->getSystemConfig()->getValue('maintenance', false)) { return false; } // Load the enabled apps here @@ -239,7 +239,7 @@ class OC_App { * @return string[] */ public static function getEnabledApps($forceRefresh = false, $all = false) { - if (!OC_Config::getValue('installed', false)) { + if (!\OC::$server->getSystemConfig()->getValue('installed', false)) { return array(); } // in incognito mode or when logged out, $user will be false, @@ -318,8 +318,8 @@ class OC_App { \OC::$server->getConfig(), \OC::$server->getLogger() ); - $appData = $ocsClient->getApplication($app, \OC_Util::getVersion()); - $download= $ocsClient->getApplicationDownload($app, \OC_Util::getVersion()); + $appData = $ocsClient->getApplication($app, \OCP\Util::getVersion()); + $download= $ocsClient->getApplicationDownload($app, \OCP\Util::getVersion()); if(isset($download['downloadlink']) and $download['downloadlink']!='') { // Replace spaces in download link without encoding entire URL $download['downloadlink'] = str_replace(' ', '%20', $download['downloadlink']); @@ -374,7 +374,7 @@ class OC_App { $settings = array(); // by default, settings only contain the help menu if (OC_Util::getEditionString() === '' && - OC_Config::getValue('knowledgebaseenabled', true) == true + \OC::$server->getSystemConfig()->getValue('knowledgebaseenabled', true) == true ) { $settings = array( array( @@ -455,7 +455,7 @@ class OC_App { * @return string|false */ public static function getInstallPath() { - if (OC_Config::getValue('appstoreenabled', true) == false) { + if (\OC::$server->getSystemConfig()->getValue('appstoreenabled', true) == false) { return false; } @@ -880,7 +880,7 @@ class OC_App { if (is_null($category)) { - $categoryNames = $ocsClient->getCategories(\OC_Util::getVersion()); + $categoryNames = $ocsClient->getCategories(\OCP\Util::getVersion()); if (is_array($categoryNames)) { // Check that categories of apps were retrieved correctly if (!$categories = array_keys($categoryNames)) { @@ -892,7 +892,7 @@ class OC_App { } $page = 0; - $remoteApps = $ocsClient->getApplications($categories, $page, $filter, \OC_Util::getVersion()); + $remoteApps = $ocsClient->getApplications($categories, $page, $filter, \OCP\Util::getVersion()); $apps = []; $i = 0; $l = \OC::$server->getL10N('core'); @@ -1050,7 +1050,7 @@ class OC_App { $config, \OC::$server->getLogger() ); - $appData = $ocsClient->getApplication($app, \OC_Util::getVersion()); + $appData = $ocsClient->getApplication($app, \OCP\Util::getVersion()); // check if app is a shipped app or not. OCS apps have an integer as id, shipped apps use a string if (!is_numeric($app)) { @@ -1080,7 +1080,7 @@ class OC_App { if ($app !== false) { // check if the app is compatible with this version of ownCloud $info = self::getAppInfo($app); - $version = OC_Util::getVersion(); + $version = \OCP\Util::getVersion(); if (!self::isAppCompatible($version, $info)) { throw new \Exception( $l->t('App "%s" cannot be installed because it is not compatible with this version of ownCloud.', diff --git a/lib/private/app/platform.php b/lib/private/app/platform.php index f433ecd9f9e..c16f050e13c 100644 --- a/lib/private/app/platform.php +++ b/lib/private/app/platform.php @@ -52,7 +52,7 @@ class Platform { * @return string */ public function getOcVersion() { - $v = OC_Util::getVersion(); + $v = \OCP\Util::getVersion(); return join('.', $v); } diff --git a/lib/private/appframework/dependencyinjection/dicontainer.php b/lib/private/appframework/dependencyinjection/dicontainer.php index ce6523cc8a8..88ffc1c6f98 100644 --- a/lib/private/appframework/dependencyinjection/dicontainer.php +++ b/lib/private/appframework/dependencyinjection/dicontainer.php @@ -62,6 +62,10 @@ class DIContainer extends SimpleContainer implements IAppContainer { $this['AppName'] = $appName; $this['urlParams'] = $urlParams; + /** @var \OC\ServerContainer $server */ + $server = $this->getServer(); + $server->registerAppContainer($appName, $this); + // aliases $this->registerAlias('appName', 'AppName'); $this->registerAlias('webRoot', 'WebRoot'); diff --git a/lib/private/archive/tar.php b/lib/private/archive/tar.php index 4448e56850d..4066e1d86c1 100644 --- a/lib/private/archive/tar.php +++ b/lib/private/archive/tar.php @@ -86,7 +86,7 @@ class OC_Archive_TAR extends OC_Archive { * @return bool */ function addFolder($path) { - $tmpBase = OC_Helper::tmpFolder(); + $tmpBase = \OC::$server->getTempManager()->getTemporaryFolder(); if (substr($path, -1, 1) != '/') { $path .= '/'; } diff --git a/lib/private/backgroundjob/job.php b/lib/private/backgroundjob/job.php index 88682cd09bb..40a27491fe6 100644 --- a/lib/private/backgroundjob/job.php +++ b/lib/private/backgroundjob/job.php @@ -54,7 +54,6 @@ abstract class Job implements IJob { if ($logger) { $logger->error('Error while running background job: ' . $e->getMessage()); } - $jobList->remove($this, $this->argument); } } diff --git a/lib/private/backgroundjob/joblist.php b/lib/private/backgroundjob/joblist.php index 03c9180ddb0..446de2fa1a4 100644 --- a/lib/private/backgroundjob/joblist.php +++ b/lib/private/backgroundjob/joblist.php @@ -24,134 +24,180 @@ namespace OC\BackgroundJob; +use OCP\AppFramework\QueryException; +use OCP\BackgroundJob\IJob; use OCP\BackgroundJob\IJobList; use OCP\AutoloadNotAllowedException; class JobList implements IJobList { - /** - * @var \OCP\IDBConnection - */ - private $conn; + /** @var \OCP\IDBConnection */ + protected $connection; /** * @var \OCP\IConfig $config */ - private $config; + protected $config; /** - * @param \OCP\IDBConnection $conn + * @param \OCP\IDBConnection $connection * @param \OCP\IConfig $config */ - public function __construct($conn, $config) { - $this->conn = $conn; + public function __construct($connection, $config) { + $this->connection = $connection; $this->config = $config; } /** - * @param Job|string $job + * @param IJob|string $job * @param mixed $argument */ public function add($job, $argument = null) { if (!$this->has($job, $argument)) { - if ($job instanceof Job) { + if ($job instanceof IJob) { $class = get_class($job); } else { $class = $job; } + $argument = json_encode($argument); if (strlen($argument) > 4000) { throw new \InvalidArgumentException('Background job arguments can\'t exceed 4000 characters (json encoded)'); } - $query = $this->conn->prepare('INSERT INTO `*PREFIX*jobs`(`class`, `argument`, `last_run`) VALUES(?, ?, 0)'); - $query->execute(array($class, $argument)); + + $query = $this->connection->getQueryBuilder(); + $query->insert('jobs') + ->values([ + 'class' => $query->createNamedParameter($class), + 'argument' => $query->createNamedParameter($argument), + 'last_run' => $query->createNamedParameter(0, \PDO::PARAM_INT), + ]); + $query->execute(); } } /** - * @param Job|string $job + * @param IJob|string $job * @param mixed $argument */ public function remove($job, $argument = null) { - if ($job instanceof Job) { + if ($job instanceof IJob) { $class = get_class($job); } else { $class = $job; } + + $query = $this->connection->getQueryBuilder(); + $query->delete('jobs') + ->where($query->expr()->eq('class', $query->createNamedParameter($class))); if (!is_null($argument)) { $argument = json_encode($argument); - $query = $this->conn->prepare('DELETE FROM `*PREFIX*jobs` WHERE `class` = ? AND `argument` = ?'); - $query->execute(array($class, $argument)); - } else { - $query = $this->conn->prepare('DELETE FROM `*PREFIX*jobs` WHERE `class` = ?'); - $query->execute(array($class)); + $query->andWhere($query->expr()->eq('argument', $query->createNamedParameter($argument))); } + $query->execute(); } + /** + * @param int $id + */ protected function removeById($id) { - $query = $this->conn->prepare('DELETE FROM `*PREFIX*jobs` WHERE `id` = ?'); - $query->execute([$id]); + $query = $this->connection->getQueryBuilder(); + $query->delete('jobs') + ->where($query->expr()->eq('id', $query->createNamedParameter($id, \PDO::PARAM_INT))); + $query->execute(); } /** * check if a job is in the list * - * @param Job|string $job + * @param IJob|string $job * @param mixed $argument * @return bool */ public function has($job, $argument) { - if ($job instanceof Job) { + if ($job instanceof IJob) { $class = get_class($job); } else { $class = $job; } $argument = json_encode($argument); - $query = $this->conn->prepare('SELECT `id` FROM `*PREFIX*jobs` WHERE `class` = ? AND `argument` = ?'); - $query->execute(array($class, $argument)); - return (bool)$query->fetch(); + + $query = $this->connection->getQueryBuilder(); + $query->select('id') + ->from('jobs') + ->where($query->expr()->eq('class', $query->createNamedParameter($class))) + ->andWhere($query->expr()->eq('argument', $query->createNamedParameter($argument))) + ->setMaxResults(1); + + $result = $query->execute(); + $row = $result->fetch(); + $result->closeCursor(); + + return (bool) $row; } /** * get all jobs in the list * - * @return Job[] + * @return IJob[] */ public function getAll() { - $query = $this->conn->prepare('SELECT `id`, `class`, `last_run`, `argument` FROM `*PREFIX*jobs`'); - $query->execute(); - $jobs = array(); - while ($row = $query->fetch()) { + $query = $this->connection->getQueryBuilder(); + $query->select('*') + ->from('jobs'); + $result = $query->execute(); + + $jobs = []; + while ($row = $result->fetch()) { $job = $this->buildJob($row); if ($job) { $jobs[] = $job; } } + $result->closeCursor(); + return $jobs; } /** * get the next job in the list * - * @return Job + * @return IJob|null */ public function getNext() { $lastId = $this->getLastJob(); - $query = $this->conn->prepare('SELECT `id`, `class`, `last_run`, `argument` FROM `*PREFIX*jobs` WHERE `id` > ? ORDER BY `id` ASC', 1); - $query->execute(array($lastId)); - if ($row = $query->fetch()) { + + $query = $this->connection->getQueryBuilder(); + $query->select('*') + ->from('jobs') + ->where($query->expr()->gt('id', $query->createNamedParameter($lastId, \PDO::PARAM_INT))) + ->orderBy('id', 'ASC') + ->setMaxResults(1); + $result = $query->execute(); + $row = $result->fetch(); + $result->closeCursor(); + + if ($row) { $jobId = $row['id']; $job = $this->buildJob($row); } else { //begin at the start of the queue - $query = $this->conn->prepare('SELECT `id`, `class`, `last_run`, `argument` FROM `*PREFIX*jobs` ORDER BY `id` ASC', 1); - $query->execute(); - if ($row = $query->fetch()) { + $query = $this->connection->getQueryBuilder(); + $query->select('*') + ->from('jobs') + ->orderBy('id', 'ASC') + ->setMaxResults(1); + $result = $query->execute(); + $row = $result->fetch(); + $result->closeCursor(); + + if ($row) { $jobId = $row['id']; $job = $this->buildJob($row); } else { return null; //empty job list } } + if (is_null($job)) { $this->removeById($jobId); return $this->getNext(); @@ -162,12 +208,18 @@ class JobList implements IJobList { /** * @param int $id - * @return Job|null + * @return IJob|null */ public function getById($id) { - $query = $this->conn->prepare('SELECT `id`, `class`, `last_run`, `argument` FROM `*PREFIX*jobs` WHERE `id` = ?'); - $query->execute(array($id)); - if ($row = $query->fetch()) { + $query = $this->connection->getQueryBuilder(); + $query->select('*') + ->from('jobs') + ->where($query->expr()->eq('id', $query->createNamedParameter($id, \PDO::PARAM_INT))); + $result = $query->execute(); + $row = $result->fetch(); + $result->closeCursor(); + + if ($row) { return $this->buildJob($row); } else { return null; @@ -178,33 +230,38 @@ class JobList implements IJobList { * get the job object from a row in the db * * @param array $row - * @return Job + * @return IJob|null */ private function buildJob($row) { - $class = $row['class']; - /** - * @var Job $job - */ try { - if (!class_exists($class)) { - // job from disabled app or old version of an app, no need to do anything - return null; + try { + // Try to load the job as a service + /** @var IJob $job */ + $job = \OC::$server->query($row['class']); + } catch (QueryException $e) { + if (class_exists($row['class'])) { + $class = $row['class']; + $job = new $class(); + } else { + // job from disabled app or old version of an app, no need to do anything + return null; + } } - $job = new $class(); + $job->setId($row['id']); $job->setLastRun($row['last_run']); $job->setArgument(json_decode($row['argument'], true)); return $job; } catch (AutoloadNotAllowedException $e) { // job is from a disabled app, ignore + return null; } - return null; } /** * set the job that was last ran * - * @param Job $job + * @param IJob $job */ public function setLastJob($job) { $this->config->setAppValue('backgroundjob', 'lastjob', $job->getId()); @@ -213,19 +270,22 @@ class JobList implements IJobList { /** * get the id of the last ran job * - * @return string + * @return int */ public function getLastJob() { - return $this->config->getAppValue('backgroundjob', 'lastjob', 0); + return (int) $this->config->getAppValue('backgroundjob', 'lastjob', 0); } /** * set the lastRun of $job to now * - * @param Job $job + * @param IJob $job */ public function setLastRun($job) { - $query = $this->conn->prepare('UPDATE `*PREFIX*jobs` SET `last_run` = ? WHERE `id` = ?'); - $query->execute(array(time(), $job->getId())); + $query = $this->connection->getQueryBuilder(); + $query->update('jobs') + ->set('last_run', $query->createNamedParameter(time(), \PDO::PARAM_INT)) + ->where($query->expr()->eq('id', $query->createNamedParameter($job->getId(), \PDO::PARAM_INT))); + $query->execute(); } } diff --git a/lib/private/defaults.php b/lib/private/defaults.php index 16f45943f54..23f0baad96e 100644 --- a/lib/private/defaults.php +++ b/lib/private/defaults.php @@ -49,7 +49,7 @@ class OC_Defaults { function __construct() { $this->l = \OC::$server->getL10N('lib'); - $version = OC_Util::getVersion(); + $version = \OCP\Util::getVersion(); $this->defaultEntity = 'ownCloud'; /* e.g. company name, used for footers and copyright notices */ $this->defaultName = 'ownCloud'; /* short name, used when referring to the software */ diff --git a/lib/private/files/objectstore/objectstorestorage.php b/lib/private/files/objectstore/objectstorestorage.php index 5ec05a3529e..b34a6bdfb84 100644 --- a/lib/private/files/objectstore/objectstorestorage.php +++ b/lib/private/files/objectstore/objectstorestorage.php @@ -274,7 +274,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common { } else { $ext = ''; } - $tmpFile = \OC_Helper::tmpFile($ext); + $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext); \OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack')); if ($this->file_exists($path)) { $source = $this->fopen($path, 'r'); @@ -329,7 +329,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common { $stat['mtime'] = $mtime; $this->getCache()->update($stat['fileid'], $stat); } else { - $mimeType = \OC_Helper::getFileNameMimeType($path); + $mimeType = \OC::$server->getMimeTypeDetector()->detectPath($path); // create new file $stat = array( 'etag' => $this->getETag($path), diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php index b06543d0a6a..1e30d48f613 100644 --- a/lib/private/files/storage/common.php +++ b/lib/private/files/storage/common.php @@ -225,7 +225,7 @@ abstract class Common implements Storage { if ($this->is_dir($path)) { return 'httpd/unix-directory'; } elseif ($this->file_exists($path)) { - return \OC_Helper::getFileNameMimeType($path); + return \OC::$server->getMimeTypeDetector()->detectPath($path); } else { return false; } @@ -248,7 +248,7 @@ abstract class Common implements Storage { } public function getLocalFolder($path) { - $baseDir = \OC_Helper::tmpFolder(); + $baseDir = \OC::$server->getTempManager()->getTemporaryFolder(); $this->addLocalFolder($path, $baseDir); return $baseDir; } diff --git a/lib/private/files/storage/localtempfiletrait.php b/lib/private/files/storage/localtempfiletrait.php index 84331f49b19..8875c2c4493 100644 --- a/lib/private/files/storage/localtempfiletrait.php +++ b/lib/private/files/storage/localtempfiletrait.php @@ -70,7 +70,7 @@ trait LocalTempFileTrait { } else { $extension = ''; } - $tmpFile = \OC_Helper::tmpFile($extension); + $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($extension); $target = fopen($tmpFile, 'w'); \OC_Helper::streamCopy($source, $target); fclose($target); diff --git a/lib/private/files/storage/temporary.php b/lib/private/files/storage/temporary.php index c8b99a55637..8abc19929b0 100644 --- a/lib/private/files/storage/temporary.php +++ b/lib/private/files/storage/temporary.php @@ -29,7 +29,7 @@ namespace OC\Files\Storage; */ class Temporary extends Local{ public function __construct($arguments = null) { - parent::__construct(array('datadir' => \OC_Helper::tmpFolder())); + parent::__construct(array('datadir' => \OC::$server->getTempManager()->getTemporaryFolder())); } public function cleanUp() { diff --git a/lib/private/files/type/detection.php b/lib/private/files/type/detection.php index c102e739e04..0e2bab39e5b 100644 --- a/lib/private/files/type/detection.php +++ b/lib/private/files/type/detection.php @@ -238,7 +238,7 @@ class Detection implements IMimeTypeDetector { $finfo = finfo_open(FILEINFO_MIME); return finfo_buffer($finfo, $data); } else { - $tmpFile = \OC_Helper::tmpFile(); + $tmpFile = \OC::$server->getTempManager()->getTemporaryFile(); $fh = fopen($tmpFile, 'wb'); fwrite($fh, $data, 8024); fclose($fh); diff --git a/lib/private/files/view.php b/lib/private/files/view.php index b8b1b8a50d6..fcea4828c49 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -912,7 +912,7 @@ class View { $source = $this->fopen($path, 'r'); if ($source) { $extension = pathinfo($path, PATHINFO_EXTENSION); - $tmpFile = \OC_Helper::tmpFile($extension); + $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($extension); file_put_contents($tmpFile, $source); return $tmpFile; } else { diff --git a/lib/private/helper.php b/lib/private/helper.php index 1c3b1064ffa..64952903712 100644 --- a/lib/private/helper.php +++ b/lib/private/helper.php @@ -54,60 +54,6 @@ class OC_Helper { private static $templateManager; /** - * Creates an absolute url - * @param string $app app - * @param string $file file - * @param array $args array with param=>value, will be appended to the returned url - * The value of $args will be urlencoded - * @return string the url - * - * Returns a absolute url to the given app and file. - */ - public static function linkToAbsolute($app, $file, $args = array()) { - return OC::$server->getURLGenerator()->getAbsoluteURL( - OC::$server->getURLGenerator()->linkTo($app, $file, $args) - ); - } - - /** - * Makes an $url absolute - * @param string $url the url - * @return string the absolute url - * @deprecated Use \OC::$server->getURLGenerator()->getAbsoluteURL($url) - * - * Returns a absolute url to the given app and file. - */ - public static function makeURLAbsolute($url) { - return OC::$server->getURLGenerator()->getAbsoluteURL($url); - } - - /** - * Creates an url for remote use - * @param string $service id - * @return string the url - * - * Returns a url to the given service. - */ - public static function linkToRemoteBase($service) { - return OC::$server->getURLGenerator()->linkTo('', 'remote.php') . '/' . $service; - } - - /** - * Creates an absolute url for remote use - * @param string $service id - * @param bool $add_slash - * @return string the url - * - * Returns a absolute url to the given service. - */ - public static function linkToRemote($service, $add_slash = true) { - return OC::$server->getURLGenerator()->getAbsoluteURL( - self::linkToRemoteBase($service) - . (($add_slash && $service[strlen($service) - 1] != '/') ? '/' : '') - ); - } - - /** * Creates an absolute url for public use * @param string $service id * @param bool $add_slash @@ -138,18 +84,6 @@ class OC_Helper { } /** - * get path to icon of file type - * @param string $mimetype mimetype - * @return string the url - * - * Returns the path to the image of this file type. - * @deprecated 8.2.0 Use \OC::$server->getMimeTypeDetector()->mimeTypeIcon($mimetype) - */ - public static function mimetypeIcon($mimetype) { - return \OC::$server->getMimeTypeDetector()->mimeTypeIcon($mimetype); - } - - /** * get path to preview of file * @param string $path path * @return string the url @@ -165,16 +99,6 @@ class OC_Helper { } /** - * shows whether the user has an avatar - * @param string $user username - * @return bool avatar set or not - * @deprecated 9.0.0 Use \OC::$server->getAvatarManager()->getAvatar($user)->exists(); - **/ - public static function userAvatarSet($user) { - return \OC::$server->getAvatarManager()->getAvatar($user)->exists(); - } - - /** * Make a human file size * @param int $bytes file size in bytes * @return string a human readable file size @@ -336,14 +260,6 @@ class OC_Helper { } /** - * @return \OC\Files\Type\Detection - * @deprecated 8.2.0 use \OC::$server->getMimeTypeDetector() - */ - static public function getMimetypeDetector() { - return \OC::$server->getMimeTypeDetector(); - } - - /** * @return \OC\Files\Type\TemplateManager */ static public function getFileTemplateManager() { @@ -354,39 +270,6 @@ class OC_Helper { } /** - * Try to guess the mimetype based on filename - * - * @param string $path - * @return string - * @deprecated 8.2.0 Use \OC::$server->getMimeTypeDetector()->detectPath($path) - */ - static public function getFileNameMimeType($path) { - return \OC::$server->getMimeTypeDetector()->detectPath($path); - } - - /** - * Get a secure mimetype that won't expose potential XSS. - * - * @param string $mimeType - * @return string - * @deprecated 8.2.0 Use \OC::$server->getMimeTypeDetector()->getSecureMimeType($mimeType) - */ - static function getSecureMimeType($mimeType) { - return \OC::$server->getMimeTypeDetector()->getSecureMimeType($mimeType); - } - - /** - * get the mimetype form a data string - * - * @param string $data - * @return string - * @deprecated 8.2.0 Use \OC::$server->getMimeTypeDetector()->detectString($data) - */ - static function getStringMimeType($data) { - return \OC::$server->getMimeTypeDetector()->detectString($data); - } - - /** * detect if a given program is found in the search PATH * * @param string $name @@ -465,31 +348,6 @@ class OC_Helper { } /** - * create a temporary file with an unique filename - * - * @param string $postfix - * @return string - * @deprecated Use the TempManager instead - * - * temporary files are automatically cleaned up after the script is finished - */ - public static function tmpFile($postfix = '') { - return \OC::$server->getTempManager()->getTemporaryFile($postfix); - } - - /** - * create a temporary folder with an unique filename - * - * @return string - * @deprecated Use the TempManager instead - * - * temporary files are automatically cleaned up after the script is finished - */ - public static function tmpFolder() { - return \OC::$server->getTempManager()->getTemporaryFolder(); - } - - /** * Adds a suffix to the name in case the file exists * * @param string $path @@ -754,7 +612,7 @@ class OC_Helper { */ public static function getStorageInfo($path, $rootInfo = null) { // return storage info without adding mount points - $includeExtStorage = \OC_Config::getValue('quota_include_external_storage', false); + $includeExtStorage = \OC::$server->getSystemConfig()->getValue('quota_include_external_storage', false); if (!$rootInfo) { $rootInfo = \OC\Files\Filesystem::getFileInfo($path, false); diff --git a/lib/private/installer.php b/lib/private/installer.php index fa9fc6704df..bbd976cda91 100644 --- a/lib/private/installer.php +++ b/lib/private/installer.php @@ -232,8 +232,8 @@ class OC_Installer{ \OC::$server->getConfig(), \OC::$server->getLogger() ); - $appData = $ocsClient->getApplication($ocsId, \OC_Util::getVersion()); - $download = $ocsClient->getApplicationDownload($ocsId, \OC_Util::getVersion()); + $appData = $ocsClient->getApplication($ocsId, \OCP\Util::getVersion()); + $download = $ocsClient->getApplicationDownload($ocsId, \OCP\Util::getVersion()); if (isset($download['downloadlink']) && trim($download['downloadlink']) !== '') { $download['downloadlink'] = str_replace(' ', '%20', $download['downloadlink']); @@ -264,7 +264,7 @@ class OC_Installer{ //download the file if necessary if($data['source']=='http') { $pathInfo = pathinfo($data['href']); - $path=OC_Helper::tmpFile('.' . $pathInfo['extension']); + $path = \OC::$server->getTempManager()->getTemporaryFile('.' . $pathInfo['extension']); if(!isset($data['href'])) { throw new \Exception($l->t("No href specified when installing app from http")); } @@ -284,7 +284,7 @@ class OC_Installer{ } //extract the archive in a temporary folder - $extractDir=OC_Helper::tmpFolder(); + $extractDir = \OC::$server->getTempManager()->getTemporaryFolder(); OC_Helper::rmdirr($extractDir); mkdir($extractDir); if($archive=OC_Archive::open($path)) { @@ -342,7 +342,7 @@ class OC_Installer{ } // check if the app is compatible with this version of ownCloud - if(!OC_App::isAppCompatible(OC_Util::getVersion(), $info)) { + if(!OC_App::isAppCompatible(\OCP\Util::getVersion(), $info)) { OC_Helper::rmdirr($extractDir); throw new \Exception($l->t("App can't be installed because it is not compatible with this version of ownCloud")); } @@ -400,7 +400,7 @@ class OC_Installer{ \OC::$server->getConfig(), \OC::$server->getLogger() ); - $ocsdata = $ocsClient->getApplication($ocsid, \OC_Util::getVersion()); + $ocsdata = $ocsClient->getApplication($ocsid, \OCP\Util::getVersion()); $ocsversion= (string) $ocsdata['version']; $currentversion=OC_App::getAppVersion($app); if (version_compare($ocsversion, $currentversion, '>')) { diff --git a/lib/private/legacy/config.php b/lib/private/legacy/config.php deleted file mode 100644 index 1835d4a4b1c..00000000000 --- a/lib/private/legacy/config.php +++ /dev/null @@ -1,94 +0,0 @@ -<?php -/** - * @author Bart Visscher <bartv@thisnet.nl> - * @author Joas Schilling <nickvergessen@owncloud.com> - * @author Jörn Friedrich Dreyer <jfd@butonic.de> - * @author Lukas Reschke <lukas@owncloud.com> - * @author Michael Gapczynski <GapczynskiM@gmail.com> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Robin McCorkell <rmccorkell@karoshi.org.uk> - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -/** - * This class is responsible for reading and writing config.php, the very basic - * configuration file of ownCloud. - * - * @deprecated use \OC::$server->getConfig() to get an \OCP\Config instance - */ -class OC_Config { - - /** @var \OC\Config */ - public static $object; - - /** - * Lists all available config keys - * @return array an array of key names - * - * This function returns all keys saved in config.php. Please note that it - * does not return the values. - */ - public static function getKeys() { - return self::$object->getKeys(); - } - - /** - * Gets a value from config.php - * @param string $key key - * @param mixed $default = null default value - * @return mixed the value or $default - * - * This function gets the value from config.php. If it does not exist, - * $default will be returned. - */ - public static function getValue($key, $default = null) { - return self::$object->getValue($key, $default); - } - - /** - * Sets a value - * @param string $key key - * @param mixed $value value - * - * This function sets the value and writes the config.php. - * - */ - public static function setValue($key, $value) { - self::$object->setValue($key, $value); - } - - /** - * Sets and deletes values and writes the config.php - * - * @param array $configs Associative array with `key => value` pairs - * If value is null, the config key will be deleted - */ - public static function setValues(array $configs) { - self::$object->setValues($configs); - } - - /** - * Removes a key from the config - * @param string $key key - * - * This function removes a key from the config.php. - */ - public static function deleteKey($key) { - self::$object->deleteKey($key); - } -} diff --git a/lib/private/memcache/apcu.php b/lib/private/memcache/apcu.php index 84147233ef0..778e27d4567 100644 --- a/lib/private/memcache/apcu.php +++ b/lib/private/memcache/apcu.php @@ -24,7 +24,101 @@ namespace OC\Memcache; -class APCu extends APC { +use OCP\IMemcache; + +class APCu extends Cache implements IMemcache { + use CASTrait { + cas as casEmulated; + } + + use CADTrait; + + public function get($key) { + $result = apcu_fetch($this->getPrefix() . $key, $success); + if (!$success) { + return null; + } + return $result; + } + + public function set($key, $value, $ttl = 0) { + return apcu_store($this->getPrefix() . $key, $value, $ttl); + } + + public function hasKey($key) { + return apcu_exists($this->getPrefix() . $key); + } + + public function remove($key) { + return apcu_delete($this->getPrefix() . $key); + } + + public function clear($prefix = '') { + $ns = $this->getPrefix() . $prefix; + $ns = preg_quote($ns, '/'); + if(class_exists('\APCIterator')) { + $iter = new \APCIterator('user', '/^' . $ns . '/', APC_ITER_KEY); + } else { + $iter = new \APCUIterator('user', '/^' . $ns . '/', APC_ITER_KEY); + } + return apcu_delete($iter); + } + + /** + * Set a value in the cache if it's not already stored + * + * @param string $key + * @param mixed $value + * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 + * @return bool + */ + public function add($key, $value, $ttl = 0) { + return apcu_add($this->getPrefix() . $key, $value, $ttl); + } + + /** + * Increase a stored number + * + * @param string $key + * @param int $step + * @return int | bool + */ + public function inc($key, $step = 1) { + $this->add($key, 0); + return apcu_inc($this->getPrefix() . $key, $step); + } + + /** + * Decrease a stored number + * + * @param string $key + * @param int $step + * @return int | bool + */ + public function dec($key, $step = 1) { + return apcu_dec($this->getPrefix() . $key, $step); + } + + /** + * Compare and set + * + * @param string $key + * @param mixed $old + * @param mixed $new + * @return bool + */ + public function cas($key, $old, $new) { + // apc only does cas for ints + if (is_int($old) and is_int($new)) { + return apcu_cas($this->getPrefix() . $key, $old, $new); + } else { + return $this->casEmulated($key, $old, $new); + } + } + + /** + * @return bool + */ static public function isAvailable() { if (!extension_loaded('apcu')) { return false; @@ -32,7 +126,10 @@ class APCu extends APC { return false; } elseif (!\OC::$server->getIniWrapper()->getBool('apc.enable_cli') && \OC::$CLI) { return false; - } elseif (version_compare(phpversion('apc'), '4.0.6') === -1) { + } elseif ( + version_compare(phpversion('apc'), '4.0.6') === -1 && + version_compare(phpversion('apcu'), '5.1.0') === -1 + ) { return false; } else { return true; diff --git a/lib/private/ocs/cloud.php b/lib/private/ocs/cloud.php index 2cf40c449ff..1b04f43d477 100644 --- a/lib/private/ocs/cloud.php +++ b/lib/private/ocs/cloud.php @@ -26,7 +26,7 @@ class OC_OCS_Cloud { public static function getCapabilities() { $result = array(); - list($major, $minor, $micro) = OC_Util::getVersion(); + list($major, $minor, $micro) = \OCP\Util::getVersion(); $result['version'] = array( 'major' => $major, 'minor' => $minor, diff --git a/lib/private/preview.php b/lib/private/preview.php index 38c043030fc..44d38b354a9 100644 --- a/lib/private/preview.php +++ b/lib/private/preview.php @@ -1168,7 +1168,7 @@ class Preview { */ private function getMimeIcon() { $image = new \OC_Image(); - $mimeIconWebPath = \OC_Helper::mimetypeIcon($this->mimeType); + $mimeIconWebPath = \OC::$server->getMimeTypeDetector()->mimeTypeIcon($this->mimeType); if (empty(\OC::$WEBROOT)) { $mimeIconServerPath = \OC::$SERVERROOT . $mimeIconWebPath; } else { diff --git a/lib/private/preview/movie.php b/lib/private/preview/movie.php index f71eaaf3eb2..2c2e6d09399 100644 --- a/lib/private/preview/movie.php +++ b/lib/private/preview/movie.php @@ -46,7 +46,7 @@ class Movie extends Provider { if ($useFileDirectly) { $absPath = $fileview->getLocalFile($path); } else { - $absPath = \OC_Helper::tmpFile(); + $absPath = \OC::$server->getTempManager()->getTemporaryFile(); $handle = $fileview->fopen($path, 'rb'); @@ -79,7 +79,7 @@ class Movie extends Provider { * @return bool|\OCP\IImage */ private function generateThumbNail($maxX, $maxY, $absPath, $second) { - $tmpPath = \OC_Helper::tmpFile(); + $tmpPath = \OC::$server->getTempManager()->getTemporaryFile(); if (self::$avconvBinary) { $cmd = self::$avconvBinary . ' -an -y -ss ' . escapeshellarg($second) . diff --git a/lib/private/server.php b/lib/private/server.php index 8439500706d..7efe78b7c37 100644 --- a/lib/private/server.php +++ b/lib/private/server.php @@ -78,14 +78,15 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; * * TODO: hookup all manager classes */ -class Server extends SimpleContainer implements IServerContainer { +class Server extends ServerContainer implements IServerContainer { /** @var string */ private $webRoot; /** * @param string $webRoot + * @param \OC\Config $config */ - public function __construct($webRoot) { + public function __construct($webRoot, \OC\Config $config) { parent::__construct(); $this->webRoot = $webRoot; @@ -238,8 +239,8 @@ class Server extends SimpleContainer implements IServerContainer { $c->getSystemConfig() ); }); - $this->registerService('SystemConfig', function ($c) { - return new \OC\SystemConfig(); + $this->registerService('SystemConfig', function ($c) use ($config) { + return new \OC\SystemConfig($config); }); $this->registerService('AppConfig', function ($c) { return new \OC\AppConfig(\OC_DB::getConnection()); diff --git a/lib/private/servercontainer.php b/lib/private/servercontainer.php new file mode 100644 index 00000000000..856e3f9b495 --- /dev/null +++ b/lib/private/servercontainer.php @@ -0,0 +1,89 @@ +<?php +/** + * @author Joas Schilling <nickvergessen@owncloud.com> + * + * @copyright Copyright (c) 2015, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ + +namespace OC; + + +use OC\AppFramework\DependencyInjection\DIContainer; +use OC\AppFramework\Utility\SimpleContainer; +use OCP\AppFramework\QueryException; + +/** + * Class ServerContainer + * + * @package OC + */ +class ServerContainer extends SimpleContainer { + /** @var DIContainer[] */ + protected $appContainers; + + /** + * ServerContainer constructor. + */ + public function __construct() { + parent::__construct(); + $this->appContainers = []; + } + + /** + * @param string $appName + * @param DIContainer $container + */ + public function registerAppContainer($appName, DIContainer $container) { + $this->appContainers[$appName] = $container; + } + + /** + * @param string $appName + * @return DIContainer + */ + public function getAppContainer($appName) { + if (isset($this->appContainers[$appName])) { + return $this->appContainers[$appName]; + } + + return new DIContainer($appName); + } + + /** + * @param string $name name of the service to query for + * @return mixed registered service for the given $name + * @throws QueryException if the query could not be resolved + */ + public function query($name) { + $name = $this->sanitizeName($name); + + // In case the service starts with OCA\ we try to find the service in + // the apps container first. + if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) { + $segments = explode('\\', $name); + $appContainer = $this->getAppContainer(strtolower($segments[0])); + try { + return $appContainer->query($name); + } catch (QueryException $e) { + // Didn't find the service in the respective app container, + // ignore it and fall back to the core container. + } + } + + return parent::query($name); + } +} diff --git a/lib/private/setup.php b/lib/private/setup.php index 4d11cb44a83..770f5cdab52 100644 --- a/lib/private/setup.php +++ b/lib/private/setup.php @@ -322,7 +322,7 @@ class Setup { 'datadirectory' => $dataDir, 'overwrite.cli.url' => $request->getServerProtocol() . '://' . $request->getInsecureServerHost() . \OC::$WEBROOT, 'dbtype' => $dbType, - 'version' => implode('.', \OC_Util::getVersion()), + 'version' => implode('.', \OCP\Util::getVersion()), ]); try { diff --git a/lib/private/systemconfig.php b/lib/private/systemconfig.php index 94b815aebd7..fb8c18123d7 100644 --- a/lib/private/systemconfig.php +++ b/lib/private/systemconfig.php @@ -44,12 +44,19 @@ class SystemConfig { 'objectstore' => ['arguments' => ['password' => true]], ]; + /** @var Config */ + private $config; + + public function __construct(Config $config) { + $this->config = $config; + } + /** * Lists all available config keys * @return array an array of key names */ public function getKeys() { - return \OC_Config::getKeys(); + return $this->config->getKeys(); } /** @@ -59,7 +66,7 @@ class SystemConfig { * @param mixed $value the value that should be stored */ public function setValue($key, $value) { - \OC_Config::setValue($key, $value); + $this->config->setValue($key, $value); } /** @@ -69,7 +76,7 @@ class SystemConfig { * If value is null, the config key will be deleted */ public function setValues(array $configs) { - \OC_Config::setValues($configs); + $this->config->setValues($configs); } /** @@ -80,7 +87,7 @@ class SystemConfig { * @return mixed the value or $default */ public function getValue($key, $default = '') { - return \OC_Config::getValue($key, $default); + return $this->config->getValue($key, $default); } /** @@ -106,7 +113,7 @@ class SystemConfig { * @param string $key the key of the value, under which it was saved */ public function deleteValue($key) { - \OC_Config::deleteKey($key); + $this->config->deleteKey($key); } /** diff --git a/lib/private/template/functions.php b/lib/private/template/functions.php index 6298f25edc1..982ecde5850 100644 --- a/lib/private/template/functions.php +++ b/lib/private/template/functions.php @@ -173,11 +173,9 @@ function image_path( $app, $image ) { * make OC_Helper::mimetypeIcon available as a simple function * @param string $mimetype mimetype * @return string link to the image - * - * For further information have a look at OC_Helper::mimetypeIcon */ function mimetype_icon( $mimetype ) { - return OC_Helper::mimetypeIcon( $mimetype ); + return \OC::$server->getMimeTypeDetector()->mimeTypeIcon( $mimetype ); } /** diff --git a/lib/private/templatelayout.php b/lib/private/templatelayout.php index 95688268c47..bf25b2d31a9 100644 --- a/lib/private/templatelayout.php +++ b/lib/private/templatelayout.php @@ -159,7 +159,7 @@ class OC_TemplateLayout extends OC_Template { if(empty(self::$versionHash)) { $v = OC_App::getAppVersions(); - $v['core'] = implode('.', \OC_Util::getVersion()); + $v['core'] = implode('.', \OCP\Util::getVersion()); self::$versionHash = md5(implode(',', $v)); } diff --git a/lib/private/updater.php b/lib/private/updater.php index d5598d339d3..04f8dcf7226 100644 --- a/lib/private/updater.php +++ b/lib/private/updater.php @@ -155,7 +155,7 @@ class Updater extends BasicEmitter { $this->config->setAppValue('core', 'installedat', microtime(true)); } - $version = \OC_Util::getVersion(); + $version = \OCP\Util::getVersion(); $version['installed'] = $this->config->getAppValue('core', 'installedat'); $version['updated'] = $this->config->getAppValue('core', 'lastupdatedat'); $version['updatechannel'] = \OC_Util::getChannel(); @@ -208,7 +208,7 @@ class Updater extends BasicEmitter { } $installedVersion = $this->config->getSystemValue('version', '0.0.0'); - $currentVersion = implode('.', \OC_Util::getVersion()); + $currentVersion = implode('.', \OCP\Util::getVersion()); $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core')); $success = true; @@ -353,7 +353,7 @@ class Updater extends BasicEmitter { } // only set the final version if everything went well - $this->config->setSystemValue('version', implode('.', \OC_Util::getVersion())); + $this->config->setSystemValue('version', implode('.', \OCP\Util::getVersion())); } } @@ -472,7 +472,7 @@ class Updater extends BasicEmitter { private function checkAppsRequirements() { $isCoreUpgrade = $this->isCodeUpgrade(); $apps = OC_App::getEnabledApps(); - $version = OC_Util::getVersion(); + $version = \OCP\Util::getVersion(); $disabledApps = []; foreach ($apps as $app) { // check if the app is compatible with this version of ownCloud @@ -509,7 +509,7 @@ class Updater extends BasicEmitter { */ private function isCodeUpgrade() { $installedVersion = $this->config->getSystemValue('version', '0.0.0'); - $currentVersion = implode('.', OC_Util::getVersion()); + $currentVersion = implode('.', \OCP\Util::getVersion()); if (version_compare($currentVersion, $installedVersion, '>')) { return true; } diff --git a/lib/private/user.php b/lib/private/user.php index 74441d9175a..cfa60d675fe 100644 --- a/lib/private/user.php +++ b/lib/private/user.php @@ -66,14 +66,6 @@ class OC_User { return OC::$server->getUserSession(); } - /** - * @return \OC\User\Manager - * @deprecated Use \OC::$server->getUserManager() - */ - public static function getManager() { - return OC::$server->getUserManager(); - } - private static $_backends = array(); private static $_usedBackends = array(); @@ -84,44 +76,6 @@ class OC_User { private static $incognitoMode = false; /** - * registers backend - * - * @param string $backend name of the backend - * @deprecated Add classes by calling OC_User::useBackend() with a class instance instead - * @return bool - * - * Makes a list of backends that can be used by other modules - */ - public static function registerBackend($backend) { - self::$_backends[] = $backend; - return true; - } - - /** - * gets available backends - * - * @deprecated - * @return array an array of backends - * - * Returns the names of all backends. - */ - public static function getBackends() { - return self::$_backends; - } - - /** - * gets used backends - * - * @deprecated - * @return array an array of backends - * - * Returns the names of all used backends. - */ - public static function getUsedBackends() { - return array_keys(self::$_usedBackends); - } - - /** * Adds the backend to the list of used backends * * @param string|OC_User_Interface $backend default: database The backend to use for user management @@ -132,7 +86,7 @@ class OC_User { public static function useBackend($backend = 'database') { if ($backend instanceof OC_User_Interface) { self::$_usedBackends[get_class($backend)] = $backend; - self::getManager()->registerBackend($backend); + \OC::$server->getUserManager()->registerBackend($backend); } else { // You'll never know what happens if (null === $backend OR !is_string($backend)) { @@ -146,17 +100,17 @@ class OC_User { case 'sqlite': \OCP\Util::writeLog('core', 'Adding user backend ' . $backend . '.', \OCP\Util::DEBUG); self::$_usedBackends[$backend] = new OC_User_Database(); - self::getManager()->registerBackend(self::$_usedBackends[$backend]); + \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); break; case 'dummy': self::$_usedBackends[$backend] = new \Test\Util\User\Dummy(); - self::getManager()->registerBackend(self::$_usedBackends[$backend]); + \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); break; default: \OCP\Util::writeLog('core', 'Adding default user backend ' . $backend . '.', \OCP\Util::DEBUG); $className = 'OC_USER_' . strToUpper($backend); self::$_usedBackends[$backend] = new $className(); - self::getManager()->registerBackend(self::$_usedBackends[$backend]); + \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); break; } } @@ -168,7 +122,7 @@ class OC_User { */ public static function clearBackends() { self::$_usedBackends = array(); - self::getManager()->clearBackends(); + \OC::$server->getUserManager()->clearBackends(); } /** @@ -176,7 +130,7 @@ class OC_User { */ public static function setupBackends() { OC_App::loadApps(array('prelogin')); - $backends = OC_Config::getValue('user_backends', array()); + $backends = \OC::$server->getSystemConfig()->getValue('user_backends', array()); foreach ($backends as $i => $config) { $class = $config['class']; $arguments = $config['arguments']; @@ -199,42 +153,6 @@ class OC_User { } /** - * Create a new user - * - * @param string $uid The username of the user to create - * @param string $password The password of the new user - * @throws Exception - * @return bool true/false - * - * Creates a new user. Basic checking of username is done in OC_User - * itself, not in its subclasses. - * - * Allowed characters in the username are: "a-z", "A-Z", "0-9" and "_.@-" - * @deprecated Use \OC::$server->getUserManager()->createUser($uid, $password) - */ - public static function createUser($uid, $password) { - return self::getManager()->createUser($uid, $password); - } - - /** - * delete a user - * - * @param string $uid The username of the user to delete - * @return bool - * - * Deletes a user - * @deprecated Use \OC::$server->getUserManager()->get() and then run delete() on the return - */ - public static function deleteUser($uid) { - $user = self::getManager()->get($uid); - if ($user) { - return $user->delete(); - } else { - return false; - } - } - - /** * Try to login a user * * @param string $loginname The login name of the user to log in @@ -343,7 +261,7 @@ class OC_User { if (is_null($displayName)) { $displayName = $uid; } - $user = self::getManager()->get($uid); + $user = \OC::$server->getUserManager()->get($uid); if ($user) { return $user->setDisplayName($displayName); } else { @@ -452,7 +370,7 @@ class OC_User { */ public static function getDisplayName($uid = null) { if ($uid) { - $user = self::getManager()->get($uid); + $user = \OC::$server->getUserManager()->get($uid); if ($user) { return $user->getDisplayName(); } else { @@ -490,7 +408,7 @@ class OC_User { * Change the password of a user */ public static function setPassword($uid, $password, $recoveryPassword = null) { - $user = self::getManager()->get($uid); + $user = \OC::$server->getUserManager()->get($uid); if ($user) { return $user->setPassword($password, $recoveryPassword); } else { @@ -507,7 +425,7 @@ class OC_User { * Check whether a specified user can change his avatar */ public static function canUserChangeAvatar($uid) { - $user = self::getManager()->get($uid); + $user = \OC::$server->getUserManager()->get($uid); if ($user) { return $user->canChangeAvatar(); } else { @@ -524,7 +442,7 @@ class OC_User { * Check whether a specified user can change his password */ public static function canUserChangePassword($uid) { - $user = self::getManager()->get($uid); + $user = \OC::$server->getUserManager()->get($uid); if ($user) { return $user->canChangePassword(); } else { @@ -541,7 +459,7 @@ class OC_User { * Check whether a specified user can change his display name */ public static function canUserChangeDisplayName($uid) { - $user = self::getManager()->get($uid); + $user = \OC::$server->getUserManager()->get($uid); if ($user) { return $user->canChangeDisplayName(); } else { @@ -560,7 +478,7 @@ class OC_User { * returns the user id or false */ public static function checkPassword($uid, $password) { - $manager = self::getManager(); + $manager = \OC::$server->getUserManager(); $username = $manager->checkPassword($uid, $password); if ($username !== false) { return $username->getUID(); @@ -576,11 +494,11 @@ class OC_User { * @deprecated Use \OC::$server->getUserManager->getHome() */ public static function getHome($uid) { - $user = self::getManager()->get($uid); + $user = \OC::$server->getUserManager()->get($uid); if ($user) { return $user->getHome(); } else { - return OC_Config::getValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $uid; + return \OC::$server->getSystemConfig()->getValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $uid; } } @@ -595,7 +513,7 @@ class OC_User { * @param integer $offset */ public static function getUsers($search = '', $limit = null, $offset = null) { - $users = self::getManager()->search($search, $limit, $offset); + $users = \OC::$server->getUserManager()->search($search, $limit, $offset); $uids = array(); foreach ($users as $user) { $uids[] = $user->getUID(); @@ -616,7 +534,7 @@ class OC_User { */ public static function getDisplayNames($search = '', $limit = null, $offset = null) { $displayNames = array(); - $users = self::getManager()->searchDisplayName($search, $limit, $offset); + $users = \OC::$server->getUserManager()->searchDisplayName($search, $limit, $offset); foreach ($users as $user) { $displayNames[$user->getUID()] = $user->getDisplayName(); } @@ -630,7 +548,7 @@ class OC_User { * @return boolean */ public static function userExists($uid) { - return self::getManager()->userExists($uid); + return \OC::$server->getUserManager()->userExists($uid); } /** @@ -639,7 +557,7 @@ class OC_User { * @param string $uid the user to disable */ public static function disableUser($uid) { - $user = self::getManager()->get($uid); + $user = \OC::$server->getUserManager()->get($uid); if ($user) { $user->setEnabled(false); } @@ -651,7 +569,7 @@ class OC_User { * @param string $uid */ public static function enableUser($uid) { - $user = self::getManager()->get($uid); + $user = \OC::$server->getUserManager()->get($uid); if ($user) { $user->setEnabled(true); } @@ -664,7 +582,7 @@ class OC_User { * @return bool */ public static function isEnabled($uid) { - $user = self::getManager()->get($uid); + $user = \OC::$server->getUserManager()->get($uid); if ($user) { return $user->isEnabled(); } else { diff --git a/lib/private/util.php b/lib/private/util.php index 578001988d4..12146f6980b 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -72,7 +72,7 @@ class OC_Util { private static function initLocalStorageRootFS() { // mount local file backend as root - $configDataDirectory = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data"); + $configDataDirectory = \OC::$server->getSystemConfig()->getValue("datadirectory", OC::$SERVERROOT . "/data"); //first set up the local "root" storage \OC\Files\Filesystem::initMountManager(); if (!self::$rootMounted) { @@ -184,7 +184,7 @@ class OC_Util { OC_Hook::emit('OC_Filesystem', 'preSetup', array('user' => $user)); //check if we are using an object storage - $objectStore = OC_Config::getValue('objectstore'); + $objectStore = \OC::$server->getSystemConfig()->getValue('objectstore', null); if (isset($objectStore)) { self::initObjectStoreRootFS($objectStore); } else { @@ -848,7 +848,7 @@ class OC_Util { public static function checkDatabaseVersion() { $l = \OC::$server->getL10N('lib'); $errors = array(); - $dbType = \OC_Config::getValue('dbtype', 'sqlite'); + $dbType = \OC::$server->getSystemConfig()->getValue('dbtype', 'sqlite'); if ($dbType === 'pgsql') { // check PostgreSQL version try { @@ -974,7 +974,7 @@ class OC_Util { */ public static function checkAppEnabled($app) { if (!OC_App::isEnabled($app)) { - header('Location: ' . OC_Helper::linkToAbsolute('', 'index.php')); + header('Location: ' . \OCP\Util::linkToAbsolute('', 'index.php')); exit(); } } @@ -988,7 +988,7 @@ class OC_Util { public static function checkLoggedIn() { // Check if we are a user if (!OC_User::isLoggedIn()) { - header('Location: ' . OC_Helper::linkToAbsolute('', 'index.php', + header('Location: ' . \OCP\Util::linkToAbsolute('', 'index.php', [ 'redirect_url' => \OC::$server->getRequest()->getRequestUri() ] @@ -1006,7 +1006,7 @@ class OC_Util { public static function checkAdminUser() { OC_Util::checkLoggedIn(); if (!OC_User::isAdminUser(OC_User::getUser())) { - header('Location: ' . OC_Helper::linkToAbsolute('', 'index.php')); + header('Location: ' . \OCP\Util::linkToAbsolute('', 'index.php')); exit(); } } @@ -1046,7 +1046,7 @@ class OC_Util { } if (!$isSubAdmin) { - header('Location: ' . OC_Helper::linkToAbsolute('', 'index.php')); + header('Location: ' . \OCP\Util::linkToAbsolute('', 'index.php')); exit(); } return true; @@ -1108,11 +1108,11 @@ class OC_Util { * @return string */ public static function getInstanceId() { - $id = OC_Config::getValue('instanceid', null); + $id = \OC::$server->getSystemConfig()->getValue('instanceid', null); if (is_null($id)) { // We need to guarantee at least one letter in instanceid so it can be used as the session_name $id = 'oc' . \OC::$server->getSecureRandom()->getLowStrengthGenerator()->generate(10, \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS); - OC_Config::$object->setValue('instanceid', $id); + \OC::$server->getSystemConfig()->setValue('instanceid', $id); } return $id; } @@ -1250,7 +1250,7 @@ class OC_Util { fclose($fp); // accessing the file via http - $url = OC_Helper::makeURLAbsolute(OC::$WEBROOT . '/data' . $fileName); + $url = \OC::$server->getURLGenerator()->getAbsoluteURL(OC::$WEBROOT . '/data' . $fileName); try { $content = \OC::$server->getHTTPClientService()->newClient()->get($url)->getBody(); } catch (\Exception $e) { @@ -1364,7 +1364,7 @@ class OC_Util { * @return string the theme */ public static function getTheme() { - $theme = OC_Config::getValue("theme", ''); + $theme = \OC::$server->getSystemConfig()->getValue("theme", ''); if ($theme === '') { if (is_dir(OC::$SERVERROOT . '/themes/default')) { @@ -1509,7 +1509,7 @@ class OC_Util { public static function needUpgrade(\OCP\IConfig $config) { if ($config->getSystemValue('installed', false)) { $installedVersion = $config->getSystemValue('version', '0.0.0'); - $currentVersion = implode('.', OC_Util::getVersion()); + $currentVersion = implode('.', \OCP\Util::getVersion()); $versionDiff = version_compare($currentVersion, $installedVersion); if ($versionDiff > 0) { return true; diff --git a/lib/public/backgroundjob/ijob.php b/lib/public/backgroundjob/ijob.php index a24a5434521..8d970dbe781 100644 --- a/lib/public/backgroundjob/ijob.php +++ b/lib/public/backgroundjob/ijob.php @@ -36,12 +36,29 @@ interface IJob { * * @param \OCP\BackgroundJob\IJobList $jobList The job list that manages the state of this job * @param ILogger $logger - * @return void * @since 7.0.0 */ public function execute($jobList, ILogger $logger = null); /** + * @param int $id + * @since 7.0.0 + */ + public function setId($id); + + /** + * @param int $lastRun + * @since 7.0.0 + */ + public function setLastRun($lastRun); + + /** + * @param mixed $argument + * @since 7.0.0 + */ + public function setArgument($argument); + + /** * Get the id of the background job * This id is determined by the job list when a job is added to the list * diff --git a/lib/public/backgroundjob/ijoblist.php b/lib/public/backgroundjob/ijoblist.php index 384f8b3d801..51431c42a67 100644 --- a/lib/public/backgroundjob/ijoblist.php +++ b/lib/public/backgroundjob/ijoblist.php @@ -36,7 +36,6 @@ interface IJobList { * * @param \OCP\BackgroundJob\IJob|string $job * @param mixed $argument The argument to be passed to $job->run() when the job is exectured - * @return void * @since 7.0.0 */ public function add($job, $argument = null); @@ -46,7 +45,6 @@ interface IJobList { * * @param \OCP\BackgroundJob\IJob|string $job * @param mixed $argument - * @return void * @since 7.0.0 */ public function remove($job, $argument = null); @@ -72,14 +70,14 @@ interface IJobList { /** * get the next job in the list * - * @return \OCP\BackgroundJob\IJob + * @return \OCP\BackgroundJob\IJob|null * @since 7.0.0 */ public function getNext(); /** * @param int $id - * @return \OCP\BackgroundJob\IJob + * @return \OCP\BackgroundJob\IJob|null * @since 7.0.0 */ public function getById($id); @@ -88,7 +86,6 @@ interface IJobList { * set the job that was last ran to the current time * * @param \OCP\BackgroundJob\IJob $job - * @return void * @since 7.0.0 */ public function setLastJob($job); @@ -105,7 +102,6 @@ interface IJobList { * set the lastRun of $job to now * * @param \OCP\BackgroundJob\IJob $job - * @return void * @since 7.0.0 */ public function setLastRun($job); diff --git a/lib/public/util.php b/lib/public/util.php index da4aa6e9deb..a9fe0e47de6 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -269,7 +269,10 @@ class Util { * @since 4.0.0 - parameter $args was added in 4.5.0 */ public static function linkToAbsolute( $app, $file, $args = array() ) { - return(\OC_Helper::linkToAbsolute( $app, $file, $args )); + $urlGenerator = \OC::$server->getURLGenerator(); + return $urlGenerator->getAbsoluteURL( + $urlGenerator->linkTo($app, $file, $args) + ); } /** @@ -279,7 +282,11 @@ class Util { * @since 4.0.0 */ public static function linkToRemote( $service ) { - return(\OC_Helper::linkToRemote( $service )); + $urlGenerator = \OC::$server->getURLGenerator(); + $remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service; + return $urlGenerator->getAbsoluteURL( + $remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '') + ); } /** diff --git a/settings/controller/appsettingscontroller.php b/settings/controller/appsettingscontroller.php index d0e465bfa9c..d2430f9b559 100644 --- a/settings/controller/appsettingscontroller.php +++ b/settings/controller/appsettingscontroller.php @@ -159,7 +159,7 @@ class AppSettingsController extends Controller { if($this->ocsClient->isAppStoreEnabled()) { // apps from external repo via OCS - $ocs = $this->ocsClient->getCategories(\OC_Util::getVersion()); + $ocs = $this->ocsClient->getCategories(\OCP\Util::getVersion()); if ($ocs) { foreach($ocs as $k => $v) { $name = str_replace('ownCloud ', '', $v); @@ -205,9 +205,10 @@ class AppSettingsController extends Controller { } return ($a < $b) ? -1 : 1; }); + $version = \OCP\Util::getVersion(); foreach($apps as $key => $app) { if(!array_key_exists('level', $app) && array_key_exists('ocsid', $app)) { - $remoteAppEntry = $this->ocsClient->getApplication($app['ocsid'], \OC_Util::getVersion()); + $remoteAppEntry = $this->ocsClient->getApplication($app['ocsid'], $version); if(is_array($remoteAppEntry) && array_key_exists('level', $remoteAppEntry)) { $apps[$key]['level'] = $remoteAppEntry['level']; @@ -221,9 +222,10 @@ class AppSettingsController extends Controller { $apps = array_filter($apps, function ($app) { return !$app['active']; }); + $version = \OCP\Util::getVersion(); foreach($apps as $key => $app) { if(!array_key_exists('level', $app) && array_key_exists('ocsid', $app)) { - $remoteAppEntry = $this->ocsClient->getApplication($app['ocsid'], \OC_Util::getVersion()); + $remoteAppEntry = $this->ocsClient->getApplication($app['ocsid'], $version); if(is_array($remoteAppEntry) && array_key_exists('level', $remoteAppEntry)) { $apps[$key]['level'] = $remoteAppEntry['level']; diff --git a/settings/help.php b/settings/help.php index 21b48242706..848ce06cf49 100644 --- a/settings/help.php +++ b/settings/help.php @@ -34,11 +34,11 @@ OC_Util::addStyle( "settings", "settings" ); if(isset($_GET['mode']) and $_GET['mode'] === 'admin') { - $url=OC_Helper::linkToAbsolute( 'core', 'doc/admin/index.html' ); + $url=\OCP\Util::linkToAbsolute( 'core', 'doc/admin/index.html' ); $style1=''; $style2=' active'; }else{ - $url=OC_Helper::linkToAbsolute( 'core', 'doc/user/index.html' ); + $url=\OCP\Util::linkToAbsolute( 'core', 'doc/user/index.html' ); $style1=' active'; $style2=''; } diff --git a/settings/templates/email.new_user.php b/settings/templates/email.new_user.php index 74149632cb8..8b13ac753eb 100644 --- a/settings/templates/email.new_user.php +++ b/settings/templates/email.new_user.php @@ -4,7 +4,7 @@ <tr> <td bgcolor="<?php p($theme->getMailHeaderColor());?>" width="20px"> </td> <td bgcolor="<?php p($theme->getMailHeaderColor());?>"> - <img src="<?php p(OC_Helper::makeURLAbsolute(image_path('', 'logo-mail.gif'))); ?>" alt="<?php p($theme->getName()); ?>"/> + <img src="<?php p(\OC::$server->getURLGenerator()->getAbsoluteURL(image_path('', 'logo-mail.gif'))); ?>" alt="<?php p($theme->getName()); ?>"/> </td> </tr> <tr><td colspan="2"> </td></tr> diff --git a/settings/users.php b/settings/users.php index ccf1bcd9e1a..0e9823e73e3 100644 --- a/settings/users.php +++ b/settings/users.php @@ -37,7 +37,7 @@ OC_Util::checkSubAdminUser(); \OC::$server->getNavigationManager()->setActiveEntry('core_users'); -$userManager = \OC_User::getManager(); +$userManager = \OC::$server->getUserManager(); $groupManager = \OC_Group::getManager(); // Set the sort option: SORT_USERCOUNT or SORT_GROUPNAME diff --git a/status.php b/status.php index f59dc16b6a2..65418336e26 100644 --- a/status.php +++ b/status.php @@ -36,7 +36,7 @@ try { $values=array( 'installed'=>$installed, 'maintenance' => $maintenance, - 'version'=>implode('.', OC_Util::getVersion()), + 'version'=>implode('.', \OCP\Util::getVersion()), 'versionstring'=>OC_Util::getVersionString(), 'edition'=>OC_Util::getEditionString()); if (OC::$CLI) { diff --git a/tests/lib/allconfig.php b/tests/lib/allconfig.php index ca3dce12eaf..0caf8163cfc 100644 --- a/tests/lib/allconfig.php +++ b/tests/lib/allconfig.php @@ -28,7 +28,9 @@ class TestAllConfig extends \Test\TestCase { $connection = $this->connection; } if($systemConfig === null) { - $systemConfig = $this->getMock('\OC\SystemConfig'); + $systemConfig = $this->getMockBuilder('\OC\SystemConfig') + ->disableOriginalConstructor() + ->getMock(); } return new \OC\AllConfig($systemConfig, $connection); } @@ -89,7 +91,9 @@ class TestAllConfig extends \Test\TestCase { public function testSetUserValueWithPreCondition() { // mock the check for the database to run the correct SQL statements for each database type - $systemConfig = $this->getMock('\OC\SystemConfig'); + $systemConfig = $this->getMockBuilder('\OC\SystemConfig') + ->disableOriginalConstructor() + ->getMock(); $systemConfig->expects($this->once()) ->method('getValue') ->with($this->equalTo('dbtype'), @@ -133,7 +137,9 @@ class TestAllConfig extends \Test\TestCase { */ public function testSetUserValueWithPreConditionFailure() { // mock the check for the database to run the correct SQL statements for each database type - $systemConfig = $this->getMock('\OC\SystemConfig'); + $systemConfig = $this->getMockBuilder('\OC\SystemConfig') + ->disableOriginalConstructor() + ->getMock(); $systemConfig->expects($this->once()) ->method('getValue') ->with($this->equalTo('dbtype'), @@ -394,7 +400,9 @@ class TestAllConfig extends \Test\TestCase { public function testGetUsersForUserValue() { // mock the check for the database to run the correct SQL statements for each database type - $systemConfig = $this->getMock('\OC\SystemConfig'); + $systemConfig = $this->getMockBuilder('\OC\SystemConfig') + ->disableOriginalConstructor() + ->getMock(); $systemConfig->expects($this->once()) ->method('getValue') ->with($this->equalTo('dbtype'), diff --git a/tests/lib/backgroundjob/job.php b/tests/lib/backgroundjob/job.php index fec9b0a792d..912e0e13b57 100644 --- a/tests/lib/backgroundjob/job.php +++ b/tests/lib/backgroundjob/job.php @@ -23,10 +23,17 @@ class Job extends \Test\TestCase { }); $jobList->add($job); + $logger = $this->getMockBuilder('OCP\ILogger') + ->disableOriginalConstructor() + ->getMock(); + $logger->expects($this->once()) + ->method('error') + ->with('Error while running background job: '); + $this->assertCount(1, $jobList->getAll()); - $job->execute($jobList); + $job->execute($jobList, $logger); $this->assertTrue($this->run); - $this->assertCount(0, $jobList->getAll()); + $this->assertCount(1, $jobList->getAll()); } public function markRun() { diff --git a/tests/lib/backgroundjob/joblist.php b/tests/lib/backgroundjob/joblist.php index 73b3255c079..c0796d8253a 100644 --- a/tests/lib/backgroundjob/joblist.php +++ b/tests/lib/backgroundjob/joblist.php @@ -15,26 +15,21 @@ use Test\TestCase; * Class JobList * * @group DB - * * @package Test\BackgroundJob */ class JobList extends TestCase { - /** - * @var \OC\BackgroundJob\JobList - */ + /** @var \OC\BackgroundJob\JobList */ protected $instance; - /** - * @var \OCP\IConfig | \PHPUnit_Framework_MockObject_MockObject $config - */ + /** @var \OCP\IConfig|\PHPUnit_Framework_MockObject_MockObject */ protected $config; protected function setUp() { parent::setUp(); - $conn = \OC::$server->getDatabaseConnection(); + $connection = \OC::$server->getDatabaseConnection(); $this->config = $this->getMock('\OCP\IConfig'); - $this->instance = new \OC\BackgroundJob\JobList($conn, $this->config); + $this->instance = new \OC\BackgroundJob\JobList($connection, $this->config); } protected function getAllSorted() { diff --git a/tests/lib/cache/file.php b/tests/lib/cache/file.php index 7aa969df02c..0880e7e1282 100644 --- a/tests/lib/cache/file.php +++ b/tests/lib/cache/file.php @@ -71,7 +71,7 @@ class FileCache extends \Test_Cache { \OC_User::useBackend(new \Test\Util\User\Dummy()); //login - \OC_User::createUser('test', 'test'); + \OC::$server->getUserManager()->createUser('test', 'test'); $this->user = \OC_User::getUser(); \OC_User::setUserId('test'); diff --git a/tests/lib/configtests.php b/tests/lib/configtests.php index 0269ae542f4..c0251e693c6 100644 --- a/tests/lib/configtests.php +++ b/tests/lib/configtests.php @@ -23,7 +23,7 @@ class ConfigTests extends TestCase { protected function setUp() { parent::setUp(); - $this->randomTmpDir = \OC_Helper::tmpFolder(); + $this->randomTmpDir = \OC::$server->getTempManager()->getTemporaryFolder(); $this->configFile = $this->randomTmpDir.'testconfig.php'; file_put_contents($this->configFile, self::TESTCONTENT); $this->config = new \OC\Config($this->randomTmpDir, 'testconfig.php'); diff --git a/tests/lib/files/cache/cache.php b/tests/lib/files/cache/cache.php index 503d25597cd..d674ac27fa1 100644 --- a/tests/lib/files/cache/cache.php +++ b/tests/lib/files/cache/cache.php @@ -317,7 +317,7 @@ class Cache extends \Test\TestCase { function testSearchByTag() { $userId = $this->getUniqueId('user'); - \OC_User::createUser($userId, $userId); + \OC::$server->getUserManager()->createUser($userId, $userId); $this->loginAsUser($userId); $user = new \OC\User\User($userId, null); @@ -373,7 +373,8 @@ class Cache extends \Test\TestCase { $tagManager->delete('tag2'); $this->logout(); - \OC_User::deleteUser($userId); + $user = \OC::$server->getUserManager()->get($userId); + if ($user !== null) { $user->delete(); } } function testMove() { diff --git a/tests/lib/files/cache/homecache.php b/tests/lib/files/cache/homecache.php index 3adb25fa9d4..e133d0afc55 100644 --- a/tests/lib/files/cache/homecache.php +++ b/tests/lib/files/cache/homecache.php @@ -69,7 +69,7 @@ class HomeCache extends \Test\TestCase { protected function setUp() { parent::setUp(); - $this->user = new DummyUser('foo', \OC_Helper::tmpFolder()); + $this->user = new DummyUser('foo', \OC::$server->getTempManager()->getTemporaryFolder()); $this->storage = new \OC\Files\Storage\Home(array('user' => $this->user)); $this->cache = $this->storage->getCache(); } diff --git a/tests/lib/files/cache/updaterlegacy.php b/tests/lib/files/cache/updaterlegacy.php index 1946913bba4..09688afd465 100644 --- a/tests/lib/files/cache/updaterlegacy.php +++ b/tests/lib/files/cache/updaterlegacy.php @@ -57,7 +57,7 @@ class UpdaterLegacy extends \Test\TestCase { self::$user = $this->getUniqueID(); } - \OC_User::createUser(self::$user, 'password'); + \OC::$server->getUserManager()->createUser(self::$user, 'password'); $this->loginAsUser(self::$user); Filesystem::init(self::$user, '/' . self::$user . '/files'); @@ -72,7 +72,10 @@ class UpdaterLegacy extends \Test\TestCase { if ($this->cache) { $this->cache->clear(); } - $result = \OC_User::deleteUser(self::$user); + + $result = false; + $user = \OC::$server->getUserManager()->get(self::$user); + if ($user !== null) { $result = $user->delete(); } $this->assertTrue($result); $this->logout(); diff --git a/tests/lib/files/etagtest.php b/tests/lib/files/etagtest.php index c214a3d4da6..d8e44000f9c 100644 --- a/tests/lib/files/etagtest.php +++ b/tests/lib/files/etagtest.php @@ -39,7 +39,7 @@ class EtagTest extends \Test\TestCase { $config = \OC::$server->getConfig(); $this->datadir = $config->getSystemValue('datadirectory'); - $this->tmpDir = \OC_Helper::tmpFolder(); + $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder(); $config->setSystemValue('datadirectory', $this->tmpDir); $this->userBackend = new \Test\Util\User\Dummy(); diff --git a/tests/lib/files/filesystem.php b/tests/lib/files/filesystem.php index c5ebbdd1a2d..db1f22f894a 100644 --- a/tests/lib/files/filesystem.php +++ b/tests/lib/files/filesystem.php @@ -72,7 +72,7 @@ class Filesystem extends \Test\TestCase { * @return array */ private function getStorageData() { - $dir = \OC_Helper::tmpFolder(); + $dir = \OC::$server->getTempManager()->getTemporaryFolder(); $this->tmpDirs[] = $dir; return array('datadir' => $dir); } @@ -302,7 +302,7 @@ class Filesystem extends \Test\TestCase { \OC\Files\Filesystem::mkdir('/bar'); // \OC\Files\Filesystem::file_put_contents('/bar//foo', 'foo'); - $tmpFile = \OC_Helper::tmpFile(); + $tmpFile = \OC::$server->getTempManager()->getTemporaryFile(); file_put_contents($tmpFile, 'foo'); $fh = fopen($tmpFile, 'r'); // \OC\Files\Filesystem::file_put_contents('/bar//foo', $fh); @@ -325,7 +325,7 @@ class Filesystem extends \Test\TestCase { public function testHomeMount() { $userId = $this->getUniqueID('user_'); - \OC_User::createUser($userId, $userId); + \OC::$server->getUserManager()->createUser($userId, $userId); \OC\Files\Filesystem::initMountPoints($userId); @@ -340,7 +340,8 @@ class Filesystem extends \Test\TestCase { $this->assertEquals('home::' . $userId, $homeMount->getId()); } - \OC_User::deleteUser($userId); + $user = \OC::$server->getUserManager()->get($userId); + if ($user !== null) { $user->delete(); } } /** @@ -360,7 +361,7 @@ class Filesystem extends \Test\TestCase { // this will trigger the insert $cache = $localStorage->getCache(); - \OC_User::createUser($userId, $userId); + \OC::$server->getUserManager()->createUser($userId, $userId); \OC\Files\Filesystem::initMountPoints($userId); $homeMount = \OC\Files\Filesystem::getStorage('/' . $userId . '/'); @@ -368,7 +369,8 @@ class Filesystem extends \Test\TestCase { $this->assertTrue($homeMount->instanceOfStorage('\OC\Files\Storage\Home')); $this->assertEquals('local::' . $datadir . '/' . $userId . '/', $homeMount->getId()); - \OC_User::deleteUser($userId); + $user = \OC::$server->getUserManager()->get($userId); + if ($user !== null) { $user->delete(); } // delete storage entry $cache->clear(); } @@ -388,7 +390,7 @@ class Filesystem extends \Test\TestCase { // no cache path configured $config->setSystemValue('cache_path', ''); - \OC_User::createUser($userId, $userId); + \OC::$server->getUserManager()->createUser($userId, $userId); \OC\Files\Filesystem::initMountPoints($userId); $this->assertEquals( @@ -398,7 +400,8 @@ class Filesystem extends \Test\TestCase { list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath('/' . $userId . '/cache'); $this->assertTrue($storage->instanceOfStorage('\OCP\Files\IHomeStorage')); $this->assertEquals('cache', $internalPath); - \OC_User::deleteUser($userId); + $user = \OC::$server->getUserManager()->get($userId); + if ($user !== null) { $user->delete(); } $config->setSystemValue('cache_path', $oldCachePath); } @@ -413,10 +416,10 @@ class Filesystem extends \Test\TestCase { $config = \OC::$server->getConfig(); $oldCachePath = $config->getSystemValue('cache_path', ''); // set cache path to temp dir - $cachePath = \OC_Helper::tmpFolder() . '/extcache'; + $cachePath = \OC::$server->getTempManager()->getTemporaryFolder() . '/extcache'; $config->setSystemValue('cache_path', $cachePath); - \OC_User::createUser($userId, $userId); + \OC::$server->getUserManager()->createUser($userId, $userId); \OC\Files\Filesystem::initMountPoints($userId); $this->assertEquals( @@ -426,7 +429,8 @@ class Filesystem extends \Test\TestCase { list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath('/' . $userId . '/cache'); $this->assertTrue($storage->instanceOfStorage('\OC\Files\Storage\Local')); $this->assertEquals('', $internalPath); - \OC_User::deleteUser($userId); + $user = \OC::$server->getUserManager()->get($userId); + if ($user !== null) { $user->delete(); } $config->setSystemValue('cache_path', $oldCachePath); } diff --git a/tests/lib/files/objectstore/swift.php b/tests/lib/files/objectstore/swift.php index 63332af68da..a63f5844145 100644 --- a/tests/lib/files/objectstore/swift.php +++ b/tests/lib/files/objectstore/swift.php @@ -51,8 +51,9 @@ class Swift extends \Test\Files\Storage\Storage { // create users $users = array('test'); foreach($users as $userName) { - \OC_User::deleteUser($userName); - \OC_User::createUser($userName, $userName); + $user = \OC::$server->getUserManager()->get($userName); + if ($user !== null) { $user->delete(); } + \OC::$server->getUserManager()->createUser($userName, $userName); } // main test user @@ -76,7 +77,8 @@ class Swift extends \Test\Files\Storage\Storage { $users = array('test'); foreach($users as $userName) { - \OC_User::deleteUser($userName); + $user = \OC::$server->getUserManager()->get($userName); + if ($user !== null) { $user->delete(); } } parent::tearDown(); } diff --git a/tests/lib/files/storage/commontest.php b/tests/lib/files/storage/commontest.php index bbe6f2a73e2..38faa9b0b21 100644 --- a/tests/lib/files/storage/commontest.php +++ b/tests/lib/files/storage/commontest.php @@ -37,7 +37,7 @@ class CommonTest extends Storage { protected function setUp() { parent::setUp(); - $this->tmpDir=\OC_Helper::tmpFolder(); + $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder(); $this->instance=new \OC\Files\Storage\CommonTest(array('datadir'=>$this->tmpDir)); } diff --git a/tests/lib/files/storage/home.php b/tests/lib/files/storage/home.php index a51912ca1b2..7e10f09d554 100644 --- a/tests/lib/files/storage/home.php +++ b/tests/lib/files/storage/home.php @@ -70,7 +70,7 @@ class Home extends Storage { protected function setUp() { parent::setUp(); - $this->tmpDir = \OC_Helper::tmpFolder(); + $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder(); $this->userId = $this->getUniqueID('user_'); $this->user = new DummyUser($this->userId, $this->tmpDir); $this->instance = new \OC\Files\Storage\Home(array('user' => $this->user)); diff --git a/tests/lib/files/storage/homestoragequota.php b/tests/lib/files/storage/homestoragequota.php index 49e8f499efd..9a3c6b151fc 100644 --- a/tests/lib/files/storage/homestoragequota.php +++ b/tests/lib/files/storage/homestoragequota.php @@ -32,7 +32,7 @@ class HomeStorageQuota extends \Test\TestCase { */ function testHomeStorageWrapperWithoutQuota() { $user1 = $this->getUniqueID(); - \OC_User::createUser($user1, 'test'); + \OC::$server->getUserManager()->createUser($user1, 'test'); \OC::$server->getConfig()->setUserValue($user1, 'files', 'quota', 'none'); \OC_User::setUserId($user1); @@ -44,7 +44,8 @@ class HomeStorageQuota extends \Test\TestCase { // clean up \OC_User::setUserId(''); - \OC_User::deleteUser($user1); + $user = \OC::$server->getUserManager()->get($user1); + if ($user !== null) { $user->delete(); } \OC::$server->getConfig()->deleteAllUserValues($user1); \OC_Util::tearDownFS(); } @@ -54,7 +55,7 @@ class HomeStorageQuota extends \Test\TestCase { */ function testHomeStorageWrapperWithQuota() { $user1 = $this->getUniqueID(); - \OC_User::createUser($user1, 'test'); + \OC::$server->getUserManager()->createUser($user1, 'test'); \OC::$server->getConfig()->setUserValue($user1, 'files', 'quota', '1024'); \OC_User::setUserId($user1); @@ -71,7 +72,8 @@ class HomeStorageQuota extends \Test\TestCase { // clean up \OC_User::setUserId(''); - \OC_User::deleteUser($user1); + $user = \OC::$server->getUserManager()->get($user1); + if ($user !== null) { $user->delete(); } \OC::$server->getConfig()->deleteAllUserValues($user1); \OC_Util::tearDownFS(); } diff --git a/tests/lib/files/storage/local.php b/tests/lib/files/storage/local.php index 36267dc6605..2583863b554 100644 --- a/tests/lib/files/storage/local.php +++ b/tests/lib/files/storage/local.php @@ -38,7 +38,7 @@ class Local extends Storage { protected function setUp() { parent::setUp(); - $this->tmpDir = \OC_Helper::tmpFolder(); + $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder(); $this->instance = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir)); } diff --git a/tests/lib/files/storage/wrapper/quota.php b/tests/lib/files/storage/wrapper/quota.php index b0a06b0d898..95bc2ff7a1a 100644 --- a/tests/lib/files/storage/wrapper/quota.php +++ b/tests/lib/files/storage/wrapper/quota.php @@ -27,7 +27,7 @@ class Quota extends \Test\Files\Storage\Storage { protected function setUp() { parent::setUp(); - $this->tmpDir = \OC_Helper::tmpFolder(); + $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder(); $storage = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir)); $this->instance = new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => 10000000)); } diff --git a/tests/lib/files/storage/wrapper/wrapper.php b/tests/lib/files/storage/wrapper/wrapper.php index 486cd0495c1..a5a678cb9f7 100644 --- a/tests/lib/files/storage/wrapper/wrapper.php +++ b/tests/lib/files/storage/wrapper/wrapper.php @@ -17,7 +17,7 @@ class Wrapper extends \Test\Files\Storage\Storage { protected function setUp() { parent::setUp(); - $this->tmpDir = \OC_Helper::tmpFolder(); + $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder(); $storage = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir)); $this->instance = new \OC\Files\Storage\Wrapper\Wrapper(array('storage' => $storage)); } diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php index 1fc4b9ab684..3e88a5306f8 100644 --- a/tests/lib/files/view.php +++ b/tests/lib/files/view.php @@ -757,7 +757,7 @@ class View extends \Test\TestCase { * 228 is the max path length in windows */ $folderName = 'abcdefghijklmnopqrstuvwxyz012345678901234567890123456789'; - $tmpdirLength = strlen(\OC_Helper::tmpFolder()); + $tmpdirLength = strlen(\OC::$server->getTempManager()->getTemporaryFolder()); if (\OC_Util::runningOnWindows()) { $this->markTestSkipped('[Windows] '); $depth = ((260 - $tmpdirLength) / 57); diff --git a/tests/lib/group.php b/tests/lib/group.php index 066dddc738e..4bb888ed725 100644 --- a/tests/lib/group.php +++ b/tests/lib/group.php @@ -31,7 +31,7 @@ class Test_Group extends \Test\TestCase { public function testSingleBackend() { $userBackend = new \Test\Util\User\Dummy(); - \OC_User::getManager()->registerBackend($userBackend); + \OC::$server->getUserManager()->registerBackend($userBackend); OC_Group::useBackend(new OC_Group_Dummy()); $group1 = $this->getUniqueID(); @@ -113,7 +113,7 @@ class Test_Group extends \Test\TestCase { public function testUsersInGroup() { OC_Group::useBackend(new OC_Group_Dummy()); $userBackend = new \Test\Util\User\Dummy(); - \OC_User::getManager()->registerBackend($userBackend); + \OC::$server->getUserManager()->registerBackend($userBackend); $group1 = $this->getUniqueID(); $group2 = $this->getUniqueID(); @@ -142,7 +142,7 @@ class Test_Group extends \Test\TestCase { public function testMultiBackend() { $userBackend = new \Test\Util\User\Dummy(); - \OC_User::getManager()->registerBackend($userBackend); + \OC::$server->getUserManager()->registerBackend($userBackend); $backend1 = new OC_Group_Dummy(); $backend2 = new OC_Group_Dummy(); OC_Group::useBackend($backend1); diff --git a/tests/lib/helper.php b/tests/lib/helper.php index 469ffecc773..c2620896157 100644 --- a/tests/lib/helper.php +++ b/tests/lib/helper.php @@ -71,37 +71,6 @@ class Test_Helper extends \Test\TestCase { ]; } - function testGetSecureMimeType() { - $dir=OC::$SERVERROOT.'/tests/data'; - - $result = OC_Helper::getSecureMimeType('image/svg+xml'); - $expected = 'text/plain'; - $this->assertEquals($result, $expected); - - $result = OC_Helper::getSecureMimeType('image/png'); - $expected = 'image/png'; - $this->assertEquals($result, $expected); - } - - function testGetFileNameMimeType() { - $this->assertEquals('text/plain', OC_Helper::getFileNameMimeType('foo.txt')); - $this->assertEquals('image/png', OC_Helper::getFileNameMimeType('foo.png')); - $this->assertEquals('image/png', OC_Helper::getFileNameMimeType('foo.bar.png')); - $this->assertEquals('application/octet-stream', OC_Helper::getFileNameMimeType('.png')); - $this->assertEquals('application/octet-stream', OC_Helper::getFileNameMimeType('foo')); - $this->assertEquals('application/octet-stream', OC_Helper::getFileNameMimeType('')); - } - - function testGetStringMimeType() { - if (\OC_Util::runningOnWindows()) { - $this->markTestSkipped('[Windows] Strings have mimetype application/octet-stream on Windows'); - } - - $result = OC_Helper::getStringMimeType("/data/data.tar.gz"); - $expected = 'text/plain; charset=us-ascii'; - $this->assertEquals($result, $expected); - } - function testIsSubDirectory() { $result = OC_Helper::isSubDirectory("./data/", "/anotherDirectory/"); $this->assertFalse($result); @@ -254,126 +223,6 @@ class Test_Helper extends \Test\TestCase { /** * @small - * test absolute URL construction - * @dataProvider provideDocRootURLs - */ - function testMakeAbsoluteURLDocRoot($url, $expectedResult) { - \OC::$WEBROOT = ''; - $result = \OC_Helper::makeURLAbsolute($url); - - $this->assertEquals($expectedResult, $result); - } - - /** - * @small - * test absolute URL construction - * @dataProvider provideSubDirURLs - */ - function testMakeAbsoluteURLSubDir($url, $expectedResult) { - \OC::$WEBROOT = '/owncloud'; - $result = \OC_Helper::makeURLAbsolute($url); - - $this->assertEquals($expectedResult, $result); - } - - public function provideDocRootURLs() { - return array( - array('index.php', 'http://localhost/index.php'), - array('/index.php', 'http://localhost/index.php'), - array('/apps/index.php', 'http://localhost/apps/index.php'), - array('apps/index.php', 'http://localhost/apps/index.php'), - ); - } - - public function provideSubDirURLs() { - return array( - array('index.php', 'http://localhost/owncloud/index.php'), - array('/index.php', 'http://localhost/owncloud/index.php'), - array('/apps/index.php', 'http://localhost/owncloud/apps/index.php'), - array('apps/index.php', 'http://localhost/owncloud/apps/index.php'), - ); - } - - /** - * @small - * test linkToAbsolute URL construction - * @dataProvider provideDocRootAppAbsoluteUrlParts - */ - public function testLinkToAbsoluteDocRoot($app, $file, $args, $expectedResult) { - \OC::$WEBROOT = ''; - $result = \OC_Helper::linkToAbsolute($app, $file, $args); - - $this->assertEquals($expectedResult, $result); - } - - /** - * @small - * test linkToAbsolute URL construction in sub directory - * @dataProvider provideSubDirAppAbsoluteUrlParts - */ - public function testLinkToAbsoluteSubDir($app, $file, $args, $expectedResult) { - \OC::$WEBROOT = '/owncloud'; - $result = \OC_Helper::linkToAbsolute($app, $file, $args); - - $this->assertEquals($expectedResult, $result); - } - - /** - * @return array - */ - public function provideDocRootAppAbsoluteUrlParts() { - return array( - array('files', 'ajax/list.php', array(), 'http://localhost/index.php/apps/files/ajax/list.php'), - array('files', 'ajax/list.php', array('trut' => 'trat', 'dut' => 'dat'), 'http://localhost/index.php/apps/files/ajax/list.php?trut=trat&dut=dat'), - array('', 'index.php', array('trut' => 'trat', 'dut' => 'dat'), 'http://localhost/index.php?trut=trat&dut=dat'), - ); - } - - /** - * @return array - */ - public function provideSubDirAppAbsoluteUrlParts() { - return array( - array('files', 'ajax/list.php', array(), 'http://localhost/owncloud/index.php/apps/files/ajax/list.php'), - array('files', 'ajax/list.php', array('trut' => 'trat', 'dut' => 'dat'), 'http://localhost/owncloud/index.php/apps/files/ajax/list.php?trut=trat&dut=dat'), - array('', 'index.php', array('trut' => 'trat', 'dut' => 'dat'), 'http://localhost/owncloud/index.php?trut=trat&dut=dat'), - ); - } - - /** - * @small - * test linkToRemoteBase URL construction - */ - public function testLinkToRemoteBase() { - \OC::$WEBROOT = ''; - $result = \OC_Helper::linkToRemoteBase('webdav'); - $this->assertEquals('/remote.php/webdav', $result); - - \OC::$WEBROOT = '/owncloud'; - $result = \OC_Helper::linkToRemoteBase('webdav'); - $this->assertEquals('/owncloud/remote.php/webdav', $result); - } - - /** - * @small - * test linkToRemote URL construction - */ - public function testLinkToRemote() { - \OC::$WEBROOT = ''; - $result = \OC_Helper::linkToRemote('webdav'); - $this->assertEquals('http://localhost/remote.php/webdav/', $result); - $result = \OC_Helper::linkToRemote('webdav', false); - $this->assertEquals('http://localhost/remote.php/webdav', $result); - - \OC::$WEBROOT = '/owncloud'; - $result = \OC_Helper::linkToRemote('webdav'); - $this->assertEquals('http://localhost/owncloud/remote.php/webdav/', $result); - $result = \OC_Helper::linkToRemote('webdav', false); - $this->assertEquals('http://localhost/owncloud/remote.php/webdav', $result); - } - - /** - * @small * test linkToPublic URL construction */ public function testLinkToPublic() { @@ -412,7 +261,7 @@ class Test_Helper extends \Test\TestCase { * Tests recursive folder deletion with rmdirr() */ public function testRecursiveFolderDeletion() { - $baseDir = \OC_Helper::tmpFolder() . '/'; + $baseDir = \OC::$server->getTempManager()->getTemporaryFolder() . '/'; mkdir($baseDir . 'a/b/c/d/e', 0777, true); mkdir($baseDir . 'a/b/c1/d/e', 0777, true); mkdir($baseDir . 'a/b/c2/d/e', 0777, true); diff --git a/tests/lib/helperstorage.php b/tests/lib/helperstorage.php index cf022109c27..3109b509549 100644 --- a/tests/lib/helperstorage.php +++ b/tests/lib/helperstorage.php @@ -23,7 +23,7 @@ class Test_Helper_Storage extends \Test\TestCase { parent::setUp(); $this->user = $this->getUniqueID('user_'); - \OC_User::createUser($this->user, $this->user); + \OC::$server->getUserManager()->createUser($this->user, $this->user); $this->storage = \OC\Files\Filesystem::getStorage('/'); \OC\Files\Filesystem::tearDown(); @@ -45,7 +45,8 @@ class Test_Helper_Storage extends \Test\TestCase { \OC\Files\Filesystem::mount($this->storage, array(), '/'); \OC_User::setUserId(''); - \OC_User::deleteUser($this->user); + $user = \OC::$server->getUserManager()->get($this->user); + if ($user !== null) { $user->delete(); } \OC::$server->getConfig()->deleteAllUserValues($this->user); parent::tearDown(); diff --git a/tests/lib/installer.php b/tests/lib/installer.php index c3c2f8a275e..cfad4d7f0de 100644 --- a/tests/lib/installer.php +++ b/tests/lib/installer.php @@ -32,7 +32,7 @@ class Test_Installer extends \Test\TestCase { $pathOfTestApp .= '/../data/'; $pathOfTestApp .= 'testapp.zip'; - $tmp = OC_Helper::tmpFile('.zip'); + $tmp = \OC::$server->getTempManager()->getTemporaryFile('.zip'); OC_Helper::copyr($pathOfTestApp, $tmp); $data = array( @@ -51,7 +51,7 @@ class Test_Installer extends \Test\TestCase { $pathOfOldTestApp .= '/../data/'; $pathOfOldTestApp .= 'testapp.zip'; - $oldTmp = OC_Helper::tmpFile('.zip'); + $oldTmp = \OC::$server->getTempManager()->getTemporaryFile('.zip'); OC_Helper::copyr($pathOfOldTestApp, $oldTmp); $oldData = array( @@ -63,7 +63,7 @@ class Test_Installer extends \Test\TestCase { $pathOfNewTestApp .= '/../data/'; $pathOfNewTestApp .= 'testapp2.zip'; - $newTmp = OC_Helper::tmpFile('.zip'); + $newTmp = \OC::$server->getTempManager()->getTemporaryFile('.zip'); OC_Helper::copyr($pathOfNewTestApp, $newTmp); $newData = array( diff --git a/tests/lib/security/certificatemanager.php b/tests/lib/security/certificatemanager.php index 43b2f1cf980..f2e29cab18e 100644 --- a/tests/lib/security/certificatemanager.php +++ b/tests/lib/security/certificatemanager.php @@ -24,7 +24,7 @@ class CertificateManagerTest extends \Test\TestCase { parent::setUp(); $this->username = $this->getUniqueID('', 20); - OC_User::createUser($this->username, $this->getUniqueID('', 20)); + \OC::$server->getUserManager()->createUser($this->username, $this->getUniqueID('', 20)); \OC_Util::tearDownFS(); \OC_User::setUserId(''); @@ -39,7 +39,8 @@ class CertificateManagerTest extends \Test\TestCase { } protected function tearDown() { - \OC_User::deleteUser($this->username); + $user = \OC::$server->getUserManager()->get($this->username); + if ($user !== null) { $user->delete(); } parent::tearDown(); } diff --git a/tests/lib/server.php b/tests/lib/server.php index 6b569e77dd9..e2670061e8d 100644 --- a/tests/lib/server.php +++ b/tests/lib/server.php @@ -38,7 +38,8 @@ class Server extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->server = new \OC\Server(''); + $config = new \OC\Config(\OC::$configDir); + $this->server = new \OC\Server('', $config); } public function dataTestQuery() { diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php index fa19577cb72..5162a03f367 100644 --- a/tests/lib/share/share.php +++ b/tests/lib/share/share.php @@ -54,13 +54,13 @@ class Test_Share extends \Test\TestCase { $this->user5 = $this->getUniqueID('user5_'); $this->user6 = $this->getUniqueID('user6_'); $this->groupAndUser = $this->getUniqueID('groupAndUser_'); - OC_User::createUser($this->user1, 'pass'); - OC_User::createUser($this->user2, 'pass'); - OC_User::createUser($this->user3, 'pass'); - OC_User::createUser($this->user4, 'pass'); - OC_User::createUser($this->user5, 'pass'); - OC_User::createUser($this->user6, 'pass'); // no group - OC_User::createUser($this->groupAndUser, 'pass'); + \OC::$server->getUserManager()->createUser($this->user1, 'pass'); + \OC::$server->getUserManager()->createUser($this->user2, 'pass'); + \OC::$server->getUserManager()->createUser($this->user3, 'pass'); + \OC::$server->getUserManager()->createUser($this->user4, 'pass'); + \OC::$server->getUserManager()->createUser($this->user5, 'pass'); + \OC::$server->getUserManager()->createUser($this->user6, 'pass'); // no group + \OC::$server->getUserManager()->createUser($this->groupAndUser, 'pass'); OC_User::setUserId($this->user1); OC_Group::clearBackends(); OC_Group::useBackend(new OC_Group_Dummy); @@ -94,13 +94,20 @@ class Test_Share extends \Test\TestCase { $query->execute(array('test')); \OC::$server->getAppConfig()->setValue('core', 'shareapi_allow_resharing', $this->resharing); - OC_User::deleteUser($this->user1); - OC_User::deleteUser($this->user2); - OC_User::deleteUser($this->user3); - OC_User::deleteUser($this->user4); - OC_User::deleteUser($this->user5); - OC_User::deleteUser($this->user6); - OC_User::deleteUser($this->groupAndUser); + $user = \OC::$server->getUserManager()->get($this->user1); + if ($user !== null) { $user->delete(); } + $user = \OC::$server->getUserManager()->get($this->user2); + if ($user !== null) { $user->delete(); } + $user = \OC::$server->getUserManager()->get($this->user3); + if ($user !== null) { $user->delete(); } + $user = \OC::$server->getUserManager()->get($this->user4); + if ($user !== null) { $user->delete(); } + $user = \OC::$server->getUserManager()->get($this->user5); + if ($user !== null) { $user->delete(); } + $user = \OC::$server->getUserManager()->get($this->user6); + if ($user !== null) { $user->delete(); } + $user = \OC::$server->getUserManager()->get($this->groupAndUser); + if ($user !== null) { $user->delete(); } OC_Group::deleteGroup($this->group1); OC_Group::deleteGroup($this->group2); @@ -375,7 +382,8 @@ class Test_Share extends \Test\TestCase { // Remove user OC_User::setUserId($this->user1); - OC_User::deleteUser($this->user1); + $user = \OC::$server->getUserManager()->get($this->user1); + if ($user !== null) { $user->delete(); } OC_User::setUserId($this->user2); $this->assertEquals(array('test1.txt'), OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET)); } diff --git a/tests/lib/streamwrappers.php b/tests/lib/streamwrappers.php index 9b097535280..7175683a60b 100644 --- a/tests/lib/streamwrappers.php +++ b/tests/lib/streamwrappers.php @@ -55,7 +55,7 @@ class Test_StreamWrappers extends \Test\TestCase { public function testCloseStream() { //ensure all basic stream stuff works $sourceFile = OC::$SERVERROOT . '/tests/data/lorem.txt'; - $tmpFile = OC_Helper::TmpFile('.txt'); + $tmpFile = \OC::$server->getTempManager()->getTemporaryFile('.txt'); $file = 'close://' . $tmpFile; $this->assertTrue(file_exists($file)); file_put_contents($file, file_get_contents($sourceFile)); @@ -65,7 +65,7 @@ class Test_StreamWrappers extends \Test\TestCase { $this->assertFalse(file_exists($file)); //test callback - $tmpFile = OC_Helper::TmpFile('.txt'); + $tmpFile = \OC::$server->getTempManager()->getTemporaryFile('.txt'); $file = 'close://' . $tmpFile; $actual = false; $callback = function($path) use (&$actual) { $actual = $path; }; diff --git a/tests/lib/tags.php b/tests/lib/tags.php index a8f59ff16e4..537c898da13 100644 --- a/tests/lib/tags.php +++ b/tests/lib/tags.php @@ -44,7 +44,7 @@ class Test_Tags extends \Test\TestCase { OC_User::clearBackends(); OC_User::useBackend('dummy'); $userId = $this->getUniqueID('user_'); - OC_User::createUser($userId, 'pass'); + \OC::$server->getUserManager()->createUser($userId, 'pass'); OC_User::setUserId($userId); $this->user = new OC\User\User($userId, null); $this->userSession = $this->getMock('\OCP\IUserSession'); @@ -290,7 +290,7 @@ class Test_Tags extends \Test\TestCase { $tagger->tagAs(1, $testTag); $otherUserId = $this->getUniqueID('user2_'); - OC_User::createUser($otherUserId, 'pass'); + \OC::$server->getUserManager()->createUser($otherUserId, 'pass'); OC_User::setUserId($otherUserId); $otherUserSession = $this->getMock('\OCP\IUserSession'); $otherUserSession diff --git a/tests/lib/updater.php b/tests/lib/updater.php index 14ae3db3276..313ffb65738 100644 --- a/tests/lib/updater.php +++ b/tests/lib/updater.php @@ -66,7 +66,7 @@ class UpdaterTest extends \Test\TestCase { * @return string */ private function buildUpdateUrl($baseUrl) { - return $baseUrl . '?version='.implode('x', \OC_Util::getVersion()).'xinstalledatxlastupdatedatx'.\OC_Util::getChannel().'x'.\OC_Util::getEditionString().'x'; + return $baseUrl . '?version='.implode('x', \OCP\Util::getVersion()).'xinstalledatxlastupdatedatx'.\OC_Util::getChannel().'x'.\OC_Util::getEditionString().'x'; } /** diff --git a/tests/lib/user.php b/tests/lib/user.php index bc1ba063c8f..c4c74cbc254 100644 --- a/tests/lib/user.php +++ b/tests/lib/user.php @@ -26,7 +26,7 @@ class User extends TestCase { parent::setUp(); $this->backend = $this->getMock('\Test\Util\User\Dummy'); - $manager = \OC_User::getManager(); + $manager = \OC::$server->getUserManager(); $manager->registerBackend($this->backend); } @@ -51,30 +51,5 @@ class User extends TestCase { $uid = \OC_User::checkPassword('foo', 'bar'); $this->assertEquals($uid, 'foo'); } - - public function testDeleteUser() { - $fail = \OC_User::deleteUser('victim'); - $this->assertFalse($fail); - - $success = \OC_User::createUser('victim', 'password'); - - $success = \OC_User::deleteUser('victim'); - $this->assertTrue($success); - } - - public function testCreateUser(){ - $this->backend->expects($this->any()) - ->method('implementsActions') - ->will($this->returnCallback(function ($actions) { - if ($actions === \OC_USER_BACKEND_CREATE_USER) { - return true; - } else { - return false; - } - })); - - $user = \OC_User::createUser('newuser', 'newpassword'); - $this->assertEquals('newuser', $user->getUid()); - } } diff --git a/tests/lib/util.php b/tests/lib/util.php index fa559c17c80..cb5d28b48a7 100644 --- a/tests/lib/util.php +++ b/tests/lib/util.php @@ -8,7 +8,7 @@ */ class Test_Util extends \Test\TestCase { public function testGetVersion() { - $version = \OC_Util::getVersion(); + $version = \OCP\Util::getVersion(); $this->assertTrue(is_array($version)); foreach ($version as $num) { $this->assertTrue(is_int($num)); diff --git a/tests/lib/utilcheckserver.php b/tests/lib/utilcheckserver.php index a5ec529ff85..94e7fd2f779 100644 --- a/tests/lib/utilcheckserver.php +++ b/tests/lib/utilcheckserver.php @@ -37,7 +37,7 @@ class Test_Util_CheckServer extends \Test\TestCase { protected function setUp() { parent::setUp(); - $this->datadir = \OC_Helper::tmpFolder(); + $this->datadir = \OC::$server->getTempManager()->getTemporaryFolder(); file_put_contents($this->datadir . '/.ocdata', ''); \OC::$server->getSession()->set('checkServer_succeeded', false); @@ -123,7 +123,7 @@ class Test_Util_CheckServer extends \Test\TestCase { $result = \OC_Util::checkServer($this->getConfig(array( 'installed' => true, - 'version' => implode('.', OC_Util::getVersion()) + 'version' => implode('.', \OCP\Util::getVersion()) ))); $this->assertCount(1, $result); } @@ -134,7 +134,7 @@ class Test_Util_CheckServer extends \Test\TestCase { public function testDataDirWritable() { $result = \OC_Util::checkServer($this->getConfig(array( 'installed' => true, - 'version' => implode('.', OC_Util::getVersion()) + 'version' => implode('.', \OCP\Util::getVersion()) ))); $this->assertEmpty($result); } @@ -150,7 +150,7 @@ class Test_Util_CheckServer extends \Test\TestCase { chmod($this->datadir, 0300); $result = \OC_Util::checkServer($this->getConfig(array( 'installed' => true, - 'version' => implode('.', OC_Util::getVersion()) + 'version' => implode('.', \OCP\Util::getVersion()) ))); $this->assertCount(1, $result); } @@ -162,7 +162,7 @@ class Test_Util_CheckServer extends \Test\TestCase { chmod($this->datadir, 0300); $result = \OC_Util::checkServer($this->getConfig(array( 'installed' => false, - 'version' => implode('.', OC_Util::getVersion()) + 'version' => implode('.', \OCP\Util::getVersion()) ))); chmod($this->datadir, 0700); //needed for cleanup $this->assertEmpty($result); |