Hi,

I get this error:

warning: array_flip(): Can only flip STRING and INTEGER values! in /home/xlkorguk/public_html/ukfilm/ukfilmintranet_svn_export/trunk/modules/location/location.inc on line 1191.

I've installed the latest location module code from the CVS and I'm running a Drupal installation that's based on a download from the Drupal CVS from about a week ago.

PHP 4.4.1
MySQL 4.1.14
Linux server

Thanks,
Jack

Comments

will-at-hotgazpacho.org’s picture

I'm seeing this, too, in location_configured_countries. I believe the real problem lies with this bit of code:

  $configured_countries_associative = array();
  foreach ($configured_countries as $country_code => $enabled) {
    if ($enabled) {
      $configured_countries_associative[$country_code] = $supported_countries[$country_code];
    }
  }
  // With array_flip() temporarily make array so that we have <English name> => <ISO code>
  // We want to do this so we can do a ksort() by ISO code. Regular sort() destroys index values 
  $configured_countries_associative = array_flip($configured_countries_associative);
  ksort($configured_countries_associative);
  reset($configured_countries_associative);
  return array_flip($configured_countries_associative);

I believe the intent is to retrieve the list of configured countries, and return a hash of => (at least this is what the comments state). However, the foreach statement makes no sense, in light of the structure of the $configured_countries array. By definition, all the values of the $configured_countries array represent enabled ISO codes. So, looks to me like the code block SHOULD look something more like this:

  $configured_countries_associative = array();
  foreach ($configured_countries as $country_code) {
    if (array_key_exists($country_code, $supported_countries)) {
      $configured_countries_associative[$country_code] = $supported_countries[$country_code];
    }
  }
  return asort($configured_countries_associative);

I believe this will do what is intended, and with less steps, too. I'll test it and submit a patch if successful.

will-at-hotgazpacho.org’s picture

Status: Active » Reviewed & tested by the community
StatusFileSize
new1.22 KB

I was close. Call to arsort needs to occur in a statement seperate from thr retun statement (otherwise it only retuns TRUE or FALSE).

dan_aka_jack’s picture

Nice, thanks for your reply and the fix. I'll wait for it to be included in the CVS before testing it.

ankur’s picture

Sorry, from the previous update to this issue, I'm not sure this patch has been verified. Has it? If so, please feel free to commit this patch and to mark this issue as fixed afterward. It looks like a patch that needs to be committed to both HEAD and DRUPAL-4-6.

-Ankur

bootleg’s picture

I've run into this same issue, is there a fix for this? Thanks!

ankur’s picture

Status: Reviewed & tested by the community » Fixed

Much thanks to WIll for looking into this and putting up a patch.

The patch has been applied to the HEAD branch.

Anonymous’s picture

Status: Fixed » Closed (fixed)