Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move \OC\User\NoUserException to OCP #33239

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/dashboard/lib/Service/BackgroundService.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
namespace OCA\Dashboard\Service;

use InvalidArgumentException;
use OC\User\NoUserException;
use OCP\User\NoUserException;
use OCP\Files\File;
use OCP\Files\IAppData;
use OCP\Files\IRootFolder;
Expand Down Expand Up @@ -143,7 +143,7 @@ public function setDefaultBackground(): void {
* @throws NotPermittedException
* @throws LockedException
* @throws PreConditionNotMetException
* @throws NoUserException
* @throws \OCP\User\NoUserException
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not consistent with having a use, you do not need to namespace it here

*/
public function setFileBackground($path): void {
$this->config->setUserValue($this->userId, 'dashboard', 'background', 'custom');
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/BackgroundJob/EventReminderJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct(ITimeFactory $time,
/**
* @throws \OCA\DAV\CalDAV\Reminder\NotificationProvider\ProviderNotAvailableException
* @throws \OCA\DAV\CalDAV\Reminder\NotificationTypeDoesNotExistException
* @throws \OC\User\NoUserException
* @throws \OCP\User\NoUserException
*/
public function run($argument):void {
if ($this->config->getAppValue('dav', 'sendEventReminders', 'yes') !== 'yes') {
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/BackgroundJob/UploadCleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
namespace OCA\DAV\BackgroundJob;

use OC\User\NoUserException;
use OCP\User\NoUserException;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJob;
use OCP\BackgroundJob\IJobList;
Expand Down
2 changes: 1 addition & 1 deletion apps/encryption/lib/Hooks/UserHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public function setPassphrase($params) {
* init mount points for given user
*
* @param string $user
* @throws \OC\User\NoUserException
* @throws \OCP\User\NoUserException
*/
protected function initMountPoints($user) {
Filesystem::initMountPoints($user);
Expand Down
2 changes: 1 addition & 1 deletion apps/files/lib/Service/OwnershipTransferService.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function __construct(IEncryptionManager $manager,
* @param OutputInterface|null $output
* @param bool $move
* @throws TransferOwnershipException
* @throws \OC\User\NoUserException
* @throws \OCP\User\NoUserException
*/
public function transfer(IUser $sourceUser,
IUser $destinationUser,
Expand Down
2 changes: 1 addition & 1 deletion apps/files_external/lib/Command/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

use OC\Core\Command\Base;
use OC\Files\Filesystem;
use OC\User\NoUserException;
use OCP\User\NoUserException;
use OCA\Files_External\Lib\Auth\AuthMechanism;
use OCA\Files_External\Lib\Backend\Backend;
use OCA\Files_External\Lib\DefinitionParameter;
Expand Down
2 changes: 1 addition & 1 deletion apps/files_external/lib/Command/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
namespace OCA\Files_External\Command;

use OC\Core\Command\Base;
use OC\User\NoUserException;
use OCP\User\NoUserException;
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\Service\BackendService;
use OCA\Files_External\Service\GlobalStoragesService;
Expand Down
2 changes: 1 addition & 1 deletion apps/files_external/lib/Command/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
namespace OCA\Files_External\Command;

use OC\Core\Command\Base;
use OC\User\NoUserException;
use OCP\User\NoUserException;
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\Service\GlobalStoragesService;
use OCA\Files_External\Service\UserStoragesService;
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/SharedStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
use OCP\Files\Node;
use OC\Files\Storage\FailedStorage;
use OC\Files\Storage\Wrapper\PermissionsMask;
use OC\User\NoUserException;
use OCP\User\NoUserException;
use OCA\Files_External\Config\ExternalMountPoint;
use OCP\Constants;
use OCP\Files\Cache\ICacheEntry;
Expand Down
2 changes: 1 addition & 1 deletion apps/files_trashbin/lib/Trashbin.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static function ensureFileScannedHook($params) {
*
* @param string $filename
* @return array
* @throws \OC\User\NoUserException
* @throws \OCP\User\NoUserException
*/
public static function getUidAndFilename($filename) {
$uid = Filesystem::getOwner($filename);
Expand Down
2 changes: 1 addition & 1 deletion apps/files_versions/lib/Sabre/VersionHome.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
namespace OCA\Files_Versions\Sabre;

use OC\User\NoUserException;
use OCP\User\NoUserException;
use OCA\Files_Versions\Versions\IVersionManager;
use OCP\Files\IRootFolder;
use OCP\IUserManager;
Expand Down
4 changes: 2 additions & 2 deletions apps/files_versions/lib/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Storage {
*
* @param string $filename
* @return array
* @throws \OC\User\NoUserException
* @throws \OCP\User\NoUserException
*/
public static function getUidAndFilename($filename) {
$uid = Filesystem::getOwner($filename);
Expand Down Expand Up @@ -755,7 +755,7 @@ public static function expire($filename, $uid) {
$user = \OC::$server->get(IUserManager::class)->get($uid);
if (is_null($user)) {
$logger->error('Backends provided no user object for ' . $uid, ['app' => 'files_versions']);
throw new \OC\User\NoUserException('Backends provided no user object for ' . $uid);
throw new \OCP\User\NoUserException('Backends provided no user object for ' . $uid);
}

\OC_Util::setupFS($uid);
Expand Down
2 changes: 1 addition & 1 deletion apps/files_versions/tests/VersioningTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ public function testExpireNonexistingFile() {


public function testExpireNonexistingUser() {
$this->expectException(\OC\User\NoUserException::class);
$this->expectException(\OCP\User\NoUserException::class);

$this->logout();
// needed to have a FS setup (the background job does this)
Expand Down
2 changes: 1 addition & 1 deletion apps/provisioning_api/lib/Controller/AUserData.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

use OC\Group\Manager;
use OC\User\Backend;
use OC\User\NoUserException;
use OCP\User\NoUserException;
use OC_Helper;
use OCP\Accounts\IAccountManager;
use OCP\Accounts\PropertyDoesNotExistException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

use OC\Group\Manager;
use OC\SubAdmin;
use OC\User\NoUserException;
use OCP\User\NoUserException;
use OCA\Provisioning_API\Controller\GroupsController;
use OCP\Accounts\IAccountManager;
use OCP\IConfig;
Expand Down
2 changes: 1 addition & 1 deletion apps/sharebymail/lib/ShareByMailProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

use OC\Share20\Exception\InvalidShare;
use OC\Share20\Share;
use OC\User\NoUserException;
use OCP\User\NoUserException;
use OCA\ShareByMail\Settings\SettingsManager;
use OCP\Activity\IManager;
use OCP\DB\QueryBuilder\IQueryBuilder;
Expand Down
2 changes: 1 addition & 1 deletion apps/testing/lib/Controller/LockingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
namespace OCA\Testing\Controller;

use OC\Lock\DBLockingProvider;
use OC\User\NoUserException;
use OCP\User\NoUserException;
use OCA\Testing\Locking\FakeDBLockingProvider;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
Expand Down
4 changes: 2 additions & 2 deletions apps/user_ldap/lib/User_LDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

use OC\ServerNotAvailableException;
use OC\User\Backend;
use OC\User\NoUserException;
use OCP\User\NoUserException;
use OCA\User_LDAP\Exceptions\NotOnLDAP;
use OCA\User_LDAP\User\OfflineUser;
use OCA\User_LDAP\User\User;
Expand Down Expand Up @@ -429,7 +429,7 @@ public function deleteUser($uid) {
*
* @param string $uid the username
* @return bool|string
* @throws NoUserException
* @throws \OCP\User\NoUserException
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

* @throws \Exception
*/
public function getHome($uid) {
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@
'OCP\\User\\Events\\UserLoggedInWithCookieEvent' => $baseDir . '/lib/public/User/Events/UserLoggedInWithCookieEvent.php',
'OCP\\User\\Events\\UserLoggedOutEvent' => $baseDir . '/lib/public/User/Events/UserLoggedOutEvent.php',
'OCP\\User\\GetQuotaEvent' => $baseDir . '/lib/public/User/GetQuotaEvent.php',
'OCP\\User\\NoUserException' => $baseDir . '/lib/public/User/NoUserException.php',
'OCP\\Util' => $baseDir . '/lib/public/Util.php',
'OCP\\WorkflowEngine\\EntityContext\\IContextPortation' => $baseDir . '/lib/public/WorkflowEngine/EntityContext/IContextPortation.php',
'OCP\\WorkflowEngine\\EntityContext\\IDisplayName' => $baseDir . '/lib/public/WorkflowEngine/EntityContext/IDisplayName.php',
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\User\\Events\\UserLoggedInWithCookieEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserLoggedInWithCookieEvent.php',
'OCP\\User\\Events\\UserLoggedOutEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserLoggedOutEvent.php',
'OCP\\User\\GetQuotaEvent' => __DIR__ . '/../../..' . '/lib/public/User/GetQuotaEvent.php',
'OCP\\User\\NoUserException' => __DIR__ . '/../../..' . '/lib/public/User/NoUserException.php',
'OCP\\Util' => __DIR__ . '/../../..' . '/lib/public/Util.php',
'OCP\\WorkflowEngine\\EntityContext\\IContextPortation' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/EntityContext/IContextPortation.php',
'OCP\\WorkflowEngine\\EntityContext\\IDisplayName' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/EntityContext/IDisplayName.php',
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Avatar/AvatarManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

use OC\KnownUser\KnownUserService;
use OC\User\Manager;
use OC\User\NoUserException;
use OCP\User\NoUserException;
use OCP\Accounts\IAccountManager;
use OCP\Accounts\PropertyDoesNotExistException;
use OCP\Files\IAppData;
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Cache/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class File implements ICache {
*
* @return \OC\Files\View cache storage
* @throws \OC\ForbiddenException
* @throws \OC\User\NoUserException
* @throws \OCP\User\NoUserException
*/
protected function getStorage() {
if ($this->storage !== null) {
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Encryption/Keys/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
use OC\Files\Filesystem;
use OC\Files\View;
use OC\ServerNotAvailableException;
use OC\User\NoUserException;
use OCP\User\NoUserException;
use OCP\Encryption\Keys\IStorage;
use OCP\IConfig;
use OCP\Security\ICrypto;
Expand Down
4 changes: 2 additions & 2 deletions lib/private/Files/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

use OCP\Cache\CappedMemoryCache;
use OC\Files\Mount\MountPoint;
use OC\User\NoUserException;
use OCP\User\NoUserException;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Events\Node\FilesystemTornDownEvent;
use OCP\Files\NotFoundException;
Expand Down Expand Up @@ -366,7 +366,7 @@ public static function initMountManager() {
* Initialize system and personal mount points for a user
*
* @param string|IUser|null $user
* @throws \OC\User\NoUserException if the user is not available
* @throws \OCP\User\NoUserException if the user is not available
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @throws \OCP\User\NoUserException if the user is not available
* @throws NoUserException if the user is not available

*/
public static function initMountPoints($user = '') {
/** @var IUserManager $userManager */
Expand Down
4 changes: 2 additions & 2 deletions lib/private/Files/Node/Root.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
use OC\Files\Utils\PathHelper;
use OC\Files\View;
use OC\Hooks\PublicEmitter;
use OC\User\NoUserException;
use OCP\User\NoUserException;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Config\IUserMountCache;
use OCP\Files\Events\Node\FilesystemTornDownEvent;
Expand Down Expand Up @@ -358,7 +358,7 @@ public function getName() {
*
* @param string $userId user ID
* @return \OCP\Files\Folder
* @throws NoUserException
* @throws \OCP\User\NoUserException
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

* @throws NotPermittedException
*/
public function getUserFolder($userId) {
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/Template/TemplateManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function createFromTemplate(string $filePath, string $templateId = '', st
* @return Folder
* @throws \OCP\Files\NotFoundException
* @throws \OCP\Files\NotPermittedException
* @throws \OC\User\NoUserException
* @throws \OCP\User\NoUserException
*/
private function getTemplateFolder(): Node {
if ($this->getTemplatePath() !== '') {
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -2155,7 +2155,7 @@ public function getPathRelativeToFiles($absolutePath) {
/**
* @param string $filename
* @return array
* @throws \OC\User\NoUserException
* @throws \OCP\User\NoUserException
* @throws NotFoundException
*/
public function getUidAndFilename($filename) {
Expand Down
3 changes: 2 additions & 1 deletion lib/private/User/NoUserException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
*/
namespace OC\User;

class NoUserException extends \Exception {
/** @depreacted 25.0.0 */
class NoUserException extends \OCP\User\NoUserException {
}
2 changes: 1 addition & 1 deletion lib/private/User/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public function setImpersonatingUserID(bool $useCurrentUser = true): void {
$currentUser = $this->getUser();

if ($currentUser === null) {
throw new \OC\User\NoUserException();
throw new \OCP\User\NoUserException();
}
$this->session->set('oldUserId', $currentUser->getUID());
}
Expand Down
2 changes: 1 addition & 1 deletion lib/public/Files/IRootFolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
namespace OCP\Files;

use OC\Hooks\Emitter;
use OC\User\NoUserException;
use OCP\User\NoUserException;

/**
* Interface IRootFolder
Expand Down
32 changes: 32 additions & 0 deletions lib/public/User/NoUserException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2022 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @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 OCP\User;

/**
* @since 25.0.0
*/
class NoUserException extends \Exception {
}
8 changes: 4 additions & 4 deletions tests/lib/Files/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

use OC\Files\Mount\MountPoint;
use OC\Files\Storage\Temporary;
use OC\User\NoUserException;
use OCP\User\NoUserException;
use OCP\Files\Config\IMountProvider;
use OCP\Files\Storage\IStorageFactory;
use OCP\IUser;
Expand Down Expand Up @@ -340,16 +340,16 @@ public function testHooks() {
*
*/
public function testLocalMountWhenUserDoesNotExist() {
$this->expectException(\OC\User\NoUserException::class);
$this->expectException(\OCP\User\NoUserException::class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->expectException(\OCP\User\NoUserException::class);
$this->expectException(NoUserException::class);


$userId = $this->getUniqueID('user_');

\OC\Files\Filesystem::initMountPoints($userId);
}


public function testNullUserThrows() {
$this->expectException(\OC\User\NoUserException::class);
$this->expectException(\OCP\User\NoUserException::class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->expectException(\OCP\User\NoUserException::class);
$this->expectException(NoUserException::class);


\OC\Files\Filesystem::initMountPoints(null);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/Files/Node/RootTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function testGetUserFolder() {


public function testGetUserFolderWithNoUserObj() {
$this->expectException(\OC\User\NoUserException::class);
$this->expectException(\OCP\User\NoUserException::class);
$this->expectExceptionMessage('Backends provided no user object');

$root = new \OC\Files\Node\Root(
Expand Down