• Resolved ressel

    (@ressel)


    Hello,

    I offer hosting to one of my clients, and last week we upgraded his webserver from Debian Squeeze to Wheezy (php 5.3 to php 5.4) and mysql 5.1 to mysql 5.5.

    But now we experience that our customer every night approx. at 23:10 will be sent exactly 10 emails away with some of the latest entries.
    But these email has already been shipped 1 time when they signed up, so it is not appropriate to send a second email.

    Do you have any idea where to troubleshoot to solve this problem?

    Best regards
    Søren Ressel

    http://wordpress.org/extend/plugins/participants-database/

Viewing 15 replies - 1 through 15 (of 17 total)
  • Plugin Author xnau webdesign

    (@xnau)

    OK, I know what can cause this, but I don’t know why your system is triggering it.

    There is a bug fix coming for this, but you won’t want to wait for that.

    In the file classes/PDb_Signup.class.php, on line 90, you’ll find:

    $this->participant_id = $_GET['id'];
    $this->submitted = true;
    $this->participant_values = Participants_Db::get_participant( $this->participant_id );

    Change this to:

    $this->participant_id = $_GET['id'];
    $this->participant_values = Participants_Db::get_participant( $this->participant_id );
    if ($this->participant_values) {
       $this->submitted = true;
    }
    Thread Starter ressel

    (@ressel)

    Great, Thanks, I will try your bugfix.

    If you need some log files or any other information to help you find the reason why it behaves like this, just tell me and I will like to help by giving you all the information I can.

    I will keep you updated when I know if this solves the problem.

    Best regards
    Søren Ressel

    Thread Starter ressel

    (@ressel)

    The problem is still there again tonight was 10 email sent even though I have changed the file as you described.

    Tell me if you need more information or log files.

    Best Regards
    Søren Ressel

    Plugin Author xnau webdesign

    (@xnau)

    Curious. Can you forward one of the emails to support AT xnau.com?

    Thread Starter ressel

    (@ressel)

    It’s sent, I have also sent you some log files

    Plugin Author xnau webdesign

    (@xnau)

    OK, well, you have two ways to solve this. One is to find out why the server is sending these GET requests that include the ID numbers that are triggering the emails.

    Second, change the plugin so it’s looking for a different variable. In the next update, this is easy, but for now the way to do this is to edit “classes/PDb_Signup.class.php” by replacing all three references to “[‘id’]” to something different like “[‘pdbid’]”

    Thread Starter ressel

    (@ressel)

    Hello again,

    I have tried edit classes/PDb_Signup.class.php as you described
    It now look’s like this:

    <?php
    /*
     * prints a signup form
     * adds a record to the database
     * emails a receipt and a notification
     *
     * @package    WordPress
     * @subpackage Participants Database Plugin
     * @author     Roland Barker <webdeign@xnau.com>
     * @copyright  2011 xnau webdesign
     * @license    GPL2
     * @version    0.3
     * @link       http://xnau.com/wordpress-plugins/
     * @depends    FormElement class, Shortcode class
     */
    class PDb_Signup extends PDb_Shortcode {
    
    	// a string identifier for the class
      var $module = 'signup';
    
    	// holds the target page for the submission
    	var $submission_page;
    
      // holds the submission status: false if the form has not been submitted
      var $submitted = false;
    
    	// holds the recipient values after a form submission
    	var $recipient;
    
    	// boolean to send the reciept email
    	var $send_reciept;
    
    	// the receipt subject line
    	var $receipt_subject;
    
    	// holds the body of the signup receipt email
    	var $receipt_body;
    
    	// boolean to send the notification email
    	var $send_notification;
    
    	// holds the notify recipient emails
    	public $notify_recipients;
    
    	// the notification subject line
    	var $notify_subject;
    
    	// holds the body of the notification email
    	var $notify_body;
      // holds the current email body
      var $current_body;
    
    	var $thanks_message;
    
    	// header added to receipts and notifications
    	private $email_header;
    
    	// holds the submission values
    	private $post = array();
    
    	// error messages
    	private $errors = array();
    
    	// methods
    	//
    
    	/**
    	 * instantiates the signup form object
    	 *
    	 * this class is called by a WP shortcode
    	 *
    	 * @param array $params   this array supplies the display parameters for the instance
    	 *              'title'   string displays a title for the form (default none)
    	 *              'captcha' string type of captcha to include: none (default), math, image, word
    	 *
    	 */
    	public function __construct( $params ) {
    
    		// define shortcode-specific attributes to use
    		$add_atts = array(
                          'type'   => 'signup',
                          );
    
    		/*
         * if we're coming back from a successful form submission, the id of the new
         * record will be present, otherwise, the id is set to the default record
         */
        if ( isset( $_GET['pdbid'] ) ) {
    
          $this->participant_id = $_GET['pdbid'];
    $this->participant_values = Participants_Db::get_participant( $this->participant_id );
    if ($this->participant_values) {
       $this->submitted = true;
    }
          $add_atts['pdbid'] = $this->participant_id;
    
        } else {
    
          $this->participant_values = Participants_Db::get_default_record();
    
        }
    
        // run the parent class initialization to set up the parent methods
        parent::__construct( $this, $params, $add_atts );
    
        $this->module = $this->shortcode_atts['type'];
    
        $this->registration_page = Participants_Db::get_record_link( $this->participant_values['private_id'] );
    
        // set up the signup form email preferences
        $this->_set_email_prefs();
    
        // set the action URI for the form
    		$this->_set_submission_page();
    
        // set up the template iteration object
        $this->_setup_iteration();
    
    		if ( ! $this->submitted ) {
    
    				/*
    				 * no submission has been made: do we show the signup form?
    				 *
    				 * yes if there's no valid PID in the GET string
    				 * but not if we're actually showing a [pdb_signup_thanks] shortcode
    				 * and there's no submission
    				 *
    				 * this is because we use the same code for both shortcodes
    				 *
    				 * we will get a no-show if we end up here with a valid ID, but
    				 * there's no [pdb_record] shortcode there.
    				 */
    				if (
    						(
    						 ! isset( $_GET['pid'] )
    						 ||
    						 ( isset( $_GET['pid'] ) && false === Participants_Db::get_participant_id( $_GET['pid'] ) )
    						)
    						&&
    						$this->module == 'signup'
    					 )
    				{
    					// no submission; output the form
    					$this->_print_from_template();
    
    				}
    
    		} elseif ( $this->submitted ) {
    
          /*
           * filter provides access to the freshly-stored record and the email and thanks message properties so user feedback can be altered.
           */
          if (has_filter(Participants_Db::$css_prefix . 'before_signup_thanks')) {
    
            $signup_feedback_props = array('recipient', 'receipt_subject', 'receipt_body', 'notify_recipients', 'notify_subject', 'notify_body', 'thanks_message', 'participant_values');
            $signup_feedback = new stdClass();
            foreach ($signup_feedback_props as $prop) {
              $signup_feedback->$prop = &$this->$prop;
            }
    
            apply_filters(Participants_Db::$css_prefix . 'before_signup_thanks', $signup_feedback);
          }
    
    			// print the thank you note
    			$this->_thanks();
    
    			/*
           * check to see if the thanks email has been sent and send it if it has not
           */
    			if ( 'sent' != get_transient( 'signup-'.$this->participant_id ) ) {
    
            $this->_send_email();
    
            // mark the record as sent to prevent duplicate emails
            set_transient( 'signup-'.$this->participant_id, 'sent', 120 );
    
          }
    
    		}
    
    	}
    
    	/**
    	 * prints a signup form called by a shortcode
    	 *
    	 * this function is called statically to instantiate the Signup object,
    	 * which captures the processed template output and returns it for display
    	 *
    	 * @param array $params parameters passed by the shortcode
    	 * @return string form HTML
    	 */
    	public function print_form( $params ) {
    
    		if ( ! isset( self::$instance ) ) self::$instance = new PDb_Signup( $params );
    
    		return self::$instance->output;
    
    	}
    
      /**
       * includes the shortcode template
       */
      protected function _include_template() {
    
        include $this->template;
    
      }
    
      /**
       * sets up the signup form email preferences
       */
      private function _set_email_prefs() {
    
    		$this->send_reciept = $this->options['send_signup_receipt_email'];
    		$this->send_notification = $this->options['send_signup_notify_email'];
    		$this->notify_recipients = $this->options['email_signup_notify_addresses'];
    		$this->notify_subject = $this->options['email_signup_notify_subject'];
    		$this->notify_body = $this->options['email_signup_notify_body'];
    		$this->receipt_subject = $this->options['signup_receipt_email_subject'];
    		$this->receipt_body = $this->options['signup_receipt_email_body'];
    		$this->thanks_message = $this->options['signup_thanks'];
    		$this->email_header = Participants_Db::$email_headers;
    
      }
    
      /**
       * sets the form submission page
       */
      private function _set_submission_page() {
    
    		if ( isset( $this->options['signup_thanks_page'] ) and $this->options['signup_thanks_page'] != 'none' ) {
    
    			$this->submission_page = get_permalink( $this->options['signup_thanks_page'] );
    
    		} else {
    
    			// the signup thanks page is not set up, so we submit to the page the form is on
    
    			$this->submission_page = $_SERVER['REQUEST_URI'];
    
    		}
    
      }
    
      // prints a signup form top
      public function print_form_head() {
        ?>
        <form method="post" enctype="multipart/form-data" >
            <?php
            FormElement::print_hidden_fields( array(
                                                    'action'=>'signup',
                                                    'subsource'=>Participants_Db::PLUGIN_NAME,
                                                    'shortcode_page' => basename( $_SERVER['REQUEST_URI'] ),
                                                    'thanks_page' => $this->submission_page
                                                    ) );
    
      }
    
    	public function print_submit_button( $class = 'button-primary' ) {
    
    		FormElement::print_element( array(
                                          'type'       => 'submit',
                                          'value'      => $this->options['signup_button_text'],
                                          'name'       => 'submit',
                                          'class'      => $class.' pdb-submit',
                                          ) );
    	}
    
    	/**
    	 * prints a thank you note
    	 */
    	private function _thanks() {
    		ob_start(); ?>
    
    		<div class="<?php echo $this->wrap_class ?> signup-thanks">
          <?php echo $this->_proc_tags( $this->thanks_message ); ?>
    		</div>
    
    		<?php $this->output = ob_get_clean();
    
    		unset( $_POST );
    
    	}
    
    	/**
    	 * adds a captcha field to the signup form
    	 *
    	 * @param string $type selects the type of CAPTCHA to employ: none, math, color, reCaptcha
    	 */
    	private function _add_captcha() {
    
    		switch ( $this->captcha_type ) {
    
    			case 'none';
    			default;
    				return false;
    
    		}
    
    	}
    
    	/**
       * sends the notification and receipt emails for a signup submission
       *
       */
    	private function _send_email() {
    
    		if ( $this->send_notification ) $this->_do_notify();
    		if ( $this->send_reciept ) $this->_do_receipt();
    
    	}
    
    	// sends a receipt email
    	private function _do_receipt() {
    
    		if ( ! isset( $this->participant_values['email'] ) || empty( $this->participant_values['email'] ) ) return NULL;
    
    		$this->_mail(
    								 $this->participant_values['email'],
    								 $this->_proc_tags( $this->receipt_subject ),
    								 $this->_proc_tags( $this->receipt_body )
    								 );
    
    	}
    
    	// sends a notification email
    	private function _do_notify() {
    
    		$this->_mail(
    								 $this->notify_recipients,
    								 $this->_proc_tags( $this->notify_subject ),
    								 $this->_proc_tags( $this->notify_body )
    								 );
    
    	}
    
    	/**
       * sends a mesage through the WP mail handler function
       *
       * @todo these email functions should be handled by an email class
       *
       * @param string $recipients comma-separated list of email addresses
       * @param string $subject    the subject of the email
       * @param string $body       the body of the email
       *
       */
    	private function _mail( $recipients, $subject, $body ) {
    
    		// error_log(__METHOD__.' with: '.$recipients.' '.$subject.' '.$body );
    
        $this->current_body = $body;
    
        if ( $this->options['html_email'] ) add_action( 'phpmailer_init', array( $this, 'set_alt_body') );
    
    		$sent = wp_mail( $recipients, $subject, $body, $this->email_header );
    
    		if ( false === $sent ) error_log( __METHOD__.' sending returned false' );
    
    	}
    
      /**
       * set the PHPMailer AltBody property with the text body of the email
       *
       * @param object $phpmailer an object of type PHPMailer
       * @return null
       */
      public function set_alt_body( &$phpmailer ) {
    
        if ( is_object( $phpmailer )) $phpmailer->AltBody = $this->_make_text_body ($this->_proc_tags( $this->current_body ));
      }
    
      /**
       * strips the HTML out of an HTML email message body to provide the text body
       *
       * this is a fairly crude conversion here. I should include some kind of library
       * to do this properly.
       *
       * @param string $HTML the HTML body of the email
       * @return string
       */
      private function _make_text_body( $HTML ) {
    
        return strip_tags( preg_replace('#(</[p|h1|h2|h3|h4|h5|h6|div|tr|li]{1,3} *>)#i', "\r", $HTML) );
      }
    
    }

    But we are still experiencing the same problem with the sending of emails to registered users who have registered from 26 May to now.

    Let me know if it will be helpful with more information.

    Plugin Author xnau webdesign

    (@xnau)

    OK, well at this point I’m wondering if it’s the plugin at all. When new people sign up, do their emails get resent at midnight with everyone else’s? I can only say that I don’t know how the plugin could be doing this. Are you sure it’s not the server resending email from the mail queue?

    One test you could run, although it might be a little drastic, is to deactivate the plugin overnight to see if the emails are still going out.

    Thread Starter ressel

    (@ressel)

    Hello again,

    The client tried a little before 23:00 to disable confirmation emails, and then about 23:30 reenable them, when he did this, no email’s was sent to the users, including email’s to him self.

    Best regards
    Søren Ressel

    I am not sure that this question is related but it’s suspicious. Let me apologize up front if I am posting in the wrong place. When a user signs up on our website, the admin gets two notification emails indicating that there is a new signup but they are sent about 5 minutes apart. At least that’s what it looks like. I cannot figure out how it’s happening. If the user went back to a previous screen and resubmitted, I think the plugin would disallow it based on a duplicate email address. I am quite perplexed by this. Could it be PDb_Signup.class.php?

    Plugin Author xnau webdesign

    (@xnau)

    Søren,

    OK, its the plugin sending the emails, but the only way that could happen would be if a request was sent to the script with the same URL. OK, try this:

    In PDb_Signup.class.php on line 173 (or so…) you’ll find this:

    set_transient( 'signup-'.$this->participant_id, 'sent', 120 );

    OK that sets a transient so the email does not get sent twice if someone hits the reload button. Change the “120” to “0” and the transient will be set permanently. See if that works.

    cbrendlinger, you could try something similar.

    Thread Starter ressel

    (@ressel)

    Hello,

    Today we didn’t have the same behavior, no email was sent at 23:18 I received a message from the client, where he wrote that no mail was arrived.
    I asked him to investigate the registration form still works, then this sends 10x registration mails from older entries … again.
    I expect to roll back to debian squeeze, because the customer no longer satisfied with this.

    Plugin Author xnau webdesign

    (@xnau)

    Well, I would have liked to see the problem solved. My next suggestion would have been to look at the logs to see if your could find the GET requests that were triggering those emails.

    Thread Starter ressel

    (@ressel)

    Hello,

    I have sent you log files from yesterday.

    Best regards
    Søren Ressel

    Plugin Author xnau webdesign

    (@xnau)

    There was no attachment with the email…but really, this is for the guy who set up your web host to do…the plugin is not the problem. If you find that it is, let me know and I’ll help, but as afar as I know now, this is a problem with your server.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘registration email problem’ is closed to new replies.