I have a block which shows one entry from my amazon wishlist on my homepage (from http://www.garyarnold.com/content/Drupal-random-Amazon-wishlist-item).
Today I installed the patch from rfay http://drupal.org/node/465516#comment-1697066 and entered the secret key.

Now I always get this error: warning: Illegal offset type in isset or empty in /var/www/html/magenbrot.net/sites/all/modules/amazon/amazon.module on line 258.
But the Item is correctly fetched and displayed in its block.

I already tried a complete reinstall of the module (also deleted amazon% from the variable table) with no effect, it even displays the error without the patch now. I also installed the dev version, still the error message, very mysterious.

This is the code I use in the block:

<?php
$list = '3V4RX81EM9KP';

$params = array(
  'ListType' => 'WishList',
  'ListId' => $list,
  'ResponseGroup' => 'ListFull',
  'IsOmitPurchasedItems' => 1,
);

$results = amazon_http_request('ListLookup', $params);
if (!empty($results->Error)) {
  return;
}

$total_items = (int)$results->Lists->List->TotalItems;
$random_item = rand(1, $total_items) - 1;
$page = (int)($random_item / 10) + 1;
$item_on_page = $random_item % 10;

$params = array(
  'ListType' => 'WishList',
  'ListId' => $list,
  'ResponseGroup' => 'ListItems',
  'ProductPage' => $page
);

$results = amazon_http_request('ListLookup', $params);
if (empty($results->Error)) {
  $asin = $results->Lists->List->ListItem[$item_on_page]->Item->ASIN;

  $items = amazon_item_lookup($asin);
  if (is_array($items)) {
    $item = array_pop($items);
    $item[detailpageurl] .= '%26colid='.$list;
    amazon_item_save($item);
    $markup = theme('amazon_item', $item, 'details');
    print $markup;
  }
}

?>

I can't find the error and I also don't know why this error occurs now. Maybe anyone could give me a hint?

regards,
Oliver

Comments

magenbrot’s picture

Status: Active » Fixed

I've found a solution in the comments on Gary Arnolds page.

Submitted by garnold on Mon, 10/20/2008 - 11:09pm.

I ran into that, too, and forgot to mention it in my blog post! I don't recall what the problem was, exactly...something along the lines of trying to index an array with something that wasn't an integer, or maybe trying to index something that wasn't an array.

In any case, to fix it, change line 235 of amazon.module. It should currently read:

if (!isset($items[$item_id])) {

Replace that line with these two:

$asin = (string)$item_id[0];
if (!isset($items[$asin])) {

That should fix the problem!

I don't know if this is relevant for this module or if this error occurs only in Garys code.

Status: Fixed » Closed (fixed)

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