X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FBlock.php;h=6e8f9f372a36d2faf329f846530d4d9e1eb6af37;hb=504fb18cacbf357beafd5be9eda786b028f40fdb;hp=dff1a5d33645307473339adf6e167b778fcb5683;hpb=32edcb1f170b6b2cfa9ff4935cd115c686e65eff;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Block.php b/includes/Block.php index dff1a5d336..6e8f9f372a 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -28,7 +28,8 @@ class Block { $mBlockEmail, $mDisableUsertalk, - $mCreateAccount; + $mCreateAccount, + $mParentBlockId; /// @var User|String protected $target; @@ -125,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 * @@ -246,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. @@ -259,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() ){ @@ -368,6 +394,7 @@ class Block { $this->mAuto = $row->ipb_auto; $this->mHideName = $row->ipb_deleted; $this->mId = $row->ipb_id; + $this->mParentBlockId = $row->ipb_parent_block_id; // I wish I didn't have to do this $db = wfGetDB( DB_SLAVE ); @@ -411,6 +438,7 @@ class Block { } $dbw = wfGetDB( DB_MASTER ); + $dbw->delete( 'ipblocks', array( 'ipb_parent_block_id' => $this->getId() ), __METHOD__ ); $dbw->delete( 'ipblocks', array( 'ipb_id' => $this->getId() ), __METHOD__ ); return $dbw->affectedRows() > 0; @@ -508,7 +536,8 @@ class Block { 'ipb_range_end' => $this->getRangeEnd(), 'ipb_deleted' => intval( $this->mHideName ), // typecast required for SQLite 'ipb_block_email' => $this->prevents( 'sendemail' ), - 'ipb_allow_usertalk' => !$this->prevents( 'editownusertalk' ) + 'ipb_allow_usertalk' => !$this->prevents( 'editownusertalk' ), + 'ipb_parent_block_id' => $this->mParentBlockId ); return $a; @@ -584,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 ); } @@ -658,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; @@ -666,6 +695,7 @@ class Block { # Continue suppressing the name if needed $autoblock->mHideName = $this->mHideName; $autoblock->prevents( 'editownusertalk', $this->prevents( 'editownusertalk' ) ); + $autoblock->mParentBlockId = $this->mId; if ( $this->mExpiry == 'infinity' ) { # Original block was indefinite, start an autoblock now @@ -990,7 +1020,7 @@ class Block { $keys = array( 'infiniteblock', 'expiringblock' ); foreach ( $keys as $key ) { - $msg[$key] = wfMsgHtml( $key ); + $msg[$key] = wfMessage( $key )->escaped(); } } @@ -1075,8 +1105,6 @@ class Block { * @return array( User|String, Block::TYPE_ constant ) */ public static function parseTarget( $target ) { - $target = trim( $target ); - # We may have been through this before if( $target instanceof User ){ if( IP::isValid( $target->getName() ) ){ @@ -1088,6 +1116,8 @@ class Block { return array( null, null ); } + $target = trim( $target ); + if ( IP::isValid( $target ) ) { # We can still create a User if it's an IP address, but we need to turn # off validation checking (which would exclude IP addresses)