Paladox has uploaded a new change for review.
https://gerrit.wikimedia.org/r/263238
Change subject: Test: Do NOT MERGE
......................................................................
Test: Do NOT MERGE
Change-Id: I882ea7a264dc19c724c846647419bdbff14a6498
---
M gateway_common/DonationData.php
M tests/Adapter/GatewayAdapterTest.php
M tests/DonationDataTest.php
3 files changed, 8 insertions(+), 24 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface
refs/changes/38/263238/1
diff --git a/gateway_common/DonationData.php b/gateway_common/DonationData.php
index cc9cfa7..f7e9473 100644
--- a/gateway_common/DonationData.php
+++ b/gateway_common/DonationData.php
@@ -353,21 +353,24 @@
* Sets user_ip and server_ip.
*/
protected function setIPAddresses(){
- if ( !$this->gateway->isBatchProcessor() ) {
- // Refresh the IP from something authoritative, unless
we're running
- // a batch process.
+ //if we are coming in from the orphan slayer, the client ip
should
+ //already be populated with something un-local, and we'd want
to keep
+ //that.
+ if ( !$this->isSomething( 'user_ip' ) || $this->getVal(
'user_ip' ) === '127.0.0.1' ){
$userIp = WmfFramework::getIP();
if ( $userIp ) {
$this->setVal( 'user_ip', $userIp );
}
}
-
+
if ( array_key_exists( 'SERVER_ADDR', $_SERVER ) ){
$this->setVal( 'server_ip', $_SERVER['SERVER_ADDR'] );
} else {
//command line?
$this->setVal( 'server_ip', '127.0.0.1' );
}
+
+
}
/**
diff --git a/tests/Adapter/GatewayAdapterTest.php
b/tests/Adapter/GatewayAdapterTest.php
index d14412f..2bee06c 100644
--- a/tests/Adapter/GatewayAdapterTest.php
+++ b/tests/Adapter/GatewayAdapterTest.php
@@ -263,23 +263,5 @@
$expectedURL = wfAppendQuery( $expectedTitle->getFullURL(),
'uselang=en' );
$this->assertEquals( $expectedURL, $page );
}
-
- public function testCannotOverrideIp() {
- $data = $this->getDonorTestData( 'FR' );
- unset( $data['country'] );
- $data['user_ip'] = '8.8.8.8';
-
- $gateway = $this->getFreshGatewayObject( $data );
- $this->assertEquals( '127.0.0.1',
$gateway->getData_Unstaged_Escaped( 'user_ip' ) );
- }
-
- public function testCanOverrideIpInBatchMode() {
- $data = $this->getDonorTestData( 'FR' );
- unset( $data['country'] );
- $data['user_ip'] = '8.8.8.8';
-
- $gateway = $this->getFreshGatewayObject( $data, array(
'batch_mode' => true ) );
- $this->assertEquals( '8.8.8.8',
$gateway->getData_Unstaged_Escaped( 'user_ip' ) );
- }
}
diff --git a/tests/DonationDataTest.php b/tests/DonationDataTest.php
index 82fb273..bf9c87b 100644
--- a/tests/DonationDataTest.php
+++ b/tests/DonationDataTest.php
@@ -149,8 +149,7 @@
'recurring' => '',
);
- $adapter = $this->getFreshGatewayObject( self::$initial_vars,
array( 'batch_mode' => true ) );
- $ddObj = new DonationData( $adapter, $expected ); //external
data
+ $ddObj = new DonationData( $this->getFreshGatewayObject(
self::$initial_vars ), $expected ); //external data
$returned = $ddObj->getDataEscaped();
--
To view, visit https://gerrit.wikimedia.org/r/263238
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I882ea7a264dc19c724c846647419bdbff14a6498
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Paladox <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits