jenkins-bot has submitted this change and it was merged.

Change subject: Update setUseFormatCookie() to use WebResponse::setcookie()
......................................................................


Update setUseFormatCookie() to use WebResponse::setcookie()

We previously relied on PHP's setcookie function rather than
WebResponse::setcookie() due to some nuances of how MW's version of
setcookie behaved which was causing problems with setUseFormatCookie()
on the WMF cluster (iirc, it was around wgCookieHttpOnly). But
WebResponse::setcookie() has since been updated to support more flexible
options, meaning we can now rely on it again.

Change-Id: I5c173b4f8c079bedefc57b1c45982c1576538b0e
---
M includes/MobileContext.php
1 file changed, 9 insertions(+), 9 deletions(-)

Approvals:
  JGonera: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/MobileContext.php b/includes/MobileContext.php
index 23960cc..b266941 100644
--- a/includes/MobileContext.php
+++ b/includes/MobileContext.php
@@ -524,22 +524,22 @@
         * This cookie can determine whether or not a user should see the mobile
         * version of pages.
         *
-        * Uses regular php setcookie rather than WebResponse::setCookie()
-        * so we can ignore $wgCookieHttpOnly since the protection is provides
-        * is irrelevant for this cookie.
-        *
         * @param string $cookieFormat
         * @param null $expiry
         */
        public function setUseFormatCookie( $cookieFormat = 'true', $expiry = 
null ) {
-               global $wgCookiePath, $wgCookieSecure;
-
                if ( is_null( $expiry ) ) {
                        $expiry = $this->getUseFormatCookieExpiry();
                }
-
-               setcookie( self::USEFORMAT_COOKIE_NAME, $cookieFormat, $expiry, 
$wgCookiePath,
-                       $this->getRequest()->getHeader( 'Host' ), 
$wgCookieSecure );
+               $this->getRequest()->response()->setcookie(
+                       self::USEFORMAT_COOKIE_NAME,
+                       $cookieFormat,
+                       $expiry,
+                       array(
+                               'prefix' => '',
+                               'httpOnly' => false,
+                       )
+               );
                wfIncrStats( 'mobile.useformat_' . $cookieFormat . 
'_cookie_set' );
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/115556
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I5c173b4f8c079bedefc57b1c45982c1576538b0e
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Awjrichards <[email protected]>
Gerrit-Reviewer: JGonera <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to