The following error is generated on servers using PHP version 5.3 or lower when using a Flickr Photo field on a node.

Notice: Uninitialized string offset: 0 in flickr_img() (line 320 of /myDrupalSite/sites/all/modules/contrib/flickr/flickr.inc).

On servers using PHP version 5.4 and higher, this error does not occur. After searching a bit, I've found this in regards to differences in the offset handling for php and believe this is the cause of the issue:

http://php.net/manual/en/migration54.incompatible.php

Non-numeric string offsets - e.g. $a['foo'] where $a is a string - now return false on isset() and true on empty(), and produce a E_WARNING if you try to use them. Offsets of types double, bool and null produce a E_NOTICE. Numeric strings (e.g. $a['2']) still work as before. Note that offsets like '12.3' and '5 foobar' are considered non-numeric and produce a E_WARNING, but are converted to 12 and 5 respectively, for backward compatibility reasons. Note: Following code returns different result. $str='abc';var_dump(isset($str['x'])); // false for PHP 5.4 or later, but true for 5.3 or less

To re-create simply add the Flickr Photo field to any content type. Create new content selecting Item Type "photo", Fill in the Item id and User Id fields, and save. When you view the page you will see the error.

Note: This issue was first reported (along with other items) in my issue on this page: https://www.drupal.org/node/2493597

Comments

ladybug_3777’s picture

In case it helps, these are the exact versions of PHP I am using:

The server that is not showing the error has PHP version 5.4.6.
The server that is showing the error is PHP version 5.3.5

lolandese’s picture

You pinpointed the cause already. Nice.

Can you do some experiments? Enable Devel and replace:

$date_taken = isset($info['dates']['taken']) ? $info['dates']['taken'] : $photo['dates']['taken'];
with

    dsm($info);
    dsm($photo);
    $date_taken = isset($photo['dates']['taken']) ? $photo['dates']['taken'] : $info['dates']['taken'];

or

    dsm($info);
    dsm($photo);
        $date_taken = !empty($info['dates']['taken']) ? $info['dates']['taken'] : $photo['dates']['taken'];
lolandese’s picture

Forget #2 and try to replace line 320 of myDrupalSite/sites/all/modules/contrib/flickr/flickr.inc with:
$date_taken = is_array($info) && isset($info['dates']['taken']) ? $info['dates']['taken'] : $photo['dates']['taken'];
or
$date_taken = is_array($info['dates']) && isset($info['dates']['taken']) ? $info['dates']['taken'] : $photo['dates']['taken'];

See http://stackoverflow.com/a/15368076/523688.

ladybug_3777’s picture

Sorry was away on the holiday weekend. I will give this a try for you today and report back.

ladybug_3777’s picture

StatusFileSize
new690 bytes

Ok, I tried your first suggestion (on comment #3) and that worked great on both versions of PHP. The second option produced an error.

If that's the only spot that needs to be fixed up then you can use the attached patch. Thanks!

lolandese’s picture

Status: Active » Fixed

Nice you tested in both versions of PHP.

Thanks.

lolandese’s picture

Version: 7.x-1.7 » 7.x-1.x-dev

Status: Fixed » Closed (fixed)

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