summaryrefslogtreecommitdiff
path: root/modules/g2_import/helpers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-06-07 17:48:42 -0700
committerBharat Mediratta <bharat@menalto.com>2009-06-07 17:48:42 -0700
commitc7aafef85279114a8ae8855647394bb26400b3de (patch)
tree5bb9220fce9901e46e15f5609420a312e4f097a4 /modules/g2_import/helpers
parentb179b106c2b4d3971498f513ffc71eff1b6b1a5d (diff)
Improve error handling support for corrupt images and report them
appropriately in g2_import.
Diffstat (limited to 'modules/g2_import/helpers')
-rw-r--r--modules/g2_import/helpers/g2_import.php38
1 files changed, 25 insertions, 13 deletions
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php
index 51dc8705..a6c21489 100644
--- a/modules/g2_import/helpers/g2_import.php
+++ b/modules/g2_import/helpers/g2_import.php
@@ -407,13 +407,19 @@ class g2_import_Core {
Kohana::log("alert", "$g2_path unsupported image type; using a placeholder gif");
$corrupt = 1;
}
- $item = photo::create(
- $parent,
- $g2_path,
- $g2_item->getPathComponent(),
- $g2_item->getTitle(),
- self::extract_description($g2_item),
- self::map($g2_item->getOwnerId()));
+ try {
+ $item = photo::create(
+ $parent,
+ $g2_path,
+ $g2_item->getPathComponent(),
+ $g2_item->getTitle(),
+ self::extract_description($g2_item),
+ self::map($g2_item->getOwnerId()));
+ } catch (Exception $e) {
+ Kohana::log("alert", "Corrupt image $g2_path\n" .
+ $e->getMessage() . "\n" . $e->getTraceAsString());
+ $corrupt = 1;
+ }
break;
case "GalleryMovieItem":
@@ -449,12 +455,18 @@ class g2_import_Core {
// Why oh why did I ever approve the session id placeholder idea in G2?
$g2_item_url =
str_replace('&amp;g2_GALLERYSID=TMP_SESSION_ID_DI_NOISSES_PMT', '', $g2_item_url);
- $warning =
- t("<a href=\"%g2_url\">%title</a> from Gallery 2 could not be processed; " .
- "(imported as <a href=\"%g3_url\">%title</a>)",
- array("g2_url" => $g2_item_url,
- "g3_url" => $item->url(),
- "title" => $g2_item->getTitle()));
+ if (!empty($item)) {
+ $warning =
+ t("<a href=\"%g2_url\">%title</a> from Gallery 2 could not be processed; " .
+ "(imported as <a href=\"%g3_url\">%title</a>)",
+ array("g2_url" => $g2_item_url,
+ "g3_url" => $item->url(),
+ "title" => $g2_item->getTitle()));
+ } else {
+ $warning =
+ t("<a href=\"%g2_url\">%title</a> from Gallery 2 could not be processed",
+ array("g2_url" => $g2_item_url, "title" => $g2_item->getTitle()));
+ }
message::warning($warning);
log::warning("g2_import", $warning);
Kohana::log("alert", $warning);