Followup r73348, r70608: move 'infinity' stuff to DB classes
authorChad Horohoe <demon@users.mediawiki.org>
Wed, 5 Jan 2011 13:43:13 +0000 (13:43 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Wed, 5 Jan 2011 13:43:13 +0000 (13:43 +0000)
includes/Block.php
includes/db/Database.php
includes/db/DatabaseMssql.php

index 7c5f0dd..162188c 100644 (file)
@@ -849,25 +849,12 @@ class Block {
 
        /**
         * Get a value to insert into expiry field of the database when infinite expiry
-        * is desired. In principle this could be DBMS-dependant, but currently all
-        * supported DBMS's support the string "infinity", so we just use that.
+        * is desired
         *
         * @return String
         */
        public static function infinity() {
-               # This is a special keyword for timestamps in PostgreSQL, and
-               # works with CHAR(14) as well because "i" sorts after all numbers.
-
-               # BEGIN DatabaseMssql hack
-               # Since MSSQL doesn't recognize the infinity keyword, set date manually.
-               # TO-DO: Refactor for better DB portability and remove magic date
-               $dbr = wfGetDB( DB_SLAVE );
-               if ( $dbr->getType() == 'mssql' ) {
-                       return '3000-01-31 00:00:00.000';
-               }
-               # End DatabaseMssql hack
-
-               return 'infinity';
+               return wfGetDB( DB_SLAVE )->getInfinity();
        }
 
        /**
index 449a9d2..017760a 100644 (file)
@@ -2663,6 +2663,17 @@ abstract class DatabaseBase implements DatabaseType {
                return 'SearchEngineDummy';
        }
 
+       /**
+        * Find out when 'infinity' is. Most DBMSes support this. This is a special
+        * keyword for timestamps in PostgreSQL, and works with CHAR(14) as well
+        * because "i" sorts after all numbers.
+        *
+        * @return String
+        */
+       public function getInfinity() {
+               return 'infinity';
+       }
+
        /**
         * Allow or deny "big selects" for this session only. This is done by setting
         * the sql_big_selects session variable.
index aa6212b..c03ffbb 100644 (file)
@@ -1040,6 +1040,14 @@ class DatabaseMssql extends DatabaseBase {
                return "SearchMssql";
        }
 
+       /**
+        * Since MSSQL doesn't recognize the infinity keyword, set date manually.
+        * @todo Remove magic date
+        */
+       public function getInfinity() {
+               return '3000-01-31 00:00:00.000';
+       }
+
 } // end DatabaseMssql class
 
 /**