Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13
  1. #11
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Creating default object from empty value in modules/payment/authorizenet_aim.php

    Quote Originally Posted by lat9 View Post
    Actually, the following statement is the something that's between the function definition and the first usage.
    Code:
     $aimdata->fields = array();
    Since it's $aimdata->fields that's being assigned that empty array, that's where the issue arises because $aimdata is not an object. I do agree that the change could be simplified as follows to "prepare" for the use of that required handling:
    Code:
    function admin_notification($zf_order_id) {
        global $db;
        $output = '';
        $aimdata = new stdClass();
        $aimdata->fields = array();
        require(DIR_FS_CATALOG . DIR_WS_MODULES . 'payment/authorizenet/authorizenet_admin_notification.php');
        return $output;
      }
    We've said the same thing.

    Note: an if statement/conditional test was not used/needed before the first $aimdata-> and that the assignment within the previous if statement was still used/needed.

    Although no question was asked nor a statement directly made of not understanding the textual description, the following expanded and broken down information is provided. In my opinion likely to still be misunderstood, but please ask away about whatever is confusing or not understood or where I have possibly used incorrect terminology.

    Function declaration:
    Code:
    function admin_notification($zf_order_id)
    Parameter(s) (none are $aimdata):
    Code:
    $zf_order_id
    Global(s) (none include $aimdata):
    Code:
        global $db;
    First usage of $aimdata->:
    Code:
     $aimdata->fields = array();
    The code expected that contains the unnecessary if condition:
    Code:
    function admin_notification($zf_order_id) {
        global $db;
        $output = '';
        if (!isset($aimdata)) {
          $aimdata = new stdClass();
        }
        $aimdata->fields = array();
        require(DIR_FS_CATALOG . DIR_WS_MODULES . 'payment/authorizenet/authorizenet_admin_notification.php');
        return $output;
      }
    Considered unnecessary because the if statement evaluates like this all of the time:
    Code:
    function admin_notification($zf_order_id) {
        global $db;
        $output = '';
        if (true) {
          $aimdata = new stdClass();
        }
        $aimdata->fields = array();
        require(DIR_FS_CATALOG . DIR_WS_MODULES . 'payment/authorizenet/authorizenet_admin_notification.php');
        return $output;
      }
    And therefore could be written without the if statement as described previously in text, as provided above (ie lat9's post) and as DrByte indicated in the rework of ZC to elimate the error/improve the code.
    Code:
    function admin_notification($zf_order_id) {
        global $db;
        $output = '';
        $aimdata = new stdClass();
        $aimdata->fields = array();
        require(DIR_FS_CATALOG . DIR_WS_MODULES . 'payment/authorizenet/authorizenet_admin_notification.php');
        return $output;
      }
    Again though as discussed if there have been other edits to the code above the first use of $aimdata->, then the if statement may be necessary. But there has not been any indication of such. If there has been such an edit, it would be beneficial to know about so that one can evaluate whether the if statement is in fact necessary or not.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  2. #12
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,472
    Plugin Contributions
    88

    Default Re: Creating default object from empty value in modules/payment/authorizenet_aim.php

    We might have; I just said it a tad more succinctly.

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

    Default Re: Creating default object from empty value in modules/payment/authorizenet_aim.php

    It can be even simpler than that, since the $aimdata variable isn't actually used in the admin_notification file. Doh. Leftover code from back when we hoped AIM would provide it.

    v1.5.6 will have it removed: https://github.com/zencart/zencart/pull/1465/files -- you can make the same changes today, in any version of Zen Cart.
    .

    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.

 

 
Page 2 of 2 FirstFirst 12

Similar Threads

  1. v139h Warning: Creating default object from empty value in shipping_estimator.php
    By split63 in forum Built-in Shipping and Payment Modules
    Replies: 6
    Last Post: 30 Apr 2016, 08:00 PM
  2. v139h Creating default object from empty value (in shipping modules)
    By Phil S in forum General Questions
    Replies: 11
    Last Post: 6 Nov 2015, 06:46 AM
  3. Replies: 20
    Last Post: 7 Dec 2014, 11:29 AM
  4. Replies: 3
    Last Post: 26 Mar 2014, 07:35 PM
  5. Replies: 0
    Last Post: 27 Sep 2012, 11:57 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