sparkapi / sparkapi4p2

A PHP wrapper for the flexmls REST API.
GNU General Public License v3.0
26 stars 28 forks source link

Bug: SparkAPI_Core::parse_cache_time($val) #9

Closed maxchirkov closed 12 years ago

maxchirkov commented 12 years ago

In Core.php on line #150:

        $time = substr($val, 0, -1);

actually removes last character from the $val variable and then the wrong value is returned in the condition below where $time = $val:

        if (empty($time)) {
            // no trailing identifier given so assuming that what was given was in seconds
            $time = $val;
        }

So, if I pass 10800 seconds (3 hours) to the method, I get 1080 back, which is only about 18 minutes.

joshcom commented 12 years ago

That method expects a parameter in one of the following formats:

I believe your use case can be solved by using one of these formats, instead of the seconds you wish to cache for.

maxchirkov commented 12 years ago

Yes, but you have a condition that checks for numeric value and assumes that seconds are being provided. Of course, I avoided the issue by using your custom format, after I realized the issue with regular seconds.

Max Chirkov

On Thu, Jul 19, 2012 at 11:23 AM, Joshua Murray < reply@reply.github.com

wrote:

That method expects a parameter in one of the following formats:

  • "1w" (One week)
  • "2d" (Two days)
  • "4h" (Four hours)
  • "15m" (Fifteen minutes)

I believe your use case can be solved by using one of these formats, instead of the seconds you wish to cache for.


Reply to this email directly or view it on GitHub: https://github.com/sparkapi/sparkapi4p2/issues/9#issuecomment-7106594

joshcom commented 12 years ago

You're right, they did make that assumption! Reopening

donclem commented 12 years ago

Code updated and merged! It was resolved with pull request from issue #12.