Skip to content

Commit

Permalink
log state when sent MsgNo 0 - do not stop, just log
Browse files Browse the repository at this point in the history
  • Loading branch information
sophistry committed Feb 12, 2012
1 parent a68c71d commit b8f5195
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 5 additions & 2 deletions peeker.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 7 additions & 1 deletion peeker_body.php
Expand Up @@ -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
Expand Down

0 comments on commit b8f5195

Please sign in to comment.