Skip Menu |

This queue is for tickets about the WebService-Solr CPAN distribution.

Report information
The Basics
Id: 114415
Status: open
Priority: 0/
Queue: WebService-Solr

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

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



Subject: BUILDARGS in WebService::Solr::Query prevents subclasses from working properly
Consider this subclass: package My::WebService::Solr::Query; use Moose; extends 'WebService::Solr::Query'; has localparams => ( is => 'ro', isa => 'Str', default => sub { '' } ); 1; This constructor call will pass localparams down into WebService::Solr::Query, where it gets taken as args to the query. my $q = My::WebService::Solr::Query->new( localparams => 'foo' ); I talked to Dave Rolsky who said that the BUILDARGS isn't processing the arguments correctly. For now, I'm working around it by not passing localparams in the constructor to my subclass, and then setting it through a mutator.
On Mon May 16 15:25:13 2016, PETDANCE wrote: Show quoted text
> Consider this subclass: > > package My::WebService::Solr::Query; > use Moose; > extends 'WebService::Solr::Query'; > has localparams => ( is => 'ro', isa => 'Str', default => sub { '' } > ); > 1; > > This constructor call will pass localparams down into > WebService::Solr::Query, where it gets taken as args to the query. > > my $q = My::WebService::Solr::Query->new( localparams => 'foo' ); > > I talked to Dave Rolsky who said that the BUILDARGS isn't processing > the arguments correctly. For now, I'm working around it by not > passing localparams in the constructor to my subclass, and then > setting it through a mutator.
The problem is that the BUILDARGS assumes that everything in @_ is a query. However, if a subclass adds attributes, then @_ can contains something like "query => { ... }, subclass_arg => 42", leading to problems. Assuming that a @_ that contains a hash or hashref _doesn't contain_ named attribute params is a bit of anti-pattern.