Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Test] [Ref] [Import]Add wrapper class for importProcessor #15028

Merged
merged 1 commit into from
Aug 15, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Aug 13, 2019

Overview

This adds a class to support future cleanup (along the lines of where we went with export) but at this stage it is only used by unit tests

Before

No 'logical' import class exists

After

Class exists as baby step towards retrofitting sanity

Technical Details

With the export cleanup creating a new sensible class & migrating code to it turned out to be a good approach.

This adds a class that wraps around the Importer Object, taking the mapping_field db format of fields
as a format - this is also where we wound up with the Export - using that format as it is what is saved.

There is a gap as I noted in https://lab.civicrm.org/dev/core/issues/1172 around the schema's adequacy.

That is not such an issue for this - in that we are not dealing with Contribution import and
this is really just exposing the wrapper for the unit tests at this stage but it does warrant further thought/discussion.

The only change to
'live' code is a little less php v4 support - we have removed a bunch of these from the constructor of the other objects already with no observed issues

Comments

@colemanw this picks up on your idea of how to handle making export sane - ie. treating the 'civicrm_mapping_field' table format as the preferred formatting to use

@civibot
Copy link

civibot bot commented Aug 13, 2019

(Standard links)

@civibot civibot bot added the master label Aug 13, 2019
* @return CRM_Contact_Import_Parser_Contact
*/
public function getImporterObject() {
$importer = new CRM_Contact_Import_Parser_Contact($this->getFieldNames());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually we want to pass more params here but I wanted to do that as a follow up

@eileenmcnaughton eileenmcnaughton force-pushed the import_processor branch 2 times, most recently from d64c2be to 258d775 Compare August 13, 2019 11:06
With the export cleanup creating a new sensible class & migrating code to it turned out to be a good approach.

This adds a class that wraps around the Importer Object, taking the mapping_field db format of fields
as a format - this is also where we wound up with the Export - using that format as it is what is saed.

There is a gap as I noted in https://lab.civicrm.org/dev/core/issues/1172 around the schema's adequacy.

That is not such an issue for this - in that we are not dealing with Contribution import and
this is really just exposing the wrapper for the unit tests at this stage - the only change to
'live' code is a little less php v4 support - we have removed a bunch of these from the constructor of the
other objects already with no observed issues
@eileenmcnaughton
Copy link
Contributor Author

test this please

@eileenmcnaughton
Copy link
Contributor Author

I just pushed up a 'big picture' on how this class can simplify - https://github.com/civicrm/civicrm-core/pull/15034/files#diff-238a76c67a9fdd3201a7917ddfe7b089 - I'll pick through that for the next 'real' pr once this is merged

@@ -122,11 +122,11 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser {
* @param array $mapperRelatedContactWebsiteType
*/
public function __construct(
&$mapperKeys, $mapperLocType = [], $mapperPhoneType = [], $mapperImProvider = [], $mapperRelated = [], $mapperRelatedContactType = [], $mapperRelatedContactDetails = [], $mapperRelatedContactLocType = [], $mapperRelatedContactPhoneType = [], $mapperRelatedContactImProvider = [],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton are you sure we don't need to modify the MapperKeys?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure - I've been digging around these classes a bit & it seems to just be a phpv4 hangover - we've removed the & from a bunch already

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To work backwards - the calling class would need to do something to change them for this to make sense - but actually it is just a list of field names submitted on the form

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seamuslee001 Specifically it's called from

CRM_Contact_Import_Form_MapField::submit
uses a variable to pass in & not again

CRM_Contact_Import_Form_DataSource::postProcess
Creates empty array to pass to constructor & then (as a non-reference) to run - just 2 lines later & not again

CRM_Contact_Import_Form_Preview::postProcessOld
This is never called.....

CRM_Contact_Import_ImportJob::runImport
The value is not used again.

Also this one of the calls to this function is called from runIncompleteImportJobs - which is never called....

@seamuslee001
Copy link
Contributor

confirmed that this is fine and that we don't need to be passing by array so merging and it adds test coverage

@seamuslee001 seamuslee001 merged commit 51d349a into civicrm:master Aug 15, 2019
@seamuslee001 seamuslee001 deleted the import_processor branch August 15, 2019 22:41
@eileenmcnaughton
Copy link
Contributor Author

thanks @seamuslee001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants