Skip to content

Commit 2ceece8

Browse files
authored
Merge pull request #177 from plesk/bugfix-getall-databases-fix
TECH Databases::getAll fix for empty filter
2 parents c8ed4fd + 0fdb0d8 commit 2ceece8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Api/Operator/Database.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ public function getUser(string $field, $value): Struct\UserInfo
6868
}
6969

7070
/**
71-
* @param string $field
71+
* @param string|null $field
7272
* @param int|string $value
7373
*
7474
* @return Struct\Info[]
7575
*/
76-
public function getAll(string $field, $value): array
76+
public function getAll(?string $field, $value): array
7777
{
7878
$response = $this->getBy('get-db', $field, $value);
7979
$items = [];
@@ -107,18 +107,20 @@ public function getAllUsers(string $field, $value): array
107107

108108
/**
109109
* @param string $command
110-
* @param string $field
110+
* @param string|null $field
111111
* @param int|string $value
112112
*
113113
* @return XmlResponse
114114
*/
115-
private function getBy(string $command, string $field, $value): XmlResponse
115+
private function getBy(string $command, ?string $field, $value): XmlResponse
116116
{
117117
$packet = $this->client->getPacket();
118118
$getTag = $packet->addChild($this->wrapperTag)->addChild($command);
119119

120120
$filterTag = $getTag->addChild('filter');
121-
$filterTag->{$field} = (string) $value;
121+
if (!is_null($field)) {
122+
$filterTag->{$field} = (string) $value;
123+
}
122124

123125
return $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
124126
}

0 commit comments

Comments
 (0)