Results 1 to 5 of 5
  1. #1
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,289
    Plugin Contributions
    22

    Default Fedex php error warning

    This happens on php 7.1. I contacted the firm who supports this module but they wanted me to pay for them to fix their dang bug.

    [16-Dec-2020 20:39:04 UTC] PHP Warning: key() expects parameter 1 to be array, null given in /home/xxxxx/public_html/xxxxx.com/includes/modules/shipping/fedexwebservices.php on line 723

    Line 723 is
    PHP Code:
     if(key($discount) <= $order->info['total']) {
                        
    $final_discount $discount;
                        continue;
                      } 
    I commented out the entire section
    PHP Code:
        //find largest discount that applies
                   
    ksort($discounts);
                    while(
    count($discounts) > 0) {
                      
    $discount array_pop($discounts);
                      if(
    key($discount) <= $order->info['total']) {
                        
    $final_discount $discount;
                        continue;
                      }
                    } 
    But the error happens anyway.

    Anyone else seen this? It's not an issue except that some services are just creating log file after log file. It does not seem to impact the functioning of the module but maybe it is and we don't realize it.
    The full-time Zen Cart Guru. WizTech4ZC.com

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

    Default Re: Fedex php error warning

    Is that this module? https://www.zen-cart.com/downloads.php?do=file&id=1784

    ... cuz I don't see any code in its /includes/modules/shipping/fedexwebservices.php file that looks anything like what you posted, let alone around line 723, and nothing about discounts.

    I don't understand why they're using a while-count-pop-key-continue loop instead of a simple foreach loop. But it's unclear what $discounts is supposed to contain (whether it's an array with custom keys, or just a set of one-dimensional values). Seeing how it is determined would be helpful. If it's a db query result or an api response result, then seeing actual data would be helpful, such as calling "die(print_r($discounts, true));" before the ksort line.
    .

    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.

  3. #3
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,289
    Plugin Contributions
    22

    Default Re: Fedex php error warning

    They no longer upload updates here. So yes, correct module. Not the recent version. I used to add updated versions like this here on zen cart but that brings questions directly to me I can’t answer. I’m thinking there’s more that needs fixing. They do not rely on in house coders by the way.
    The full-time Zen Cart Guru. WizTech4ZC.com

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

    Default Re: Fedex php error warning

    I'm certain there's a much better way to write it, but there's not enough code provided here to investigate.
    And yes I'd definitely call it a bug that they haven't accounted for.

    You can put a bandage on it by changing like this:
    Code:
    if($discount !== null && key($discount) <= $order->info['total']) {
    .

    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.

  5. #5
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,289
    Plugin Contributions
    22

    Default Re: Fedex php error warning

    well either I did that wrong or it didn't work. So dang frustrating but still not major on this particular site as it's low traffic. I wonder how many high traffic sites are using this and not even realizing they have an issue. Responsible coding is all I ask of anyone.
    The full-time Zen Cart Guru. WizTech4ZC.com

 

 

Similar Threads

  1. v157 FedEx Module Version 1.5.4, PHP Warning and Deprecated error in logs
    By Mattie C in forum Addon Shipping Modules
    Replies: 3
    Last Post: 12 Aug 2020, 11:58 PM
  2. v151 PHP warning error on Send Email to Customers
    By sports guy in forum General Questions
    Replies: 7
    Last Post: 17 May 2013, 02:06 AM
  3. Warning:require(includes/application_top.php) error
    By Lurkzilla in forum Installing on a Linux/Unix Server
    Replies: 1
    Last Post: 25 Aug 2010, 06:00 PM
  4. PHP Warning error
    By bugmenot in forum General Questions
    Replies: 2
    Last Post: 21 Feb 2008, 07:42 PM
  5. php warning and SQL syntax error [1.3.5]
    By helmetman in forum Bug Reports
    Replies: 4
    Last Post: 15 Oct 2006, 04:44 AM

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