Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 2019
    Posts
    242
    Plugin Contributions
    0

    Default PHP Warning Parameter must be an array or an object that implements Countable

    [01-Oct-2020 11:41:41 America/Boise] Request URI: /test/index.php?main_page=checkout_process,
    #1 sizeof() called at [/public_html/test/includes/classes/order_total.php:66]
    #2 order_total->process() called at [/public_html/test/includes/modules/checkout_process.php:83]
    #3 require(/public_html/test/includes/modules/checkout_process.php) called at [/public_html/test/includes/modules/pages/checkout_process/header_php.php:14]
    #4 require(/public_html/test/includes/modules/pages/checkout_process/header_php.php) called at [/public_html/test/index.php:35]
    --> PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in /public_html/test/includes/classes/order_total.php on line 66.


    [01-Oct-2020 11:41:40 America/Boise] Request URI: /test/ipn_main_handler.php?type=ec&token=EC-5GK6XXXX
    #1 sizeof() called at [/public_html/test/includes/classes/order_total.php:66]
    #2 order_total->process() called at [/public_html/test/includes/modules/payment/paypalwpp.php:2813]
    #3 paypalwpp->terminateEC() called at [/public_html/test/includes/modules/payment/paypalwpp.php:2083]
    #4 paypalwpp->ec_step2_finish() called at [/public_html/test/includes/modules/payment/paypalwpp.php:1900]
    #5 paypalwpp->ec_step2() called at [/public_html/test/ipn_main_handler.php:80]
    --> PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in /public_html/test/includes/classes/order_total.php on line 66.


    ZC: 157 PHP 7.2

    I tried to place two test orders via PayPal express checkout and PayPal pro and I got some error warning logs. Line 66 in order_total.php is the following:
    Code:
    function process() {
        global $order;
        $order_total_array = array();
        if (is_array($this->modules)) {
          foreach($this->modules as $value) {
            $class = substr($value, 0, strrpos($value, '.'));
            if (!isset($GLOBALS[$class])) continue;
            $GLOBALS[$class]->process();
            //line 66
            for ($i=0, $n=sizeof($GLOBALS[$class]->output); $i<$n; $i++) {
              if (zen_not_null($GLOBALS[$class]->output[$i]['title']) && zen_not_null($GLOBALS[$class]->output[$i]['text'])) {
                $order_total_array[] = array('code' => $GLOBALS[$class]->code,
                                             'title' => $GLOBALS[$class]->output[$i]['title'],
                                             'text' => $GLOBALS[$class]->output[$i]['text'],
                                             'value' => $GLOBALS[$class]->output[$i]['value'],
                                             'sort_order' => $GLOBALS[$class]->sort_order);
    Did anyone have similar issues for PayPal checkout?

  2. #2
    Join Date
    Apr 2019
    Posts
    242
    Plugin Contributions
    0

    Default Re: PHP Warning Parameter must be an array or an object that implements Countable

    One note, my server database is upgraded from 139. It looks like my paypal settings in database are still good for 157, and I haven't changed any PayPal settings.

    Both test orders & payments are received correctly.

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

    Default Re: PHP Warning Parameter must be an array or an object that implements Countable

    What non-original Order Total modules do you have added to your store? (eg: the problem is likely in there, where it's not returning expected results)

    Does the same problem happen when completing an order using the MoneyOrder module? or a non-PayPal module?
    .

    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.

  4. #4
    Join Date
    Apr 2019
    Posts
    242
    Plugin Contributions
    0

    Default Re: PHP Warning Parameter must be an array or an object that implements Countable

    Thanks for your help.

    In 157, I haven't installed Order Total module by myself. I think it should come from ZC directly?

    I installed local sales tax 2.5.3a module in 157, but it doesn't change order_total.php file...

    In my original 139, I installed superorder plug-in. When I upgraded my database to 157, I have run sql codes to remove superorder plug-in from the database. Unsure it is related or not...

    I tried to check out with the payment of money order, no new log file is generated.

  5. #5
    Join Date
    Apr 2019
    Posts
    242
    Plugin Contributions
    0

    Default Re: PHP Warning Parameter must be an array or an object that implements Countable

    Another note. Actually I received four log files after two test orders. Two are above, regarding the sizeof() warning. Another two are Error while sending QUERY packet. See below:

    #1 mysqli_query() called at [/public_html/test/includes/classes/db/mysql/query_factory.php:44]
    #2 queryFactory->query() called at [/public_html/test/includes/classes/db/mysql/query_factory.php:260]
    #3 queryFactory->Execute() called at [/public_html/test/includes/functions/sessions.php:77]
    #4 _sess_write()
    #5 session_write_close() called at [/public_html/test/includes/functions/functions_general.php:41]
    #6 zen_redirect() called at [/public_html/test/includes/modules/pages/contact_us/header_php.php:98]
    #7 require(/public_html/test/includes/modules/pages/contact_us/header_php.php) called at [/public_html/test/index.php:35]
    --> PHP Warning: Error while sending QUERY packet. PID=879489 in /public_html/test/includes/classes/db/mysql/query_factory.php on line 44.

    I did some research and it looks like this error is on server side, not ZC side. I'm not sure if it is related to issue above.

  6. #6
    Join Date
    Apr 2019
    Posts
    242
    Plugin Contributions
    0

    Default Re: PHP Warning Parameter must be an array or an object that implements Countable

    2nd update. I downgraded my php to 7.1 and no more warning log files.

    All test orders are shipped to international location, so local sales tax module should not be used...

    Unfortunately, my server provider will only support php 7.2 or higher in about two weeks from now...
    Last edited by njcyx; 1 Oct 2020 at 09:54 PM.

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

    Default Re: PHP Warning Parameter must be an array or an object that implements Countable

    The sizeof() warnings are warnings. Not fatal errors. Their presence does not always mean anything is actually going "wrong". Perhaps just something not fully upgraded to work with the newer PHP version.

    The Warning about "Error while sending QUERY packet" does sound like something to be concerned about. The error message suggests it was happening when trying to end a session after using the contact_us form. Given that the contact_us form only sends an email and doesn't store anything critical to the database it's likely that no fatal problem is occurring there. But yes if it continues in other places then it does strongly suggest something wrong with the server's database stability.

    In your earlier post you said orders are occurring and saving fine. So I'm guessing you're just "worried about warnings being present in the logs".

    As to your claim that "the local sales tax module should not...", actually its very presence could very well be what's causing your "sizeof()" warnings, if indeed it is not up-to-date for PHP 7.2+ and for Zen Cart 1.5.7+. When a module's files are present and the module enabled in the store, it always returns a response of some sort, and that requires "running its code", and if the code is not compatible with your current PHP version it will not perform as required and thus there can be a domino effect cascading to other parts of the code, which is what appears to be happening in the order_total.php class file, which is processing ALL of your order_total modules, including local_sales_tax ... and everything else you've added.
    .

    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.

  8. #8
    Join Date
    Apr 2019
    Posts
    242
    Plugin Contributions
    0

    Default Re: PHP Warning Parameter must be an array or an object that implements Countable

    Quote Originally Posted by DrByte View Post
    The sizeof() warnings are warnings. Not fatal errors. Their presence does not always mean anything is actually going "wrong". Perhaps just something not fully upgraded to work with the newer PHP version.

    The Warning about "Error while sending QUERY packet" does sound like something to be concerned about. The error message suggests it was happening when trying to end a session after using the contact_us form. Given that the contact_us form only sends an email and doesn't store anything critical to the database it's likely that no fatal problem is occurring there. But yes if it continues in other places then it does strongly suggest something wrong with the server's database stability.

    In your earlier post you said orders are occurring and saving fine. So I'm guessing you're just "worried about warnings being present in the logs".

    As to your claim that "the local sales tax module should not...", actually its very presence could very well be what's causing your "sizeof()" warnings, if indeed it is not up-to-date for PHP 7.2+ and for Zen Cart 1.5.7+. When a module's files are present and the module enabled in the store, it always returns a response of some sort, and that requires "running its code", and if the code is not compatible with your current PHP version it will not perform as required and thus there can be a domino effect cascading to other parts of the code, which is what appears to be happening in the order_total.php class file, which is processing ALL of your order_total modules, including local_sales_tax ... and everything else you've added.
    Thanks for your detailed reply again. Yes, I just concerned about the generated log files. If every order generates one log file, we may need to clean our log folder every week. Is there anyway I can disable log function?

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

    Default Re: PHP Warning Parameter must be an array or an object that implements Countable

    Quote Originally Posted by njcyx View Post
    Is there anyway I can disable log function?
    Don't do that.

    Do pay attention to resolving the logs. That requires fixing the outdated code you have.
    .

    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.

  10. #10
    Join Date
    Apr 2019
    Posts
    242
    Plugin Contributions
    0

    Default Re: PHP Warning Parameter must be an array or an object that implements Countable

    Quote Originally Posted by DrByte View Post
    Don't do that.

    Do pay attention to resolving the logs. That requires fixing the outdated code you have.
    Unfornatley, I'm not professional developer, and it is beyond my ability to inspect the code and fix this sizeof() warning. I don't think there will be any updates for local sales tax code in the nearly future...

    Also I'm not quite sure this warning is related to this plug-in anyway. Because if I checked out by check/money order, there is no warning log generated. I suspect this warning could also be related to PayPal plug-in.

    Thanks for your help on this case. Appreciated.
    Last edited by njcyx; 2 Oct 2020 at 05:57 PM.

 

 

Similar Threads

  1. Replies: 36
    Last Post: 26 Sep 2020, 10:13 PM
  2. Replies: 3
    Last Post: 24 Dec 2019, 08:16 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