WikiFile::getHistory PHP Method

getHistory() public method

The initial history at object creation contains only the current revision of the file. To obtain more revisions, set $refresh to true and also optionally set $limit and the timestamps. The maximum limit is 500 for user accounts and 5000 for bot accounts. Timestamps can be in several formats as described here: https://www.mediawiki.org/w/api.php?action=help&modules=main#main.2Fdatatypes
public getHistory ( boolean $refresh = false, integer $limit = null, string $startts = null, string $endts = null ) : mixed
$refresh boolean True to query the wiki API again
$limit integer The number of file revisions to return (the maximum number by default)
$startts string The start timestamp of the listing (optional)
$endts string The end timestamp of the listing (optional)
return mixed The array of selected file revisions, or null if error
    public function getHistory($refresh = false, $limit = null, $startts = null, $endts = null)
    {
        if ($refresh) {
            // We want to query the API
            // Collect optional history parameters
            $history = array();
            if (!is_null($limit)) {
                $history['iilimit'] = $limit;
            } else {
                $history['iilimit'] = 'max';
            }
            if (!is_null($startts)) {
                $history['iistart'] = $startts;
            }
            if (!is_null($endts)) {
                $history['iiend'] = $endts;
            }
            // Get file revision history
            if ($this->getInfo($refresh, $history) === null) {
                return null;
            }
        }
        return $this->history;
    }