Skip to content

Commit 45cd68c

Browse files
Merge pull request #188 from whytea91/bugfix-correctly-fetch-current-databases-number
BUGFIX EXTPLESK-8950 Fix case when getAll returns 1 database instead of 0
2 parents a206932 + f57322f commit 45cd68c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Api/Operator/Database.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function getAll(?string $field, $value): array
7878
$response = $this->getBy('get-db', $field, $value);
7979
$items = [];
8080
foreach ((array) $response->xpath('//result') as $xmlResult) {
81-
if ($xmlResult) {
81+
if ($xmlResult && isset($xmlResult->id) && (int) $xmlResult->id > 0) {
8282
$items[] = new Struct\Info($xmlResult);
8383
}
8484
}

tests/DatabaseTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,12 @@ private function createUser(array $params): \PleskX\Api\Struct\Database\UserInfo
225225

226226
return $user;
227227
}
228+
229+
public function testGetAllForWebspaceWithNoDatabases()
230+
{
231+
$databases = static::$client->database()->getAll('webspace-id', static::$webspace->id);
232+
233+
$this->assertIsArray($databases);
234+
$this->assertEmpty($databases);
235+
}
228236
}

0 commit comments

Comments
 (0)