Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Headers: no catchable exception #246

Closed
wujku opened this issue Oct 16, 2017 · 8 comments
Closed

Headers: no catchable exception #246

wujku opened this issue Oct 16, 2017 · 8 comments
Milestone

Comments

@wujku
Copy link
Contributor

wujku commented Oct 16, 2017

When date is incorrect, I can not get any of message header.

throw new InvalidDateHeaderException(\sprintf('Invalid Date header found: "%s"', $value), 0, $ex);

I suggest to parse date header when user use getDate() method or return false instead of InvalidDateHeaderException.

try {
    $message->getId();
} catch (InvalidDateHeaderException $e) {
    ???
}
@Slamdunk
Copy link
Collaborator

Slamdunk commented Oct 16, 2017

I'll look at this, hoping to push a fix without a BC break.

In the meantime, can you post please the Date header that produced the exception?

@Slamdunk
Copy link
Collaborator

Lazy loading the parameters is a good idea, unfortunately Headers extends ArrayIterator and lazy loading an item involves too much code overwrite, because a user can access to a header through a lot of methods (current, getArrayCopy, next, offsetGet, get, seek, serialize etc).

I'm going to tag this for v2.0, but I'm going to release a major version not before 6 months from now.

@Slamdunk Slamdunk added this to the 2.0 milestone Oct 16, 2017
@wujku
Copy link
Contributor Author

wujku commented Oct 16, 2017

This is a raw email which cause this error.
I fetch messages from imap account, which I used to phpunit tests.

Date: Thu, 05 Oct 2017 13:14:32 +0000
From: [email protected]
To: [email protected]
Subject: Message 2
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 8bit

Message 259d6303839b75

@Slamdunk
Copy link
Collaborator

Thu, 05 Oct 2017 13:14:32 +0000 doesn't raise an Exception, it is correctly parsed to 2017-10-05T13:14:32+0000

@wujku
Copy link
Contributor Author

wujku commented Oct 16, 2017

@Slamdunk Sorry, this mail has below content:

Subject: test
MIME-Version: 1.0
Content-Type: text/plain
Date: Fri!
From: [email protected]
To: [email protected]

Hi!

@wujku
Copy link
Contributor Author

wujku commented Oct 18, 2017

@Slamdunk Do you have idea how catch this exception and have ability to access other header variables?

@Slamdunk
Copy link
Collaborator

At the time being, no

@Slamdunk Slamdunk changed the title No catchable exception Headers: no catchable exception Oct 18, 2017
@Slamdunk Slamdunk modified the milestones: 2.0, 1.1 Oct 23, 2017
@Slamdunk
Copy link
Collaborator

Implemented in #250

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants