From: Chad Horohoe Date: Wed, 5 Jan 2011 13:43:13 +0000 (+0000) Subject: Followup r73348, r70608: move 'infinity' stuff to DB classes X-Git-Tag: 1.31.0-rc.0~32809 X-Git-Url: https://git.cyclocoop.org/admin/?a=commitdiff_plain;h=b61756cdeac238c920093e9ceeb89135226d5f63;p=lhc%2Fweb%2Fwiklou.git Followup r73348, r70608: move 'infinity' stuff to DB classes --- diff --git a/includes/Block.php b/includes/Block.php index 7c5f0ddd72..162188cfbf 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -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(); } /** diff --git a/includes/db/Database.php b/includes/db/Database.php index 449a9d2336..017760a526 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -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. diff --git a/includes/db/DatabaseMssql.php b/includes/db/DatabaseMssql.php index aa6212b096..c03ffbb7ea 100644 --- a/includes/db/DatabaseMssql.php +++ b/includes/db/DatabaseMssql.php @@ -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 /**