From 8687278954f27fdcd962eee7c36a6287abc1f0e8 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 2 Jul 2009 13:18:52 +0800 Subject: Fix for ticket #357. Changed the set the created date as part of the import and change models/comment::save() to not set the creation date if it is already set. Signed-off-by: Tim Almdal --- modules/comment/models/comment.php | 2 +- modules/g2_import/helpers/g2_import.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/comment/models/comment.php b/modules/comment/models/comment.php index ec4d4794..22c465df 100644 --- a/modules/comment/models/comment.php +++ b/modules/comment/models/comment.php @@ -59,7 +59,7 @@ class Comment_Model extends ORM { public function save() { if (!empty($this->changed)) { $this->updated = time(); - if (!$this->loaded) { + if (!$this->loaded && empty($this->created)) { $this->created = $this->updated; } } diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 910f9342..c2ad443c 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -554,6 +554,7 @@ class g2_import_Core { $comment->text = $text; $comment->state = "published"; $comment->server_http_host = $g2_comment->getHost(); + $comment->created = $g2_comment->getDate(); $comment->save(); self::map($g2_comment->getId(), $comment->id); -- cgit v1.2.3 From 3dfe19e99a9a808640087c00eaa7096f7a9300f6 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 2 Jul 2009 14:14:01 +0800 Subject: Start of fixing a problem with importing movies w/o a thumbnail Signed-off-by: Tim Almdal --- modules/g2_import/helpers/g2_import.php | 48 ++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index c2ad443c..93d92659 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -638,33 +638,37 @@ class g2_import_Core { $target_thumb_size = module::get_var("gallery", "thumb_size"); $target_resize_size = module::get_var("gallery", "resize_size"); - foreach ($derivatives[$g2_item_id] as $derivative) { - if ($derivative->getPostFilterOperations()) { - // Let's assume for now that this is a watermark operation, which we can't handle. - continue; - } + if (!empty($derivatives[$g2_item_id])) { + foreach ($derivatives[$g2_item_id] as $derivative) { + if ($derivative->getPostFilterOperations()) { + // Let's assume for now that this is a watermark operation, which we can't handle. + continue; + } - if ($derivative->getDerivativeType() == DERIVATIVE_TYPE_IMAGE_THUMBNAIL && - $item->thumb_dirty && - ($derivative->getWidth() == $target_thumb_size || - $derivative->getHeight() == $target_thumb_size)) { - if (@copy(g2($derivative->fetchPath()), $item->thumb_path())) { - $item->thumb_height = $derivative->getHeight(); - $item->thumb_width = $derivative->getWidth(); - $item->thumb_dirty = false; + if ($derivative->getDerivativeType() == DERIVATIVE_TYPE_IMAGE_THUMBNAIL && + $item->thumb_dirty && + ($derivative->getWidth() == $target_thumb_size || + $derivative->getHeight() == $target_thumb_size)) { + if (@copy(g2($derivative->fetchPath()), $item->thumb_path())) { + $item->thumb_height = $derivative->getHeight(); + $item->thumb_width = $derivative->getWidth(); + $item->thumb_dirty = false; + } } - } - if ($derivative->getDerivativeType() == DERIVATIVE_TYPE_IMAGE_RESIZE && - $item->resize_dirty && - ($derivative->getWidth() == $target_resize_size || - $derivative->getHeight() == $target_resize_size)) { - if (@copy(g2($derivative->fetchPath()), $item->resize_path())) { - $item->resize_height = $derivative->getHeight(); - $item->resize_width = $derivative->getWidth(); - $item->resize_dirty = false; + if ($derivative->getDerivativeType() == DERIVATIVE_TYPE_IMAGE_RESIZE && + $item->resize_dirty && + ($derivative->getWidth() == $target_resize_size || + $derivative->getHeight() == $target_resize_size)) { + if (@copy(g2($derivative->fetchPath()), $item->resize_path())) { + $item->resize_height = $derivative->getHeight(); + $item->resize_width = $derivative->getWidth(); + $item->resize_dirty = false; + } } } + } else { + // @todo Figure out away to create the thumbnail and resizes? } $item->save(); } -- cgit v1.2.3 From 768657d8b1a3dae8b7da4a7de8996d40294ec31d Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 2 Jul 2009 22:53:24 +0800 Subject: Suppress the filesize error if the thumbnail is not found so we can get an EMPTY_INPUT_FILE exception which we can then log and continue. Signed-off-by: Tim Almdal --- modules/g2_import/helpers/g2_import.php | 2 -- modules/gallery/helpers/graphics.php | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 93d92659..71199eaf 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -667,8 +667,6 @@ class g2_import_Core { } } } - } else { - // @todo Figure out away to create the thumbnail and resizes? } $item->save(); } diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index 71b8ddd8..bbae0602 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -195,7 +195,7 @@ class graphics_Core { self::init_toolkit(); } - if (filesize($input_file) == 0) { + if (@filesize($input_file) == 0) { throw new Exception("@todo EMPTY_INPUT_FILE"); } -- cgit v1.2.3