Skip Menu |

This queue is for tickets about the WWW-PerlMonks CPAN distribution.

Report information
The Basics
Id: 119125
Status: new
Priority: 0/
Queue: WWW-PerlMonks

People
Owner: TMHARISH [...] cpan.org
Requestors: nick [...] nicktonkin.net
Cc:
AdminCc:

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



CC: Harish Madabushi <harish.tmh [...] gmail.com>
Subject: Bug with recent node list
Date: Mon, 5 Dec 2016 06:23:06 -0500
To: bug-WWW-PerlMonks [...] rt.cpan.org
From: Nick Tonkin <nick [...] nicktonkin.net>
Hi there, It seems there's a bug regarding the maximum age of nodes to be included in the recent nodes list returned by get_newest_nodes(). The module's doc indicates that one can restrict the results returned with: Parameters : Optional - 'unix timestamp' of earliest message ( cannot be more than 8 days - 691200 sec - ago ) However it appears that the PerlMonks API expects the actual epoch time of the earliest node requested. So a call like: $pm->get_newest_nodes( time - 86400 ) ... should return all nodes created in the previous 24 hours. However, this module attempts to enforce the PerlMonks limit of 8 days, and treats the value passed as an interval, rather than an absolute value. So in the case above, it compares the value of ( time - 86400 ) to 691200 and if the passed value is greater, it is coerced to 691200 (with a warning). The new value of 691200 is passed to the PerlMonks API, which is expecting an absolute value, and gets the epoch time for "Fri Jan 9 00:00:00 1970 UTC" ! So PerlMonks does its own coercion, to ( time - 691200 ), and returns those results, which of course match what the module coercion would have returned, if there were not this bug -- so the bug is hidden! You can see this if you attempt to use the module as documented, and instead of passing (time - 86400) to get the last 24 hours' results, you pass (86400) -- the PerlMonks API thinks you are asking for nodes from Fri Jan 2 00:00:00 1970 UTC. To fix: Treat the value of the arg passed to get_newest_nodes() as an absolute time, coercing it to a minimum value of ( time - 691200 ). Alternatively, extend the method to accept named parameters, allowing the caller to choose between passing an interval or a fixed time. Thanks! - nick