From 89f6247f45f3178c401299271ac6d8a83ba67736 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 11 Mar 2016 14:37:28 +1300 Subject: [PATCH] CRM-18213 remove hard-coded DAO names Change-Id: I2b6e66b225f5ecbebce737656f0a41e0372174f1 --- CRM/Logging/Reverter.php | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/CRM/Logging/Reverter.php b/CRM/Logging/Reverter.php index 6cb8a80370..ed04ddb4b2 100644 --- a/CRM/Logging/Reverter.php +++ b/CRM/Logging/Reverter.php @@ -49,22 +49,11 @@ class CRM_Logging_Reverter { } /** + * Revert changes in the array of diffs in $this->diffs. + * * @param $tables */ public function revert($tables) { - // FIXME: split off the table → DAO mapping to a GenCode-generated class - $daos = array( - 'civicrm_address' => 'CRM_Core_DAO_Address', - 'civicrm_contact' => 'CRM_Contact_DAO_Contact', - 'civicrm_email' => 'CRM_Core_DAO_Email', - 'civicrm_im' => 'CRM_Core_DAO_IM', - 'civicrm_openid' => 'CRM_Core_DAO_OpenID', - 'civicrm_phone' => 'CRM_Core_DAO_Phone', - 'civicrm_website' => 'CRM_Core_DAO_Website', - 'civicrm_contribution' => 'CRM_Contribute_DAO_Contribution', - 'civicrm_note' => 'CRM_Core_DAO_Note', - 'civicrm_relationship' => 'CRM_Contact_DAO_Relationship', - ); // get custom data tables, columns and types $ctypes = array(); @@ -109,14 +98,13 @@ class CRM_Logging_Reverter { foreach ($deletes as $table => $ids) { CRM_Core_DAO::executeQuery("DELETE FROM `$table` WHERE id IN (" . implode(', ', array_unique($ids)) . ')'); } - // revert updates by updating to previous values foreach ($reverts as $table => $row) { switch (TRUE) { // DAO-based tables - case in_array($table, array_keys($daos)): - $dao = new $daos[$table](); + case (($tableDAO = CRM_Core_DAO_AllCoreTables::getClassForTable($table)) != FALSE): + $dao = new $tableDAO (); foreach ($row as $id => $changes) { $dao->id = $id; foreach ($changes as $field => $value) { -- 2.25.1