IMPORTANT - STOP DOUBLE EMAILS

Report issues with Enuuk Auction Platform or Mods here - remember to raise a ticket with phpauction.net as well
Post Reply
RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

IMPORTANT - STOP DOUBLE EMAILS

Post by RWAP » Tue Oct 23, 2012 7:49 pm

Similar to the previous topic on double charging, you can sometimes get double emails sent out when a listing is created, or for users watching a keyword (for example).

To overcome this, you need to make the change mentioned in the previous topic, and also:

In class\OfferObserver\KeywordObserver.php

Find:

Code: Select all

        if($subject->lastEvent ==  Offer::EVENT_NEW_SAVED){
Add below this:

Code: Select all

            $subject->lastEvent = null;
Then, in each of the classes within the folder: class\OfferMail\

Find:

Code: Select all

        switch($subject->lastEvent){
Change this to:

Code: Select all

        $event = $subject->lastEvent;
        $subject->lastEvent = null;
        switch($event){

DO NOT USE THIS CODE - SEE BELOW

RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Re: IMPORTANT - STOP DOUBLE EMAILS

Post by RWAP » Thu Nov 15, 2012 7:21 pm

I have found that in certain circumstances, this can prevent the keyword observer working - therefore to overcome this, REMOVE THE ABOVE CHANGE and instead, in class\Offer.php find:

Code: Select all

    public function notify()
    {
        if($this->observers){
            foreach($this->observers as $obs){
                $obs->update($this);
            }
        }
    }
and change this to:

Code: Select all

    public function notify()
    {
        if($this->observers){
            foreach($this->observers as $obs){
                $this->detach($obs); // Prevent double calling for offer
                $obs->update($this); 
            }
        }
        $this->lastEvent = null;
    }
Last edited by RWAP on Fri Nov 16, 2012 7:55 pm, edited 1 time in total.
Reason: Altered order of code

RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Re: IMPORTANT - STOP DOUBLE EMAILS

Post by RWAP » Fri Nov 16, 2012 12:39 pm

I found that 2 lots of emails were still being sent when the user does not have to pay fees for some reason....

I have now amended the suggested change above to rectify this issue also.

RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Re: IMPORTANT - STOP DOUBLE EMAILS

Post by RWAP » Fri Nov 16, 2012 7:54 pm

There are still some instances where this is happening - it could be as a result of a race between instances of PHP - I have therefore amended the code order slightly which seems to help

Any more ideas why this is happening?

RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Re: IMPORTANT - STOP DOUBLE EMAILS - FIXED IN V3.5

Post by RWAP » Mon Mar 16, 2015 10:34 pm

This appears to have been fixed in v3.5 thankfully

RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Re: IMPORTANT - STOP DOUBLE EMAILS - FIXED IN V3.5

Post by RWAP » Thu Apr 30, 2015 11:55 am

Actually, whether this is required appears to depend on the version of Linux, which is a real pain.

The change above is definitely required on Centos 5, but on Centos 7 stops the notification emails being sent out!

Another potential solution which appears to work on Centos 5 (at least - to be tested on Centos 7) is to change the notify function to read:

Code: Select all

    public function notify()
    {
        if ($this->observers) {
            foreach ($this->observers as $obs) {
                $obs->update($this);
            }
        }
        $this->observers = null;
    }

RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Re: IMPORTANT - STOP DOUBLE EMAILS

Post by RWAP » Sat May 23, 2015 8:36 pm

I have today come across another instance of this happening which is infuriating.

It was a popular auction which came to an end after attracting a lot of interest - unfortunately, the end of auction emails were sent out multiple times.

After much thought and investigation, I think the problem was that the seller left their browser open on the offer/fees page, and the browser was automatically refreshing that page which triggered the code into re-activating the listing albeit it briefly.

Answer is to add code to class\Action\Offer.php to the publishOffer() function

Code: Select all

if ($offer->active || strtotime($offer->endDate) < time() ) return false;
That prevents the publishoffer code re-running!

RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Re: IMPORTANT - STOP DOUBLE EMAILS

Post by RWAP » Tue Jun 02, 2015 6:18 pm

Another part of the issue is the code which handles the sale of a fixed price item, a buy now option and/or the last item in a LOT auction...

All of these trigger a EVENT_BID bid immediately followed by an EVENT_CLOSE

This breaks the suggested fixes above - the answer is to add a flag to notify() to tell it not to use $this->observers = null; in these circumstances.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest