Skip to content

Commit 08bf0ed

Browse files
authored
Merge pull request #993 from nextcloud/register-backends-boot
register user backends in `boot` instead of `register`
2 parents 5fafb28 + 726d1ad commit 08bf0ed

File tree

4 files changed

+31
-25
lines changed

4 files changed

+31
-25
lines changed

lib/AppInfo/Application.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@
3737
use OCP\AppFramework\Bootstrap\IBootContext;
3838
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
3939
use OCP\AppFramework\IAppContainer;
40+
use OCP\IGroupManager;
4041
use OCP\IServerContainer;
4142
use OCP\IUser;
43+
use OCP\IUserManager;
4244
use OCP\Notification\IManager as INotificationManager;
4345
use OCP\Share\Events\ShareCreatedEvent;
4446

@@ -55,16 +57,14 @@ public function register(IRegistrationContext $context): void {
5557
$context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalScriptsListener::class);
5658
$context->registerEventListener(ShareCreatedEvent::class, ShareAutoAcceptListener::class);
5759
$context->registerEventListener(BeforeTemplateRenderedEvent::class, TalkIntegrationListener::class);
58-
59-
// need to cheat here since there's no way to register these in IRegistrationContext
60-
$container = $this->getContainer();
61-
$server = $container->getServer();
62-
$server->getUserManager()->registerBackend($container->query(UserBackend::class));
63-
\OC_App::loadApp('theming');
64-
$server->getGroupManager()->addBackend($container->query(GroupBackend::class));
6560
}
6661

6762
public function boot(IBootContext $context): void {
63+
// need to cheat here since there's no way to register these in IRegistrationContext
64+
$container = $context->getServerContainer();
65+
$container->get(IUserManager::class)->registerBackend($container->query(UserBackend::class));
66+
$container->get(IGroupManager::class)->addBackend($container->query(GroupBackend::class));
67+
6868
$this->setupGuestManagement($context->getAppContainer(), $context->getServerContainer());
6969
$this->setupGuestRestrictions($context->getAppContainer(), $context->getServerContainer());
7070
$this->setupNotifications($context->getAppContainer());

lib/GroupBackend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function getUserGroups($uid): array {
111111
* Returns a list with all groups
112112
*/
113113
public function getGroups($search = '', $limit = -1, $offset = 0): array {
114-
return $offset === 0 ? [$this->groupName] : [];
114+
return $offset == 0 ? [$this->groupName] : [];
115115
}
116116

117117
/**

lib/Storage/DirMask.php

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,41 +100,47 @@ public function getPermissions($path): int {
100100
}
101101
}
102102

103-
public function rename($path1, $path2): bool {
104-
if (!$this->isUpdatable($path1)) {
103+
/**
104+
* @psalm-suppress ParamNameMismatch
105+
*/
106+
public function rename($source, $target): bool {
107+
if (!$this->isUpdatable($source)) {
105108
return false;
106109
}
107-
if ($this->file_exists($path2)) {
108-
if ($this->isUpdatable($path2)) {
109-
return $this->storage->rename($path1, $path2);
110+
if ($this->file_exists($target)) {
111+
if ($this->isUpdatable($target)) {
112+
return $this->storage->rename($source, $target);
110113
}
111114
} else {
112-
$parent = dirname($path2);
115+
$parent = dirname($target);
113116
if ($parent === '.') {
114117
$parent = '';
115118
}
116119
if ($this->isCreatable($parent)) {
117-
return $this->storage->rename($path1, $path2);
120+
return $this->storage->rename($source, $target);
118121
}
119122
}
120123
return false;
121124
}
122-
123-
public function copy($path1, $path2): bool {
124-
if (!$this->isReadable($path1)) {
125+
126+
/**
127+
* @psalm-suppress ParamNameMismatch
128+
*/
129+
public function copy($source, $target): bool {
130+
if (!$this->isReadable($source)) {
125131
return false;
126132
}
127-
if ($this->file_exists($path2)) {
128-
if ($this->isUpdatable($path2)) {
129-
return $this->storage->copy($path1, $path2);
133+
if ($this->file_exists($target)) {
134+
if ($this->isUpdatable($target)) {
135+
return $this->storage->copy($source, $target);
130136
}
131137
} else {
132-
$parent = dirname($path2);
138+
$parent = dirname($target);
133139
if ($parent === '.') {
134140
$parent = '';
135141
}
136142
if ($this->isCreatable($parent)) {
137-
return $this->storage->copy($path1, $path2);
143+
return $this->storage->copy($source, $target);
138144
}
139145
}
140146
return false;

lib/UserBackend.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ public function getDisplayNames($search = '', $limit = null, $offset = null): ar
247247
/**
248248
* Check if the password is correct
249249
*
250-
* @return string|bool
250+
* @return string|false
251251
*
252252
* Check if the password is correct without logging in the user
253253
* returns the user id or false
@@ -377,7 +377,7 @@ public function hasUserListings() {
377377
/**
378378
* counts the users in the database
379379
*
380-
* @return int|bool
380+
* @return int|false
381381
*/
382382
public function countUsers() {
383383
$query = $this->dbConn->getQueryBuilder();

0 commit comments

Comments
 (0)