summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Staudacher <andy.st@gmail.com>2010-03-02 13:53:09 -0800
committerAndy Staudacher <andy.st@gmail.com>2010-03-02 13:53:09 -0800
commit109c390f256eb0f7c99dc7d472cec0e0ab911c7b (patch)
tree5ed674df16dbb96795d7e42c3f308ff7c5972fda
parent06d0ed57a7c57b0b398756ae08c836f14c4d4565 (diff)
Ignore fetchItemViewCount errors during import and default to 0. The error is still logged to the G3 syslog.
-rw-r--r--modules/g2_import/helpers/g2_import.php21
1 files changed, 15 insertions, 6 deletions
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php
index 6240403d..9009ac82 100644
--- a/modules/g2_import/helpers/g2_import.php
+++ b/modules/g2_import/helpers/g2_import.php
@@ -414,7 +414,12 @@ class g2_import_Core {
$album->title or $album->title = $album->name;
$album->description = self::_decode_html_special_chars(self::extract_description($g2_album));
$album->owner_id = self::map($g2_album->getOwnerId());
- $album->view_count = g2(GalleryCoreApi::fetchItemViewCount($g2_album_id));
+ try {
+ $album->view_count = (int) g2(GalleryCoreApi::fetchItemViewCount($g2_album_id));
+ } catch (Exception $e) {
+ // @todo log
+ $album->view_count = 0;
+ }
$album->created = $g2_album->getCreationTimestamp();
$order_map = array(
@@ -490,7 +495,11 @@ class g2_import_Core {
$g3_album = ORM::factory("item", $g3_album_id);
$g3_album->album_cover_item_id = $item->id;
$g3_album->thumb_dirty = 1;
- $g3_album->view_count = (int) g2(GalleryCoreApi::fetchItemViewCount($g2_album_id));
+ try {
+ $g3_album->view_count = (int) g2(GalleryCoreApi::fetchItemViewCount($g2_album_id));
+ } catch (Exception $e) {
+ $g3_album->view_count = 0;
+ }
try {
$g3_album->save();
graphics::generate($g2_album);
@@ -614,11 +623,11 @@ class g2_import_Core {
$g2_item_url = self::g2_url(array("view" => "core.ShowItem", "itemId" => $g2_item->getId()));
if (isset($item)) {
- $view_count = g2(GalleryCoreApi::fetchItemViewCount($g2_item_id));
- if (!is_numeric($view_count)) {
- $messages[] = t("Bad view count value '%view_count'", array("view_count" => $view_count));
+ try {
+ $item->view_count = (int) g2(GalleryCoreApi::fetchItemViewCount($g2_item_id));
+ } catch (Exception $e) {
+ $view_count = 1;
}
- $item->view_count = (int) $view_count;
$item->save();
self::set_map($g2_item_id, $item->id, "item", $g2_item_url);