https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112939
Revision: 112939
Author: aaron
Date: 2012-03-03 11:49:02 +0000 (Sat, 03 Mar 2012)
Log Message:
-----------
[DatabaseBase] Made encodeExpiry() recognize 'infinity' and added a
decodeExpiry() function
Modified Paths:
--------------
trunk/phase3/includes/db/Database.php
Modified: trunk/phase3/includes/db/Database.php
===================================================================
--- trunk/phase3/includes/db/Database.php 2012-03-03 11:31:55 UTC (rev
112938)
+++ trunk/phase3/includes/db/Database.php 2012-03-03 11:49:02 UTC (rev
112939)
@@ -3443,20 +3443,31 @@
}
/**
- * Encode an expiry time
+ * Encode an expiry time into the DBMS dependent format
*
* @param $expiry String: timestamp for expiry, or the 'infinity' string
* @return String
*/
public function encodeExpiry( $expiry ) {
- if ( $expiry == '' || $expiry == $this->getInfinity() ) {
- return $this->getInfinity();
- } else {
- return $this->timestamp( $expiry );
- }
+ return ( $expiry == '' || $expiry == 'infinity' || $expiry ==
$this->getInfinity() )
+ ? $this->getInfinity()
+ : $this->timestamp( $expiry );
}
/**
+ * Decode an expiry time into a DBMS independent format
+ *
+ * @param $expiry String: DB timestamp field value for expiry
+ * @param $format integer: TS_* constant, defaults to TS_MW
+ * @return String
+ */
+ public function decodeExpiry( $expiry, $format = TS_MW ) {
+ return ( $expiry == '' || $expiry == $this->getInfinity() )
+ ? 'infinity'
+ : wfTimestamp( $format, $expiry );
+ }
+
+ /**
* Allow or deny "big selects" for this session only. This is done by
setting
* the sql_big_selects session variable.
*
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs