Eileen has uploaded a new change for review.
https://gerrit.wikimedia.org/r/277356
Change subject: CRM-18213 remove hard-coded DAO names
......................................................................
CRM-18213 remove hard-coded DAO names
Merged into 4.7
Change-Id: I2b6e66b225f5ecbebce737656f0a41e0372174f1
---
M CRM/Logging/Reverter.php
1 file changed, 4 insertions(+), 16 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm/civicrm
refs/changes/56/277356/1
diff --git a/CRM/Logging/Reverter.php b/CRM/Logging/Reverter.php
index cc0d2ac..675acc9 100644
--- a/CRM/Logging/Reverter.php
+++ b/CRM/Logging/Reverter.php
@@ -49,22 +49,11 @@
}
/**
+ * 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 @@
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) {
--
To view, visit https://gerrit.wikimedia.org/r/277356
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2b6e66b225f5ecbebce737656f0a41e0372174f1
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm/civicrm
Gerrit-Branch: master
Gerrit-Owner: Eileen <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits