jenkins-bot has submitted this change and it was merged.

Change subject: Avoid using computed variables to determine stash keys
......................................................................


Avoid using computed variables to determine stash keys

These variables are not used as "inputs" and are expensive to
compute (the main reason for caching to begin with).

Bug: T138550
Change-Id: I75849ca8eab941f75ebb82313d07d946bc095ae9
---
M AbuseFilter.class.php
M AbuseFilterVariableHolder.php
2 files changed, 23 insertions(+), 6 deletions(-)

Approvals:
  MaxSem: Looks good to me, approved
  Hashar: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/AbuseFilter.class.php b/AbuseFilter.class.php
index e1ee041..2c9e2ef 100644
--- a/AbuseFilter.class.php
+++ b/AbuseFilter.class.php
@@ -979,7 +979,7 @@
        private static function getStashKey(
                BagOStuff $cache, AbuseFilterVariableHolder $vars, $group
        ) {
-               $inputVars = $vars->exportAllVars();
+               $inputVars = $vars->exportNonLazyVars();
                // Exclude noisy fields that have superficial changes
                unset( $inputVars['old_html'] );
                unset( $inputVars['new_html'] );
diff --git a/AbuseFilterVariableHolder.php b/AbuseFilterVariableHolder.php
index f93ec59..657b7c3 100644
--- a/AbuseFilterVariableHolder.php
+++ b/AbuseFilterVariableHolder.php
@@ -95,13 +95,11 @@
        /**
         * Export all variables stored in this object as string
         *
-        * @return array
+        * @return string[]
         */
        function exportAllVars() {
-               $allVarNames = array_keys( $this->mVars );
-               $exported = array();
-
-               foreach ( $allVarNames as $varName ) {
+               $exported = [];
+               foreach ( array_keys( $this->mVars ) as $varName ) {
                        if ( !in_array( $varName, self::$varBlacklist ) ) {
                                $exported[$varName] = $this->getVar( $varName 
)->toString();
                        }
@@ -111,6 +109,25 @@
        }
 
        /**
+        * Export all non-lazy variables stored in this object as string
+        *
+        * @return string[]
+        */
+       function exportNonLazyVars() {
+               $exported = [];
+               foreach ( $this->mVars as $varName => $data ) {
+                       if (
+                               !( $data instanceof AFComputedVariable )
+                               && !in_array( $varName, self::$varBlacklist )
+                       ) {
+                               $exported[$varName] = $this->getVar( $varName 
)->toString();
+                       }
+               }
+
+               return $exported;
+       }
+
+       /**
         * Dump all variables stored in this object in their native types.
         * If you want a not yet set variable to be included in the results you 
can
         * either set $compute to an array with the name of the variable or set

-- 
To view, visit https://gerrit.wikimedia.org/r/296457
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I75849ca8eab941f75ebb82313d07d946bc095ae9
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/AbuseFilter
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Hashar <has...@free.fr>
Gerrit-Reviewer: Jackmcbarn <jackmcb...@gmail.com>
Gerrit-Reviewer: MaxSem <maxsem.w...@gmail.com>
Gerrit-Reviewer: Se4598 <se4...@gmx.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to