diff options
author | Bharat Mediratta <bharat@menalto.com> | 2011-05-22 21:36:16 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2011-05-22 21:36:16 -0700 |
commit | f567bdde2817a52afbd436421b61adad8f4a9fd8 (patch) | |
tree | 1edde96cb5b2189d941dc21b64b12ff2c64ae4b0 /modules/g2_import | |
parent | 784ebe75321304fe3f83cddaf3cb1030410fb5ed (diff) |
Clear any existing, matching g2_map rows before mapping new rows.
This is an extra query, but should keep duplicate rows out of the
database and let new rows supercede old ones. Fixes #1737.
Diffstat (limited to 'modules/g2_import')
-rw-r--r-- | modules/g2_import/helpers/g2_import.php | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 5c690da4..8a5d2c5f 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -915,7 +915,6 @@ class g2_import_Core { } // This comment was already imported, but now it no longer exists. Import it again, per // ticket #1736. - self::clear_map($g2_comment_id); } $item_id = self::map($g2_comment->getParentId()); @@ -1298,6 +1297,7 @@ class g2_import_Core { * Associate a Gallery 2 id with a Gallery 3 item id. */ static function set_map($g2_id, $g3_id, $resource_type, $g2_url=null) { + self::clear_map($g2_id, $resource_type); $g2_map = ORM::factory("g2_map"); $g2_map->g3_id = $g3_id; $g2_map->g2_id = $g2_id; @@ -1315,10 +1315,11 @@ class g2_import_Core { /** * Remove all map entries associated with the given Gallery 2 id. */ - static function clear_map($g2_id) { + static function clear_map($g2_id, $resource_type) { db::build() ->delete("g2_maps") ->where("g2_id", "=", $g2_id) + ->where("resource_type", "=", $resource_type) ->execute(); } |