[MediaWiki-commits] [Gerrit] Remove openTask cookie on logout - change (mediawiki...GettingStarted)
jenkins-bot has submitted this change and it was merged. Change subject: Remove openTask cookie on logout .. Remove openTask cookie on logout Also, remove setPageTask method, since we no longer need a server-side method to assign tasks. Bug: 54992 Change-Id: I00f25c191d7eafe0c7c78d35c42bbb62f250f33f --- M GettingStarted.php M Hooks.php 2 files changed, 25 insertions(+), 19 deletions(-) Approvals: Phuedx: Looks good to me, approved jenkins-bot: Verified diff --git a/GettingStarted.php b/GettingStarted.php index 7295cfa..4cc9157 100644 --- a/GettingStarted.php +++ b/GettingStarted.php @@ -257,5 +257,6 @@ $wgHooks[ 'MakeGlobalVariablesScript' ][] = 'GettingStarted\Hooks::onMakeGlobalVariablesScript'; $wgHooks[ 'ResourceLoaderGetConfigVars' ][] = 'GettingStarted\Hooks::onResourceLoaderGetConfigVars'; $wgHooks[ 'GetPreferences' ][] = 'GettingStarted\Hooks::onGetPreferences'; +$wgHooks[ 'UserLogoutComplete'][] = 'GettingStarted\Hooks::onUserLogoutComplete'; // Extension:CentralAuth's hook $wgHooks[ 'CentralAuthPostLoginRedirect' ][] = 'GettingStarted\Hooks::onCentralAuthPostLoginRedirect'; diff --git a/Hooks.php b/Hooks.php index 2585d89..b8d4375 100644 --- a/Hooks.php +++ b/Hooks.php @@ -26,8 +26,13 @@ */ protected static $openTask = null; - // There is used unprefixed for legacy reasons. + // There is used unprefixed and with a custom path for legacy reasons. const COOKIE_NAME = 'openTask'; + + protected static $COOKIE_OPTIONS = array( + 'prefix' = '', + 'path' = '/', + ); const INTRO_OPTION = 'gettingstarted-task-toolbar-show-intro'; @@ -113,24 +118,6 @@ } return null; - } - - /** -* Sets a task for the title in the openTask structure, then sets the cookie. -* If applicable, this should already be prefixed (e.g. 'gettingstarted-addlinks', not 'addlinks'). -* -* @param WebRequest $request current request -* @param Title $title title to set -* @param string $task task to set -*/ - public static function setPageTask( WebRequest $request, Title $title, $task ) { - self::initializeOpenTask( $request ); - - self::$openTask[$title-getPrefixedText()] = $task; - - // WebResponse-setcookie cannot set session cookies - // This encoding will be decoded properly by jQuery.cookie (it uses decodeURIComponent). - setrawcookie( self::COOKIE_NAME, rawurlencode( FormatJson::encode( self::$openTask ) ), 0, '/' ); } /** @@ -398,6 +385,24 @@ } /** +* Delete the user's openTask cookie. +* +* Called when user is on the 'You are now logged out.' page +* +* @param User $user user object of the now-anonymous user +* @param string $inject_html reference that can be used to inject HTML into logout page. +* @param string $old_name name of user that just logged out +*/ + public static function onUserLogoutComplete( $user, $inject_html, $old_name ) { + global $wgRequest; + + // Set expiration time in the past to expire. Uses -1 day like User.php. + $wgRequest-response()-setcookie( self::COOKIE_NAME, '', time() - 86400, self::$COOKIE_OPTIONS ); + + return true; + } + + /** * When the CentralAuth extension has redirected away from the create * account form, preventing the BeforeWelcomeCreation hook, it runs this * hook. If user is not mobile, tweak the page returned to or its -- To view, visit https://gerrit.wikimedia.org/r/113337 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I00f25c191d7eafe0c7c78d35c42bbb62f250f33f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/GettingStarted Gerrit-Branch: master Gerrit-Owner: Mattflaschen mflasc...@wikimedia.org Gerrit-Reviewer: Ori.livneh o...@wikimedia.org Gerrit-Reviewer: Phuedx g...@samsmith.io Gerrit-Reviewer: Swalling swall...@wikimedia.org Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Remove openTask cookie on logout - change (mediawiki...GettingStarted)
Mattflaschen has uploaded a new change for review. https://gerrit.wikimedia.org/r/113337 Change subject: Remove openTask cookie on logout .. Remove openTask cookie on logout Also, remove setPageTask method, since we no longer need a server-side method to assign tasks. Bug: 54992 Change-Id: I00f25c191d7eafe0c7c78d35c42bbb62f250f33f --- M GettingStarted.php M Hooks.php 2 files changed, 25 insertions(+), 19 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GettingStarted refs/changes/37/113337/1 diff --git a/GettingStarted.php b/GettingStarted.php index 7295cfa..4cc9157 100644 --- a/GettingStarted.php +++ b/GettingStarted.php @@ -257,5 +257,6 @@ $wgHooks[ 'MakeGlobalVariablesScript' ][] = 'GettingStarted\Hooks::onMakeGlobalVariablesScript'; $wgHooks[ 'ResourceLoaderGetConfigVars' ][] = 'GettingStarted\Hooks::onResourceLoaderGetConfigVars'; $wgHooks[ 'GetPreferences' ][] = 'GettingStarted\Hooks::onGetPreferences'; +$wgHooks[ 'UserLogoutComplete'][] = 'GettingStarted\Hooks::onUserLogoutComplete'; // Extension:CentralAuth's hook $wgHooks[ 'CentralAuthPostLoginRedirect' ][] = 'GettingStarted\Hooks::onCentralAuthPostLoginRedirect'; diff --git a/Hooks.php b/Hooks.php index 2585d89..b8d4375 100644 --- a/Hooks.php +++ b/Hooks.php @@ -26,8 +26,13 @@ */ protected static $openTask = null; - // There is used unprefixed for legacy reasons. + // There is used unprefixed and with a custom path for legacy reasons. const COOKIE_NAME = 'openTask'; + + protected static $COOKIE_OPTIONS = array( + 'prefix' = '', + 'path' = '/', + ); const INTRO_OPTION = 'gettingstarted-task-toolbar-show-intro'; @@ -113,24 +118,6 @@ } return null; - } - - /** -* Sets a task for the title in the openTask structure, then sets the cookie. -* If applicable, this should already be prefixed (e.g. 'gettingstarted-addlinks', not 'addlinks'). -* -* @param WebRequest $request current request -* @param Title $title title to set -* @param string $task task to set -*/ - public static function setPageTask( WebRequest $request, Title $title, $task ) { - self::initializeOpenTask( $request ); - - self::$openTask[$title-getPrefixedText()] = $task; - - // WebResponse-setcookie cannot set session cookies - // This encoding will be decoded properly by jQuery.cookie (it uses decodeURIComponent). - setrawcookie( self::COOKIE_NAME, rawurlencode( FormatJson::encode( self::$openTask ) ), 0, '/' ); } /** @@ -398,6 +385,24 @@ } /** +* Delete the user's openTask cookie. +* +* Called when user is on the 'You are now logged out.' page +* +* @param User $user user object of the now-anonymous user +* @param string $inject_html reference that can be used to inject HTML into logout page. +* @param string $old_name name of user that just logged out +*/ + public static function onUserLogoutComplete( $user, $inject_html, $old_name ) { + global $wgRequest; + + // Set expiration time in the past to expire. Uses -1 day like User.php. + $wgRequest-response()-setcookie( self::COOKIE_NAME, '', time() - 86400, self::$COOKIE_OPTIONS ); + + return true; + } + + /** * When the CentralAuth extension has redirected away from the create * account form, preventing the BeforeWelcomeCreation hook, it runs this * hook. If user is not mobile, tweak the page returned to or its -- To view, visit https://gerrit.wikimedia.org/r/113337 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I00f25c191d7eafe0c7c78d35c42bbb62f250f33f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/GettingStarted Gerrit-Branch: master Gerrit-Owner: Mattflaschen mflasc...@wikimedia.org ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits