Skip to content

Commit

Permalink
Merge branch 'master' into 3.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
bharat committed May 23, 2011
2 parents 4d98a89 + f567bdd commit 0307d1e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
5 changes: 5 additions & 0 deletions modules/g2_import/controllers/admin_g2_import.php
Expand Up @@ -60,6 +60,11 @@ public function index() {
array("url" => url::site("admin/modules"), "module_id" => $module_id)));
}
}
if (module::is_active("akismet")) {
message::warning(
t("The Akismet module may mark some or all of your imported comments as spam. <a href=\"%url\">Deactivate</a> it to avoid that outcome.",
array("url" => url::site("admin/modules"))));
}
} else if (g2_import::is_configured()) {
$view->content->form->configure_g2_import->embed_path->add_error("invalid", 1);
}
Expand Down
27 changes: 22 additions & 5 deletions modules/g2_import/helpers/g2_import.php
Expand Up @@ -908,9 +908,13 @@ static function import_comment(&$queue) {
array("id" => $g2_comment_id, "exception" => (string)$e));
}

if (self::map($g2_comment->getId())) {
// Already imported
return;
if ($id = self::map($g2_comment->getId())) {
if (ORM::factory("comment", $id)->loaded()) {
// Already imported and still exists
return;
}
// This comment was already imported, but now it no longer exists. Import it again, per
// ticket #1736.
}

$item_id = self::map($g2_comment->getParentId());
Expand Down Expand Up @@ -948,10 +952,11 @@ static function import_comment(&$queue) {
self::set_map($g2_comment->getId(), $comment->id, "comment");

// Backdate the creation date. We can't do this at creation time because
// Comment_Model::save() will override it.
// Comment_Model::save() will override it. Leave the updated date alone
// so that if the comments get marked as spam, they don't immediately get
// flushed (see ticket #1736)
db::update("comments")
->set("created", $g2_comment->getDate())
->set("updated", $g2_comment->getDate())
->where("id", "=", $comment->id)
->execute();
}
Expand Down Expand Up @@ -1292,6 +1297,7 @@ static function map($g2_id) {
* 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;
Expand All @@ -1306,6 +1312,17 @@ static function set_map($g2_id, $g3_id, $resource_type, $g2_url=null) {
self::$map[$g2_id] = $g3_id;
}

/**
* Remove all map entries associated with the given Gallery 2 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();
}

static function log($msg) {
message::warning($msg);
Kohana_Log::add("alert", $msg);
Expand Down

0 comments on commit 0307d1e

Please sign in to comment.