Skip Menu |

This queue is for tickets about the Mail-IMAPClient CPAN distribution.

Report information
The Basics
Id: 61835
Status: resolved
Priority: 0/
Queue: Mail-IMAPClient

People
Owner: PLOBBES [...] cpan.org
Requestors: SVOELKEL [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in:
  • 2.2.9
  • 3.00
Fixed in: 3.27



The method sub search() has an explicit return undef; in it which can cause problems when used in list context, e.g. as suggested by the documentation: my @recent = $imap->recent() With that checks like if (@recent) of scalar(@recent) > 0 won't work.
Agreed, the behavior is not very desirable. I'll need to check against .2.9 but this may be behavior that has been this way way for a long time. If so, I may not change it until a major release. In the future I'm thinking about moving more towards returning an exception object that will evaluate properly in given contexts but I don't want to do that in the 3.x series. I'll look to see what we can do to make this behavior better sooner than later though, thanks for the report!.
I have just patched documentation to recommended use of scalar context due to historical API behavior. Also, the "Errors" section was brought closer to the top of the documentation to hopefully help highlight this unfortunate behavior. I'll close this bug once Mail::IMAPClient 3.27 is released. Although, if desired, feel free to re-open and we'll just keep this open as an RFE for some future release where the API changes to handle errors in a LIST context better. Clearly documentation doesn't justify bad API behavior...
Mail::IMAPClient 3.27 has been released and is available on CPAN with updated documentation. Closing for now, but if desired we can re-open until error handling in general is replaced with something more flexible.