https://www.mediawiki.org/wiki/Special:Code/MediaWiki/103513

Revision: 103513
Author:   khorn
Date:     2011-11-17 21:57:45 +0000 (Thu, 17 Nov 2011)
Log Message:
-----------
MFT r103506, r103501, r103499, r103491, r103416, r103385, r103288, r103246, 
r103076, r103024

Modified Paths:
--------------
    
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/custom_filters.body.php
    
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/functions/functions.body.php
    
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/minfraud/minfraud.body.php
    
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/referrer/referrer.body.php
    
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/source/source.body.php
    
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/minfraud/minfraud.body.php
    
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php
    
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/gateway.adapter.php
    
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php

Property Changed:
----------------
    
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/
    
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/custom_filters.body.php
    
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php


Property changes on: 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras:99568
/branches/fundraising/extensions/DonationInterface/extras:98263-100243
/trunk/extensions/DonationInterface/extras:75657-77440,77442-79147,79149-79286,79288-79296,79298-79299,79301-79303,79305-86440,90286,92825,96120-96121,96125,97945-99042,99045-99408,99503,99555,99568,100119-101026,101060,101063-101064,101073,101076,101163,101335,101553,101557,101561,101785,101823,101826,101837,101870-101872,101882,101890,101910,101947,101949-101951,101955-101960,101964-101966,102030,102032-102033,102047,102050-102052,102054,102056,102058,102065,102081,102085-102087,102118,102120,102124-102125,102127,102134,102140,102147,102151-102152,102155-102156,102186,102188,102318,102332,102341-102342,102345,102424-102425,102445,102463,102467-102468,102470,102476,102479-102480,102549-102550,102576-102581,102590,102594,102611,102639,102664,102689,102698,102700-102703,102707,102711-102712,102729,102736,102752,102763,102805,102809,102812,102819-102824,102826,102830-102831,102833,102835,102841,102872
   + 
/branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras:99568
/branches/fundraising/extensions/DonationInterface/extras:98263-100243
/trunk/extensions/DonationInterface/extras:75657-77440,77442-79147,79149-79286,79288-79296,79298-79299,79301-79303,79305-86440,90286,92825,96120-96121,96125,97945-99042,99045-99408,99503,99555,99568,100119-101026,101060,101063-101064,101073,101076,101163,101335,101553,101557,101561,101785,101823,101826,101837,101870-101872,101882,101890,101910,101947,101949-101951,101955-101960,101964-101966,102030,102032-102033,102047,102050-102052,102054,102056,102058,102065,102081,102085-102087,102118,102120,102124-102125,102127,102134,102140,102147,102151-102152,102155-102156,102186,102188,102318,102332,102341-102342,102345,102424-102425,102445,102463,102467-102468,102470,102476,102479-102480,102549-102550,102576-102581,102590,102594,102611,102639,102664,102689,102698,102700-102703,102707,102711-102712,102729,102736,102752,102763,102805,102809,102812,102819-102824,102826,102830-102831,102833,102835,102841,102872,103024,103076,103246,103288,103385,103416,103491,103499,103501,103506

Modified: 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/custom_filters.body.php
===================================================================
--- 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/custom_filters.body.php
    2011-11-17 21:54:41 UTC (rev 103512)
+++ 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/custom_filters.body.php
    2011-11-17 21:57:45 UTC (rev 103513)
@@ -41,7 +41,6 @@
                        $this->risk_score = 0;
                if ( $this->risk_score > 100 )
                        $this->risk_score = 100;
