[MediaWiki-commits] [Gerrit] $_SESSION cleanup: session_velocity filter - change (mediawiki...DonationInterface)
jenkins-bot has submitted this change and it was merged. Change subject: $_SESSION cleanup: session_velocity filter .. $_SESSION cleanup: session_velocity filter Use WebRequest session accessors instead of superglobal. Bug: T123006 Change-Id: I73e483b3cea419b197ae356580f105b3d18e6404 --- M extras/session_velocity/session_velocity.body.php 1 file changed, 14 insertions(+), 11 deletions(-) Approvals: Cdentinger: Looks good to me, approved jenkins-bot: Verified diff --git a/extras/session_velocity/session_velocity.body.php b/extras/session_velocity/session_velocity.body.php index 663562b..410ec8b 100644 --- a/extras/session_velocity/session_velocity.body.php +++ b/extras/session_velocity/session_velocity.body.php @@ -97,32 +97,35 @@ $threshold = $this->getVar( 'Threshold', $transaction ); // Initialize the filter - if ( !array_key_exists( self::SESS_ROOT, $_SESSION ) ) { - $_SESSION[self::SESS_ROOT] = array(); + $sessionData = $this->gateway_adapter->getRequest()->getSessionData( self::SESS_ROOT ); + if ( !is_array( $sessionData ) ) { + $sessionData = array(); } - if ( !array_key_exists( $gateway, $_SESSION[self::SESS_ROOT] ) ) { - $_SESSION[self::SESS_ROOT][$gateway] = array(); + if ( !array_key_exists( $gateway, $sessionData ) ) { + $sessionData[$gateway] = array(); } - if ( !array_key_exists( $transaction, $_SESSION[self::SESS_ROOT][$gateway] ) ) { - $_SESSION[self::SESS_ROOT][$gateway][$transaction] = array( + if ( !array_key_exists( $transaction, $sessionData[$gateway] ) ) { + $sessionData[$gateway][$transaction] = array( $this::SESS_SCORE => 0, $this::SESS_TIME => $cRequestTime, ); } - $lastTime = $_SESSION[self::SESS_ROOT][$gateway][$transaction][self::SESS_TIME]; - $score = $_SESSION[self::SESS_ROOT][$gateway][$transaction][self::SESS_SCORE]; + $lastTime = $sessionData[$gateway][$transaction][self::SESS_TIME]; + $score = $sessionData[$gateway][$transaction][self::SESS_SCORE]; // Update the filter if it's stale if ( $cRequestTime != $lastTime ) { $score = max( 0, $score - ( ( $cRequestTime - $lastTime ) * $decayRate ) ); $score += $this->getVar( 'HitScore', $transaction ); - // Store the results - $_SESSION[self::SESS_ROOT][$gateway][$transaction][$this::SESS_SCORE] = $score; - $_SESSION[self::SESS_ROOT][$gateway][$transaction][$this::SESS_TIME] = $cRequestTime; + $sessionData[$gateway][$transaction][$this::SESS_SCORE] = $score; + $sessionData[$gateway][$transaction][$this::SESS_TIME] = $cRequestTime; } + // Store the results + $this->gateway_adapter->getRequest()->setSessionData( self::SESS_ROOT, $sessionData ); + // Analyze the filter results if ( $score >= $threshold ) { // Ahh!!! Failure!!! Slw d -- To view, visit https://gerrit.wikimedia.org/r/265384 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I73e483b3cea419b197ae356580f105b3d18e6404 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Ejegg Gerrit-Reviewer: AndyRussG Gerrit-Reviewer: Awight Gerrit-Reviewer: Cdentinger Gerrit-Reviewer: Ssmith Gerrit-Reviewer: XenoRyet Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] $_SESSION cleanup: session_velocity filter - change (mediawiki...DonationInterface)
Ejegg has uploaded a new change for review. https://gerrit.wikimedia.org/r/265384 Change subject: $_SESSION cleanup: session_velocity filter .. $_SESSION cleanup: session_velocity filter Use WebRequest session accessors instead of superglobal. Bug: T123006 Change-Id: I73e483b3cea419b197ae356580f105b3d18e6404 --- M extras/session_velocity/session_velocity.body.php 1 file changed, 14 insertions(+), 11 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/84/265384/1 diff --git a/extras/session_velocity/session_velocity.body.php b/extras/session_velocity/session_velocity.body.php index 663562b..410ec8b 100644 --- a/extras/session_velocity/session_velocity.body.php +++ b/extras/session_velocity/session_velocity.body.php @@ -97,32 +97,35 @@ $threshold = $this->getVar( 'Threshold', $transaction ); // Initialize the filter - if ( !array_key_exists( self::SESS_ROOT, $_SESSION ) ) { - $_SESSION[self::SESS_ROOT] = array(); + $sessionData = $this->gateway_adapter->getRequest()->getSessionData( self::SESS_ROOT ); + if ( !is_array( $sessionData ) ) { + $sessionData = array(); } - if ( !array_key_exists( $gateway, $_SESSION[self::SESS_ROOT] ) ) { - $_SESSION[self::SESS_ROOT][$gateway] = array(); + if ( !array_key_exists( $gateway, $sessionData ) ) { + $sessionData[$gateway] = array(); } - if ( !array_key_exists( $transaction, $_SESSION[self::SESS_ROOT][$gateway] ) ) { - $_SESSION[self::SESS_ROOT][$gateway][$transaction] = array( + if ( !array_key_exists( $transaction, $sessionData[$gateway] ) ) { + $sessionData[$gateway][$transaction] = array( $this::SESS_SCORE => 0, $this::SESS_TIME => $cRequestTime, ); } - $lastTime = $_SESSION[self::SESS_ROOT][$gateway][$transaction][self::SESS_TIME]; - $score = $_SESSION[self::SESS_ROOT][$gateway][$transaction][self::SESS_SCORE]; + $lastTime = $sessionData[$gateway][$transaction][self::SESS_TIME]; + $score = $sessionData[$gateway][$transaction][self::SESS_SCORE]; // Update the filter if it's stale if ( $cRequestTime != $lastTime ) { $score = max( 0, $score - ( ( $cRequestTime - $lastTime ) * $decayRate ) ); $score += $this->getVar( 'HitScore', $transaction ); - // Store the results - $_SESSION[self::SESS_ROOT][$gateway][$transaction][$this::SESS_SCORE] = $score; - $_SESSION[self::SESS_ROOT][$gateway][$transaction][$this::SESS_TIME] = $cRequestTime; + $sessionData[$gateway][$transaction][$this::SESS_SCORE] = $score; + $sessionData[$gateway][$transaction][$this::SESS_TIME] = $cRequestTime; } + // Store the results + $this->gateway_adapter->getRequest()->setSessionData( self::SESS_ROOT, $sessionData ); + // Analyze the filter results if ( $score >= $threshold ) { // Ahh!!! Failure!!! Slw d -- To view, visit https://gerrit.wikimedia.org/r/265384 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I73e483b3cea419b197ae356580f105b3d18e6404 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Ejegg ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits