Skip Menu |

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

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

People
Owner: MARKOV [...] cpan.org
Requestors: jlh [...] gmx.ch
Cc:
AdminCc:

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



Subject: Mail::Message::Head::Complete->clone doesn't behave as documented
The documentation tells that I can use Mail::Message::Head::Complete as follows $head->clone('Subject', 'Received'); causing only the given headers to be copied. However, clone() doesn't do that, it copies everything without looking at those arguments. Using Mail-Box-2.068, perl 5.8.8, linux
Subject: Re: [rt.cpan.org #23020] Mail::Message::Head::Complete->clone doesn't behave as documented
Date: Sun, 12 Nov 2006 00:11:48 +0100
To: via RT <bug-Mail-Box [...] rt.cpan.org>
From: Mark Overmeer <mark [...] overmeer.net>
* via RT (bug-Mail-Box@rt.cpan.org) [061111 22:22]: Show quoted text
> Subject: Mail::Message::Head::Complete->clone doesn't behave as documented > > The documentation tells that I can use Mail::Message::Head::Complete as > follows > $head->clone('Subject', 'Received');
Right. What is your wish? Adapt the docs or implement it? -- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
From: jlh [...] gmx.ch
On Sat Nov 11 18:12:04 2006, Mark@Overmeer.net wrote: Show quoted text
> Right. What is your wish? Adapt the docs or implement it?
As you like, really. I now work around it by using $copy = $head->clone; $copy->removeFieldsExcept('Subject', 'Received');
Subject: Re: [rt.cpan.org #23020] Mail::Message::Head::Complete->clone doesn't behave as documented
Date: Mon, 13 Nov 2006 17:13:29 +0100
To: via RT <bug-Mail-Box [...] rt.cpan.org>
From: Mark Overmeer <solutions [...] overmeer.net>
* via RT (bug-Mail-Box@rt.cpan.org) [061112 00:26]: Show quoted text
> > Queue: Mail-Box > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=23020 > > > On Sat Nov 11 18:12:04 2006, Mark@Overmeer.net wrote:
> > Right. What is your wish? Adapt the docs or implement it?
> > As you like, really. I now work around it by using > > $copy = $head->clone; > $copy->removeFieldsExcept('Subject', 'Received');
Can you check whether this works for you: - $copy->addNoRealize($_->clone) foreach $self->orderedFields(@_); + $copy->addNoRealize($_->clone) foreach $self->grepNames(@_); -- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
From: jlh [...] gmx.ch
Show quoted text
> Can you check whether this works for you: > - $copy->addNoRealize($_->clone) foreach $self->orderedFields(@_); > + $copy->addNoRealize($_->clone) foreach $self->grepNames(@_);
You probably mean this (orderedFields takes no args anyway): - $copy->addNoRealize($_->clone) foreach $self->orderedFields; + $copy->addNoRealize($_->clone) foreach $self->grepNames(@_); At least that's what my copy looks like. That patch works for me in my test case that I used to confirm the problem, but not in my original program where I experienced the problem. I looked into this a bit. The sub grepNames() (line 133) will not return a list of blessed refs, but a list of scalars iff it exits at line 138, i.e. when you didn't pass it any arguments. I understand that this is an optimization: If you grepNames for nothing, it returns everything. However the expression $_->clone (line 20, modified by patch) won't work if $_ is a scalar. I'm not sure about this as I don't know all that code well, but maybe grepNames is meant to return $self->orderedFields instead of $self- Show quoted text
>names when it's not given any arguments.
grepName returning names i.s.o objects is a bug... it is no use to make a function which simplifies grep /a/, $head->names into $head->grepNames( qr/a/ ). Besides, it could never preserve the order of the fields for clone. So, we also need to change - return $self->names unless @take; + return $self->orderedFields unless @take; I have adapted the docs. Thanks for the investigations.
Subject: Re: [rt.cpan.org #23020] Mail::Message::Head::Complete->clone doesn't behave as documented
Date: Wed, 15 Nov 2006 00:08:51 +0100
To: via RT <bug-Mail-Box [...] rt.cpan.org>
From: Mark Overmeer <solutions [...] overmeer.net>
* via RT (bug-Mail-Box@rt.cpan.org) [061114 00:03]: Show quoted text
> > Can you check whether this works for you: > > - $copy->addNoRealize($_->clone) foreach $self->orderedFields(@_); > > + $copy->addNoRealize($_->clone) foreach $self->grepNames(@_);
> > I looked into this a bit. The sub grepNames() (line 133) will not > return a list of blessed refs, but a list of scalars iff it exits at > line 138, i.e. when you didn't pass it any arguments.
That was a bug. Next version of the module attached (contains my OODoc markup, but is usuable this way) Thanks for the help -- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net

Message body is not shown because sender requested not to inline it.