initMountPoints is marking a user as successfully initialized too early. If the user was not found an NoUserException was thrown, the second time initMountPoints is called would not rethrow the exception and happily continue. This fix makes sure that we consistently throw NoUserException when initMountPoints is called repeatedly with invalid users.tags/v9.1.0beta1
if (isset(self::$usersSetup[$user])) { | if (isset(self::$usersSetup[$user])) { | ||||
return; | return; | ||||
} | } | ||||
self::$usersSetup[$user] = true; | |||||
$root = \OC_User::getHome($user); | $root = \OC_User::getHome($user); | ||||
$userManager = \OC::$server->getUserManager(); | $userManager = \OC::$server->getUserManager(); | ||||
throw new \OC\User\NoUserException('Backends provided no user object for ' . $user); | throw new \OC\User\NoUserException('Backends provided no user object for ' . $user); | ||||
} | } | ||||
self::$usersSetup[$user] = true; | |||||
$homeStorage = \OC::$server->getConfig()->getSystemValue('objectstore'); | $homeStorage = \OC::$server->getConfig()->getSystemValue('objectstore'); | ||||
if (!empty($homeStorage)) { | if (!empty($homeStorage)) { | ||||
// sanity checks | // sanity checks |
$this->assertEquals(2, $thrown); | $this->assertEquals(2, $thrown); | ||||
} | } | ||||
/** | |||||
* Tests that an exception is thrown when passed user does not exist. | |||||
*/ | |||||
public function testLocalMountWhenUserDoesNotExistTwice() { | |||||
$thrown = 0; | |||||
$userId = $this->getUniqueID('user_'); | |||||
try { | |||||
\OC\Files\Filesystem::initMountPoints($userId); | |||||
} catch (NoUserException $e) { | |||||
$thrown++; | |||||
} | |||||
try { | |||||
\OC\Files\Filesystem::initMountPoints($userId); | |||||
} catch (NoUserException $e) { | |||||
$thrown++; | |||||
} | |||||
$this->assertEquals(2, $thrown); | |||||
} | |||||
/** | /** | ||||
* Tests that the home storage is used for the user's mount point | * Tests that the home storage is used for the user's mount point | ||||
*/ | */ |