Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2012
    Posts
    406
    Plugin Contributions
    0

    Default [Done v160] Illegal String Offset Errors in functions_email

    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.

  2. #2
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Illegal String Offset Errors in functions_email

    Good catch on that seldom-used approach.

    Here's how I plan to fix it for v1.6.0: https://github.com/zencart/zencart/pull/1151
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. v151 [Done v1.5.5] PHP 5.4 warnings: Illegal string offset
    By lat9 in forum Bug Reports
    Replies: 38
    Last Post: 28 Dec 2015, 11:13 PM
  2. Illegal string offset 'id' in order.php
    By marcopolo in forum General Questions
    Replies: 16
    Last Post: 25 Jul 2015, 04:31 PM
  3. v153 Illegal string offset 'id' in order.php
    By jeking in forum General Questions
    Replies: 0
    Last Post: 5 Sep 2014, 07:32 PM
  4. v151 PHP Warning: Illegal string offset 'id'
    By Nettric in forum Bug Reports
    Replies: 3
    Last Post: 30 May 2014, 06:53 AM
  5. Replies: 1
    Last Post: 30 Sep 2013, 07:39 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR