Skip Menu |

This queue is for tickets about the MIME-tools CPAN distribution.

Report information
The Basics
Id: 41228
Status: rejected
Priority: 0/
Queue: MIME-tools

People
Owner: Nobody in particular
Requestors: jpierce [...] cpan.org
Cc:
AdminCc:

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



Subject: [patch] Fix MIME::Entity::parts() so that removal of sections actually works.
--- /usr/lib/perl5/site_perl/5.8.5/MIME/Entity.pm~ 2008-06-30 14:25:19.000000000 -0400 +++ /usr/lib/perl5/site_perl/5.8.5/MIME/Entity.pm 2008-11-25 23:36:57.000000000 -0500 @@ -1000,7 +1000,7 @@ sub parts { my $self = shift; - ref($_[0]) and return @{$self->{ME_Parts} = [@{$_[0]}]}; ### set the parts + ref($_[0]) and return @{$self->{ME_Parts} = [ @{$self->{ME_Parts}}[@{$_[0]}] ]}; (@_ ? $self->{ME_Parts}[$_[0]] : @{$self->{ME_Parts}}); }
Show quoted text
> - ref($_[0]) and return @{$self->{ME_Parts} = [@{$_[0]}]}; ### set
the parts Show quoted text
> + ref($_[0]) and return @{$self->{ME_Parts} = [
@{$self->{ME_Parts}}[@{$_[0]}] ]}; No thanks. Doing that breaks all sorts of existing behaviour -- like making it impossible to replace the parts entirely. The current way to remove parts (yes, it's possible) is described in the POD -- is there a reason it's not suitable? I _would_ take a patch that made something like $entity->del_part( $index ); possible, though. That wouldn't break current behaviour, and would complement the existing add_part() method.
Subject: Re: [rt.cpan.org #41228] [patch] Fix MIME::Entity::parts() so that removal of sections actually works.
Date: Wed, 03 Dec 2008 22:39:49 -0500
To: bug-MIME-tools [...] rt.cpan.org
From: Jerrad Pierce <belg4mit [...] MIT.EDU>
Show quoted text
>The current way to remove parts (yes, it's possible) is described in the POD >-- is there a reason it's not suitable?
No, it doesn't work. The documented method clears all parts from the message. That's the only reason I dove into the funky code. Show quoted text
>I _would_ take a patch that made something like >$entity->del_part( $index ); >possible, though. That wouldn't break current behaviour, and would >complement the existing add_part() method.
It's easy enough to turn my submission into that, it's how it was developed before being backported. -- Free map of local environmental resources: http://CambridgeMA.GreenMap.org -- MOTD on Boomtime, the 45th of The Aftermath, in the YOLD 3174: Human history becomes more and more a race between education and catastrophe. --H. G. Wells
On Wed Dec 03 22:40:06 2008, belg4mit@MIT.EDU wrote: Show quoted text
> No, it doesn't work. The documented method clears all parts from the > message.
The documented method lets you provide a new array of parts like so: $entity->parts( \@new_parts ); This new array replaces the existing one. So, if you want to remove parts, fetch the current parts, delete whatever you need to delete, and then call parts again to replace, like so: # Get them. my @new_parts = $entity->parts(); # Nuke the last part pop @new_parts; # Replace the entity's parts with the new array $entity->parts( \@new_parts ); This works fine, and has for quite some time. What part of this isn't working for you (and in which version of MIME-tools)? Show quoted text
> It's easy enough to turn my submission into that, it's how it was > developed before being backported.
It may be easy, but it requires time I don't have. If you send me a patch that implements del_part(), along with tests and POD for it, I'll include it. Cheers, Dave
Rejecting - existing removal of sections works as documented. Patch for del_part() will be accepted if you feel like writing it.