tedious / Fetch

An IMAP library for PHP
http://www.tedivm.com
Other
503 stars 158 forks source link

Message->loadMessage() error; message without subject (empty) #167

Open Apacz opened 8 years ago

Apacz commented 8 years ago

Undefined property: stdClass::$subject in /var/www/html/thor-lovo/vendor/tedivm/fetch/src/Fetch/Message.php line 236

Problem is when i try to search on the server. If is any message is with empty subject then i can't remove or do anything ... my process is stopped

andrewtch commented 8 years ago

Same thing, however, messages are really present and have subjects.

You should add if (isset($messageOverview->subject).... check.

Apacz commented 8 years ago

Yes, I Overwrited your method becouse i had to use \Fetch\Server->seach() and that makes error.

just i did:
protected function loadMessage() { if(!property_exists($messageOverview,'subject')) { $messageOverview->subject = ''; } return parent::loadMessage(); } and it work, but still it cant work without little change.

deemyboy commented 8 years ago

I have fixed this in src/Fetch/Message.php

protected function loadMessage() { //First load the message overview information if (!is_object($messageOverview = $this->getOverview())) return false; if (property_exists($this->messageOverview, 'subject')) { $this->subject = MIME::decode($messageOverview->subject, self::$charset); } else { $this->subject = "No subject - PLEASE CHANGE!"; } $this->date = strtotime($messageOverview->date); $this->size = $messageOverview->size; foreach (self::$flagTypes as $flag) $this->status[$flag] = ($messageOverview->$flag == 1); // Next load in all of the header information

https://github.com/deemyboy/Fetch/blob/master/src/Fetch/Message.php