ChangeLog::getRevisionInfo PHP Method

getRevisionInfo() public method

Adjacent changelog lines are optimistically parsed and cached to speed up consecutive calls to getRevisionInfo. For large changelog files, only the chunk containing the requested changelog line is read.
Author: Ben Coburn ([email protected])
Author: Kate Arzamastseva ([email protected])
public getRevisionInfo ( integer $rev ) : boolean | array
$rev integer revision timestamp
return boolean | array false or array with entries: - date: unix timestamp - ip: IPv4 address (127.0.0.1) - type: log line type - id: page id - user: user name - sum: edit summary (or action reason) - extra: extra data (varies by line type)
    public function getRevisionInfo($rev)
    {
        $rev = max($rev, 0);
        // check if it's already in the memory cache
        if (isset($this->cache[$this->id]) && isset($this->cache[$this->id][$rev])) {
            return $this->cache[$this->id][$rev];
        }
        //read lines from changelog
        list($fp, $lines) = $this->readloglines($rev);
        if ($fp) {
            fclose($fp);
        }
        if (empty($lines)) {
            return false;
        }
        // parse and cache changelog lines
        foreach ($lines as $value) {
            $tmp = parseChangelogLine($value);
            if ($tmp !== false) {
                $this->cache[$this->id][$tmp['date']] = $tmp;
            }
        }
        if (!isset($this->cache[$this->id][$rev])) {
            return false;
        }
        return $this->cache[$this->id][$rev];
    }