Awight has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/343795 )
Change subject: [WIP] Perform currency fallback earlier ...................................................................... [WIP] Perform currency fallback earlier This allows us to validate the changed data. Change-Id: Icf39eeb26860f58ba5244b36d01dcac060c81027 --- M gateway_common/gateway.adapter.php 1 file changed, 14 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/95/343795/1 diff --git a/gateway_common/gateway.adapter.php b/gateway_common/gateway.adapter.php index a7b360d..c0aafe7 100644 --- a/gateway_common/gateway.adapter.php +++ b/gateway_common/gateway.adapter.php @@ -2453,10 +2453,23 @@ */ public function validate() { $normalized = $this->dataObj->getData(); + + $this->errors = array(); + + // Try to fall back to a default currency, clearing the error if + // successful. + // TODO: Rewrite as something modular? It's in-between validation and + // normalization, it modifies a bunch of values, needs access to the + // error array, and we may need to do post-validation. Whee! + $this->fallbackToDefaultCurrency(); + // FIXME: This is part of the same wart, we're copying potentially + // modified data back out of the data object. + $this->unstaged_data = $this->dataObj->getData(); // Run legacy validations $check_not_empty = $this->getRequiredFields(); - $this->errors = DataValidator::validate( $this, $normalized, $check_not_empty ); + $old_style_errors = DataValidator::validate( $this, $normalized, $check_not_empty ); + $this->errors = array_merge_recursive( $this->errors, $old_style_errors ); // Run modular validations. $transformers = $this->getDataTransformers(); @@ -2464,15 +2477,6 @@ if ( $transformer instanceof ValidationHelper ) { $transformer->validate( $this, $normalized, $this->errors ); } - } - - // TODO: Rewrite as something modular? It's in-between validation and normalization... - if ( isset( $this->errors['currency_code'] ) ) { - // Try to fall back to a default currency, clearing the error if - // successful. - $this->fallbackToDefaultCurrency(); - // FIXME: This is part of the same wart. - $this->unstaged_data = $this->dataObj->getData(); } return $this->validatedOK(); -- To view, visit https://gerrit.wikimedia.org/r/343795 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icf39eeb26860f58ba5244b36d01dcac060c81027 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface 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