X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=includes%2FBlock.php;h=732699dce6285357181613cbfa0ae64f025dc6fc;hb=12166f46b4d63d3fd3cab68cf4c7090a1646dd09;hp=7cdc756303a23280449736c4a2154cb4d72dd3ad;hpb=01f36b721f6fb60000b625fd681993d50ebd0e40;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Block.php b/includes/Block.php index 7cdc756303..732699dce6 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -126,17 +126,42 @@ class Block { $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->selectRow( 'ipblocks', - '*', + self::selectFields(), array( 'ipb_id' => $id ), __METHOD__ ); if ( $res ) { - return Block::newFromRow( $res ); + return self::newFromRow( $res ); } else { return null; } } + /** + * Return the list of ipblocks fields that should be selected to create + * a new block. + * @return array + */ + public static function selectFields() { + return array( + 'ipb_id', + 'ipb_address', + 'ipb_by', + 'ipb_by_text', + 'ipb_reason', + 'ipb_timestamp', + 'ipb_auto', + 'ipb_anon_only', + 'ipb_create_account', + 'ipb_enable_autoblock', + 'ipb_expiry', + 'ipb_deleted', + 'ipb_block_email', + 'ipb_allow_usertalk', + 'ipb_parent_block_id', + ); + } + /** * Check if two blocks are effectively equal. Doesn't check irrelevant things like * the blocking user or the block timestamp, only things which affect the blocked user * @@ -247,7 +272,7 @@ class Block { } } - $res = $db->select( 'ipblocks', '*', $conds, __METHOD__ ); + $res = $db->select( 'ipblocks', self::selectFields(), $conds, __METHOD__ ); # This result could contain a block on the user, a block on the IP, and a russian-doll # set of rangeblocks. We want to choose the most specific one, so keep a leader board. @@ -260,7 +285,7 @@ class Block { $bestBlockPreventsEdit = null; foreach( $res as $row ){ - $block = Block::newFromRow( $row ); + $block = self::newFromRow( $row ); # Don't use expired blocks if( $block->deleteIfExpired() ){ @@ -588,7 +613,7 @@ class Block { $key = wfMemcKey( 'ipb', 'autoblock', 'whitelist' ); $lines = $wgMemc->get( $key ); if ( !$lines ) { - $lines = explode( "\n", wfMsgForContentNoTrans( 'autoblock_whitelist' ) ); + $lines = explode( "\n", wfMessage( 'autoblock_whitelist' )->inContentLanguage()->plain() ); $wgMemc->set( $key, $lines, 3600 * 24 ); } @@ -662,7 +687,7 @@ class Block { wfDebug( "Autoblocking {$this->getTarget()}@" . $autoblockIP . "\n" ); $autoblock->setTarget( $autoblockIP ); $autoblock->setBlocker( $this->getBlocker() ); - $autoblock->mReason = wfMsgForContent( 'autoblocker', $this->getTarget(), $this->mReason ); + $autoblock->mReason = wfMessage( 'autoblocker', $this->getTarget(), $this->mReason )->inContentLanguage()->text(); $timestamp = wfTimestampNow(); $autoblock->mTimestamp = $timestamp; $autoblock->mAuto = 1; @@ -977,41 +1002,6 @@ class Block { return wfGetDB( DB_SLAVE )->getInfinity(); } - /** - * Convert a DB-encoded expiry into a real string that humans can read. - * - * @param $encoded_expiry String: Database encoded expiry time - * @return Html-escaped String - * @deprecated since 1.18; use $wgLang->formatExpiry() instead - */ - public static function formatExpiry( $encoded_expiry ) { - wfDeprecated( __METHOD__, '1.18' ); - - global $wgContLang; - static $msg = null; - - if ( is_null( $msg ) ) { - $msg = array(); - $keys = array( 'infiniteblock', 'expiringblock' ); - - foreach ( $keys as $key ) { - $msg[$key] = wfMsgHtml( $key ); - } - } - - $expiry = $wgContLang->formatExpiry( $encoded_expiry, TS_MW ); - if ( $expiry == wfGetDB( DB_SLAVE )->getInfinity() ) { - $expirystr = $msg['infiniteblock']; - } else { - global $wgLang; - $expiredatestr = htmlspecialchars( $wgLang->date( $expiry, true ) ); - $expiretimestr = htmlspecialchars( $wgLang->time( $expiry, true ) ); - $expirystr = wfMsgReplaceArgs( $msg['expiringblock'], array( $expiredatestr, $expiretimestr ) ); - } - - return $expirystr; - } - /** * Convert a submitted expiry time, which may be relative ("2 weeks", etc) or absolute * ("24 May 2034"), into an absolute timestamp we can put into the database.