Awight has uploaded a new change for review.
https://gerrit.wikimedia.org/r/155319
Change subject: Add dates to banner-hiding cookies (server side)
......................................................................
Add dates to banner-hiding cookies (server side)
This should not be deployed until the JS portion is everywhere.
Update Special:HideBanners to change the value of hiding cookies
from 'hide' to a new JSON format:
{
"v" : 1, (cookie version)
"created" : 12345678,
"reason" : "close"
}
where "created" is in seconds since the epoch, and "reason" indicates
why the banner should be hidden (i.e., the user has donated or has
clicked the close button on a banner.)
Not including special cases for requests from the old JS, as the old
JS is getting a zero value for $wgNoticeCookiesShortExpiry and thus
sending 0 for duration. Also, no more old JS requests have been caught
in the log filter in the past week.
Change-Id: I62834899c2a861099340003c5528440595e67e6c
---
M special/SpecialHideBanners.php
1 file changed, 11 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralNotice
refs/changes/19/155319/1
diff --git a/special/SpecialHideBanners.php b/special/SpecialHideBanners.php
index e8f2bb1..5bce154 100644
--- a/special/SpecialHideBanners.php
+++ b/special/SpecialHideBanners.php
@@ -16,11 +16,11 @@
function execute( $par ) {
global $wgNoticeCookieDurations;
- $reason = 'donate'; //Once bannerController.js is fully
deployed, get this from the query string
+ $reason = $this->getRequest()->getText( 'reason', 'donate' );
$duration = $this->getRequest()->getInt( 'duration',
$wgNoticeCookieDurations[$reason] );
$category = $this->getRequest()->getText( 'category',
'fundraising' );
$category = Banner::sanitizeRenderedCategory( $category );
- $this->setHideCookie( $category, $duration );
+ $this->setHideCookie( $category, $duration, $reason );
$this->getOutput()->disable();
wfResetOutputBuffers();
@@ -35,16 +35,22 @@
/**
* Set the cookie for hiding fundraising banners.
*/
- function setHideCookie( $category, $duration ) {
+ function setHideCookie( $category, $duration, $reason ) {
global $wgNoticeCookieDomain;
- $exp = time() + $duration;
+ $created = time();
+ $exp = $created + $duration;
+ $value = array(
+ 'v' => 1,
+ 'created' => $created,
+ 'reason' => $reason
+ );
if ( is_callable( array( 'CentralAuthUser', 'getCookieDomain' )
) ) {
$cookieDomain = CentralAuthUser::getCookieDomain();
} else {
$cookieDomain = $wgNoticeCookieDomain;
}
- setcookie( "centralnotice_hide_{$category}", 'hide', $exp, '/',
$cookieDomain, false, false );
+ setcookie( "centralnotice_hide_{$category}", json_encode(
$value ), $exp, '/', $cookieDomain, false, false );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/155319
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I62834899c2a861099340003c5528440595e67e6c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: wmf_deploy
Gerrit-Owner: Awight <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits