From a41222c2042d7260927cf0454e59cd2c272b363f Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 20 Apr 2022 22:10:05 +1200 Subject: [PATCH] [REF] [Import] Handle limit with more sanity --- CRM/Contact/Import/Parser/Contact.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/CRM/Contact/Import/Parser/Contact.php b/CRM/Contact/Import/Parser/Contact.php index b9a80bf4d3..31908cc656 100644 --- a/CRM/Contact/Import/Parser/Contact.php +++ b/CRM/Contact/Import/Parser/Contact.php @@ -2618,6 +2618,18 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { if ($mode == self::MODE_IMPORT) { $query .= " WHERE $statusFieldName = 'NEW'"; } + if ($this->_maxLinesToProcess > 0) { + // Note this would only be the case in MapForm mode, where it is set to 100 + // rows. In fact mapField really only needs 2 rows - the reason for + // 100 seems to be that the other import classes are processing a + // csv file, and there was a concern that some rows might have more + // columns than others - hence checking 100 rows perhaps seemed like + // a good precaution presumably when determining the activeFieldsCount + // which is the number of columns a row might have. + // However, the mapField class may no longer use activeFieldsCount for contact + // to be continued.... + $query .= ' LIMIT ' . $this->_maxLinesToProcess; + } $result = CRM_Core_DAO::executeQuery($query); @@ -2629,9 +2641,6 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { foreach ($values as $k => $v) { $values[$k] = trim($v, " \t\r\n"); } - if (CRM_Utils_System::isNull($values)) { - continue; - } $this->_totalCount++; @@ -2702,11 +2711,6 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { break; } - // if we are done processing the maxNumber of lines, break - if ($this->_maxLinesToProcess > 0 && $this->_validCount >= $this->_maxLinesToProcess) { - break; - } - // see if we've hit our timeout yet /* if ( $the_thing_with_the_stuff ) { do_something( ); -- 2.25.1