I am getting this error message on a page that I don't even use amazon link on. It is on a basic page only the article pages doesn't have any issues with it.

http://chrisallen.us/aboutme

Comments

pancho’s picture

Obviously you managed to fix the issue yourselves. Did doing some update help, or did you patch your installation? Might be an issue between amazon module and some other contrib module...

00trav’s picture

I had the exact same issue. It was very strange as it seemed to occur at random (and on pages that were not using the amazon module).

What I think caused it was the amazon asin field being 'hidden' in the teaser view.

00trav’s picture

Status: Active » Needs review

I figured out my issue. It seems to relate to the Metatags_quick module. The seemingly random nature of the error is caused by the Metatag description field being empty which then doesn't pass an element to asin_field_formatter_view().

the quick and easy fix is to update the asin_field_formatter_view to add a check and break
However, I don't know if there are other negative implications with this code.....

<?php
function asin_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();

  foreach ($items as $delta => $value) {

//being alteration
    if (!empty($value['asin'])){
        $asin = trim($value['asin']);
    }else{
      break;
    }
//end of alteration

    if (!empty($asin)) {
      $lookup = amazon_item_lookup($asin);
      if (!empty($lookup) && $item = $lookup[$asin]) {
              // TODO: kill off amazon_inline_item. There's no reason for it to clutter the earth.
              $theme_function = $display['type'] == 'inline' ? 'amazon_inline_item' : 'amazon_item';
              $element[$delta] = array('#markup' => theme($theme_function, array('item' => $item, 'style' => $display['type'])));
      }
    }
  }
  return $element;
}
?>

Granted with this alteration you can probably take out the second !empty check, but I didn't want to modify too far from committed code.

rfay’s picture

Status: Needs review » Active

No patch provided, so this is not "needs review"

It *sure* looks to me like the patch should be done in metatags_quick.

The formatter shouldn't be called here without any asins should it?

dave reid’s picture

Priority: Normal » Major

I think I actually have this narrowed down to a problem with the asin field's default formatter:

/**
 * Implementation of hook_field_info().
 */
function asin_field_info() {
  return array(
    'asin' => array(
      'label' => t('Amazon item'),
      'description' => t('Store the id of a product listed on Amazon.com.'),
      'default_widget' => 'asin_text',
      'default_formatter' => 'default',
    ),
  );
}

Note that 'default' is not prefixed *at all* in addition to the rest of the asin formatters named 'details', 'thumbnail', etc. The documentation for hook_field_formatter_info() clearly states: "An array describing the formatter types implemented by the module. The keys are formatter type names. To avoid name clashes, formatter type names should be prefixed with the name of the module that exposes them. The values are arrays describing the formatter type, with the following key/value pairs:"

dave reid’s picture

Title: Undefined index: asin in asin_field_formatter_view() (line 135 of *l/sites/all/modules/amazon/asin/asin. » Field formatters not properly prefixed with 'asin_'
dave reid’s picture

Status: Active » Needs review
StatusFileSize
new4.38 KB

Patch attached that prefixes all the formatter keys, and also updates any existing field instances.

dave reid’s picture

rfay’s picture

davereid is truly amazing.

How high is your confidence that this will deal successfully with existing installs?

dave reid’s picture

It's been tested with two different installs without any error. It would be good to ensure that the field formatter is unaffected though.

rfay’s picture

Status: Needs review » Fixed

Committed: 1217676

Thanks so much!

Status: Fixed » Closed (fixed)
Issue tags: -duplicate field_formatter

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