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

Change subject: Quit setting default email in form
......................................................................


Quit setting default email in form

Old forms relied on a special case to keep the default value out of
the placeholder.  Let's set the default in staging instead.
Also update mustache form to use newer 'email' name, not 'emailAdd'

Change-Id: Iaf742da324c372842e41e5458390f2df38d0967e
---
M DonationInterface.php
M gateway_common/DonationData.php
M gateway_common/gateway.adapter.php
M gateway_forms/mustache/personal_info.html.mustache
M tests/DonationDataTest.php
M tests/DonationInterfaceTestCase.php
6 files changed, 14 insertions(+), 8 deletions(-)

Approvals:
  Awight: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/DonationInterface.php b/DonationInterface.php
index 435b062..6f435d1 100644
--- a/DonationInterface.php
+++ b/DonationInterface.php
@@ -141,6 +141,9 @@
  */
 $wgDonationInterfaceAppealWikiTemplate = 
'LanguageSwitch|2011FR/$appeal/text|$language';
 
+// Email address used when donor enters nothing
+$wgDonationInterfaceDefaultEmail = 'nob...@wikimedia.org';
+
 //all of the following variables make sense to override directly,
 //or change "DonationInterface" to the gateway's id to override just for that 
gateway.
 //for instance: To override $wgDonationInterfaceUseSyslog just for 
GlobalCollect, add
diff --git a/gateway_common/DonationData.php b/gateway_common/DonationData.php
index 669f08c..84cce42 100644
--- a/gateway_common/DonationData.php
+++ b/gateway_common/DonationData.php
@@ -674,18 +674,12 @@
         * Normalize email
         * Check regular name, and horrible old name for values (preferring the
         * reasonable name over the legacy version)
-        * Set the value to 'nob...@wikimedia.org' if nothing has been entered.
         */
        protected function setEmail() {
                // Look at the old style value (because that's canonical if 
populated first)
                $email = $this->getVal( 'emailAdd' );
                if ( is_null( $email ) ) {
                        $email = $this->getVal( 'email' );
-               }
-
-               if ( is_null( $email ) ) {
-                       // We still have nothing, populate with default
-                       $email = 'nob...@wikimedia.org';
                }
 
                $this->setVal( 'email', $email );
diff --git a/gateway_common/gateway.adapter.php 
b/gateway_common/gateway.adapter.php
index 81e64fc..eedcc25 100644
--- a/gateway_common/gateway.adapter.php
+++ b/gateway_common/gateway.adapter.php
@@ -1992,6 +1992,9 @@
                // This allows transactions to each stage different data.
                $this->defineStagedVars();
 
+               // Always stage email address
+               $this->staged_vars[] = 'email';
+
                foreach ( $this->staged_vars as $field ) {
                        $function_name = 'stage_' . $field;
                        $this->executeIfFunctionExists( $function_name );
@@ -2141,6 +2144,12 @@
                }
        }
 
+       protected function stage_email() {
+               if ( empty( $this->staged_data['email'] ) ) {
+                       $this->staged_data['email'] = $this->getGlobal( 
'DefaultEmail' );
+               }
+       }
+
        protected function buildRequestParams() {
                // Look up the request structure for our current transaction 
type in the transactions array
                $structure = $this->getTransactionRequestStructure();
diff --git a/gateway_forms/mustache/personal_info.html.mustache 
b/gateway_forms/mustache/personal_info.html.mustache
index f3c691b..4622774 100644
--- a/gateway_forms/mustache/personal_info.html.mustache
+++ b/gateway_forms/mustache/personal_info.html.mustache
@@ -5,7 +5,7 @@
                                                </tr>
                                                <tr>
                                                        <td>
-                                                               <input 
class="fullwidth" name="emailAdd" value="{{ email }}" type="email" title="{{ 
l10n "donate_interface-donor-email" }}" placeholder="{{ l10n 
"donate_interface-donor-email" }}" id="emailAdd" required>
+                                                               <input 
class="fullwidth" name="email" value="{{ email }}" type="email" title="{{ l10n 
"donate_interface-donor-email" }}" placeholder="{{ l10n 
"donate_interface-donor-email" }}" id="email" required>
                                                        </td>
                                                </tr>
 {{# fiscal_number_required }}
diff --git a/tests/DonationDataTest.php b/tests/DonationDataTest.php
index 2a0dbd4..f8e43d3 100644
--- a/tests/DonationDataTest.php
+++ b/tests/DonationDataTest.php
@@ -88,7 +88,6 @@
                $returned = $ddObj->getDataEscaped();
                $expected = array(  'posted' => '',
                        'amount' => '0.00',
-                       'email' => 'nob...@wikimedia.org',
                        'country' => 'XX',
                        'payment_method' => '',
                        'referrer' => '',
diff --git a/tests/DonationInterfaceTestCase.php 
b/tests/DonationInterfaceTestCase.php
index 452377e..3d9fba2 100644
--- a/tests/DonationInterfaceTestCase.php
+++ b/tests/DonationInterfaceTestCase.php
@@ -128,6 +128,7 @@
                                'lname' => 'Surname',
                                'amount' => '1.55',
                                'language' => 'en',
+                               'email' => 'nob...@wikimedia.org',
                        ),
                        'ES' => array (
                                'city' => 'Barcelona',

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iaf742da324c372842e41e5458390f2df38d0967e
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Ejegg <eeggles...@wikimedia.org>
Gerrit-Reviewer: AndyRussG <andrew.green...@gmail.com>
Gerrit-Reviewer: Awight <awi...@wikimedia.org>
Gerrit-Reviewer: Ssmith <ssm...@wikimedia.org>
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