AndyRussG has uploaded a new change for review.
https://gerrit.wikimedia.org/r/257811
Change subject: Prevent notice in logs for custom hide cookie reasons
......................................................................
Prevent notice in logs for custom hide cookie reasons
Bug: T120890
Change-Id: Iaf0a91a444126276f41512a34ad284ecd91a66f2
---
M special/SpecialHideBanners.php
1 file changed, 13 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralNotice
refs/changes/11/257811/1
diff --git a/special/SpecialHideBanners.php b/special/SpecialHideBanners.php
index 3eb8d4c..917a2b7 100644
--- a/special/SpecialHideBanners.php
+++ b/special/SpecialHideBanners.php
@@ -27,7 +27,19 @@
}
$reason = $this->getRequest()->getText( 'reason', 'donate' );
- $duration = $this->getRequest()->getInt( 'duration',
$wgNoticeCookieDurations[$reason] );
+
+ // No duration parameter for a custom reason would be a strange
but unimportant
+ // error state.
+ $duration = $this->getRequest()->getInt( 'duration', 0 );
+ if ( !$duration ) {
+ if ( isset( $wgNoticeCookieDurations[$reason] ) ) {
+ $duration = $wgNoticeCookieDurations[$reason];
+ } else {
+ throw new InvalidArgumentException(
+ 'No duration for setting hide cookie
with reason ' + $reason );
+ }
+ }
+
$category = $this->getRequest()->getText( 'category',
'fundraising' );
$category = Banner::sanitizeRenderedCategory( $category );
$this->setHideCookie( $category, $duration, $reason );
--
To view, visit https://gerrit.wikimedia.org/r/257811
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaf0a91a444126276f41512a34ad284ecd91a66f2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: master
Gerrit-Owner: AndyRussG <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits