Permalink
Browse files

log state when sent MsgNo 0 - do not stop, just log

  • Loading branch information...
1 parent a68c71d commit b8f5195ca0362be1d41ef0448774a6dc6dd87015 sophistry committed Feb 12, 2012
Showing with 12 additions and 3 deletions.
  1. +5 −2 peeker.php
  2. +7 −1 peeker_body.php
View
@@ -129,7 +129,10 @@ public function get_message($start, $end=NULL)
public function message($start, $end=NULL)
{
// protect the command from
- // using empty string like NULL
+ // using empty string like NULL or 0
+ // because messages start at MsgNo 1, not 0
+ // TODO: add exception, better error handling
+ if ($start===0) $this->log_state('ERROR: MsgNo cannot be 0. Mail server MsgNo starts at 1.');
// force it to message 1
// should change this to error
$start = ($start==='') ? 1 : $start;
@@ -754,7 +757,7 @@ public function make_detector_set()
{
include_once('peeker_detector_set.php');
// make a new one if we don't have it already
- if ($this->detector_set === NULL) $this->detector_set = new peeker_detector_set();
+ if (!isset($this->detector_set)) $this->detector_set = new peeker_detector_set();
$this->detectors_on = TRUE;
return $this->detector_set;
}
View
@@ -75,7 +75,13 @@ public function get_body()
// it effectively invisible (depending on gmail account's POP3 settings)
$this->log_state('Fetching structure for email #'.$this->Msgno);
$structure = @imap_fetchstructure($this->peek_parent->resource, $this->Msgno);
- // check for errors here to clear the
+
+ // make sure $structure is not null - can happen if passed MsgNo 0
+ // log state
+ // TODO: build error handling, exception
+ if ($structure===NULL) $this->log_state('get_body() method $structure is NULL. MsgNo is: '.(int)$this->MsgNo);
+
+ // check for mail server errors here to clear the
// error stack and prevent it from posting
// PHP errors about badly formatted emails
// should probably store the errors with the email in a db

0 comments on commit b8f5195

Please sign in to comment.