Skip Menu |

This queue is for tickets about the API-CPanel CPAN distribution.

Report information
The Basics
Id: 57646
Status: resolved
Priority: 0/
Queue: API-CPanel

People
Owner: Nobody in particular
Requestors:
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.04
Fixed in: (no value)



Subject: Error when XML::Simple don't create arrays in fetch_array_abstract
When we do API::CPanel::User::list( $connection_params ); CPanel can return this XML: <listaccts> <acct> <disklimit>50M</disklimit> ... </acct> </listaccts> If the number of users is one, XML::Simple don't create an array of acct (the container) because only have one element. fetch_array_abstract() receive from query_abstract a hash reference, not a array reference: $VAR1 = { 'acct' => { 'disklimit' => '50M', ... }, }; then fetch_array_abstract() return a empty list: return $result_list unless $result && ref $result eq 'ARRAY'; A possible solution (work verified for one user list): sub fetch_array_abstract { my %params = @_; my $result_field = $params{result_field} || ''; my $result_list = [ ]; my $result = query_abstract( params => $params{params}, func => $params{func}, container => $params{container}, allowed_fields => $params{allowed_fields}, ); return $result_list unless $result; # <= exit $result = [$result] unless ref $result eq 'ARRAY'; # <= make an array ref foreach my $elem ( @{ $result } ) { push @$result_list, $result_field ? $elem->{$result_field} : $elem; }; return $result_list; }
Срд Май 19 19:38:52 2010, explorer@joaquinferrero.com писал: Show quoted text
> When we do API::CPanel::User::list( $connection_params ); CPanel can > return this XML: > > <listaccts> > <acct> > <disklimit>50M</disklimit> > ... > </acct> > </listaccts> > > If the number of users is one, XML::Simple don't create an array of acct > (the container) because only have one element. > > fetch_array_abstract() receive from query_abstract a hash reference, not > a array reference: > > $VAR1 = { > 'acct' => { > 'disklimit' => '50M', > ... > }, > }; > > then fetch_array_abstract() return a empty list: > > return $result_list unless $result && ref $result eq 'ARRAY'; > > > A possible solution (work verified for one user list): > > sub fetch_array_abstract { > my %params = @_; > > my $result_field = $params{result_field} || ''; > my $result_list = [ ]; > my $result = query_abstract( > params => $params{params}, > func => $params{func}, > container => $params{container}, > allowed_fields => $params{allowed_fields}, > ); > return $result_list unless $result; # <= exit > $result = [$result] unless ref $result eq 'ARRAY'; # <= make an > array ref > > foreach my $elem ( @{ $result } ) { > push @$result_list, $result_field ? $elem->{$result_field} : $elem; > }; > > return $result_list; > } >
hi! thx for bugreport, bug fixed in 0.06 version