Skip Menu |

This queue is for tickets about the Pipeline CPAN distribution.

Report information
The Basics
Id: 6305
Status: new
Priority: 0/
Queue: Pipeline

People
Owner: Nobody in particular
Requestors: spurkis [...] quiup.com
Cc:
AdminCc:

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



Subject: Backwards compat broken in Pipeline::Store::ISA->get
Hey James, There's 2 bugs I've found in Pipeline::Store::ISA: 1. set / get stores multiple identical values in the 'isa_store'. this results in a get() returning the same object more than once. 2. get sometimes returns single objects in an arrayref (breaks backwards compat). The patch attached fixes (1) with a hash, and (2) by checking the size of the array of objects found. It's as backwards compat as it's gonna get. If you are willing to break this (it was broken anyway since last time I used it ;-), you might fix (2) by simply returning the whole array of objects in get(): return @objs; Haven't thought of the knock-on effects though... hth, -Steve
Only in Pipeline-3.09/lib/Pipeline/Store: #ISA.pm# diff -ru Pipeline-3.09/lib/Pipeline/Store/ISA.pm Pipeline-3.09_01/lib/Pipeline/Store/ISA.pm --- Pipeline-3.09/lib/Pipeline/Store/ISA.pm Fri Apr 2 13:37:37 2004 +++ Pipeline-3.09_01/lib/Pipeline/Store/ISA.pm Fri Apr 2 13:34:43 2004 @@ -8,7 +8,7 @@ use Class::ISA; -our $VERSION=3.09; +our $VERSION=3.09_01; sub init { my $self = shift; @@ -43,9 +43,10 @@ my $store = $self->isa_store; foreach my $isa (@isa) { if (!exists $self->isa_store->{ $isa }) { - $store->{ $isa } = []; + $store->{ $isa } = {}; } - push @{$store->{ $isa }}, ref($obj); + $store->{ $isa }->{ ref($obj) } = 1; + #push @{$store->{ $isa }}, ref($obj); } $self->obj_store->{ref($obj)} = $obj; $self->emit("setting object " . ref($obj)); @@ -63,10 +64,11 @@ return $self->obj_store->{ $key }; } elsif (exists( $self->isa_store->{$key})) { my @objs; - foreach my $thing ( @{$self->isa_store->{ $key }} ) { + foreach my $thing ( keys %{$self->isa_store->{ $key }} ) { push @objs, $self->get( $thing ); } - return [ @objs ]; + return [ @objs ] if (@objs > 1); + return @objs; } else { $self->emit("no object $key"); return undef; @@ -106,7 +108,8 @@ =item set( OBJECT ) -The C<set> method stores an object specified by OBJECT in itself. +The C<set> method stores an object specified by OBJECT in itself. Replaces +existing objects of the same type. =item get( SCALAR )
From: Steve Purkis <spurkis [...] quiup.com>
Subject: Re: [cpan #6305] AutoReply: Backwards compat broken in Pipeline::Store::ISA->get
Date: Fri, 14 May 2004 20:33:32 +0100
To: bug-Pipeline [...] rt.cpan.org
RT-Send-Cc:
Actually, just found a bug in that patch - get() should read: ... return [ @objs ] if (@objs > 1); return $objs[0]; In cases where the user does not want an array it returns '1' (perl 5.8.4). This also means my recommendation won't work: Show quoted text
> you might fix (2) by simply returning the whole array of objects in > get(): > > return @objs;
Ahh well... +-- Steve Purkis | www.quiup.com | Quiup Ltd.