Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chertzog’s picture

Status: Active » Needs review
FileSize
2.75 KB

The linked issue above is showing a 404.

But here is a patch that adds some checks as well as makes sure that what is being passed to foreach is an array.

anarcat’s picture

could you actually reproduce the issue and fix it with the patch??

chertzog’s picture

When creating a new server, i actually get the following error.

"warning: Invalid argument supplied for foreach() in /var/aegir/hostmaster-6.x-2.x/profiles/hostmaster/modules/hosting/server/hosting.ip.inc on line 51."

The offending lines are

function hosting_ip_validate($node) { 
  foreach ($node->ip_addresses as $id => $ip) { // Line 51

Its assuming that $node->ip_addresses is set.

As for the line 39 error, it looks like its because the code checks if isset, not is_array.

$ips = isset($node->new_ip_addresses) ? $node->new_ip_addresses : array();

Which btw, is different from the way its handled earlier in the function when checking for $node->ip_addresses.

$ips = is_array($node->ip_addresses) ? $node->ip_addresses : array(); // Line 26.
lieb’s picture

Version: 6.x-2.x-dev » 6.x-2.0-rc4

I am getting this error in 6.x-2.0-rc4 trying to update the properties of a pack server. I believe it is because a pack server does not have a valid IP to begin with. I will test the patch above and report back.

lieb’s picture

Status: Needs review » Reviewed & tested by the community

I applied this patch on two different hostmaster's both configured with server packs and it appears to work. I no longer get the warning when saving a server.

anarcat’s picture

Status: Reviewed & tested by the community » Needs work

unfortunately, the patch doesn't apply anymore.

anarcat@angela:hosting[6.x-2.x]*$ patch -p1 < hosting-ip-checks.patch
patching file server/hosting.ip.inc
Hunk #3 FAILED at 48.
1 out of 3 hunks FAILED -- saving rejects to file server/hosting.ip.inc.rej
chertzog’s picture

Status: Needs work » Needs review
FileSize
896 bytes

Here is an updated patch. It looks like the other stuff was fixed in a recent commit.

anarcat’s picture

Status: Needs review » Fixed

pushed in 08c2986

ergonlogic’s picture

Version: 6.x-2.0-rc4 » 6.x-2.x-dev
Status: Fixed » Needs work

I'm still seeing this in our tests, and I can't find that commit...

ergonlogic’s picture

Status: Needs work » Fixed

Fixed in fb8c79ab. I only cast to array for the two lines where we do isset()'s, since it doesn't seem to make much sense after an is_array().

Tests are now clean again.

lieb’s picture

Did this make it into RC5? I am getting this in RC5 when I do a 'hosting import' on an existing site that I just migrated with provision-migrate

$ drush @hostmaster hosting-import  @migrated-site-alias
Invalid argument supplied for foreach() hosting.ip.inc:39                                               [warning]
Invalid argument supplied for foreach() hosting.ip.inc:39                                               [warning]
anarcat’s picture

actually, bits of this *didn't* get into rc5 because i forgot a push in the office. the missing commit, now pushed, is 23d5153

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

  • Commit 23d5153 on 6.x-2.x, 7.x-3.x, dev-sni, dev-helmo-3.x authored by chertzog, committed by anarcat:
    Issue #2085077 by chertzog | ergonlogic: Fixed Invalid argument supplied...
  • Commit fb8c79a on 6.x-2.x, 7.x-3.x, dev-sni, dev-helmo-3.x by ergonlogic:
    Issus #2085077 by chertzog, ergonlogic, anarcat: Fix invalid argument...

  • Commit 23d5153 on 6.x-2.x, 7.x-3.x, dev-sni, dev-helmo-3.x authored by chertzog, committed by anarcat:
    Issue #2085077 by chertzog | ergonlogic: Fixed Invalid argument supplied...
  • Commit fb8c79a on 6.x-2.x, 7.x-3.x, dev-sni, dev-helmo-3.x by ergonlogic:
    Issus #2085077 by chertzog, ergonlogic, anarcat: Fix invalid argument...