Thread: PHP Notices

Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2012
    Posts
    481
    Plugin Contributions
    0

    Default PHP Notices

    Does the development team want reports of PHP error notices for core files (except duplicate defines)? ZC v1.5.5f, PHP 7.1.18.

    Dave

  2. #2
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,845
    Plugin Contributions
    25

    Default Re: PHP Notices

    I love it when Zenners come up with the same ideas in just a few hours time difference. It's like we all share a common sense.
    I have made a few PR on GitHub regarding the same issue.
    see :https://github.com/zencart/zencart/pulls
    Quote Originally Posted by Dave224 View Post
    Does the development team want reports of PHP error notices for core files (except duplicate defines)? ZC v1.5.5f, PHP 7.1.18.

    Dave

  3. #3
    Join Date
    Jun 2012
    Posts
    481
    Plugin Contributions
    0

    Default Re: PHP Notices

    One PHP notice is:
    [30-Apr-2018 13:56:03 America/New_York] PHP Notice: Undefined offset: 1 in .../includes/functions/functions_email.php on line 135

    The associated code is:
    Code:
          // clean up currencies for text emails
          $zen_fix_currencies = preg_split("/[:,]/" , str_replace(' ', '', CURRENCIES_TRANSLATIONS));
          $size = sizeof($zen_fix_currencies);
          for ($i=0, $n=$size; $i<$n; $i+=2) {
            $zen_fix_current = $zen_fix_currencies[$i];
            $zen_fix_replace = $zen_fix_currencies[$i+1];
            if (strlen($zen_fix_current)>0) {
              while (strpos($email_text, $zen_fix_current)) $email_text = str_replace($zen_fix_current, $zen_fix_replace, $email_text);
            }
          }
    Line 135 is $zen_fix_replace = $zen_fix_currencies[$i+1];
    Looks like $zen_fix_currencies[1] is undefined. Couldn't find CURRENCIES_TRANSLATIONS defined either.

  4. #4
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,845
    Plugin Contributions
    25

    Default Re: PHP Notices

    CURRENCIES_TRANSLATIONS is a constant in the database in the configuration table

  5. #5
    Join Date
    Jun 2012
    Posts
    481
    Plugin Contributions
    0

    Default Re: PHP Notices

    Thank you Design75 for helping me find CURRENCIES_TRANSLATIONS. The problem with this error is that CURRENCIES_TRANSLATIONS can be blank like on my system that deals only with USD. Thus preg_split returns a single element array, the size is 1, so $zen_fix_currencies[1] is undefined.

  6. #6
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,845
    Plugin Contributions
    25

    Default Re: PHP Notices

    Yes, there are a lot of variables like that. Checks need to be build in to see if variables are set, or are of the correct/expected type, like array or string.
    Older php versions didn't care, so programming could be "sloppy", but newer versions get more tight, so now we get notices.
    To solve these, try to think of a way to check, and output a correct result.

 

 

Similar Threads

  1. Adding Notices
    By gsdcypher in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 21 Sep 2007, 03:27 PM
  2. cart vs expresscheckout in IPN notices
    By disciple in forum PayPal Express Checkout support
    Replies: 8
    Last Post: 1 Apr 2007, 06:54 PM
  3. Off Topic - Legal Notices
    By 3dfrog in forum General Questions
    Replies: 4
    Last Post: 14 Aug 2006, 07:33 PM

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