Katie Horn has submitted this change and it was merged.
Change subject: Make fredge data validation exceptions recoverable
......................................................................
Make fredge data validation exceptions recoverable
Change-Id: If8f9a1af29e6efb4aa0eb0a99e38c2a93c3f4f53
---
M sites/all/modules/queue2civicrm/fredge/wmf_fredge_qc.module
M sites/all/modules/wmf_common/WmfException.php
2 files changed, 23 insertions(+), 2 deletions(-)
Approvals:
Katie Horn: Looks good to me, approved
diff --git a/sites/all/modules/queue2civicrm/fredge/wmf_fredge_qc.module
b/sites/all/modules/queue2civicrm/fredge/wmf_fredge_qc.module
index ea1553a..4a0adfe 100644
--- a/sites/all/modules/queue2civicrm/fredge/wmf_fredge_qc.module
+++ b/sites/all/modules/queue2civicrm/fredge/wmf_fredge_qc.module
@@ -195,7 +195,7 @@
if ( !is_array($msg) || empty($msg) ){
$error = "$log_identifier: Trying to insert nothing into table $table.
Dropping message on floor.";
- throw new WmfException('fredge', $error);
+ throw new FredgeDataValidationException( $error );
}
$insert = array();
@@ -203,12 +203,22 @@
if (!array_key_exists($field, $msg)) {
if ($require_all) {
$error = "$log_identifier: Expected field $field bound for table
$table not present! Dropping message on floor.";
- throw new WmfException('fredge', $error);
+ throw new FredgeDataValidationException( $error );
//so... add fields to DI first when you do schema changes.
}
$insert[$field] = null;
} else {
//the field exists. Woot.
+
+ // Check data length.
+ if ( array_key_exists( 'length', $definition )
+ && $definition['length'] < strlen( $msg[$field] )
+ ) {
+ $error = "$log_identifier: Data in field $field is too long! Dropping
message on floor.";
+ throw new FredgeDataValidationException( $error );
+ }
+
+ // Convert timestamps to native SQL format datetime.
if (array_key_exists('mysql_type', $definition) &&
$definition['mysql_type'] === 'DATETIME') {
$msg[$field] = wmf_common_date_unix_to_sql($msg[$field]);
}
@@ -226,3 +236,10 @@
return $id;
}
+class FredgeDataValidationException extends WmfException {
+ public function __construct( $message ) {
+ // FIXME: other exception types are descriptive of the error,
+ // not just its source module. Make like the others.
+ parent::__construct( 'fredge', $message );
+ }
+}
diff --git a/sites/all/modules/wmf_common/WmfException.php
b/sites/all/modules/wmf_common/WmfException.php
index d004b65..b79d78c 100644
--- a/sites/all/modules/wmf_common/WmfException.php
+++ b/sites/all/modules/wmf_common/WmfException.php
@@ -56,6 +56,10 @@
'INVALID_FILE_FORMAT' => array(
'fatal' => TRUE,
),
+
+ 'fredge' => array(
+ 'reject' => TRUE,
+ ),
);
var $extra;
--
To view, visit https://gerrit.wikimedia.org/r/178276
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If8f9a1af29e6efb4aa0eb0a99e38c2a93c3f4f53
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Awight <[email protected]>
Gerrit-Reviewer: AndyRussG <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: Katie Horn <[email protected]>
Gerrit-Reviewer: Ssmith <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits