-
Notifications
You must be signed in to change notification settings - Fork 81
Closed
Description
Hey,
today I tried to create a webspace with two IP addresses.
When I tried to pass my IP addresses as an array, I got the following error.
mod_fcgid: stderr: PHP Fatal error: Uncaught TypeError: SimpleXMLElement::addChild(): Argument #2 ($value) must be of type ?string, array given in /**/cp/vendor/plesk/api-php-lib/src/Api/Operator/Webspace.php:78
I don't know how to do this as a string, but if any of you know, please give me the solution.
In my opinion this is a bug that can be solved as follows:
We add in Webspace.php:78, before $infoGeneral
is added the child, the following query.
if ($value == $properties['ip_address'])
continue;
According to my research $infoGeneral
does not need this information.
The IP addresses are added a bit later.
So in my case the method now looks like this:
PleskX\Api\Operator\Webspace
namespace PleskX\Api\Operator
/**
* @param array $properties
* @param array|null $hostingProperties
* @param string $planName
*
* @return Struct\Info
*/
public function create(array $properties, array $hostingProperties = null, string $planName = ''): Struct\Info
{
$packet = $this->client->getPacket();
$info = $packet->addChild($this->wrapperTag)->addChild('add');
$infoGeneral = $info->addChild('gen_setup');
foreach ($properties as $name => $value) {
if ($value == $properties['ip_address'])
continue;
$infoGeneral->addChild($name, (string) $value);
}
if ($hostingProperties) {
$infoHosting = $info->addChild('hosting')->addChild('vrt_hst');
foreach ($hostingProperties as $name => $value) {
$property = $infoHosting->addChild('property');
$property->name = $name;
$property->value = $value;
}
if (isset($properties['ip_address'])) {
foreach ((array) $properties['ip_address'] as $ipAddress) {
$infoHosting->addChild('ip_address', $ipAddress);
}
}
}
if ('' !== $planName) {
$info->addChild('plan-name', $planName);
}
$response = $this->client->request($packet);
return new Struct\Info($response, $properties['name'] ?? '');
}
aarongerig
Metadata
Metadata
Assignees
Labels
No labels