Skip to content

Commit

Permalink
Fetch attributes set to null
Browse files Browse the repository at this point in the history
  • Loading branch information
Webklex committed Sep 4, 2020
1 parent 96eb056 commit e76800f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/IMAP/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ public function deleteFolder($name, $expunge = true) {
* @deprecated 1.0.5.2:2.0.0 No longer needed. Use Folder::getMessages() instead
* @see Folder::getMessages()
*/
public function getMessages(Folder $folder, $criteria = 'ALL', $fetch_options = null, $fetch_body = true, $fetch_attachment = true, $fetch_flags = false) {
public function getMessages(Folder $folder, $criteria = 'ALL', $fetch_options = null, $fetch_body = null, $fetch_attachment = null, $fetch_flags = null) {
return $folder->getMessages($criteria, $fetch_options, $fetch_body, $fetch_attachment, $fetch_flags);
}

Expand Down
4 changes: 2 additions & 2 deletions src/IMAP/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public function setChildren($children = []) {
* @throws Exceptions\ConnectionFailedException
* @throws Exceptions\InvalidMessageDateException
*/
public function getMessage($uid, $msglist = null, $fetch_options = null, $fetch_body = false, $fetch_attachment = false, $fetch_flags = true) {
public function getMessage($uid, $msglist = null, $fetch_options = null, $fetch_body = null, $fetch_attachment = null, $fetch_flags = null) {
$this->client->openFolder($this->path);
if (\imap_msgno($this->getClient()->getConnection(), $uid) > 0) {
return new Message($uid, $msglist, $this->getClient(), $fetch_options, $fetch_body, $fetch_attachment, $fetch_flags);
Expand All @@ -217,7 +217,7 @@ public function getMessage($uid, $msglist = null, $fetch_options = null, $fetch_
* @throws Exceptions\InvalidWhereQueryCriteriaException
* @throws GetMessagesFailedException
*/
public function getMessages($criteria = 'ALL', $fetch_options = null, $fetch_body = true, $fetch_attachment = true, $fetch_flags = true, $limit = null, $page = 1, $charset = "UTF-8") {
public function getMessages($criteria = 'ALL', $fetch_options = null, $fetch_body = null, $fetch_attachment = null, $fetch_flags = null, $limit = null, $page = 1, $charset = "UTF-8") {

return $this->query($charset)->where($criteria)->setFetchOptions($fetch_options)->setFetchBody($fetch_body)
->setFetchAttachment($fetch_attachment)->setFetchFlags($fetch_flags)
Expand Down
29 changes: 3 additions & 26 deletions src/IMAP/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class Message {
* @throws Exceptions\ConnectionFailedException
* @throws InvalidMessageDateException
*/
public function __construct($uid, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_attachment = false, $fetch_flags = false) {
public function __construct($uid, $msglist, Client $client, $fetch_options = null, $fetch_body = null, $fetch_attachment = null, $fetch_flags = null) {

$default_mask = $client->getDefaultMessageMask();
if($default_mask != null) {
Expand Down Expand Up @@ -349,37 +349,14 @@ public function hasHTMLBody() {

/**
* Get the Message html body
* If $replaceImages is callable it should expect string $body as first parameter, $oAttachment as second and return
* the resulting $body.
*
* @var bool|callable $replaceImages
*
* @return string|null
*
* @deprecated 1.4.0:2.0.0 No longer needed. Use AttachmentMask::getImageSrc() instead
*/
public function getHTMLBody($replaceImages = false) {
public function getHTMLBody() {
if (!isset($this->bodies['html'])) {
return null;
}

$body = $this->bodies['html']->content;
if ($replaceImages !== false) {
$this->attachments->each(function($oAttachment) use(&$body, $replaceImages) {
/** @var Attachment $oAttachment */
if(is_callable($replaceImages)) {
$body = $replaceImages($body, $oAttachment);
}elseif(is_string($replaceImages)) {
call_user_func($replaceImages, [$body, $oAttachment]);
}else{
if ($oAttachment->id && $oAttachment->getImgSrc() != null) {
$body = str_replace('cid:'.$oAttachment->id, $oAttachment->getImgSrc(), $body);
}
}
});
}

return $body;
return $this->bodies['html']->content;
}

/**
Expand Down

0 comments on commit e76800f

Please sign in to comment.