Skip to content

ListSubscriptions check status #54

@ilievsoft

Description

@ilievsoft

You have to check the status of each subscription before calling the children() method on each iteration. Subscription with status error gives a fatal error of the PHP script since it does not have any children...
`protected function processResponse($xml)
{
$result = [];

    for ($i = 0; $i < count($xml->webspace->get->result); $i++) {
        $webspace = $xml->webspace->get->result[$i];
        
        if ( $webspace->status  != "ok" )
            continue;
        
        foreach ($webspace->data->hosting->children() as $host) {
            $hosting[$host->getName()] = Xml::getProperties($host);
        }

        $subscriptions = [];
        foreach ($webspace->data->subscriptions->children() as $subscription) {
            $subscriptions[] = [
                'locked' => (bool)$subscription->locked,
                'synchronized' => (bool)$subscription->synchronized,
                'plan-guid' => (string)$subscription->plan->{"plan-guid"},
            ];
        }

        $result[] = [
            'id' => (string)$webspace->id,
            'status' => (string)$webspace->status,
            'subscription_status' => (int)$webspace->data->gen_info->status,
            'created' => (string)$webspace->data->gen_info->cr_date,
            'name' => (string)$webspace->data->gen_info->name,
            'owner_id' => (string)$webspace->data->gen_info->{"owner-id"},
            'hosting' => $hosting,
            'real_size' => (int)$webspace->data->gen_info->real_size,
            'dns_ip_address' => (string)$webspace->data->gen_info->dns_ip_address,
            'htype' => (string)$webspace->data->gen_info->htype,
            'subscriptions' => $subscriptions,
        ];
    }

    return $result;
}`

So I just put a simple check:

if ( $webspace->status != "ok" ) continue;

And it is OK.
Thanks for committing this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions