X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FBlock.php;h=b6b3ae05f1c8ce461a9619b528ce7565b46efd92;hb=4f43a9608fd4af27cce666c94caabb8106d50cc4;hp=66b9ff02d5ac60de90d5a050046f2a029b9e5650;hpb=8bb5a6c461c31ee5ce6874548246fc2c520686f6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Block.php b/includes/Block.php index 66b9ff02d5..b6b3ae05f1 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -20,6 +20,7 @@ * @file */ +use Wikimedia\Rdbms\IDatabase; use MediaWiki\MediaWikiServices; class Block { @@ -265,7 +266,7 @@ class Block { } # Be aware that the != '' check is explicit, since empty values will be - # passed by some callers (bug 29116) + # passed by some callers (T31116) if ( $vagueTarget != '' ) { list( $target, $type ) = self::parseTarget( $vagueTarget ); switch ( $type ) { @@ -358,7 +359,7 @@ class Block { if ( $end === null ) { $end = $start; } - # Per bug 14634, we want to include relevant active rangeblocks; for + # Per T16634, we want to include relevant active rangeblocks; for # rangeblocks, we want to include larger ranges which enclose the given # range. We know that all blocks must be smaller than $wgBlockCIDRLimit, # so we can improve performance by filtering on a LIKE clause @@ -553,7 +554,7 @@ class Block { $affected = $dbw->affectedRows(); if ( $this->isAutoblocking() ) { - // update corresponding autoblock(s) (bug 48813) + // update corresponding autoblock(s) (T50813) $dbw->update( 'ipblocks', $this->getAutoblockUpdateArray(), @@ -1117,7 +1118,7 @@ class Block { } elseif ( $target === null && $vagueTarget == '' ) { # We're not going to find anything useful here # Be aware that the == '' check is explicit, since empty values will be - # passed by some callers (bug 29116) + # passed by some callers (T31116) return null; } elseif ( in_array( @@ -1142,7 +1143,7 @@ class Block { * Get all blocks that match any IP from an array of IP addresses * * @param array $ipChain List of IPs (strings), usually retrieved from the - * X-Forwarded-For header of the request + * X-Forwarded-For header of the request * @param bool $isAnon Exclude anonymous-only blocks if false * @param bool $fromMaster Whether to query the master or replica DB * @return array Array of Blocks @@ -1223,9 +1224,9 @@ class Block { * * @param array $blocks Array of Block objects * @param array $ipChain List of IPs (strings). This is used to determine how "close" - * a block is to the server, and if a block matches exactly, or is in a range. - * The order is furthest from the server to nearest e.g., (Browser, proxy1, proxy2, - * local-squid, ...) + * a block is to the server, and if a block matches exactly, or is in a range. + * The order is furthest from the server to nearest e.g., (Browser, proxy1, proxy2, + * local-squid, ...) * @throws MWException * @return Block|null The "best" block from the list */ @@ -1450,13 +1451,9 @@ class Block { * Set the 'BlockID' cookie to this block's ID and expiry time. The cookie's expiry will be * the same as the block's, to a maximum of 24 hours. * - * An empty value can also be set, in order to retain the cookie but remove the block ID - * (e.g. as used in User::getBlockedStatus). - * * @param WebResponse $response The response on which to set the cookie. - * @param boolean $setEmpty Whether to set the cookie's value to the empty string. */ - public function setCookie( WebResponse $response, $setEmpty = false ) { + public function setCookie( WebResponse $response ) { // Calculate the default expiry time. $maxExpiryTime = wfTimestamp( TS_MW, wfTimestamp() + ( 24 * 60 * 60 ) ); @@ -1467,12 +1464,21 @@ class Block { } // Set the cookie. Reformat the MediaWiki datetime as a Unix timestamp for the cookie. - $cookieValue = $setEmpty ? '' : $this->getCookieValue(); $expiryValue = DateTime::createFromFormat( 'YmdHis', $expiryTime )->format( 'U' ); $cookieOptions = [ 'httpOnly' => false ]; + $cookieValue = $this->getCookieValue(); $response->setCookie( 'BlockID', $cookieValue, $expiryValue, $cookieOptions ); } + /** + * Unset the 'BlockID' cookie. + * + * @param WebResponse $response The response on which to unset the cookie. + */ + public static function clearCookie( WebResponse $response ) { + $response->clearCookie( 'BlockID', [ 'httpOnly' => false ] ); + } + /** * Get the BlockID cookie's value for this block. This is usually the block ID concatenated * with an HMAC in order to avoid spoofing (T152951), but if wgSecretKey is not set will just