However, I am having a problem with the code:
Code: Select all
/**
* Attach a Observer to Offer
* @param SplObserver $obs Observer instance
*
* return void
*/
public function attach(SplObserver $obs)
{
$id = spl_object_hash($obs);
$this->observers[$id] = $obs;
}
/**
* Remove a Observer to Offer
* @param SplObserver $obs Observer instance
*
* @return void
*/
public function detach(SplObserver $obs)
{
$id = spl_object_hash($obs);
unset($this->observers[$id]);
}
/**
* Notify attached Observer
*/
public function notify()
{
if ($this->observers) {
foreach ($this->observers as $obs) {
$this->detach($obs);
$obs->update($this);
}
}
$this->lastEvent = null;
}
public function prepareCommonObservers(MyPDO $DB, Core_Context $context, $extraInfo=null)
{
//Mails
require_once ('class/contrib/phpmailer/class.phpmailer.php');
$notificator = new MailNotificator(new PHPMailer(),new FileReader(),$context);
$mailObs = OfferObserver_OfferMail::getInstance($this->type(), $context, $notificator, $DB);
$mailObs->extraInfo=$extraInfo;
$this->attach($mailObs);
//Business Listing Limits
$keyObs = new OfferObserver_BusinessLimitObserver($context, $notificator, $DB);
$this->attach($keyObs);
//Keywords
$keyObs = new OfferObserver_KeywordObserver($context, $notificator, $DB);
$this->attach($keyObs);
//Banned Words
$bannedWordObs = new OfferObserver_BannedWordsObserver($DB);
$this->attach($bannedWordObs);
//Final value fee
if ($this->item->user->businessSeller) {
$finalFee = BusinessFee::getInstanceFromDB($DB, 'offer/finalValue', $this->originalSiteId, $context->siteOptions['currentChargeStructure']);
} else {
$finalFee = Fee::getInstanceFromDB($DB, 'offer/finalValue', $this->originalSiteId, $context->siteOptions['currentChargeStructure']);
}
if ($finalFee->active) {
$finalValueObs = new OfferObserver_FinalValueFeeObserver($context, $notificator, $DB);
$this->attach($finalValueObs);
}
//Auction Item queue
$itemQueueObs = new OfferObserver_AuctionQueue($DB);
$this->attach($itemQueueObs);
}
Code: Select all
public function notify()
{
if ($this->observers) {
foreach ($this->observers as $obs) {
$obs->update($this);
}
}
}
Code: Select all
public function notify()
{
if ($this->observers) {
foreach ($this->observers as $obs) {
$this->detach($obs);
$obs->update($this);
}
}
$this->lastEvent = null;
}
However, on another site running on Centos 7 (PHP 5.6), I have to revert to the original function, otherwise emails are not sent out...
Any suggestions as to what may be happening?