diff options
-rw-r--r-- | apps/accessibility/css/dark.scss | 2 | ||||
-rw-r--r-- | apps/accessibility/l10n/zh_CN.js | 4 | ||||
-rw-r--r-- | apps/accessibility/l10n/zh_CN.json | 4 | ||||
-rw-r--r-- | apps/dav/l10n/he.js | 1 | ||||
-rw-r--r-- | apps/dav/l10n/he.json | 1 | ||||
-rw-r--r-- | apps/files_external/lib/config.php | 28 | ||||
-rw-r--r-- | apps/files_external/tests/Config/PlaceholderSubstituteTest.php | 49 | ||||
-rw-r--r-- | apps/files_trashbin/tests/TrashbinTest.php | 4 | ||||
-rw-r--r-- | apps/files_versions/tests/VersioningTest.php | 6 | ||||
-rw-r--r-- | apps/oauth2/lib/Controller/LoginRedirectorController.php | 7 | ||||
-rw-r--r-- | apps/oauth2/tests/Controller/LoginRedirectorControllerTest.php | 22 | ||||
-rw-r--r-- | core/css/variables.scss | 2 | ||||
-rw-r--r-- | lib/private/Files/View.php | 5 | ||||
-rw-r--r-- | lib/private/Server.php | 145 | ||||
-rw-r--r-- | lib/private/Share20/Manager.php | 5 | ||||
-rw-r--r-- | tests/lib/User/UserTest.php | 5 |
16 files changed, 131 insertions, 159 deletions
diff --git a/apps/accessibility/css/dark.scss b/apps/accessibility/css/dark.scss index e85b3cb393c..c779f64ffd8 100644 --- a/apps/accessibility/css/dark.scss +++ b/apps/accessibility/css/dark.scss @@ -12,7 +12,7 @@ $color-text-lighter: darken($color-main-text, 20%); $color-loading-light: #777; $color-loading-dark: #ccc; -$color-box-shadow: rgba(darken($color-main-background, 70%), 0.5); +$color-box-shadow: transparentize(darken($color-main-background, 70%), 0.5); $color-border: lighten($color-main-background, 7%); $color-border-dark: lighten($color-main-background, 14%); diff --git a/apps/accessibility/l10n/zh_CN.js b/apps/accessibility/l10n/zh_CN.js index a50acf9f008..6ae15398cf1 100644 --- a/apps/accessibility/l10n/zh_CN.js +++ b/apps/accessibility/l10n/zh_CN.js @@ -3,7 +3,7 @@ OC.L10N.register( { "Dark theme" : "深色主题", "Enable dark theme" : "启用深色主题", - "A dark theme to ease your eyes by reducing the overall luminosity and brightness. It is still under development, so please report any issues you may find." : "一款通过降低整体亮度来使您的眼睛放松的深色主题。它仍在开发中,所以请报告您发现的问题。", + "A dark theme to ease your eyes by reducing the overall luminosity and brightness. It is still under development, so please report any issues you may find." : "一款通过降低整体亮度来使您的眼睛放松的深色主题。它仍在开发中,因此请报告您发现的任何问题。", "High contrast mode" : "高对比度模式", "Enable high contrast mode" : "启用高对比度模式", "A high contrast mode to ease your navigation. Visual quality will be reduced but clarity will be increased." : "使用高对比度模式。图像质量会下降但清晰度会提升。", @@ -11,7 +11,7 @@ OC.L10N.register( "Enable dyslexia font" : "启用阅读障碍字体", "OpenDyslexic is a free typeface/font designed to mitigate some of the common reading errors caused by dyslexia." : "OpenDyslexic是一款免费的字样/字体,这款字体的设计目的是缓解由阅读障碍引起的一些常见阅读错误。", "Accessibility" : "易用性", - "Accessibility options for nextcloud" : "nextcloud的易用性选项", + "Accessibility options for nextcloud" : "Nextcloud的易用性选项", "Provides multiple accessibilities options to ease your use of Nextcloud" : "提供多种易用性选项以便于您使用Nextcloud", "Universal access is very important to us. We follow web standards and check to make everything usable also without mouse, and assistive software such as screenreaders. We aim to be compliant with the {guidelines}Web Content Accessibility Guidelines{linkend} 2.1 on AA level, with the high contrast theme even on AAA level." : "通用访问对我们非常重要。 我们遵循网络标准,并进行检查以确保所有内容都可以在没有鼠标或辅助软件(例如屏幕阅读器)的情况下使用。 我们的目标是遵守 {guidelines} Web 内容可访问性指南 {linkend} 2.1 能达到 AA 级别,具有高对比度主题甚至能达到 AAA 级别。", "If you find any issues, don’t hesitate to report them on {issuetracker}our issue tracker{linkend}. And if you want to get involved, come join {designteam}our design team{linkend}!" : "如果您发现任何问题,请随时在 {issuetracker} 我们的问题跟踪器 {linkend} 上报告。 如果您想参与其中,请加入 {designteam} 我们的设计团队 {linkend}!", diff --git a/apps/accessibility/l10n/zh_CN.json b/apps/accessibility/l10n/zh_CN.json index 59792ba1aff..e70d1c2c735 100644 --- a/apps/accessibility/l10n/zh_CN.json +++ b/apps/accessibility/l10n/zh_CN.json @@ -1,7 +1,7 @@ { "translations": { "Dark theme" : "深色主题", "Enable dark theme" : "启用深色主题", - "A dark theme to ease your eyes by reducing the overall luminosity and brightness. It is still under development, so please report any issues you may find." : "一款通过降低整体亮度来使您的眼睛放松的深色主题。它仍在开发中,所以请报告您发现的问题。", + "A dark theme to ease your eyes by reducing the overall luminosity and brightness. It is still under development, so please report any issues you may find." : "一款通过降低整体亮度来使您的眼睛放松的深色主题。它仍在开发中,因此请报告您发现的任何问题。", "High contrast mode" : "高对比度模式", "Enable high contrast mode" : "启用高对比度模式", "A high contrast mode to ease your navigation. Visual quality will be reduced but clarity will be increased." : "使用高对比度模式。图像质量会下降但清晰度会提升。", @@ -9,7 +9,7 @@ "Enable dyslexia font" : "启用阅读障碍字体", "OpenDyslexic is a free typeface/font designed to mitigate some of the common reading errors caused by dyslexia." : "OpenDyslexic是一款免费的字样/字体,这款字体的设计目的是缓解由阅读障碍引起的一些常见阅读错误。", "Accessibility" : "易用性", - "Accessibility options for nextcloud" : "nextcloud的易用性选项", + "Accessibility options for nextcloud" : "Nextcloud的易用性选项", "Provides multiple accessibilities options to ease your use of Nextcloud" : "提供多种易用性选项以便于您使用Nextcloud", "Universal access is very important to us. We follow web standards and check to make everything usable also without mouse, and assistive software such as screenreaders. We aim to be compliant with the {guidelines}Web Content Accessibility Guidelines{linkend} 2.1 on AA level, with the high contrast theme even on AAA level." : "通用访问对我们非常重要。 我们遵循网络标准,并进行检查以确保所有内容都可以在没有鼠标或辅助软件(例如屏幕阅读器)的情况下使用。 我们的目标是遵守 {guidelines} Web 内容可访问性指南 {linkend} 2.1 能达到 AA 级别,具有高对比度主题甚至能达到 AAA 级别。", "If you find any issues, don’t hesitate to report them on {issuetracker}our issue tracker{linkend}. And if you want to get involved, come join {designteam}our design team{linkend}!" : "如果您发现任何问题,请随时在 {issuetracker} 我们的问题跟踪器 {linkend} 上报告。 如果您想参与其中,请加入 {designteam} 我们的设计团队 {linkend}!", diff --git a/apps/dav/l10n/he.js b/apps/dav/l10n/he.js index 65c0d301fee..0d5387f4ecd 100644 --- a/apps/dav/l10n/he.js +++ b/apps/dav/l10n/he.js @@ -86,6 +86,7 @@ OC.L10N.register( "Your attendance was updated successfully." : "ההשתתפות שלך עודכנה בהצלחה.", "Calendar server" : "שרת לוח שנה", "Send invitations to attendees" : "שליחת הזמנות למשתתפים", + "Please make sure to properly set up {emailopen}the email server{linkclose}." : "נא לוודא שהגדרת את {emailopen}שרת הדוא״ל{linkclose} כראוי.", "Automatically generate a birthday calendar" : "יצירת יומן ימי הולדת אוטומטית", "Birthday calendars will be generated by a background job." : "יומני ימי הולדת ייווצרו על ידי משימה ברקע.", "Hence they will not be available immediately after enabling but will show up after some time." : "לכן הם לא יהיה זמינים מיד לאחר ההפעלה אלא הם יופיעו לאחר זמן מה.", diff --git a/apps/dav/l10n/he.json b/apps/dav/l10n/he.json index ba99cc27bf1..e18efa116ba 100644 --- a/apps/dav/l10n/he.json +++ b/apps/dav/l10n/he.json @@ -84,6 +84,7 @@ "Your attendance was updated successfully." : "ההשתתפות שלך עודכנה בהצלחה.", "Calendar server" : "שרת לוח שנה", "Send invitations to attendees" : "שליחת הזמנות למשתתפים", + "Please make sure to properly set up {emailopen}the email server{linkclose}." : "נא לוודא שהגדרת את {emailopen}שרת הדוא״ל{linkclose} כראוי.", "Automatically generate a birthday calendar" : "יצירת יומן ימי הולדת אוטומטית", "Birthday calendars will be generated by a background job." : "יומני ימי הולדת ייווצרו על ידי משימה ברקע.", "Hence they will not be available immediately after enabling but will show up after some time." : "לכן הם לא יהיה זמינים מיד לאחר ההפעלה אלא הם יופיעו לאחר זמן מה.", diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index 9040f40e66b..f799fd25f57 100644 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -252,20 +252,6 @@ class OC_Mount_Config { continue; } $option = self::substitutePlaceholdersInConfig($option); - if(!self::arePlaceholdersSubstituted($option)) { - \OC::$server->getLogger()->error( - 'A placeholder was not substituted: {option} for mount type {class}', - [ - 'app' => 'files_external', - 'option' => $option, - 'class' => $class, - ] - ); - throw new StorageNotAvailableException( - 'Mount configuration incomplete', - StorageNotAvailableException::STATUS_INCOMPLETE_CONF - ); - } } if (class_exists($class)) { try { @@ -290,20 +276,6 @@ class OC_Mount_Config { return StorageNotAvailableException::STATUS_ERROR; } - public static function arePlaceholdersSubstituted($option):bool { - $result = true; - if(is_array($option)) { - foreach ($option as $optionItem) { - $result = $result && self::arePlaceholdersSubstituted($optionItem); - } - } else if (is_string($option)) { - if (strpos(rtrim($option, '$'), '$') !== false) { - $result = false; - } - } - return $result; - } - /** * Read the mount points in the config file into an array * diff --git a/apps/files_external/tests/Config/PlaceholderSubstituteTest.php b/apps/files_external/tests/Config/PlaceholderSubstituteTest.php deleted file mode 100644 index 3cc19bfd85d..00000000000 --- a/apps/files_external/tests/Config/PlaceholderSubstituteTest.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -/** - * @copyright Copyright (c) 2019 Daniel Kesselberg <mail@danielkesselberg.de> - * - * @author Daniel Kesselberg <mail@danielkesselberg.de> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * 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 - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -namespace OCA\files_external\tests\Config; - -use OC_Mount_Config; -use Test\TestCase; - -class PlaceholderSubstituteTest extends TestCase { - - public function dataArePlaceholdersSubstituted(): array { - return [ - ['smb_$user', false], - ['hidden_share$', true], - [['smb_$user', 'hidden_share$'], false], - [['smb_hello', 'hidden_share$'], true] - ]; - } - - /** - * @dataProvider dataArePlaceholdersSubstituted - * @param string|array $option - * @param bool $expected - */ - public function testArePlaceholdersSubstituted($option, $expected): void { - $this->assertSame($expected, OC_Mount_Config::arePlaceholdersSubstituted($option)); - } - -} diff --git a/apps/files_trashbin/tests/TrashbinTest.php b/apps/files_trashbin/tests/TrashbinTest.php index 1e041498390..e682d0dd51f 100644 --- a/apps/files_trashbin/tests/TrashbinTest.php +++ b/apps/files_trashbin/tests/TrashbinTest.php @@ -129,7 +129,7 @@ class TrashbinTest extends \Test\TestCase { return $config->getSystemValue($key, $default); } })); - $this->overwriteService('AllConfig', $mockConfig); + $this->overwriteService(\OC\AllConfig::class, $mockConfig); $this->trashRoot1 = '/' . self::TEST_TRASHBIN_USER1 . '/files_trashbin'; $this->trashRoot2 = '/' . self::TEST_TRASHBIN_USER2 . '/files_trashbin'; @@ -138,7 +138,7 @@ class TrashbinTest extends \Test\TestCase { } protected function tearDown(): void { - $this->restoreService('AllConfig'); + $this->restoreService(\OC\AllConfig::class); // disable trashbin to be able to properly clean up \OC::$server->getAppManager()->disableApp('files_trashbin'); diff --git a/apps/files_versions/tests/VersioningTest.php b/apps/files_versions/tests/VersioningTest.php index 9bee9e0abc2..e07a1816c30 100644 --- a/apps/files_versions/tests/VersioningTest.php +++ b/apps/files_versions/tests/VersioningTest.php @@ -93,7 +93,7 @@ class VersioningTest extends \Test\TestCase { return $config->getSystemValue($key, $default); } })); - $this->overwriteService('AllConfig', $mockConfig); + $this->overwriteService(\OC\AllConfig::class, $mockConfig); // clear hooks \OC_Hook::clear(); @@ -115,7 +115,7 @@ class VersioningTest extends \Test\TestCase { } protected function tearDown(): void { - $this->restoreService('AllConfig'); + $this->restoreService(\OC\AllConfig::class); if ($this->rootView) { $this->rootView->deleteAll(self::TEST_VERSIONS_USER . '/files/'); @@ -629,7 +629,7 @@ class VersioningTest extends \Test\TestCase { $this->assertFalse(\OCA\Files_Versions\Storage::expire('/void/unexist.txt', self::TEST_VERSIONS_USER)); } - + public function testExpireNonexistingUser() { $this->expectException(\OC\User\NoUserException::class); diff --git a/apps/oauth2/lib/Controller/LoginRedirectorController.php b/apps/oauth2/lib/Controller/LoginRedirectorController.php index 8700ce10172..b5568b824d3 100644 --- a/apps/oauth2/lib/Controller/LoginRedirectorController.php +++ b/apps/oauth2/lib/Controller/LoginRedirectorController.php @@ -85,11 +85,10 @@ class LoginRedirectorController extends Controller { try { $client = $this->clientMapper->getByIdentifier($client_id); } catch (ClientNotFoundException $e) { - $response = new TemplateResponse('core', '404', 'guest'); - $response->setParams([ + $params = [ 'content' => $this->l->t('Your client is not authorized to connect. Please inform the administrator of your client.'), - ]); - return $response; + ]; + return new TemplateResponse('core', '404', $params, 'guest'); } if ($response_type !== 'code') { diff --git a/apps/oauth2/tests/Controller/LoginRedirectorControllerTest.php b/apps/oauth2/tests/Controller/LoginRedirectorControllerTest.php index a2dfd048dda..9bea0b328cb 100644 --- a/apps/oauth2/tests/Controller/LoginRedirectorControllerTest.php +++ b/apps/oauth2/tests/Controller/LoginRedirectorControllerTest.php @@ -24,15 +24,17 @@ namespace OCA\OAuth2\Tests\Controller; -use OCA\Files_Sharing\Tests\TestCase; use OCA\OAuth2\Controller\LoginRedirectorController; use OCA\OAuth2\Db\Client; use OCA\OAuth2\Db\ClientMapper; +use OCA\OAuth2\Exceptions\ClientNotFoundException; use OCP\AppFramework\Http\RedirectResponse; +use OCP\AppFramework\Http\TemplateResponse; use OCP\IL10N; use OCP\IRequest; use OCP\ISession; use OCP\IURLGenerator; +use Test\TestCase; /** * @group DB @@ -114,4 +116,22 @@ class LoginRedirectorControllerTest extends TestCase { $expected = new RedirectResponse('http://foo.bar?error=unsupported_response_type&state=MyState'); $this->assertEquals($expected, $this->loginRedirectorController->authorize('MyClientId', 'MyState', 'wrongcode')); } + + public function testClientNotFound() { + $clientNotFound = new ClientNotFoundException('could not find client test123', 0); + $this->clientMapper + ->expects($this->once()) + ->method('getByIdentifier') + ->willThrowException($clientNotFound); + $this->session + ->expects($this->never()) + ->method('set'); + + $response = $this->loginRedirectorController->authorize('MyClientId', 'MyState', 'wrongcode'); + $this->assertInstanceOf(TemplateResponse::class, $response); + + /** @var TemplateResponse $response */ + $this->assertEquals('404', $response->getTemplateName()); + $this->assertEquals('guest', $response->getRenderAs()); + } } diff --git a/core/css/variables.scss b/core/css/variables.scss index 3a14acb0ad7..68b1312c958 100644 --- a/core/css/variables.scss +++ b/core/css/variables.scss @@ -72,7 +72,7 @@ $image-favicon: url('../img/logo/logo.svg?v=1') !default; $color-loading-light: #ccc !default; $color-loading-dark: #444 !default; -$color-box-shadow: rgba(nc-darken($color-main-background, 70%), 0.5) !default; +$color-box-shadow: transparentize(nc-darken($color-main-background, 70%), 0.5) !default; // light border like file table or app-content list $color-border: nc-darken($color-main-background, 7%) !default; diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 90ac1e1988d..8ea94626a2a 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1687,6 +1687,11 @@ class View { if (!$info) { throw new NotFoundException($path . ' not found while trying to get owner'); } + + if ($info->getOwner() === null) { + throw new NotFoundException($path . ' has no owner'); + } + return $info->getOwner()->getUID(); } diff --git a/lib/private/Server.php b/lib/private/Server.php index d6c8e57d696..d57d2138913 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -134,6 +134,7 @@ use OCA\Theming\ThemingDefaults; use OCA\Theming\Util; use OCP\Accounts\IAccountManager; use OCP\App\IAppManager; +use OCP\AppFramework\QueryException; use OCP\Authentication\LoginCredentials\IStore; use OCP\Collaboration\AutoComplete\IManager; use OCP\Contacts\ContactsMenu\IActionFactory; @@ -158,9 +159,11 @@ use OCP\Group\Events\UserAddedEvent; use OCP\Group\Events\UserRemovedEvent; use OCP\Group\ISubAdmin; use OCP\ICacheFactory; +use OCP\IContainer; use OCP\IDBConnection; use OCP\IInitialStateService; use OCP\IL10N; +use OCP\ILogger; use OCP\IServerContainer; use OCP\ITempManager; use OCP\IUser; @@ -214,16 +217,16 @@ class Server extends ServerContainer implements IServerContainer { }); $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); - $this->registerAlias('CalendarManager', \OC\Calendar\Manager::class); + $this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class); $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class); - $this->registerAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class); + $this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class); $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class); - $this->registerAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class); + $this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class); $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); - $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); + $this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class); $this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class); @@ -240,7 +243,7 @@ class Server extends ServerContainer implements IServerContainer { $c->getSession()->get('user_id') ); }); - $this->registerAlias('PreviewManager', \OCP\IPreview::class); + $this->registerDeprecatedAlias('PreviewManager', \OCP\IPreview::class); $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { return new \OC\Preview\Watcher( @@ -265,7 +268,7 @@ class Server extends ServerContainer implements IServerContainer { new ArrayCache() ); }); - $this->registerAlias('EncryptionManager', \OCP\Encryption\IManager::class); + $this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class); $this->registerService('EncryptionFileHelper', function (Server $c) { $util = new Encryption\Util( @@ -300,7 +303,7 @@ class Server extends ServerContainer implements IServerContainer { $tagMapper = $c->query('TagMapper'); return new TagManager($tagMapper, $c->getUserSession()); }); - $this->registerAlias('TagManager', \OCP\ITagManager::class); + $this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class); $this->registerService('SystemTagManagerFactory', function (Server $c) { $config = $c->getConfig(); @@ -310,7 +313,7 @@ class Server extends ServerContainer implements IServerContainer { $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { return $c->query('SystemTagManagerFactory')->getManager(); }); - $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); + $this->registerDeprecatedAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { return $c->query('SystemTagManagerFactory')->getObjectMapper(); @@ -334,16 +337,16 @@ class Server extends ServerContainer implements IServerContainer { return $root; }); - $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); + $this->registerDeprecatedAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { return new LazyRoot(function () use ($c) { return $c->query('RootFolder'); }); }); - $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); + $this->registerDeprecatedAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); - $this->registerAlias('UserManager', \OC\User\Manager::class); + $this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class); $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); $this->registerService(\OCP\IGroupManager::class, function (Server $c) { @@ -404,7 +407,7 @@ class Server extends ServerContainer implements IServerContainer { }); return $groupManager; }); - $this->registerAlias('GroupManager', \OCP\IGroupManager::class); + $this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class); $this->registerService(Store::class, function (Server $c) { $session = $c->getSession(); @@ -547,30 +550,30 @@ class Server extends ServerContainer implements IServerContainer { return $userSession; }); $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class); - $this->registerAlias('UserSession', \OC\User\Session::class); + $this->registerDeprecatedAlias('UserSession', \OC\User\Session::class); $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class); $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); - $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); + $this->registerDeprecatedAlias('NavigationManager', \OCP\INavigationManager::class); $this->registerService(\OC\AllConfig::class, function (Server $c) { return new \OC\AllConfig( $c->getSystemConfig() ); }); - $this->registerAlias('AllConfig', \OC\AllConfig::class); + $this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class); $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) { return new \OC\SystemConfig($config); }); - $this->registerAlias('SystemConfig', \OC\SystemConfig::class); + $this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class); $this->registerService(\OC\AppConfig::class, function (Server $c) { return new \OC\AppConfig($c->getDatabaseConnection()); }); - $this->registerAlias('AppConfig', \OC\AppConfig::class); + $this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class); $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { @@ -581,7 +584,7 @@ class Server extends ServerContainer implements IServerContainer { \OC::$SERVERROOT ); }); - $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); + $this->registerDeprecatedAlias('L10NFactory', \OCP\L10N\IFactory::class); $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { $config = $c->getConfig(); @@ -593,15 +596,15 @@ class Server extends ServerContainer implements IServerContainer { $request ); }); - $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); + $this->registerDeprecatedAlias('URLGenerator', \OCP\IURLGenerator::class); - $this->registerAlias('AppFetcher', AppFetcher::class); - $this->registerAlias('CategoryFetcher', CategoryFetcher::class); + $this->registerDeprecatedAlias('AppFetcher', AppFetcher::class); + $this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class); $this->registerService(\OCP\ICache::class, function ($c) { return new Cache\File(); }); - $this->registerAlias('UserCache', \OCP\ICache::class); + $this->registerDeprecatedAlias('UserCache', \OCP\ICache::class); $this->registerService(Factory::class, function (Server $c) { @@ -628,7 +631,7 @@ class Server extends ServerContainer implements IServerContainer { return $arrayCacheFactory; }); - $this->registerAlias('MemCacheFactory', Factory::class); + $this->registerDeprecatedAlias('MemCacheFactory', Factory::class); $this->registerAlias(ICacheFactory::class, Factory::class); $this->registerService('RedisFactory', function (Server $c) { @@ -644,7 +647,7 @@ class Server extends ServerContainer implements IServerContainer { $c->query(IValidator::class) ); }); - $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); + $this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class); $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { return new \OC\Activity\EventMerger( @@ -663,13 +666,13 @@ class Server extends ServerContainer implements IServerContainer { ); }); $this->registerAlias(\OCP\IAvatarManager::class, AvatarManager::class); - $this->registerAlias('AvatarManager', AvatarManager::class); + $this->registerDeprecatedAlias('AvatarManager', AvatarManager::class); $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class); $this->registerService(\OC\Log::class, function (Server $c) { - $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); + $logType = $c->query(AllConfig::class)->getSystemValue('log_type', 'file'); $factory = new LogFactory($c, $this->getSystemConfig()); $logger = $factory->get($logType); $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); @@ -677,7 +680,7 @@ class Server extends ServerContainer implements IServerContainer { return new Log($logger, $this->getSystemConfig(), null, $registry); }); $this->registerAlias(\OCP\ILogger::class, \OC\Log::class); - $this->registerAlias('Logger', \OC\Log::class); + $this->registerDeprecatedAlias('Logger', \OC\Log::class); $this->registerService(ILogFactory::class, function (Server $c) { return new LogFactory($c, $this->getSystemConfig()); @@ -691,7 +694,7 @@ class Server extends ServerContainer implements IServerContainer { new TimeFactory() ); }); - $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); + $this->registerDeprecatedAlias('JobList', \OCP\BackgroundJob\IJobList::class); $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { $cacheFactory = $c->getMemCacheFactory(); @@ -703,12 +706,12 @@ class Server extends ServerContainer implements IServerContainer { } return $router; }); - $this->registerAlias('Router', \OCP\Route\IRouter::class); + $this->registerDeprecatedAlias('Router', \OCP\Route\IRouter::class); $this->registerService(\OCP\ISearch::class, function ($c) { return new Search(); }); - $this->registerAlias('Search', \OCP\ISearch::class); + $this->registerDeprecatedAlias('Search', \OCP\ISearch::class); $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { return new \OC\Security\RateLimiting\Backend\MemoryCache( @@ -720,22 +723,22 @@ class Server extends ServerContainer implements IServerContainer { $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { return new SecureRandom(); }); - $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); + $this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class); $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { return new Crypto($c->getConfig(), $c->getSecureRandom()); }); - $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); + $this->registerDeprecatedAlias('Crypto', \OCP\Security\ICrypto::class); $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { return new Hasher($c->getConfig()); }); - $this->registerAlias('Hasher', \OCP\Security\IHasher::class); + $this->registerDeprecatedAlias('Hasher', \OCP\Security\IHasher::class); $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); }); - $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); + $this->registerDeprecatedAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); $this->registerService(IDBConnection::class, function (Server $c) { $systemConfig = $c->getSystemConfig(); @@ -749,7 +752,7 @@ class Server extends ServerContainer implements IServerContainer { $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); return $connection; }); - $this->registerAlias('DatabaseConnection', IDBConnection::class); + $this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class); $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { @@ -766,7 +769,7 @@ class Server extends ServerContainer implements IServerContainer { ) ); }); - $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); + $this->registerDeprecatedAlias('HttpClientService', \OCP\Http\Client\IClientService::class); $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { $eventLogger = new EventLogger(); if ($c->getSystemConfig()->getValue('debug', false)) { @@ -775,7 +778,7 @@ class Server extends ServerContainer implements IServerContainer { } return $eventLogger; }); - $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); + $this->registerDeprecatedAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { $queryLogger = new QueryLogger(); @@ -785,7 +788,7 @@ class Server extends ServerContainer implements IServerContainer { } return $queryLogger; }); - $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); + $this->registerDeprecatedAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); $this->registerService(TempManager::class, function (Server $c) { return new TempManager( @@ -793,7 +796,7 @@ class Server extends ServerContainer implements IServerContainer { $c->getConfig() ); }); - $this->registerAlias('TempManager', TempManager::class); + $this->registerDeprecatedAlias('TempManager', TempManager::class); $this->registerAlias(ITempManager::class, TempManager::class); $this->registerService(AppManager::class, function (Server $c) { @@ -807,7 +810,7 @@ class Server extends ServerContainer implements IServerContainer { $c->getLogger() ); }); - $this->registerAlias('AppManager', AppManager::class); + $this->registerDeprecatedAlias('AppManager', AppManager::class); $this->registerAlias(IAppManager::class, AppManager::class); $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { @@ -816,7 +819,7 @@ class Server extends ServerContainer implements IServerContainer { $c->getSession() ); }); - $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); + $this->registerDeprecatedAlias('DateTimeZone', \OCP\IDateTimeZone::class); $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); @@ -826,7 +829,7 @@ class Server extends ServerContainer implements IServerContainer { $c->getL10N('lib', $language) ); }); - $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); + $this->registerDeprecatedAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); @@ -834,7 +837,7 @@ class Server extends ServerContainer implements IServerContainer { $listener->listen($c->getUserManager()); return $mountCache; }); - $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); + $this->registerDeprecatedAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { $loader = \OC\Files\Filesystem::getLoader(); @@ -850,7 +853,7 @@ class Server extends ServerContainer implements IServerContainer { return $manager; }); - $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); + $this->registerDeprecatedAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); $this->registerService('IniWrapper', function ($c) { return new IniGetWrapper(); @@ -881,7 +884,7 @@ class Server extends ServerContainer implements IServerContainer { $c->getConfig() ); }); - $this->registerAlias('Throttler', Throttler::class); + $this->registerDeprecatedAlias('Throttler', Throttler::class); $this->registerService('IntegrityCodeChecker', function (Server $c) { // IConfig and IAppManager requires a working database. This code // might however be called when ownCloud is not yet setup. @@ -938,7 +941,7 @@ class Server extends ServerContainer implements IServerContainer { $stream ); }); - $this->registerAlias('Request', \OCP\IRequest::class); + $this->registerDeprecatedAlias('Request', \OCP\IRequest::class); $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { return new Mailer( @@ -949,7 +952,7 @@ class Server extends ServerContainer implements IServerContainer { $c->getL10N('lib') ); }); - $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); + $this->registerDeprecatedAlias('Mailer', \OCP\Mail\IMailer::class); $this->registerService('LDAPProvider', function (Server $c) { $config = $c->getConfig(); @@ -982,12 +985,12 @@ class Server extends ServerContainer implements IServerContainer { } return new NoopLockingProvider(); }); - $this->registerAlias('LockingProvider', ILockingProvider::class); + $this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class); $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { return new \OC\Files\Mount\Manager(); }); - $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); + $this->registerDeprecatedAlias('MountManager', \OCP\Files\Mount\IMountManager::class); $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { return new \OC\Files\Type\Detection( @@ -997,14 +1000,14 @@ class Server extends ServerContainer implements IServerContainer { \OC::$SERVERROOT . '/resources/config/' ); }); - $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); + $this->registerDeprecatedAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { return new \OC\Files\Type\Loader( $c->getDatabaseConnection() ); }); - $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); + $this->registerDeprecatedAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); $this->registerService(BundleFetcher::class, function () { return new BundleFetcher($this->getL10N('lib')); }); @@ -1014,7 +1017,7 @@ class Server extends ServerContainer implements IServerContainer { $c->getLogger() ); }); - $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); + $this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class); $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { $manager = new \OC\CapabilitiesManager($c->getLogger()); @@ -1026,7 +1029,7 @@ class Server extends ServerContainer implements IServerContainer { }); return $manager; }); - $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); + $this->registerDeprecatedAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { $config = $c->getConfig(); @@ -1049,7 +1052,7 @@ class Server extends ServerContainer implements IServerContainer { return $manager; }); - $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); + $this->registerDeprecatedAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); $this->registerService('ThemingDefaults', function (Server $c) { /* @@ -1102,7 +1105,7 @@ class Server extends ServerContainer implements IServerContainer { ); }); $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class); - $this->registerAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class); + $this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class); $this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class); $this->registerService('CryptoWrapper', function (Server $c) { @@ -1138,12 +1141,12 @@ class Server extends ServerContainer implements IServerContainer { $c->query(SessionStorage::class) ); }); - $this->registerAlias('CsrfTokenManager', CsrfTokenManager::class); + $this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class); $this->registerService(SessionStorage::class, function (Server $c) { return new SessionStorage($c->getSession()); }); $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, \OC\Security\CSP\ContentSecurityPolicyManager::class); - $this->registerAlias('ContentSecurityPolicyManager', \OC\Security\CSP\ContentSecurityPolicyManager::class); + $this->registerDeprecatedAlias('ContentSecurityPolicyManager', \OC\Security\CSP\ContentSecurityPolicyManager::class); $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { return new ContentSecurityPolicyNonceManager( @@ -1179,7 +1182,7 @@ class Server extends ServerContainer implements IServerContainer { return $manager; }); - $this->registerAlias('ShareManager', \OCP\Share\IManager::class); + $this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class); $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { $instance = new Collaboration\Collaborators\Search($c); @@ -1193,7 +1196,7 @@ class Server extends ServerContainer implements IServerContainer { return $instance; }); - $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); + $this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class); $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); @@ -1244,17 +1247,17 @@ class Server extends ServerContainer implements IServerContainer { }); $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); + $this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); + $this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); $this->registerService(Defaults::class, function (Server $c) { return new Defaults( $c->getThemingDefaults() ); }); - $this->registerAlias('Defaults', \OCP\Defaults::class); + $this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class); $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { return $c->query(\OCP\IUserSession::class)->getSession(); @@ -1574,14 +1577,14 @@ class Server extends ServerContainer implements IServerContainer { * @return \OCP\IConfig */ public function getConfig() { - return $this->query('AllConfig'); + return $this->query(AllConfig::class); } /** * @return \OC\SystemConfig */ public function getSystemConfig() { - return $this->query('SystemConfig'); + return $this->query(SystemConfig::class); } /** @@ -2179,4 +2182,18 @@ class Server extends ServerContainer implements IServerContainer { public function getGeneratorHelper() { return $this->query(\OC\Preview\GeneratorHelper::class); } + + private function registerDeprecatedAlias(string $alias, string $target) { + $this->registerService($alias, function (IContainer $container) use ($target, $alias) { + try { + /** @var ILogger $logger */ + $logger = $container->query(ILogger::class); + $logger->debug('The requested alias "' . $alias . '" is depreacted. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']); + } catch (QueryException $e) { + // Could not get logger. Continue + } + + return $container->query($target); + }, false); + } } diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index ca668e24e7f..82e948344c1 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -784,6 +784,11 @@ class Manager implements IManager { //reuse the node we already have $share->setNode($oldShare->getNode()); + // Reset the target if it is null for the new share + if ($share->getTarget() === '') { + $share->setTarget($target); + } + // Post share event $event = new GenericEvent($share); $this->legacyDispatcher->dispatch('OCP\Share::postShare', $event); diff --git a/tests/lib/User/UserTest.php b/tests/lib/User/UserTest.php index 0bf582727ff..adcb2adec58 100644 --- a/tests/lib/User/UserTest.php +++ b/tests/lib/User/UserTest.php @@ -9,6 +9,7 @@ namespace Test\User; +use OC\AllConfig; use OC\Hooks\PublicEmitter; use OC\User\User; use OCP\Comments\ICommentsManager; @@ -560,11 +561,11 @@ class UserTest extends TestCase { $this->overwriteService('NotificationManager', $notificationManager); $this->overwriteService('CommentsManager', $commentsManager); - $this->overwriteService('AllConfig', $config); + $this->overwriteService(AllConfig::class, $config); $this->assertSame($result, $user->delete()); - $this->restoreService('AllConfig'); + $this->restoreService(AllConfig::class); $this->restoreService('CommentsManager'); $this->restoreService('NotificationManager'); |