Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2005
    Posts
    22
    Plugin Contributions
    0

    Default Custom observer class stopped working after upgrade to v1.5.5a

    I had a custom observer class in the following location that was doing some additional processing after a new customer signup:

    /includes/classes/observers/class.create_file_add_customer_record.php

    It is no longer working correctly after upgrading from 1.5.1 to 1.5.5a. The values I am looking for in the $paramsArray are coming back blank now:

    Code:
    class create_file_add_customer_record extends base {
    	
      function __construct() 
      {
        global $zco_notifier;
        $zco_notifier->attach($this, array('NOTIFY_MODULE_CREATE_ACCOUNT_ADDED_CUSTOMER_RECORD'));
      }
    
      function update(&$class, $eventID, $paramsArray = array())
      {
    	$_SESSION['cst_customers_firstname'] = $paramsArray['customers_firstname'];
    	$_SESSION['cst_customers_lastname'] = $paramsArray['customers_lastname'];
    	$_SESSION['cst_customers_email_address'] = $paramsArray['customers_email_address'];
    	
    	...
    Is there something that would have changed between these versions to make $paramsArray not work anymore, or is there something I should be looking for in another file that may have been overwritten?

    Other points to note:
    - Along with Zen Cart, I have also upgraded from PHP 5.3 to 5.6
    - I have other custom observer classes dealing with customer updates and order creation. These other classes are still working correctly, as far as I can tell.

    Thanks!

  2. #2
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Custom observer class stopped working after upgrade to v1.5.5a

    Do any of the other observers redirect to somewhere else? Do they load earlier than this one? (if not mistaken load first by the order of the invoking config file. (got transferred over did it?) and then alphabetically.)

    Something to take note of though is also the change in structure of the received array. To support better sanitization, the array has been modified to below as an array of arrays. Further interesting is that the customers_id which is merged into that array (read-only) does not include the sanitization. I plan to submit a pull request related to that.

    Code:
      $sql_data_array = array(array('fieldName'=>'customers_firstname', 'value'=>$firstname, 'type'=>'stringIgnoreNull'),
                               array('fieldName'=>'customers_lastname', 'value'=>$lastname, 'type'=>'stringIgnoreNull'),
                               array('fieldName'=>'customers_email_address', 'value'=>$email_address, 'type'=>'stringIgnoreNull'),
                               array('fieldName'=>'customers_nick', 'value'=>$nick, 'type'=>'stringIgnoreNull'),
                               array('fieldName'=>'customers_telephone', 'value'=>$telephone, 'type'=>'stringIgnoreNull'),
                               array('fieldName'=>'customers_fax', 'value'=>$fax, 'type'=>'stringIgnoreNull'),
                               array('fieldName'=>'customers_newsletter', 'value'=>$newsletter, 'type'=>'integer'),
                               array('fieldName'=>'customers_email_format', 'value'=>$email_format, 'type'=>'stringIgnoreNull'),
                               array('fieldName'=>'customers_default_address_id', 'value'=>0, 'type'=>'integer'),
                               array('fieldName'=>'customers_password', 'value'=>zen_encrypt_password($password), 'type'=>'stringIgnoreNull'),
                               array('fieldName'=>'customers_authorization', 'value'=>$customers_authorization, 'type'=>'integer'),
        );
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Jun 2005
    Posts
    22
    Plugin Contributions
    0

    Default Re: Custom observer class stopped working after upgrade to v1.5.5a

    Quote Originally Posted by mc12345678 View Post
    Do any of the other observers redirect to somewhere else? Do they load earlier than this one? (if not mistaken load first by the order of the invoking config file. (got transferred over did it?) and then alphabetically.)
    Are you referring to the files in /includes/auto_loaders ? It has been a couple years since I set this up, so I'm a little fuzzy on all the steps involved.

    I do have files in auto_loaders, for example, config.create_file_add_customer_record.php, which contains the following:

    Code:
    <?php
    $autoLoadConfig[190][] = array('autoType'=>'class',
                                  'loadFile'=>'observers/class.create_file_add_customer_record.php');
    $autoLoadConfig[190][] = array('autoType'=>'classInstantiate',
                                  'className'=>'create_file_add_customer_record',
                                  'objectName'=>'create_file_add_customer_record');
    The other files have higher-ordered numbers than 190.


    Quote Originally Posted by mc12345678 View Post
    Something to take note of though is also the change in structure of the received array. To support better sanitization, the array has been modified to below as an array of arrays. Further interesting is that the customers_id which is merged into that array (read-only) does not include the sanitization. I plan to submit a pull request related to that.

    Code:
      $sql_data_array = array(array('fieldName'=>'customers_firstname', 'value'=>$firstname, 'type'=>'stringIgnoreNull'),
                               array('fieldName'=>'customers_lastname', 'value'=>$lastname, 'type'=>'stringIgnoreNull'),
                               array('fieldName'=>'customers_email_address', 'value'=>$email_address, 'type'=>'stringIgnoreNull'),
                               array('fieldName'=>'customers_nick', 'value'=>$nick, 'type'=>'stringIgnoreNull'),
                               array('fieldName'=>'customers_telephone', 'value'=>$telephone, 'type'=>'stringIgnoreNull'),
                               array('fieldName'=>'customers_fax', 'value'=>$fax, 'type'=>'stringIgnoreNull'),
                               array('fieldName'=>'customers_newsletter', 'value'=>$newsletter, 'type'=>'integer'),
                               array('fieldName'=>'customers_email_format', 'value'=>$email_format, 'type'=>'stringIgnoreNull'),
                               array('fieldName'=>'customers_default_address_id', 'value'=>0, 'type'=>'integer'),
                               array('fieldName'=>'customers_password', 'value'=>zen_encrypt_password($password), 'type'=>'stringIgnoreNull'),
                               array('fieldName'=>'customers_authorization', 'value'=>$customers_authorization, 'type'=>'integer'),
        );
    Does this mean I should be referencing the values in $paramsArray in a different format?

    Thanks for your help so far.

  4. #4
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Custom observer class stopped working after upgrade to v1.5.5a

    Regarding the auto_loaders, yes, that was to what I was referring, though in part should have been able to realize that it was present based on "testing" the paramsarray. Though not sure what the test was, because a print_r of the array should have identified the modified structure of the array. Back in ZC 1.5.4 for example the array could have been generated like below:

    Code:
     $sql_data_array = array('customers_firstname' => $firstname,
                                'customers_lastname' => $lastname,
                                'customers_email_address' => $email_address,
                                'customers_nick' => $nick,
                                'customers_telephone' => $telephone,
                                'customers_fax' => $fax,
                                'customers_newsletter' => (int)$newsletter,
                                'customers_email_format' => $email_format,
                                'customers_default_address_id' => 0,
                                'customers_password' => zen_encrypt_password($password),
                                'customers_authorization' => (int)CUSTOMERS_APPROVAL_AUTHORIZATION
    (though I may have missed copying a portion of the array, sorry)

    So yes, if you are/were directly accessing the data in the array, that access has changed a little. As it currently stands though the customer_id is still "structured" the same as it was. It is this maintained structure to which I was referring to look incorrect in the larger scheme unless one uses the remaining sql_data_array information through some form of ZC handler when the customer_id is known/also used. Off the top of my head I don't know of such a handler, but doesn't mean it doesn't exist. :)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Jun 2005
    Posts
    22
    Plugin Contributions
    0

    Default Re: Custom observer class stopped working after upgrade to v1.5.5a

    Ok, that makes sense, thanks.

    My testing consisted of print_r of the _SESSION and seeing that nothing was being written from the array to the session object as expected.

    I'll take a look at the array itself and see what accessors I need to change.

    Thanks

  6. #6
    Join Date
    Jan 2004
    Posts
    66,450
    Plugin Contributions
    81

    Default Re: Custom observer class stopped working after upgrade to v1.5.5a

    Ya, you'll need to "loop through" the entries in the $paramsArray in order to access individual entries in that particular case.
    .
    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.

  7. #7
    Join Date
    Jun 2005
    Posts
    22
    Plugin Contributions
    0

    Default Re: Custom observer class stopped working after upgrade to v1.5.5a

    I got it working now, thanks!

  8. #8
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Custom observer class stopped working after upgrade to v1.5.5a

    Quote Originally Posted by d9000 View Post
    I got it working now, thanks!
    Glad you did. BTW, for future development related things, there is a plugin called super globals that would/could help with Session related data instead of print_r. It's not a fix for every situation/condition, but it does offer a lot of information and ability to set/track some things like you were trying. :)

    All the same, again, glad you were able to work out a solution. Happy Zenning.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. setting $_SESSION variables in an Observer Class
    By tcarden in forum Contribution-Writing Guidelines
    Replies: 1
    Last Post: 13 Feb 2013, 06:37 AM
  2. tax class suddenly stopped working
    By rackcrew in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 0
    Last Post: 20 May 2010, 03:33 AM
  3. Payment method radio buttons stopped working after adding custom fields
    By sparklefish in forum Addon Payment Modules
    Replies: 5
    Last Post: 9 Mar 2009, 05:56 PM
  4. session objects in the observer class
    By wdrwc in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 18 Jul 2006, 06:48 PM
  5. session objects in the observer class
    By wdrwc in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 18 Jul 2006, 11:19 AM

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