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

dev/core#183 Convert database testing to use CRM_Utils_SQL_TempTable … #15798

Merged
merged 1 commit into from
Nov 10, 2019

Conversation

seamuslee001
Copy link
Contributor

…fuctionality and remove Incomplete Jobs handling as it is not called

Overview

Ok this is a much more limited PR than https://github.com/civicrm/civicrm-core/pull/15797/files but much more correct in that it only touches on the temporary tables and also removes a function and class that are not called by anything else

Before

Temporary table name not standard

After

Temp table name standard and cruft code removed

ping @eileenmcnaughton

…fuctionality and remove Incomplete Jobs handling as it is not called
@civibot
Copy link

civibot bot commented Nov 10, 2019

(Standard links)

@civibot civibot bot added the master label Nov 10, 2019
* This class mainly exists to allow imports to be triggered synchronously (i.e.
* via a form post) and asynchronously (i.e. by the workflow system)
*/
class CRM_Contact_Import_Importer {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eileenmcnaughton i couldn't find this class called from anywhere

/**
* @return array
*/
public static function getIncompleteImportTables() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is only called from the class that is being removed

@@ -38,7 +38,7 @@ class CRM_Import_DataSource_CsvTest extends CiviUnitTestCase {
* @dataProvider getCsvFiles
*/
public function testToCsv($fileName) {
$dataSource = new CRM_Import_DataSource_Csv();
$dataSource = new CRM_Import_DataSource_CSV();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just to match to the actual class name

$daoTestPrivilege->query("CREATE TEMPORARY TABLE import_job_permission_one(test int) ENGINE=InnoDB");
$daoTestPrivilege->query("CREATE TEMPORARY TABLE import_job_permission_two(test int) ENGINE=InnoDB");
$daoTestPrivilege->query("DROP TEMPORARY TABLE IF EXISTS import_job_permission_one, import_job_permission_two");
$tempTable1 = CRM_Utils_SQL_TempTable::build()->getName();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This feels a bit odd if we are actually creating tables (non temporary) why is the test here creating temporary tables

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh wow - that routine is kinda silly - that errorScope stuff should be a try-catch.

Anyway I tested this & it works

Copy link
Member

Choose a reason for hiding this comment

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

Think about the importer pageflow:

  1. You upload a large a CSV file
  2. It shows a config screen -- where you can choose field-mappings
  3. It shows progress as it imports each of the records

In step 1, you need to put the uploaded content somewhere that will endure long enough to run the other steps (maybe 5 min; maybe an hour; maybe more). The importer uses CREATE TABLE to produce such a semi-durable storage place. CREATE TEMPORARY TABLE is not going to give you a place that lives long enough. (You could plausibly rewrite the importer to use other places for temporary storage -- like a cache record or civicrm.files -- but that's a hypothetical and broader proposition.)

This test is more informative if it's doing CREATE TABLE not CREATE TEMPORARY TABLE -- because those two may be stored in different places with different permissioning. For example: A MySQL user could have permission to CREATE TEMPORARY TABLE but not toCREATE new tables. (It's very easy to imagine a sysadmin improvising those permissions because there are use-cases/apps where it's sensible to split those permissions.) But in this case it would be a false-pass.

@eileenmcnaughton
Copy link
Contributor

I stepped through the loading of the import form & that silliness is all about testing db perm to create a temp table. Still works - mop

@seamuslee001
Copy link
Contributor Author

Test fail unrelated

@seamuslee001 seamuslee001 merged commit f3196a0 into civicrm:master Nov 10, 2019
@seamuslee001 seamuslee001 deleted the dev_core_183_imports_2 branch November 10, 2019 23:10
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.

3 participants