Re: Use Of Notifiers - How To
Quote:
Originally Posted by
DrByte
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
Re: Use Of Notifiers - How To
Quote:
Originally Posted by
neekfenwick
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
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
Re: Use Of Notifiers - How To
Quote:
Originally Posted by
DrByte
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.
Quote:
Originally Posted by
DrByte
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.
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
Re: Use Of Notifiers - How To
Quote:
Originally Posted by
mesnitu
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?
Re: Use Of Notifiers - How To
Quote:
Originally Posted by
mc12345678
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
Re: Use Of Notifiers - How To
Quote:
Originally Posted by
mesnitu
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...
Re: Use Of Notifiers - How To
ok! thanks for the reply!