gladiopeace / opensocial-php-client

Automatically exported from code.google.com/p/opensocial-php-client
Apache License 2.0
0 stars 0 forks source link

Memcache storage always removes token when you do a storage get with no expiration #67

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
1. Have an openauth connection started.
2. Next time you run the script with an api call and need the access token

last trunk version

when you get with default false expire, it always returns false?
i guess that's not right.. it only should do that when a time is given.

copy of code that does the wrong thing:
public function get($key, $expiration = false) {
    $this->check();
    if (($ret = @memcache_get($this->connection, $key)) === false) {
      return false;
    }
    if (! $expiration || (time() - $ret['time'] > $expiration)) {
      $this->delete($key);
      return false;
    }
    return $ret['data'];
  }

posible fix:

public function get($key, $expiration = false) {
    $this->check();
    if (($ret = @memcache_get($this->connection, $key)) === false) {
      return false;
    }
    if ($expiration)
    if (time() - $ret['time'] > $expiration) {
      $this->delete($key);
      return false;
    }
    return $ret['data'];
  }

Original issue reported on code.google.com by maescool on 2 Dec 2009 at 12:08