-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
dev/core#183 Convert database testing to use CRM_Utils_SQL_TempTable … #15798
Conversation
…fuctionality and remove Incomplete Jobs handling as it is not called
(Standard links)
|
* 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 { |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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:
- You upload a large a CSV file
- It shows a config screen -- where you can choose field-mappings
- 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.
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 |
Test fail unrelated |
…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