Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: jwdevel [...] gmail.com
Cc:
AdminCc:

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



Subject: Bugs in Mail::IMAPClient
Date: Sun, 13 Apr 2008 16:50:37 -0700
To: bug-Mail-IMAPClient [...] rt.cpan.org
From: "j w" <jwdevel [...] gmail.com>
Hello, I'm playing around with Mail::IMAPClient, and there's a couple issues that came up: (1) The expunge method seems buggy. There is one 'ne' that I think should be 'eq' Here is a patch against v3.05: diff --git a/site/lib/Mail/IMAPClient.pm b/site/lib/Mail/IMAPClient.pm --- a/site/lib/Mail/IMAPClient.pm +++ b/site/lib/Mail/IMAPClient.pm @@ -1761,7 +1761,7 @@ or return; my $old = $self->Folder; - if(defined $old && $folder eq $old) + if(defined $old && $folder ne $old) { $self->select($folder); my $succ = $self->_imap_command('EXPUNGE'); $self->select($old); As it is now, passing the name of a mailbox to the function will likely cause it to expunge the wrong mailbox. (2) Calling expunge with no arguments returns undef, rather than expunging the currently selected mailbox, as the docs indicate. This seems like it must be by design, since there is the following code at the beginning of expunge: sub expunge { my ($self, $folder) = @_; defined $folder or return; So if no $folder is passed in, it returns undef. It's just not what the docs indicate. (3) I can't seem to get the "default method" to work. I tried to use $imap->EXPUNGE as a workaround to the above issues, but it didn't work. I tried the example in the documentation, and it doesn't seem to work either: Try this script: use Mail::IMAPClient; my $imap = Mail::IMAPClient->new( User => 'joeblo', Password => 'blabla', Debug => 1, ); my @results = $imap->FOO("bar","an example","of the default"); That gives me the error: Can't locate object method "FOO" via package "Mail::IMAPClient" at ... I would expect it to error (since it's not connected), but it says it can't even find the method to run. Or perhaps I misunderstand how the default method functionality works? My setup: Perl v5.8.7 built for MSWin32-x86-multi-thread Windows XP Let me know if you need other info -John
Subject: Re: [rt.cpan.org #34976] AutoReply: Bugs in Mail::IMAPClient
Date: Sun, 13 Apr 2008 16:58:10 -0700
To: bug-Mail-IMAPClient [...] rt.cpan.org
From: "j w" <jwdevel [...] gmail.com>
I just realized a better fix for issue (1) is to swap the code in the if/else, rather than switch 'eq' to 'ne' (for handling undef better) Better patch: diff --git a/site/lib/Mail/IMAPClient.pm b/site/lib/Mail/IMAPClient.pm --- a/site/lib/Mail/IMAPClient.pm +++ b/site/lib/Mail/IMAPClient.pm @@ -1762,14 +1762,14 @@ my $old = $self->Folder; if(defined $old && $folder eq $old) + { $self->_imap_command('EXPUNGE') + or return undef; + } + else { $self->select($folder); my $succ = $self->_imap_command('EXPUNGE'); $self->select($old); $succ or return undef; - } - else - { $self->_imap_command('EXPUNGE') - or return undef; } wantarray ? $self->History : $self->Results; -John On Sun, Apr 13, 2008 at 4:50 PM, Bugs in Mail-IMAPClient via RT < bug-Mail-IMAPClient@rt.cpan.org> wrote: Show quoted text
> > Greetings, > > This message has been automatically generated in response to the > creation of a trouble ticket regarding: > "Bugs in Mail::IMAPClient", > a summary of which appears below. > > There is no need to reply to this message right now. Your ticket has been > assigned an ID of [rt.cpan.org #34976]. Your ticket is accessible > on the web at: > > http://rt.cpan.org/Ticket/Display.html?id=34976 > > Please include the string: > > [rt.cpan.org #34976] > > in the subject line of all future correspondence about this issue. To do > so, > you may reply to this message. > > Thank you, > bug-Mail-IMAPClient@rt.cpan.org > > ------------------------------------------------------------------------- > Hello, > I'm playing around with Mail::IMAPClient, and there's a couple issues that > came up: > > (1) The expunge method seems buggy. There is one 'ne' that I think should > be > 'eq' > Here is a patch against v3.05: > > diff --git a/site/lib/Mail/IMAPClient.pm b/site/lib/Mail/IMAPClient.pm > --- a/site/lib/Mail/IMAPClient.pm > +++ b/site/lib/Mail/IMAPClient.pm > @@ -1761,7 +1761,7 @@ > or return; > > my $old = $self->Folder; > - if(defined $old && $folder eq $old) > + if(defined $old && $folder ne $old) > { $self->select($folder); > my $succ = $self->_imap_command('EXPUNGE'); > $self->select($old); > > As it is now, passing the name of a mailbox to the function will likely > cause it to expunge the wrong mailbox. > > (2) Calling expunge with no arguments returns undef, rather than expunging > the currently selected mailbox, as the docs indicate. > This seems like it must be by design, since there is the following code at > the beginning of expunge: > > sub expunge > { my ($self, $folder) = @_; > defined $folder > or return; > > So if no $folder is passed in, it returns undef. It's just not what the > docs > indicate. > > (3) I can't seem to get the "default method" to work. I tried to use > $imap->EXPUNGE as a workaround to the above issues, but it didn't work. > I tried the example in the documentation, and it doesn't seem to work > either: > > Try this script: > > use Mail::IMAPClient; > my $imap = Mail::IMAPClient->new( > User => 'joeblo', > Password => 'blabla', > Debug => 1, > ); > my @results = $imap->FOO("bar","an example","of the default"); > > > That gives me the error: Can't locate object method "FOO" via package > "Mail::IMAPClient" at ... > > I would expect it to error (since it's not connected), but it says it > can't > even find the method to run. Or perhaps I misunderstand how the default > method functionality works? > > My setup: > Perl v5.8.7 built for MSWin32-x86-multi-thread > Windows XP > > Let me know if you need other info > -John > >
Subject: Re: [rt.cpan.org #34976] Bugs in Mail::IMAPClient
Date: Mon, 14 Apr 2008 09:50:31 +0200
To: j w via RT <bug-Mail-IMAPClient [...] rt.cpan.org>
From: Mark Overmeer <mark [...] overmeer.net>
* j w via RT (bug-Mail-IMAPClient@rt.cpan.org) [080413 23:50]: Show quoted text
> Sun Apr 13 19:50:57 2008: Request 34976 was acted upon. > Transaction: Ticket created by jwdevel@gmail.com > Queue: Mail-IMAPClient > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=34976 > > > I'm playing around with Mail::IMAPClient, and there's a couple issues that > came up: > > (1) The expunge method seems buggy. There is one 'ne' that I think > should be 'eq'
Try to understand the logic in the pre-2.99 code, and you will understand it. Your observations are corrent Show quoted text
> - if(defined $old && $folder eq $old) > + if(defined $old && $folder ne $old)
Yes. And your follow-up is better, indeed. Show quoted text
> > (2) Calling expunge with no arguments returns undef, rather than expunging > the currently selected mailbox, as the docs indicate. > So if no $folder is passed in, it returns undef. It's just not what the docs > indicate.
True. Show quoted text
> (3) I can't seem to get the "default method" to work. I tried to use > $imap->EXPUNGE as a workaround to the above issues, but it didn't work.
I had removed this in 2.99, when I took over maintenance, because this auto-generation of methods is dangerous (typos not detected) and stops people from contributing the extensions. The text in the manual now has changed. Do you like an intermediate release of this, or can you live with your manually fixed version? -- Thanks for the improvements, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
Subject: Re: [rt.cpan.org #34976] Bugs in Mail::IMAPClient
Date: Tue, 15 Apr 2008 22:11:51 -0700
To: bug-Mail-IMAPClient [...] rt.cpan.org
From: "j w" <jwdevel [...] gmail.com>
On Mon, Apr 14, 2008 at 12:50 AM, Mark Overmeer via RT <bug-Mail-IMAPClient@rt.cpan.org> wrote: Show quoted text
> > Do you like an intermediate release of this, or can you live with your > manually fixed version?
It's just a small personal project - I can use my local changes for now. Thanks for your prompt reply; always nice to know there's someone listening at the other end of the line (: -John
3.07 released, which should fix this problem