Make boundary inclusion optional in getHistory()
authorAaron Schulz <aaron@users.mediawiki.org>
Sun, 14 Dec 2008 03:53:05 +0000 (03:53 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Sun, 14 Dec 2008 03:53:05 +0000 (03:53 +0000)
includes/filerepo/File.php
includes/filerepo/LocalFile.php

index 4969647..9335799 100644 (file)
@@ -683,8 +683,9 @@ abstract class File {
         * @param $limit integer Limit of rows to return
         * @param $start timestamp Only revisions older than $start will be returned
         * @param $end timestamp Only revisions newer than $end will be returned
+        * @param $inc bool Include the endpoints of the time range
         */
-       function getHistory($limit = null, $start = null, $end = null) {
+       function getHistory($limit = null, $start = null, $end = null, $inc=true) {
                return array();
        }
 
index 36f72c1..dfd8332 100644 (file)
@@ -624,18 +624,18 @@ class LocalFile extends File
        /** purgeDescription inherited */
        /** purgeEverything inherited */
 
-       function getHistory($limit = null, $start = null, $end = null) {
+       function getHistory($limit = null, $start = null, $end = null, $inc = true) {
                $dbr = $this->repo->getSlaveDB();
                $tables = array('oldimage');
-               $join_conds = array();
                $fields = OldLocalFile::selectFields();
-               $conds = $opts = array();
+               $conds = $opts = $join_conds = array();
+               $eq = $inc ? "=" : "";
                $conds[] = "oi_name = " . $dbr->addQuotes( $this->title->getDBKey() );
                if( $start ) {
-                       $conds[] = "oi_timestamp <= " . $dbr->addQuotes( $dbr->timestamp( $start ) );
+                       $conds[] = "oi_timestamp <$eq " . $dbr->addQuotes( $dbr->timestamp( $start ) );
                }
                if( $end ) {
-                       $conds[] = "oi_timestamp >= " . $dbr->addQuotes( $dbr->timestamp( $end ) );
+                       $conds[] = "oi_timestamp >$eq " . $dbr->addQuotes( $dbr->timestamp( $end ) );
                }
                if( $limit ) {
                        $opts['LIMIT'] = $limit;