Accessor for LinksUpdate's parser output
[lhc/web/wiklou.git] / includes / Block.php
index 6be0348..ded9cf9 100644 (file)
@@ -81,8 +81,8 @@ class Block {
                $this->mAuto = $auto;
                $this->isHardblock( !$anonOnly );
                $this->prevents( 'createaccount', $createAccount );
-               if ( $expiry == wfGetDB( DB_SLAVE )->getInfinity() ) {
-                       $this->mExpiry = $expiry;
+               if ( $expiry == 'infinity' || $expiry == wfGetDB( DB_SLAVE )->getInfinity() ) {
+                       $this->mExpiry = 'infinity';
                } else {
                        $this->mExpiry = wfTimestamp( TS_MW, $expiry );
                }
@@ -105,6 +105,7 @@ class Block {
         * @deprecated since 1.18
         */
        public static function newFromDB( $address, $user = 0 ) {
+               wfDeprecated( __METHOD__, '1.18' );
                return self::newFromTarget( User::whoIs( $user ), $address );
        }
 
@@ -159,6 +160,7 @@ class Block {
         * @deprecated since 1.18
         */
        public function clear() {
+               wfDeprecated( __METHOD__, '1.18' );
                # Noop
        }
 
@@ -171,7 +173,7 @@ class Block {
         * @deprecated since 1.18
         */
        public function load( $address = '', $user = 0 ) {
-               wfDeprecated( __METHOD__ );
+               wfDeprecated( __METHOD__, '1.18' );
                if( $user ){
                        $username = User::whoIs( $user );
                        $block = self::newFromTarget( $username, $address );
@@ -362,8 +364,9 @@ class Block {
                $this->mId = $row->ipb_id;
 
                // I wish I didn't have to do this
-               if ( $row->ipb_expiry == wfGetDB( DB_SLAVE )->getInfinity() ) {
-                       $this->mExpiry = $row->ipb_expiry;
+               $db = wfGetDB( DB_SLAVE );
+               if ( $row->ipb_expiry == $db->getInfinity() ) {
+                       $this->mExpiry = 'infinity';
                } else {
                        $this->mExpiry = wfTimestamp( TS_MW, $row->ipb_expiry );
                }
@@ -427,7 +430,7 @@ class Block {
 
                $row = $this->getDatabaseArray();
                $row['ipb_id'] = $dbw->nextSequenceValue("ipblocks_ipb_id_seq");
-               
+
                $dbw->insert(
                        'ipblocks',
                        $row,
@@ -652,7 +655,7 @@ class Block {
                $autoblock->mHideName = $this->mHideName;
                $autoblock->prevents( 'editownusertalk', $this->prevents( 'editownusertalk' ) );
 
-               if ( $this->mExpiry == wfGetDB( DB_SLAVE )->getInfinity() ) {
+               if ( $this->mExpiry == 'infinity' ) {
                        # Original block was indefinite, start an autoblock now
                        $autoblock->mExpiry = Block::getAutoblockExpiry( $timestamp );
                } else {
@@ -806,6 +809,7 @@ class Block {
         * @param $x Bool
         */
        public function forUpdate( $x = null ) {
+               wfDeprecated( __METHOD__, '1.18' );
                # noop
        }
 
@@ -894,6 +898,7 @@ class Block {
         * @deprecated since 1.18; use $dbw->encodeExpiry() instead
         */
        public static function encodeExpiry( $expiry, $db ) {
+               wfDeprecated( __METHOD__, '1.18' );
                return $db->encodeExpiry( $expiry );
        }
 
@@ -906,6 +911,7 @@ class Block {
         * @deprecated since 1.18; use $wgLang->formatExpiry() instead
         */
        public static function decodeExpiry( $expiry, $timestampType = TS_MW ) {
+               wfDeprecated( __METHOD__, '1.18' );
                global $wgContLang;
                return $wgContLang->formatExpiry( $expiry, $timestampType );
        }
@@ -930,6 +936,7 @@ class Block {
         * @deprecated since 1.18, call IP::sanitizeRange() directly
         */
        public static function normaliseRange( $range ) {
+               wfDeprecated( __METHOD__, '1.18' );
                return IP::sanitizeRange( $range );
        }
 
@@ -949,6 +956,7 @@ class Block {
         * @return String
         */
        public static function infinity() {
+               wfDeprecated( __METHOD__, '1.18' );
                return wfGetDB( DB_SLAVE )->getInfinity();
        }
 
@@ -960,6 +968,8 @@ class Block {
         * @deprecated since 1.18; use $wgLang->formatExpiry() instead
         */
        public static function formatExpiry( $encoded_expiry ) {
+               wfDeprecated( __METHOD__, '1.18' );
+
                global $wgContLang;
                static $msg = null;
 
@@ -993,7 +1003,7 @@ class Block {
         * @deprecated since 1.18 moved to SpecialBlock::parseExpiryInput()
         */
        public static function parseExpiryInput( $expiry ) {
-               wfDeprecated( __METHOD__ );
+               wfDeprecated( __METHOD__, '1.18' );
                return SpecialBlock::parseExpiryInput( $expiry );
        }
 
@@ -1029,7 +1039,7 @@ class Block {
                        # passed by some callers (bug 29116)
                        return null;
 
-               } elseif( in_array( $type, array( Block::TYPE_USER, Block::TYPE_IP, Block::TYPE_RANGE, null ) ) ) {
+               } elseif( in_array( $type, array( Block::TYPE_USER, Block::TYPE_IP, Block::TYPE_RANGE ) ) ) {
                        $block = new Block();
                        $block->fromMaster( $fromMaster );
 
@@ -1039,12 +1049,9 @@ class Block {
 
                        if( $block->newLoad( $vagueTarget ) ){
                                return $block;
-                       } else {
-                               return null;
                        }
-               } else {
-                       return null;
                }
+               return null;
        }
 
        /**
@@ -1138,6 +1145,15 @@ class Block {
                return $this->target;
        }
 
+       /**
+        * @since 1.19
+        *
+        * @return Mixed|string
+        */
+       public function getExpiry() {
+               return $this->mExpiry;
+       }
+
        /**
         * Set the target for this block, and update $this->type accordingly
         * @param $target Mixed