Jump to content

Recommended Posts

Posted

The following change will prevent an error if, for some reason, Enom is only returning one nameserver, which happened me today.


            if ($response->status() == "OK") {
                $data = $response->response();
                if ( isset( $data->dns ) && is_array( $data->dns ) ) {
                    foreach ($data->dns as $ns)
                        $vars->ns[] = $ns;
                }
                
            }

Blesta Version 3.6.1

Enom (ver 2.2.1)

 

File: components/modules/enom/enom.php

Line: 1151

Posted

What's the bug exactly and how does your code change resolve it?

 

What is returned by the module (check the Module Logs for raw Output)? What error do you receive?

Posted

The expected output returned by the module is a list of nameservers associated with the domain, which is converted into a PHP array:

https://reseller.enom.com/interface.asp
<?xml version="1.0" encoding="utf-8"?>
<interface-response>
<dns>ns1.example.com</dns>
<dns>ns2.example.com</dns>
<UseDNS></UseDNS>

However, the actual result I got was just 1 nameserver, which resulted in a fatal PHP error:

Invalid argument supplied for foreach()
https://reseller.enom.com/interface.asp
<?xml version="1.0" encoding="utf-8"?>
<interface-response>
<dns>ns1.example.com</dns>
<UseDNS></UseDNS>

I added "&& is_array( $data->dns )", which checks if $data->dns is an array, and prevents a fatal error in this scenario.

  • 2 weeks later...
Posted

To elaborate further, it wasn't the module's fault that only one NS was returned. This was just how the domain was (mis)configured. However, adding this code in the module would prevent fatal errors in Blesta in this situation, as rare as it may be.

  • 1 month later...
Guest
This topic is now closed to further replies.
×
×
  • Create New...