Skip to content

Commit 9c5bd23

Browse files
blizzzbackportbot[bot]
authored andcommitted
fixes determining whether former user is a share owner
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
1 parent 7544f0c commit 9c5bd23

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

apps/user_ldap/lib/User/OfflineUser.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,29 +243,22 @@ protected function fetchDetails() {
243243
*/
244244
protected function determineShares() {
245245
$query = $this->db->prepare('
246-
SELECT COUNT(`uid_owner`)
246+
SELECT `uid_owner`
247247
FROM `*PREFIX*share`
248248
WHERE `uid_owner` = ?
249249
', 1);
250250
$query->execute([$this->ocName]);
251-
$sResult = $query->fetchColumn(0);
252-
if ((int)$sResult === 1) {
251+
if ($query->rowCount() > 0) {
253252
$this->hasActiveShares = true;
254253
return;
255254
}
256255

257256
$query = $this->db->prepare('
258-
SELECT COUNT(`owner`)
257+
SELECT `owner`
259258
FROM `*PREFIX*share_external`
260259
WHERE `owner` = ?
261260
', 1);
262261
$query->execute([$this->ocName]);
263-
$sResult = $query->fetchColumn(0);
264-
if ((int)$sResult === 1) {
265-
$this->hasActiveShares = true;
266-
return;
267-
}
268-
269-
$this->hasActiveShares = false;
262+
$this->hasActiveShares = $query->rowCount() > 0;
270263
}
271264
}

apps/user_ldap/tests/User/OfflineUserTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,12 @@ public function shareOwnerProvider(): array {
7878
public function testHasActiveShares(int $internalOwnerships, int $externalOwnerships, bool $expected) {
7979
$queryMock = $this->createMock(Statement::class);
8080
$queryMock->expects($this->atLeastOnce())
81-
->method('fetchColumn')
81+
->method('execute');
82+
$queryMock->expects($this->atLeastOnce())
83+
->method('rowCount')
8284
->willReturnOnConsecutiveCalls(
83-
(string)$internalOwnerships,
84-
(string)$externalOwnerships
85+
$internalOwnerships > 0 ? 1 : 0,
86+
$externalOwnerships > 0 ? 1 : 0
8587
);
8688

8789
$this->dbc->expects($this->atLeastOnce())

0 commit comments

Comments
 (0)