Skip to content

Commit

Permalink
Avoid "splice() offset past end of array" warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
oalders committed Nov 19, 2016
1 parent ed3e71c commit 4302a53
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/MetaCPAN/Web/Model/API/Module.pm
Expand Up @@ -130,7 +130,11 @@ sub search_collapsed {
&& $data->{hits}->{total}
&& $data->{hits}->{total} > $hits + ( $run - 2 ) * $RESULTS_PER_RUN );

@distributions = splice( @distributions, $from, $page_size );
# Avoid "splice() offset past end of array" warning.
@distributions
= $from > @distributions
? ()
: splice( @distributions, $from, $page_size );

# Everything else will fail (slowly and quietly) without distributions.
if ( !@distributions ) {
Expand Down

0 comments on commit 4302a53

Please sign in to comment.