Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: james2vegas [...] aim.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2.108
Fixed in: 2.109



With this folder format:
Perl
Perl.sbd/search.cpan.org
Perl.sbd/rt.cpan.org

This code should return the number of messages in the subfolders of the foldername passed on the command line:

    use Mail::Box::Manager;
    my $mgr = Mail::Box::Manager->new;
    my $flder = shift;
    my $src = $mgr->open( folder => $flder, subfolder_extension => '.sbd', fix_headers => 1 );
    for ($src->listSubFolders) {
        my $x = $src->openSubFolder( $_ );
        warn "$_ => ",
            $src->nameOfSubFolder($_), ' => ',
            scalar $x->messages, "\n";
    }
    $mgr->closeAllFolders;

but instead, I get something like this:
WARNING: Folder does not exist, failed opening mbox folder Perl/search.cpan.org.
Can't call method "messages" on an undefined value at ml2.pl line 7.

so listSubFolders successfully gets the folders in the Perl.sbd folder, but openSubFolder (and openRelatedFolder) do not honour the subfolder_extension option, renaming Perl.sbd to Perl.d results in expected behaviour:

  search.cpan.org => Perl/search.cpan.org => 52089
  rt.cpan.org => Perl/rt.cpan.org => 2928

also adding:
 local $Mail::Box::Mbox::default_sub_extension = '.sbd';
in appropriate places works too.

It seems that sub Mail::Box::Mbox::folderToFilename doesn't get passed %args in $thingy, so this line:
    $extension ||=
          ref $thingy ? $thingy->{MBM_sub_ext} : $default_sub_extension;

only ever uses $default_sub_extension instead of $args{MBM_sub_ext}



Subject: Re: [rt.cpan.org #87912]
Date: Mon, 19 Aug 2013 09:43:35 +0200
To: James Wright via RT <bug-Mail-Box [...] rt.cpan.org>
From: Mark Overmeer <mark [...] overmeer.net>
* James Wright via RT (bug-Mail-Box@rt.cpan.org) [130817 13:06]: Show quoted text
> Sat Aug 17 09:06:21 2013: Request 87912 was acted upon. > Transaction: Ticket created by JWRIGHT > Queue: Mail-Box > Broken in: 2.108 > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=87912 > > > so listSubFolders successfully gets the folders in the Perl.sbd folder, but > openSubFolder (and openRelatedFolder) do not honour the subfolder_extension > option, renaming Perl.sbd to Perl.d results in expected behaviour:
Right. Something is missing. Can you add this in Mail::Box::Mbox: sub openRelatedFolder(@) { my $self = shift; $self->SUPER::openRelatedFolder ( subfolder_extension => $self->{MBM_sub_ext}, @_); } -- Thanks for reporting, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
On Mon Aug 19 03:44:01 2013, Mark@Overmeer.net wrote:
Show quoted text
> ...

Unfortunately this doesn't seem to change anything.  The problem seems to be that Mail::Box::Mbox::folderToFilename is only ever called as a class method, not an instance method, so doesn't ever see $self->{MBM_sub_ext}.  Adding $self->{MBM_sub_ext} to the parameters passed to folderToFilename (see the patch) in sub Mail::Box::File::init makes this work.  The modified package still passes the appropriate parts of the test suite.
Subject: patch-Mail_Box_File_pm
Download patch-Mail_Box_File_pm
application/octet-stream 317b

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #87912] Mail::Box::Mbox openSubFolder and openRelatedFolder do not honour subfolder_extension
Date: Mon, 19 Aug 2013 11:44:55 +0200
To: James Wright via RT <bug-Mail-Box [...] rt.cpan.org>
From: Mark Overmeer <solutions [...] overmeer.net>
* James Wright via RT (bug-Mail-Box@rt.cpan.org) [130819 09:17]: Show quoted text
> Queue: Mail-Box > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=87912 > > > On Mon Aug 19 03:44:01 2013, Mark@Overmeer.net wrote:
> > ...
> > Unfortunately this doesn't seem to change anything. The problem seems to be > that Mail::Box::Mbox::folderToFilename is only ever called as a class method, > not an instance method, so doesn't ever see $self->{MBM_sub_ext}. Adding > $self->{MBM_sub_ext} to the parameters passed to folderToFilename (see the > patch) in sub Mail::Box::File::init makes this work. The modified package still > passes the appropriate parts of the test suite.
Your fix is certainly not correct, because now the super-class uses an attribute of a sub-class... However, the hint you give tells me that this may work: my $filename = $self->{MBF_filename} - = $class->folderToFilename + = $self->folderToFilename ( $self->name , $self->folderdir ); -- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
On Mon Aug 19 05:45:22 2013, solutions@overmeer.net wrote:
Show quoted text
> ...

I had avoided that as I couldn't find another instance of folderToFilename being called on an instance instead of the class in the code and I didn't think to use $args->{subfolder_extension} directly instead (like MBM::create and MBF::create) which also works.

That said, using the instance does the right thing and makes the above code work correctly, and seems the most correct solution.

Subject: Re: [rt.cpan.org #87912] Mail::Box::Mbox openSubFolder and openRelatedFolder do not honour subfolder_extension
Date: Mon, 19 Aug 2013 12:58:52 +0200
To: James Wright via RT <bug-Mail-Box [...] rt.cpan.org>
From: Mark Overmeer <secretaris [...] nluug.nl>
Thanks for your bug-report and helping me to fix this. I have now released version 2.109 to CPAN (wait a few hours for it to be distributed), containing the fix for this bug and a few more fixes. * James Wright via RT (bug-Mail-Box@rt.cpan.org) [130819 10:53]: Show quoted text
> Queue: Mail-Box > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=87912 > > > On Mon Aug 19 05:45:22 2013, solutions@overmeer.net wrote: > That said, using the instance does the right thing and makes the above code > work correctly, and seems the most correct solution.
-- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net