Illegal string offset errors occur in functions_email if a string is passed to the function for the variable $block and the php version is greater than 5.4. The applicable code from about line 98 is:
Code:
//define some additional html message blocks available to templates, then build the html portion.
if (!isset($block['EMAIL_TO_NAME']) || $block['EMAIL_TO_NAME'] == '') $block['EMAIL_TO_NAME'] = $to_name;
if (!isset($block['EMAIL_TO_ADDRESS']) || $block['EMAIL_TO_ADDRESS'] == '') $block['EMAIL_TO_ADDRESS'] = $to_email_address;
if (!isset($block['EMAIL_SUBJECT']) || $block['EMAIL_SUBJECT'] == '') $block['EMAIL_SUBJECT'] = $email_subject;
if (!isset($block['EMAIL_FROM_NAME']) || $block['EMAIL_FROM_NAME'] == '') $block['EMAIL_FROM_NAME'] = $from_email_name;
if (!isset($block['EMAIL_FROM_ADDRESS']) || $block['EMAIL_FROM_ADDRESS'] == '') $block['EMAIL_FROM_ADDRESS'] = $from_email_address;
$email_html = (!is_array($block) && substr($block, 0, 6) == '<html>') ? $block : zen_build_html_email_from_template($module, $block);
if (!is_array($block) && $block == '' || $block == 'none') $email_html = '';
The last two lines process possible string values of 'none', '', and strings starting with '<html>', but the five if statements treat $block as an array variable. If a string is passed to the function, these five statements will cause an Illegal String Offset value for php greater than 5.4.
I discovered this problem integrating the Shipping by Quote addon into v1.5.5, which I had used in v1.5.1 successfully with php 5.3.x. This addon passes the string 'none' to the function.
Not only does the Illegal String Offset error occur, but also the email content is garbage if any recipient is a customer with html email preference.
One fix is to enclose the five if statements within an if (is_array($block)) construct, so only the last two lines of the above code are executed if $block is a string.
Bookmarks