Put block cookie expiry into UTC for comparison with current time
authorThalia <thalia.e.chan@googlemail.com>
Tue, 20 Aug 2019 14:32:47 +0000 (15:32 +0100)
committerThalia <thalia.e.chan@googlemail.com>
Tue, 20 Aug 2019 15:22:14 +0000 (16:22 +0100)
Change-Id: Ia01a364a01ebacec8783ecdcfe4a129cfb746eb8

includes/block/BlockManager.php

index b67703c..4a5df8e 100644 (file)
@@ -21,6 +21,7 @@
 namespace MediaWiki\Block;
 
 use DateTime;
+use DateTimeZone;
 use DeferredUpdates;
 use IP;
 use MediaWiki\Config\ServiceOptions;
@@ -435,7 +436,11 @@ class BlockManager {
                }
 
                // Set the cookie. Reformat the MediaWiki datetime as a Unix timestamp for the cookie.
-               $expiryValue = DateTime::createFromFormat( 'YmdHis', $expiryTime )->format( 'U' );
+               $expiryValue = DateTime::createFromFormat(
+                       'YmdHis',
+                       $expiryTime,
+                       new DateTimeZone( 'UTC' )
+               )->format( 'U' );
                $cookieOptions = [ 'httpOnly' => false ];
                $cookieValue = $this->getCookieValue( $block );
                $response->setCookie( 'BlockID', $cookieValue, $expiryValue, $cookieOptions );