Page 4 of 4 FirstFirst ... 234
Results 31 to 38 of 38
  1. #31
    Join Date
    Feb 2009
    Posts
    88
    Plugin Contributions
    1

    Default Re: Use Of Notifiers - How To

    Quote Originally Posted by DrByte View Post
    A number of things were addresed with respect to notifiers in v1.3.9. Have you tested the same thing in the latest version of Zen Cart yet?
    Sorry, I hadn't tried it, and should have before posting.

    I'm not sure I'll have time or willpower to look at completely upgrading this 1.3.8a to 1.3.9. This shop has been installed for 4 or 5 years and has had some quite extensive hacking done to it before I started work on it, so even where the override system was followed, the job of merging the hacks into the 1.3.9 file base seems insurmountable.

    However, I'm happy to code against the 1.3.9 model.. I just need the same code to work on my 1.3.8a shop.

    I was hoping to determine what's wrong with this 1.3.8a installation, in terms of how the code is going wrong, and fix it up. The other Zen Cart I will be migrating the same code to is a much more recent one and hopefully won't suffer from this bug. Diff shows some fairly simple modifications to class.base.php, some kind of StaticObserver code that looks like it fixes the problem I identified above. It looks like there is now a single static array of observer info, which stores references to all the different 'base'-derived objects that registered for notifications.

    I wonder if I'll be safe just taking the 1.3.9f class.base.php and using it in a 1.3.8a Zen Cart? it looks pretty safe :) I'll try it soon.

    Thanks
    Nick

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

    Default Re: Use Of Notifiers - How To

    Quote Originally Posted by neekfenwick View Post
    I'm not sure I'll have time or willpower to look at completely upgrading this 1.3.8a to 1.3.9. This shop has been installed for 4 or 5 years and has had some quite extensive hacking done to it before I started work on it, so even where the override system was followed, the job of merging the hacks into the 1.3.9 file base seems insurmountable.
    If you're comfortable keeping up a site that's using software with known security vulnerabilities, then that's your call I guess.

    Quote Originally Posted by neekfenwick View Post
    I was hoping to determine what's wrong with this 1.3.8a installation, in terms of how the code is going wrong, and fix it up.
    ...
    I wonder if I'll be safe just taking the 1.3.9f class.base.php and using it in a 1.3.8a Zen Cart?
    http://www.zen-cart.com/forum/showthread.php?t=150127
    .

    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. #33
    Join Date
    Feb 2009
    Posts
    88
    Plugin Contributions
    1

    Default Re: Use Of Notifiers - How To

    Quote Originally Posted by DrByte View Post
    If you're comfortable keeping up a site that's using software with known security vulnerabilities, then that's your call I guess.
    Fair point. I've applied the applicable security patches over the past two years, and will rename my admin directory .. I think I'm keeping up with security concerns.

    Wonderful.. shame I didn't see that thread before. I've changed my class.base.php and everything seems to be working well. It's very refreshing working with notifiers and not having to hack core code! :) I'm having to re-write some of my work to make it work in this new way, but I'm sure I'll be left with a cleaner, better, shinier final product.

    A clarification on http://www.zen-cart.com/wiki/index.p...er_is_watching would be nice, to make it clear why 1.3.8 code had to use $_SESSION['cart']->attach instead of $this->attach, referencing the changed base class implementation. I don't seem to be able to create a user account to edit the wiki.

    Thanks again.

  4. #34
    Join Date
    Aug 2014
    Location
    Lisbon
    Posts
    594
    Plugin Contributions
    0

    Default Re: Use Of Notifiers - How To

    Auto load notifier:
    I had this working loading the config. and init_ files. But since init_canonical it loaded at point 161 and this autoload at 175, would be 2 less files.
    However, I'm not getting this right.
    I've also tried to use function updateNotifyInitCanonicalParamWhitelist(&$class, $eventID,$paramsArray = array()), but that would be for the update function (?)


    two more files , two less files is not the issue, but I would like to understand how this works.

    PHP Code:
    class zcObserverBookxCanonical extends base
    {

        public function 
    __construct()
        {
            
            
    $this->attach($this, array(
                
    'NOTIFY_INIT_CANONICAL_PARAM_WHITELIST',
                
    'NOTIFY_INIT_CANONICAL_DEFAULT'));  
        }
       

        
    //$zco_notifier->notify ('NOTIFY_INIT_CANONICAL_PARAM_WHITELIST', $current_page, $excludeParams, $keepableParams, $includeCPath);
          
        
    function updateNotifyInitCanonicalParamWhitelist(&$class$eventID$current_page, &$excludeParams, &$keepableParams$includeCPath)
        {
            
            global 
    $keepableParams// ??
            
    pr($keepableParams'$paramsArray');
            
    $keepableParams[] = 'bookx_publisher_id';
            
    $keepableParams[] = 'bookx_genre_id';
            
    $keepableParams[] = 'bookx_author_id';
            
    $keepableParams[] = 'bookx_author_type_id';
            
    $keepableParams[] = 'bookx_author_type_id';
            
    $keepableParams[] = 'bookx_imprint_id';
            
    $keepableParams[] = 'bookx_series_id';
        } 
    thanks
    “Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

  5. #35
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Use Of Notifiers - How To

    Quote Originally Posted by mesnitu View Post
    Auto load notifier:
    I had this working loading the config. and init_ files. But since init_canonical it loaded at point 161 and this autoload at 175, would be 2 less files.
    However, I'm not getting this right.
    I've also tried to use function updateNotifyInitCanonicalParamWhitelist(&$class, $eventID,$paramsArray = array()), but that would be for the update function (?)


    two more files , two less files is not the issue, but I would like to understand how this works.

    PHP Code:
    class zcObserverBookxCanonical extends base
    {

        public function 
    __construct()
        {
            
            
    $this->attach($this, array(
                
    'NOTIFY_INIT_CANONICAL_PARAM_WHITELIST',
                
    'NOTIFY_INIT_CANONICAL_DEFAULT'));  
        }
       

        
    //$zco_notifier->notify ('NOTIFY_INIT_CANONICAL_PARAM_WHITELIST', $current_page, $excludeParams, $keepableParams, $includeCPath);
          
        
    function updateNotifyInitCanonicalParamWhitelist(&$class$eventID$current_page, &$excludeParams, &$keepableParams$includeCPath)
        {
            
            global 
    $keepableParams// ??
            
    pr($keepableParams'$paramsArray');
            
    $keepableParams[] = 'bookx_publisher_id';
            
    $keepableParams[] = 'bookx_genre_id';
            
    $keepableParams[] = 'bookx_author_id';
            
    $keepableParams[] = 'bookx_author_type_id';
            
    $keepableParams[] = 'bookx_author_type_id';
            
    $keepableParams[] = 'bookx_imprint_id';
            
    $keepableParams[] = 'bookx_series_id';
        } 
    thanks
    Couple of things. For your observer to trigger, it needs to be loaded into the workspace before the notifier that would trigger it. So, if your notifier is triggered at load point 161, then somehow your observer needs to be loaded before then. It could possibly loaded at load point 161 if it can be brought in before the core code's loading of the asociated file. Better to just pick something convenient before then and give yourself some expansion room.

    Then because the variable keepableParams is passed as an editable variable, it is not needed to bring the same variable from the global space at least for ZC 1.5.3 and higher. There are some other things that would need to be done to populate that variable in the parameter list if working with an older version of ZC.

    Besides that I assume the function pr is some debug utility that has been added allowing you to retrieve the specified data?
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  6. #36
    Join Date
    Aug 2014
    Location
    Lisbon
    Posts
    594
    Plugin Contributions
    0

    Default Re: Use Of Notifiers - How To

    Quote Originally Posted by mc12345678 View Post
    Couple of things. For your observer to trigger, it needs to be loaded into the workspace before the notifier that would trigger it. So, if your notifier is triggered at load point 161
    So, in this case is not going to work ( if I'm understanding right)
    Canonical is loaded at 161
    /**
    * point 161 was selected specifically based on dependancies
    */

    From the init_observers.php:

    * This fires at AutoLoader point 175, so all previously-processed system dependencies are in place.
    * If you need an observer class to fire at a much earlier point so it fires before other system processes, you'll need to add your own auto_loaders/config.yyyyy.php file with relevant rules to load those observers.

    ps: yes, ignore de pr
    “Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

  7. #37
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Use Of Notifiers - How To

    Quote Originally Posted by mesnitu View Post
    So, in this case is not going to work ( if I'm understanding right)
    Canonical is loaded at 161
    /**
    * point 161 was selected specifically based on dependancies
    */

    From the init_observers.php:

    * This fires at AutoLoader point 175, so all previously-processed system dependencies are in place.
    * If you need an observer class to fire at a much earlier point so it fires before other system processes, you'll need to add your own auto_loaders/config.yyyyy.php file with relevant rules to load those observers.

    ps: yes, ignore de pr
    You are correct, you will need to add an includes/init_includes file that loads your observer before 161 and not be able to use the auto load observer when working with a default ZC store. There are examples in that directory that you could use as a template.

    If you only need one of the notifiers to be picked up early you could split the two from the file. If they need to interact with each other then it may make sense for them both to be loaded early, etc...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  8. #38
    Join Date
    Aug 2014
    Location
    Lisbon
    Posts
    594
    Plugin Contributions
    0

    Default Re: Use Of Notifiers - How To

    ok! thanks for the reply!
    “Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

 

 
Page 4 of 4 FirstFirst ... 234

Similar Threads

  1. Can I use notifiers to assist during product edits/updates?
    By vukan71 in forum General Questions
    Replies: 4
    Last Post: 6 Aug 2012, 04:59 PM
  2. How can I use Multiple mods that use same files?
    By sfklaas in forum General Questions
    Replies: 1
    Last Post: 8 May 2009, 10:27 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