-//             error_log("Risk score: " . $this->risk_score );
                foreach ( $this->action_ranges as $action => $range ) {
                        if ( $this->risk_score >= $range[0] && 
$this->risk_score <= $range[1] ) {
                                return $action;
@@ -73,7 +72,7 @@
        }
 
        static function singleton( &$gateway_adapter ) {
-               if ( !self::$instance ) {
+               if ( !self::$instance || $gateway_adapter->isBatchProcessor() ) 
{
                        self::$instance = new self( $gateway_adapter );
                }
                return self::$instance;


Property changes on: 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/custom_filters.body.php
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/branches/fundraising/extensions/DonationInterface/extras/custom_filters/custom_filters.body.php:98262-100243
/branches/fundraising/extensions/DonationInterface/payflowpro_gateway/extras/custom_filters/custom_filters.body.php:95444-98261
/trunk/extensions/DonationInterface/extras/custom_filters/custom_filters.body.php:90286,100119-101026,101060,101063-101064,101073,101076,101335,101553,101557,101561,101785,101823,101826,101837,101870-101872,101882,101890,101910,101947,101949-101951,101955-101960,101964-101966,102030,102032-102033,102047,102050-102052,102054,102056,102058,102065,102081,102085-102087,102118,102120,102124-102125,102127,102134,102140,102147,102151-102152,102155-102156,102186,102188,102576-102579,102581,102689,102736,102752,102763,102805,102809,102812,102819-102824,102826,102830-102831,102833,102835,102841,102872
   + 
/branches/fundraising/extensions/DonationInterface/extras/custom_filters/custom_filters.body.php:98262-100243
/branches/fundraising/extensions/DonationInterface/payflowpro_gateway/extras/custom_filters/custom_filters.body.php:95444-98261
/trunk/extensions/DonationInterface/extras/custom_filters/custom_filters.body.php:90286,100119-101026,101060,101063-101064,101073,101076,101335,101553,101557,101561,101785,101823,101826,101837,101870-101872,101882,101890,101910,101947,101949-101951,101955-101960,101964-101966,102030,102032-102033,102047,102050-102052,102054,102056,102058,102065,102081,102085-102087,102118,102120,102124-102125,102127,102134,102140,102147,102151-102152,102155-102156,102186,102188,102576-102579,102581,102689,102736,102752,102763,102805,102809,102812,102819-102824,102826,102830-102831,102833,102835,102841,102872,103024,103076,103246,103288,103385,103416,103491,103499,103501,103506

Modified: 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/functions/functions.body.php
===================================================================
--- 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/functions/functions.body.php
       2011-11-17 21:54:41 UTC (rev 103512)
+++ 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/functions/functions.body.php
       2011-11-17 21:57:45 UTC (rev 103513)
@@ -54,7 +54,7 @@
        }
 
        static function singleton( &$gateway_adapter, &$custom_filter_object ) {
-               if ( !self::$instance ) {
+               if ( !self::$instance || $gateway_adapter->isBatchProcessor() ) 
{
                        self::$instance = new self( $gateway_adapter, 
$custom_filter_object );
                }
                return self::$instance;

Modified: 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/minfraud/minfraud.body.php
===================================================================
--- 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/minfraud/minfraud.body.php
 2011-11-17 21:54:41 UTC (rev 103512)
+++ 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/minfraud/minfraud.body.php
 2011-11-17 21:57:45 UTC (rev 103513)
@@ -37,7 +37,7 @@
        }
 
        static function singleton( &$gateway_adapter ) {
-               if ( !self::$instance ) {
+               if ( !self::$instance || $gateway_adapter->isBatchProcessor() ) 
{
                        self::$instance = new self( $gateway_adapter );
                }
                return self::$instance;

Modified: 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/referrer/referrer.body.php
===================================================================
--- 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/referrer/referrer.body.php
 2011-11-17 21:54:41 UTC (rev 103512)
+++ 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/referrer/referrer.body.php
 2011-11-17 21:57:45 UTC (rev 103513)
@@ -56,7 +56,7 @@
        }
 
        static function singleton( &$gateway_adapter, &$custom_filter_object ) {
-               if ( !self::$instance ) {
+               if ( !self::$instance || $gateway_adapter->isBatchProcessor() ) 
{
                        self::$instance = new self( $gateway_adapter, 
$custom_filter_object );
                }
                return self::$instance;

Modified: 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/source/source.body.php
===================================================================
--- 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/source/source.body.php
     2011-11-17 21:54:41 UTC (rev 103512)
+++ 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/custom_filters/filters/source/source.body.php
     2011-11-17 21:57:45 UTC (rev 103513)
@@ -56,7 +56,7 @@
        }
 
        static function singleton( &$gateway_adapter, &$custom_filter_object ) {
-               if ( !self::$instance ) {
+               if ( !self::$instance || $gateway_adapter->isBatchProcessor() ) 
{
                        self::$instance = new self( $gateway_adapter, 
$custom_filter_object );
                }
                return self::$instance;

Modified: 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/minfraud/minfraud.body.php
===================================================================
--- 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/minfraud/minfraud.body.php
        2011-11-17 21:54:41 UTC (rev 103512)
+++ 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/extras/minfraud/minfraud.body.php
        2011-11-17 21:57:45 UTC (rev 103513)
@@ -112,7 +112,7 @@
        public function can_bypass_minfraud() {
                // if the data bits data_hash and action are not set, we need 
to hit minFraud
                $localdata = $this->gateway_adapter->getData_Raw();
-               if ( !strlen( $localdata['data_hash'] ) || !strlen( 
$localdata['action'] ) ) {
+               if ( !isset($localdata['data_hash']) || !strlen( 
$localdata['data_hash'] ) || !isset($localdata['action']) || !strlen( 
$localdata['action'] ) ) {
                        return FALSE;
                }
 

Modified: 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php
===================================================================
--- 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php
  2011-11-17 21:54:41 UTC (rev 103512)
+++ 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php
  2011-11-17 21:57:45 UTC (rev 103513)
@@ -101,7 +101,7 @@
                                'iban' => $wgRequest->getText( 'iban', null ),
                                'transaction_type' => $wgRequest->getText( 
'transaction_type', null ),
                        );
-                       if ( !$wgRequest->wasPosted() ) {
+                       if ( !$this->wasPosted() ) {
                                $this->setVal( 'posted', false );
                        }
                }
@@ -1004,6 +1004,23 @@
                );
                return $stomp_fields;
        }
+       
+       /**
+        * Basically, this is a wrapper for the $wgRequest wasPosted function 
that 
+        * won't give us notices if we weren't even a web request. 
+        * I realize this is pretty lame. 
+        * Notices, however, are more lame. 
+        * @global type $wgRequest
+        * @staticvar string $posted Keeps track so we don't have to figure it 
out twice. 
+        */
+       public function wasPosted(){
+               global $wgRequest;
+               static $posted = null;
+               if ($posted === null){
+                       $posted = (array_key_exists('REQUEST_METHOD', $_SERVER) 
&& $wgRequest->wasPosted());
+               }
+               return $posted; 
+       }
 }
 
 ?>


Property changes on: 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php:99568
/trunk/extensions/DonationInterface/gateway_common/DonationData.php:75657-77440,77442-79147,79149-79286,79288-79296,79298-79299,79301-79303,79305-86440,90286,92825,96120-96121,96125,97945-99042,99045-99408,99503,99555,99568,99570-101026,101056,101060,101063-101064,101071-101074,101076,101099,101109,101112,101163,101180,101192,101200,101205,101207,101217,101230,101232,101236,101335,101382,101399,101441,101501-101504,101512,101541,101547,101549,101553-101555,101557,101559,101561,101563,101576,101578-101579,101631,101633,101638,101669,101676,101679,101689,101700,101706,101719,101740,101747,101757,101764,101778-101779,101781,101785-101789,101798,101823,101826,101837,101846,101852,101870-101872,101878,101882,101890,101910,101917,101929,101947,101949-101951,101955-101960,101962,101964-101966,101996,102003,102011-102012,102030,102032-102033,102047,102050-102052,102054,102056,102058,102065,102081,102085-102087,102118,102120,102124-102125,102127,102134,102140,102147,102151-102152,102155-102156,102186,102188-102241,102309,102318,102332,102341-102342,102345,102419,102424-102425,102445,102463,102467-102468,102470,102476,102479-102480,102549-102550,102576-102581,102590,102594,102611,102639,102664,102689,102698,102700-102703,102707,102711-102712,102729,102736,102752,102763,102805,102809,102812,102819-102824,102826,102830-102831,102833,102835,102841,102872
   + 
/branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php:99568
/trunk/extensions/DonationInterface/gateway_common/DonationData.php:75657-77440,77442-79147,79149-79286,79288-79296,79298-79299,79301-79303,79305-86440,90286,92825,96120-96121,96125,97945-99042,99045-99408,99503,99555,99568,99570-101026,101056,101060,101063-101064,101071-101074,101076,101099,101109,101112,101163,101180,101192,101200,101205,101207,101217,101230,101232,101236,101335,101382,101399,101441,101501-101504,101512,101541,101547,101549,101553-101555,101557,101559,101561,101563,101576,101578-101579,101631,101633,101638,101669,101676,101679,101689,101700,101706,101719,101740,101747,101757,101764,101778-101779,101781,101785-101789,101798,101823,101826,101837,101846,101852,101870-101872,101878,101882,101890,101910,101917,101929,101947,101949-101951,101955-101960,101962,101964-101966,101996,102003,102011-102012,102030,102032-102033,102047,102050-102052,102054,102056,102058,102065,102081,102085-102087,102118,102120,102124-102125,102127,102134,102140,102147,102151-102152,102155-102156,102186,102188-102241,102309,102318,102332,102341-102342,102345,102419,102424-102425,102445,102463,102467-102468,102470,102476,102479-102480,102549-102550,102576-102581,102590,102594,102611,102639,102664,102689,102698,102700-102703,102707,102711-102712,102729,102736,102752,102763,102805,102809,102812,102819-102824,102826,102830-102831,102833,102835,102841,102872,103024,103076,103246,103288,103385,103416,103491,103499,103501,103506

Modified: 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/gateway.adapter.php
===================================================================
--- 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/gateway.adapter.php
       2011-11-17 21:54:41 UTC (rev 103512)
+++ 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/gateway.adapter.php
       2011-11-17 21:57:45 UTC (rev 103513)
@@ -162,6 +162,7 @@
        protected $current_transaction;
        protected $action;
        public $debugarray; 
+       protected $batch = false;
 
        //ALL OF THESE need to be redefined in the children. Much voodoo 
depends on the accuracy of these constants. 
        const GATEWAY_NAME = 'Donation Gateway';
@@ -194,24 +195,26 @@
                extract( $options );
 
                $testData = isset( $testData ) ? $testData : false;
+               $external_data = isset( $external_data ) ? $external_data : 
false; //not test data: Regular type. 
                $postDefaults = isset( $postDefaults ) ? $postDefaults : false;
-
+               
                if ( !self::getGlobal( 'Test' ) ) {
                        $this->url = self::getGlobal( 'URL' );
-
                        // Only submit test data if we are in test mode.
-                       $testData = false;
                } else {
                        $this->url = self::getGlobal( 'TestingURL' );
+                       if ( $testData ){
+                               $external_data = $testData;
+                       }
                }
+               
+               $this->dataObj = new DonationData( get_called_class(), 
self::getGlobal( 'Test' ), $external_data );
 
-               $this->dataObj = new DonationData( get_called_class(), 
self::getGlobal( 'Test' ), $testData );
-
                $this->raw_data = $this->dataObj->getData();
                $this->staged_data = $this->raw_data;
+               
+               $this->posted = ( $this->dataObj->wasPosted() && ( !is_null( 
$wgRequest->getVal( 'numAttempt', null ) ) ) );
 
-               $this->posted = ( $wgRequest->wasPosted() && ( !is_null( 
$wgRequest->getVal( 'numAttempt', null ) ) ) );
-
                $this->setPostDefaults( $postDefaults );
                $this->defineTransactions();
                $this->defineErrorMap();
@@ -1653,7 +1656,7 @@
         * @return mixed Transaction results status, or false if not set.  
         */
        public function getTransactionStatus() {
-               if ( array_key_exists( 'status', $this->transaction_results ) ) 
{
+               if ( is_array( $this->transaction_results ) && 
array_key_exists( 'status', $this->transaction_results ) ) {
                        return $this->transaction_results['status'];
                } else {
                        return false;
@@ -1973,5 +1976,18 @@
        public function hasDonorDataInSession( $key = false, $value= '' ){
                return $this->dataObj->hasDonorDataInSession( $key, $value );
        }
+       
+       /**
+        * Lets the outside world (particularly hooks that accumulate points 
scores)
+        * know if we are a batch processor. 
+        * @return type 
+        */
+       public function isBatchProcessor(){
+               if (!property_exists($this, 'batch')){
+                       return false;
+               } else {
+                       return $this->batch;
+               }
+       }
 
 }

Modified: 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
===================================================================
--- 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
  2011-11-17 21:54:41 UTC (rev 103512)
+++ 
branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
  2011-11-17 21:57:45 UTC (rev 103513)
@@ -976,22 +976,50 @@
                                $addme[$ourkey] = $tmp;
                        }
                }
-               if ( count( $addme ) ){
+               
+               $post_status_check = false;
+               if ( count( $addme ) ){ //nothing unusual here. 
                        $this->addData( $addme );
+                       $logmsg = $this->getData_Raw( 
'contribution_tracking_id' ) . ': ';
+                       $logmsg .= 'CVV Result: ' . $this->getData_Raw( 
'cvv_result' );
+                       $logmsg .= ', AVS Result: ' . $this->getData_Raw( 
'avs_result' );
+                       self::log( $logmsg );
+               } else { //this is an orphan transaction. 
+                       $this->staged_data['order_id'] = 
$this->staged_data['i_order_id'];
+                       $post_status_check = true;
                }
-               $logmsg = $this->getData_Raw( 'contribution_tracking_id' ) . ': 
';
-               $logmsg .= 'CVV Result: ' . $this->getData_Raw( 'cvv_result' );
-               $logmsg .= ', AVS Result: ' . $this->getData_Raw( 'avs_result' 
);
-               self::log( $logmsg );
                
                $status_result = $this->do_transaction( 'GET_ORDERSTATUS' );
                
-               //error_log( "GET_ORDERSTATUS result: " . $status_result );
-               
                $cancelflag = false; //this will denote the thing we're trying 
to do with the donation attempt
                $problemflag = false; //this will get set to true, if we can't 
continue and need to give up and just log the hell out of it. 
                $problemmessage = ''; //to be used in conjunction with the flag.
+
                
+               if ( $post_status_check ){
+                       if ( array_key_exists('data', $status_result) ) {
+                               foreach ( $pull_vars as $theirkey => $ourkey) {
+                                       if ( array_key_exists($theirkey, 
$status_result['data']) ) {
+                                               $addme[$ourkey] = 
$status_result['data'][$theirkey];
+                                       }
+                               }
+                       }
+                       
+                       if ( count( $addme ) ){
+                               $this->addData( $addme );
+                               $this->staged_data['order_id'] = 
$this->staged_data['i_order_id'];
+                               $logmsg = $this->getData_Raw( 
'contribution_tracking_id' ) . ': ';
+                               $logmsg .= 'CVV Result: ' . $this->getData_Raw( 
'cvv_result' );
+                               $logmsg .= ', AVS Result: ' . 
$this->getData_Raw( 'avs_result' );
+                               self::log( $logmsg );
+                               $this->runPreProcessHooks();
+                               $status_result['action'] = 
$this->getValidationAction();
+                       } else {
+                               $problemflag = true; //nothing to be done.
+                               $problemmessage = "Unable to retrieve orphan 
cvv/avs results (Communication problem?).";
+                       }
+               }
+               
                //we filtered
                if ( array_key_exists( 'action', $status_result ) && 
$status_result['action'] != 'process' ){
                        $cancelflag = true;
@@ -1014,9 +1042,13 @@
                                case 'revised' :  
                                        $cancelflag = true; //makes sure we 
don't try to confirm.
                                        break;
-                       }
+                               case 'complete' :
+                                       $problemflag = true; //nothing to be 
done.
+                                       $problemmessage = "GET_ORDERSTATUS 
reports that the payment is already complete.";
+                                       break;
+                       }       
                }
-
+               
                //if we got here with no problemflag, 
                //confirm or cancel the payment based on $cancelflag 
                if ( !$problemflag ){
@@ -1194,7 +1226,9 @@
                                break;
                        case 'GET_ORDERSTATUS':
                                $data = $this->xmlChildrenToArray( $response, 
'STATUS' );
-                               $this->setTransactionWMFStatus( 
$this->findCodeAction( 'GET_ORDERSTATUS', 'STATUSID', $data['STATUSID'] ) );
+                               if (isset($data['STATUSID'])){
+                                       $this->setTransactionWMFStatus( 
$this->findCodeAction( 'GET_ORDERSTATUS', 'STATUSID', $data['STATUSID'] ) );
+                               }
                                $data['ORDER'] = $this->xmlChildrenToArray( 
$response, 'ORDER' );
                                break;
                }
@@ -1548,23 +1582,34 @@
        protected function stage_language( $type = 'request' ) {
                $language = strtolower( $this->staged_data['language'] );
                
-               $count = 0;
-               //Count's just there making sure we don't get stuck here. 
-               while ( !in_array( $language, $this->getAvailableLanguages() ) 
&& $count < 3 ){
-                       // Get the fallback language
-                       $language = Language::getFallbackFor( $language );
-                       $count += 1;
+               switch ( $type ) {
+                       case 'request':
+                               $count = 0;
+                               //Count's just there making sure we don't get 
stuck here. 
+                               while ( !in_array( $language, 
$this->getAvailableLanguages() ) && $count < 3 ){
+                                       // Get the fallback language
+                                       $language = Language::getFallbackFor( 
$language );
+                                       $count += 1;
+                               }
+
+                               if ( !in_array( $language, 
$this->getAvailableLanguages() ) ){
+                                       $language = 'en';
+                               }
+
+                               if ( $language === 'zh' ) { //Handles GC's 
mutant Chinese code.
+                                       $language = 'sc';
+                               }
+
+                               break;
+                       case 'response':
+                               if ( $language === 'sc' ){
+                                       $language = 'zh';
+                               }
+                               break;
                }
                
-               if ( !in_array( $language, $this->getAvailableLanguages() ) ){
-                       $language = 'en';
-               }
-               
-               if ( $language === 'zh' ) { //Handles GC's mutant Chinese code.
-                       $language = 'sc';
-               }
-               
                $this->staged_data['language'] = $language;
+                       
        }
        
        /**


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to