LibreCat / Catmandu

Catmandu - a data processing toolkit
https://librecat.org
175 stars 31 forks source link

Catmandu::Paged : "illegal division by zero" when limit is 0 #375

Closed nicolasfranck closed 3 years ago

nicolasfranck commented 4 years ago
my $hits = Catmandu::Hits->new( start => 0, limit => 0, hits => [], total => 100 );
say $hits->page;

returns:

Runtime error: Illegal division by zero at /Users/njfranck/.plenv/versions/5.22.0/lib/perl5/site_perl/5.22.0/Catmandu/Paged.pm

This happens when you call $hits->page or $hits->last_page.

nics commented 3 years ago

I can't reproduce this with the latest Catmandu (1.2013).

nicolasfranck commented 3 years ago

cf. https://github.com/LibreCat/Catmandu/blob/dev/lib/Catmandu/Paged.pm#L130 cf. https://github.com/LibreCat/Catmandu/blob/dev/lib/Catmandu/Paged.pm#L139

If you set limit to zero, then these lines should fail, not?

nics commented 3 years ago

You're right, I only tried out your example, which doesn't die.

nics commented 3 years ago

resolved in 604b5d973a6cc4ea382da98b79384e7ccfcef996

nicolasfranck commented 3 years ago

@nics nice ;-)