Skip to content
Snippets Groups Projects
Commit bcc5ddd5 authored by Prasad's avatar Prasad
Browse files

Fix #664: Alert pre-requisite for CSV import ahead than silent failure

parent 94dec625
No related branches found
No related tags found
No related merge requests found
......@@ -756,6 +756,19 @@ class Vtiger_Util_Helper {
return (stristr($db_character_set, 'utf8') && stristr($db_collation_type, 'utf8'));
}
public static function checkDbLocalInfileSupport() {
$db = PearDatabase::getInstance();
$rs = $db->pquery("show variables like 'local_infile'", array());
$db_local_infile = null;
while ($arr = $db->fetch_array($rs)) {
switch($arr['variable_name']) {
case 'local_infile': $db_local_infile = $arr['value']; break;
}
if ($db_local_infile != null) break;
}
return ($db_local_infile == '1' || strtolower($db_local_infile) == 'on');
}
/**
* Function to get both date string and date difference string
* @param <Date Time> $dateTime
......
......@@ -129,6 +129,12 @@ class Vtiger_Import_View extends Vtiger_Index_View {
}
//End
// Pre-conditional check for CSV import.
if ($fileFormat == 'csv') {
$isLocalInfileEnabled = Vtiger_Util_Helper::checkDbLocalInfileSupport();
if (!$isLocalInfileEnabled) throw new Exception(vtranslate('ERR_LOCAL_INFILE_NOT_ON', 'Import'));
}
$viewer->assign('AVAILABLE_FIELDS', $moduleMeta->getMergableFields());
$viewer->assign('ENTITY_FIELDS', $moduleMeta->getEntityFields());
$viewer->assign('ERROR_MESSAGE', $request->get('error_message'));
......
......@@ -53,6 +53,7 @@ $languageStrings = array(
'LBL_CANCEL_IMPORT' => 'Cancel Import',
'LBL_ERROR' => 'Error',
'LBL_CLEAR_DATA' => 'Clear Data',
'ERR_LOCAL_INFILE_NOT_ON' => 'local_infile variable is turned off on the database server.',
'ERR_UNIMPORTED_RECORDS_EXIST' => 'Unable to import more data in this batch. Please start a new import.',
'ERR_IMPORT_INTERRUPTED' => 'Current Import has been interrupted. Please try again later',
'ERR_FAILED_TO_LOCK_MODULE' => 'Failed to lock the module for import. Re-try again later',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment