Skip Menu |

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

Report information
The Basics
Id: 7861
Status: resolved
Priority: 0/
Queue: Mail-Box

People
Owner: Nobody in particular
Requestors: aa29 [...] mail.ru
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Mail::Box::MH is too lazy to perform messageId() right after new()
Mail::Box::MH->new(...)->messageId(...) always returns undef, becouse messageId() uses 'MB_msgid' field which is not populated at this stage. It's necessary to call messageIds() to fill it: use Mail::Box::MH; use Mail::Message; my $dir = Mail::Box::MH->new(folder=>'./mail', access => 'rw', create => 1, keep_index => 1, ); my $msg = Mail::Message->build(Subject => 'foo'); $dir->addMessage($msg); my $mid = $msg->messageId; print "added $mid\n"; print $dir->messageId($mid) ? "found $mid\n" : "where's $mid\n"; undef $dir; $dir = Mail::Box::MH->new(folder=>'./mail', access => 'rw', create => 1, keep_index => 1, ); print $dir->messageId($mid) ? "found $mid\n" : "missed $mid\n"; $dir->messageIds; print $dir->messageId($mid) ? "found $mid\n" : "missed $mid\n";
From the manual pages, Mail::Box::messageId() http://perl.overmeer.net/mailbox/html/jump.cgi?Mail::Box&2371 WARNING: when the message headers are delay-parsed, the message might be in the folder but not yet parsed into memory. In this case, use find() instead of messageId() if you really need a thorough search. The problem is, that you can only index based on msgid when the msgids are known. For MH folders, that would require parsing of all message headers, which is extremely expensive. find() is much nicer, because you can limit its search. Probably some more text must be added to the warning, to explain the problem.
Mea culpa, I did not rebuild html docs after upgrading. Is it nice to have so similar methods with different behaviour? IMHO, method name messageId() is more descriptive then find(). It may be worth joining them somehow?
[guest - Tue Oct 5 03:58:19 2004]: Show quoted text
> Mea culpa, I did not rebuild html docs after upgrading.
You can always look at http://perl.overmeer.net/mailbox/html/ for the latest version. Show quoted text
> Is it nice to have so similar methods with different behaviour? IMHO, > method name messageId() is more descriptive then find(). It may be > worth joining them somehow?
Actually, I think that the $folder->find($msgid) is a nicer interface than $folder->messageId($msgid), the latter being lower-level and maybe better of in the 'Internals' part of the manual.