r94211 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94210‎ | r94211 | r94212 >
Date:23:27, 10 August 2011
Author:demon
Status:ok
Tags:
Comment:
Allow overriding $wgCookiePrefix and $wgCookieDomain in WebResponse::setcookie() so I can stop crying when I look at things like CentralAuth and CentralNotice
Modified paths:
  • /trunk/phase3/includes/WebResponse.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/WebResponse.php
@@ -43,29 +43,37 @@
4444 * @param $name String: name of cookie
4545 * @param $value String: value to give cookie
4646 * @param $expire Int: number of seconds til cookie expires
 47+ * @param $prefix String: Prefix to use, if not $wgCookiePrefix (use '' for no prefix)
 48+ * @param @domain String: Cookie domain to use, if not $wgCookieDomain
4749 */
48 - public function setcookie( $name, $value, $expire = 0 ) {
 50+ public function setcookie( $name, $value, $expire = 0, $prefix = null, $domain = null ) {
4951 global $wgCookiePath, $wgCookiePrefix, $wgCookieDomain;
5052 global $wgCookieSecure,$wgCookieExpiration, $wgCookieHttpOnly;
5153 if ( $expire == 0 ) {
5254 $expire = time() + $wgCookieExpiration;
5355 }
 56+ if( $prefix === null ) {
 57+ $prefix = $wgCookiePrefix;
 58+ }
 59+ if( $domain === null ) {
 60+ $domain = $wgCookieDomain;
 61+ }
5462 $httpOnlySafe = wfHttpOnlySafe() && $wgCookieHttpOnly;
5563 wfDebugLog( 'cookie',
5664 'setcookie: "' . implode( '", "',
5765 array(
58 - $wgCookiePrefix . $name,
 66+ $prefix . $name,
5967 $value,
6068 $expire,
6169 $wgCookiePath,
62 - $wgCookieDomain,
 70+ $domain,
6371 $wgCookieSecure,
6472 $httpOnlySafe ) ) . '"' );
65 - setcookie( $wgCookiePrefix . $name,
 73+ setcookie( $prefix . $name,
6674 $value,
6775 $expire,
6876 $wgCookiePath,
69 - $wgCookieDomain,
 77+ $domain,
7078 $wgCookieSecure,
7179 $httpOnlySafe );
7280 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r94216Followup r94211...reedy00:17, 11 August 2011
r101106MFT r94211,r94216: setcookie() tweaks for overriding the path, etc.demon01:02, 28 October 2011
r101107MFT r94211,r94216: setcookie() tweaks for overriding the path, etc.demon01:02, 28 October 2011

Status & tagging log