Skip to content
Snippets Groups Projects
Commit c85badff authored by jaapjansma's avatar jaapjansma
Browse files

Fixed issue with importing and deleting data processors

parent c6b589ec
No related branches found
No related tags found
No related merge requests found
......@@ -221,11 +221,27 @@ class CRM_Dataprocessor_Utils_Importer {
}
// Remove all data processors which are in code or overridden but not imported
$dao = CRM_Core_DAO::executeQuery("SELECT id, name FROM civicrm_data_processor WHERE id NOT IN (".implode($importedIds, ",").") AND status IN (".CRM_Dataprocessor_Status::STATUS_IN_CODE.", ".CRM_Dataprocessor_Status::STATUS_OVERRIDDEN.") AND source_file IS NOT NULL");
$removeSql = "
SELECT id, name, status
FROM civicrm_data_processor
WHERE status IN (".CRM_Dataprocessor_Status::STATUS_IN_CODE.", ".CRM_Dataprocessor_Status::STATUS_OVERRIDDEN.")
AND source_file IS NOT NULL";
if (count($importedIds)) {
$removeSql .= " AND id NOT IN (".implode($importedIds, ",").")";
}
if ($extension) {
$removeSql .= " AND source_file LIKE '".CRM_Utils_Type::escape($extension, 'String')."/data-processors/%'";
}
$dao = CRM_Core_DAO::executeQuery($removeSql);
while ($dao->fetch()) {
try {
civicrm_api3('DataProcessor', 'delete', ['id' => $dao->id]);
$return['deleted data processors'][] = $dao->id.": ".$dao->name;
if ($dao->status == CRM_Dataprocessor_Status::STATUS_OVERRIDDEN) {
civicrm_api3('DataProcessor', 'create', array('id' => $dao->id, 'status' => CRM_Dataprocessor_Status::STATUS_IN_DATABASE, 'source_file' => 'null'));
$return['kept data processors'][] = $dao->id.": ".$dao->name;
} else {
civicrm_api3('DataProcessor', 'delete', ['id' => $dao->id]);
$return['deleted data processors'][] = $dao->id . ": " . $dao->name;
}
} catch (\Exception $e) {
$return['deleted data processors'][] = 'Error: '. $dao->id.": ".$dao->name;
}
......
......@@ -11,7 +11,7 @@
</maintainer>
<urls>
<url desc="Main Extension Page">https://lab.civicrm.org/extensions/dataprocessor</url>
<url desc="Documentation">https://lab.civicrm.org/extensions/dataprocessor/README.md</url>
<url desc="Documentation">https://lab.civicrm.org/extensions/dataprocessor/blob/master/README.md</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2019-07-15</releaseDate>
......
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