r100466 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100465‎ | r100466 | r100467 >
Date:22:26, 21 October 2011
Author:khorn
Status:ok
Tags:
Comment:
Fixes for all the custom filters extras.
r100455, r100249
Modified paths:
  • /trunk/extensions/DonationInterface/donationinterface.php (modified) (history)
  • /trunk/extensions/DonationInterface/extras/custom_filters/filters/minfraud/minfraud.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/extras/custom_filters/filters/referrer/referrer.php (deleted) (history)
  • /trunk/extensions/DonationInterface/extras/custom_filters/filters/source/source.php (deleted) (history)
  • /trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/donationinterface.php
@@ -35,14 +35,16 @@
3636
3737 $optionalParts = array( //define as fail closed. This variable will be unset before we leave this file.
3838 'Extras' => false, //this one gets set in the next loop, so don't bother.
 39+ 'CustomFilters' => false, //Also gets set in the next loop.
3940 'Stomp' => false,
40 - 'CustomFilters' => false, //this is definitely an Extra
4141 'ConversionLog' => false, //this is definitely an Extra
4242 'Minfraud' => false, //this is definitely an Extra
43 - 'Minfraud_as_filter' => false, //extra
4443 'Recaptcha' => false, //extra
4544 'PayflowPro' => false,
4645 'GlobalCollect' => false,
 46+ 'ReferrerFilter' => false, //extra
 47+ 'SourceFilter' => false, //extra
 48+ 'Minfraud_as_filter' => false, //extra
4749
4850 );
4951
@@ -51,13 +53,26 @@
5254 global $$globalname;
5355 if ( isset( $$globalname ) && $$globalname === true ) {
5456 $optionalParts[$subextension] = true;
55 - if ( $subextension === 'CustomFilters' ||
 57+ //this is getting annoying.
 58+ if ( $subextension === 'ReferrerFilter' ||
 59+ $subextension === 'SourceFilter' ||
 60+ $subextension === 'Minfraud_as_filter' ||
5661 $subextension === 'ConversionLog' ||
5762 $subextension === 'Minfraud' ||
5863 $subextension === 'Recaptcha' ) {
5964
 65+ //we have extras
6066 $optionalParts['Extras'] = true;
 67+
 68+ if ( $subextension === 'ReferrerFilter' ||
 69+ $subextension === 'SourceFilter' ||
 70+ $subextension === 'Minfraud_as_filter' ){
 71+
 72+ //and at least one of them is a custom filter.
 73+ $optionalParts['CustomFilters'] = true;
 74+ }
6175 }
 76+
6277 }
6378 }
6479
@@ -134,6 +149,16 @@
135150 $wgAutoloadClasses['Gateway_Extras_CustomFilters_MinFraud'] = $donationinterface_dir . "extras/custom_filters/filters/minfraud/minfraud.body.php";
136151 }
137152
 153+//Referrer Filter classes
 154+if ( $optionalParts['ReferrerFilter'] === true ){
 155+ $wgAutoloadClasses['Gateway_Extras_CustomFilters_Referrer'] = $donationinterface_dir . "extras/custom_filters/filters/referrer/referrer.body.php";
 156+}
 157+
 158+//Source Filter classes
 159+if ( $optionalParts['SourceFilter'] === true ){
 160+ $wgAutoloadClasses['Gateway_Extras_CustomFilters_Source'] = $donationinterface_dir . "extras/custom_filters/filters/source/source.body.php";
 161+}
 162+
138163 //Recaptcha classes
139164 if ( $optionalParts['Recaptcha'] === true ){
140165 $wgAutoloadClasses['Gateway_Extras_ReCaptcha'] = $donationinterface_dir . "extras/recaptcha/recaptcha.body.php";
@@ -348,6 +373,16 @@
349374 $wgMinFraudStandalone = FALSE;
350375 }
351376
 377+//Referrer Filter globals
 378+if ( $optionalParts['ReferrerFilter'] === true ){
 379+ $wgCustomFiltersRefRules = array( );
 380+}
 381+
 382+//Source Filter globals
 383+if ( $optionalParts['SourceFilter'] === true ){
 384+ $wgCustomFiltersSrcRules = array( );
 385+}
 386+
352387 //Recaptcha globals
353388 if ( $optionalParts['Recaptcha'] === true ){
354389 /**
@@ -414,6 +449,16 @@
415450 $wgHooks["GatewayValidate"][] = array( 'Gateway_Extras_CustomFilters::onValidate' );
416451 }
417452
 453+//Referrer Filter hooks
 454+if ( $optionalParts['ReferrerFilter'] === true ){
 455+ $wgHooks["GatewayCustomFilter"][] = array( 'Gateway_Extras_CustomFilters_Referrer::onFilter' );
 456+}
 457+
 458+//Source Filter hooks
 459+if ( $optionalParts['SourceFilter'] === true ){
 460+ $wgHooks["GatewayCustomFilter"][] = array( 'Gateway_Extras_CustomFilters_Source::onFilter' );
 461+}
 462+
418463 //Conversion Log hooks
419464 if ($optionalParts['ConversionLog'] === true){
420465 // Sets the 'conversion log' as logger for post-processing
Index: trunk/extensions/DonationInterface/extras/custom_filters/filters/source/source.php
@@ -1,34 +0,0 @@
2 -<?php
3 -
4 -/**
5 - * Provides a method for filtering transactions based on source
6 - *
7 - * To install:
8 - * require_once( "$IP/extensions/DonationInterface/extras/custom_filters/filters/source/source.php" );
9 - */
10 -if ( !defined( 'MEDIAWIKI' ) ) {
11 - die( "This file is part of the source custom filter part of the Gateway extension. It is not a valid entry point\n" );
12 -}
13 -
14 -$wgExtensionCredits['gateway_customfilters_source'][] = array(
15 - 'name' => 'custom filter: source',
16 - 'author' => 'Arthur Richards',
17 - 'url' => '',
18 - 'description' => 'This extension provides a way to filter transactions based on their source.'
19 -);
20 -
21 -/**
22 - * An array defining source strings and their associated risk score amount
23 - *
24 - * The key of the array is a regular expression to run against the source and the value is
25 - * the amount to add to the risk score. The regex is run through preg_match and does not
26 - * need to include staring/ending delimiters - be sure to escape your characters!
27 - *
28 - * eg:
29 - * $wgCustomFiltersSrcRules['support.cc'] = "100";
30 - * // increases risk score for trxns with source of 'support.cc' referrals by 100
31 - */
32 -$wgCustomFiltersSrcRules = array( );
33 -
34 -$wgAutoloadClasses['Gateway_Extras_CustomFilters_Source'] = dirname( __FILE__ ) . "/source.body.php";
35 -$wgHooks["GatewayCustomFilter"][] = array( 'Gateway_Extras_CustomFilters_Source::onFilter' );
Index: trunk/extensions/DonationInterface/extras/custom_filters/filters/minfraud/minfraud.body.php
@@ -30,12 +30,12 @@
3131
3232 static function onFilter( &$gateway_adapter, &$custom_filter_object ) {
3333 $gateway_adapter->debugarray[] = 'minfraud onFilter hook!';
34 - return self::singleton( &$gateway_adapter )->filter( $custom_filter_object );
 34+ return self::singleton( $gateway_adapter )->filter( $custom_filter_object );
3535 }
3636
3737 static function singleton( &$gateway_adapter ) {
3838 if ( !self::$instance ) {
39 - self::$instance = new self( &$gateway_adapter );
 39+ self::$instance = new self( $gateway_adapter );
4040 }
4141 return self::$instance;
4242 }
Index: trunk/extensions/DonationInterface/extras/custom_filters/filters/referrer/referrer.php
@@ -1,34 +0,0 @@
2 -<?php
3 -
4 -/**
5 - * Provides a method for filtering transactions based on referrer
6 - *
7 - * To install:
8 - * require_once( "$IP/extensions/DonationInterface/extras/custom_filters/filters/referrer/referrer.php" );
9 - */
10 -if ( !defined( 'MEDIAWIKI' ) ) {
11 - die( "This file is part of the referrer custom filter part of the Gateway extension. It is not a valid entry point\n" );
12 -}
13 -
14 -$wgExtensionCredits['gateway_customfilters_referrer'][] = array(
15 - 'name' => 'custom filter: referrer',
16 - 'author' => 'Arthur Richards',
17 - 'url' => '',
18 - 'description' => 'This extension provides a way to filter transactions based on their referrer.'
19 -);
20 -
21 -/**
22 - * An array defining a regex to match referrer URLs and their associated risk score amount
23 - *
24 - * The key of the array is a regular expression to run against the referrer and the value is
25 - * the amount to add to the risk score. The regex is run through preg_match and does not
26 - * need to include staring/ending delimiters - be sure to escape your characters!
27 - *
28 - * eg:
29 - * $wgCustomFiltersRefRules['fraud\.com'] = "100";
30 - * // increases risk score for trxns with http://fraud.com referrals by 100
31 - */
32 -$wgCustomFiltersRefRules = array( );
33 -
34 -$wgAutoloadClasses['Gateway_Extras_CustomFilters_Referrer'] = dirname( __FILE__ ) . "/referrer.body.php";
35 -$wgHooks["GatewayCustomFilter"][] = array( 'Gateway_Extras_CustomFilters_Referrer::onFilter' );
Index: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php
@@ -1299,8 +1299,8 @@
13001300 }
13011301
13021302 function runPreProcess() {
 1303+ global $wgHooks;
13031304 if ( $this->transaction_option( 'do_validation' ) ) {
1304 - global $wgHooks;
13051305 if ( !isset( $wgHooks['GatewayValidate'] ) ) {
13061306 //if there ARE no validate hooks, we're okay.
13071307 $this->action = 'process';

Follow-up revisions

RevisionCommit summaryAuthorDate
r100472Even more fixes for all the custom filters extras....khorn23:05, 21 October 2011
r100484Debugging minfraud as a filter: Made sure we're passing in the contribution_t...khorn01:41, 22 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r100249Merging the fundraising branch of DonationInterface back into trunk....khorn18:36, 19 October 2011
r100455Bug fix: None of the pre-process hooks will ever fire until we're checking th...khorn21:39, 21 October 2011

Status & tagging log