[Koha-bugs] [Bug 28883] Koha::Objects->_new_from_dbic doesn't work correctly in list context
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Fri Aug 20 10:47:39 CEST 2021
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28883
--- Comment #7 from Marcel de Rooy <m.de.rooy at rijksmuseum.nl> ---
Seems to work as it is, but I am just wondering if we should force scalar
context within the map statement of _wrap ?
To prevent perl one day (another version etc) guessing list context and
creating an nice endless loop.
So making it:
my @objects = map { scalar $self->object_class->_new_from_dbic( $_ ) } etc
Instead of:
sub _new_from_dbic {
my ( $class, $resultset ) = @_;
+ if ( wantarray ) {
+ return $class->_wrap( $resultset->all() );
+ }
my $self = { _resultset => $resultset };
bless( $self, $class );
[..]
sub _wrap {
my ( $self, @dbic_rows ) = @_;
my @objects = map { $self->object_class->_new_from_dbic( $_ ) } @dbic_rows;
return @objects;
}
Adding an optional follow-up for it too. Please let me know what you think.
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list