Awight has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/220711

Change subject: WIP remove audit cruft
......................................................................

WIP remove audit cruft

Bookmark for future destruction.  In a better world, these functions wouldn't
be necessary.

Change-Id: Ib08792d89ef0210b6c00e34ea370982ba94808a3
---
M sites/all/modules/wmf_audit/wmf_audit.module
1 file changed, 0 insertions(+), 120 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/11/220711/1

diff --git a/sites/all/modules/wmf_audit/wmf_audit.module 
b/sites/all/modules/wmf_audit/wmf_audit.module
index adff527..a78b8ed 100644
--- a/sites/all/modules/wmf_audit/wmf_audit.module
+++ b/sites/all/modules/wmf_audit/wmf_audit.module
@@ -760,28 +760,6 @@
 }
 
 /**
- * Executes a function that is expected to exist in the relevant submodule
- * defined at runtime. Fails angrily if that function doesn't exist.
- * @param string $function_name_base Everything after the submodule . '_audit_'
- * in the function you're trying to call.
- * @param array $parameters The parameters you want to send to the function, in
- * array format.
- * @return mixed The return value of the specified function.
- */
-function wmfa_execute($function_name_base, $parameters = array()) {
-  $submod_prefix = wmf_audit_runtime_options('submod_prefix');
-  $function_name = $submod_prefix . '_audit_' . $function_name_base;
-  if (function_exists($function_name)) {
-    return call_user_func_array($function_name, $parameters);
-  } else {
-    //serious issues, you have.
-    wmf_audit_log_error("Missing required function $function_name", 
'MISSING_FUNCTION'); //should be fatal
-    die(); //this really should die here. For real, though.
-  }
-  return false; //no way to get here with all the dying
-}
-
-/**
  * Check the database to see if we have already recorded the transactions
  * present in the recon files.
  * @param array $transactions An array of transactions we have already parsed
@@ -887,79 +865,6 @@
     $chars = 0;
   }
 }
-
-/**
- * A confusing function for holding local runtime vars without having to goof
- * around with globals. Works as both get and set, depending on what you pass 
in
- * with $confusing_thing
- * @staticvar array $args The arguments set at runtime via drush command
- * @param array|string|null $confusing_thing A confusing thing.
- * * When it is an array, sets the internal static $args variable to that array
- * * When it is a string, it interprets the string to be the key for which 
there
- *   should be a value in $args, and returns that value (or false if not
- *   present).
- * * When it is null, it returns the whole $args array.
- * @return mixed Either a boolean, or a specific runtime setting (if
- * $confusing_thing is neither an array nor null)
- */
-function wmf_audit_runtime_options($confusing_thing = null) {
-  static $args = array();
-  if (is_array($confusing_thing)) { //we're setting up the function for later 
use, and $confusing_thing is the array of current settings.
-    $args = $confusing_thing;
-    return true;
-  } elseif (is_null($confusing_thing)) { //we want all the settings
-    return $args;
-  } elseif (array_key_exists($confusing_thing, $args)) { //we are after a 
specific setting
-    return $args[$confusing_thing];
-  }
-  return false;
-}
-
-/**
- * Logs the errors we get in a consistent way
- * @param string $watchdog_message The message we want to log. Should be
- * descriptive enough that we can bug hunt without having to go all cowboy in
- * prod.
- * @param string $drush_code If this code is fatal (According to
- * wmf_audit_error_isfatal), this will result in the whole script dying.
- */
-function wmf_audit_log_error($watchdog_message, $drush_code) {
-
-  watchdog(wmf_audit_runtime_options('submod_prefix') . '_audit', 
$watchdog_message, NULL, WATCHDOG_ERROR);
-
-  //Maybe explode
-  if (wmf_audit_error_isfatal($drush_code)) {
-    die("\n*** Fatal Error $drush_code: $watchdog_message");
-  }
-}
-
-/**
- * Returns an array of errors that should not cause the script to blow up, but
- * which will probably still cause messages to get thrown out.
- * @return boolean true if the error code is fatal, otherwise false.
- */
-function wmf_audit_error_isfatal($error) {
-  //All of these "nonfatal" things are meant to be nonfatal to the *job*, and
-  //not nonfatal to the contribution itself. We hit one of these,
-  //the contribution will be skipped, and we move to the next one.
-  //ALL OTHER CODES will cause the process to come to a screeching halt.
-  $nonfatal = array(
-    'DATA_INCONSISTENT',
-    'DATA_INCOMPLETE',
-    'DATA_WEIRD',
-    'MISSING_PAYMENTS_LOG',
-    'MISSING_MANDATORY_DATA',
-    'UTM_DATA_MISMATCH',
-    'NORMALIZE_DATA',
-  );
-
-  if (in_array($error, $nonfatal)) {
-    return false;
-  } else {
-    return true;
-  }
-}
-
 
 /**
  * Returns supplemental data for the relevant order id from the specified
@@ -1167,31 +1072,6 @@
   }
 
   return false;
-}
-
-/**
- * Makes everything we need to fake contribution tracking data.
- * So: Mostly the timestamp.
- * @param array $record Transaction parsed into an array
- * @return array utm and date data appropriate for $record
- */
-function wmf_audit_make_contribution_tracking_data($record) {
-  $utm_stuffer = wmf_audit_runtime_options('submod_prefix') . '_audit';
-  //anything we don't put in here should be handled by the universal defaults 
on
-  //import. And that's good.
-  $return = array(
-    'utm_source' => $utm_stuffer,
-    'utm_medium' => $utm_stuffer,
-    'utm_campaign' => $utm_stuffer,
-  );
-
-  if (!array_key_exists('date', $record)) {
-    wmf_audit_log_error(__FUNCTION__ . ": Record has no date field. Weirdness 
probably ensues", 'DATA_WEIRD');
-  } else {
-    $return['date'] = $record['date'];
-  }
-
-  return $return;
 }
 
 /**

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib08792d89ef0210b6c00e34ea370982ba94808a3
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Awight <awi...@wikimedia.org>

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

Reply via email to