From 784ebe75321304fe3f83cddaf3cb1030410fb5ed Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 22 May 2011 21:24:27 -0700 Subject: Leave the "updated" field alone when importing comments so that if Akismet marks them as spam, we don't immediately flush them out of the database on the next visit to Admin > Content > Comments. Also warn the user about Akismet, and fix up the G2 import code to reimport deleted comments. --- modules/g2_import/controllers/admin_g2_import.php | 5 +++++ modules/g2_import/helpers/g2_import.php | 26 ++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php index 1a705bea..4c8af852 100644 --- a/modules/g2_import/controllers/admin_g2_import.php +++ b/modules/g2_import/controllers/admin_g2_import.php @@ -60,6 +60,11 @@ class Admin_g2_import_Controller extends Admin_Controller { 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. Deactivate 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); } diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index c79a8d36..5c690da4 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -908,9 +908,14 @@ class g2_import_Core { 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. + self::clear_map($g2_comment_id); } $item_id = self::map($g2_comment->getParentId()); @@ -948,10 +953,11 @@ class g2_import_Core { 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(); } @@ -1306,6 +1312,16 @@ class g2_import_Core { self::$map[$g2_id] = $g3_id; } + /** + * Remove all map entries associated with the given Gallery 2 id. + */ + static function clear_map($g2_id) { + db::build() + ->delete("g2_maps") + ->where("g2_id", "=", $g2_id) + ->execute(); + } + static function log($msg) { message::warning($msg); Kohana_Log::add("alert", $msg); -- cgit v1.2.3 From f567bdde2817a52afbd436421b61adad8f4a9fd8 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 22 May 2011 21:36:16 -0700 Subject: 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. --- modules/g2_import/helpers/g2_import.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules') 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(); } -- cgit v1.2.3 From c71bb5418557c4a6ac4ff3101f7dca296a4dced5 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 24 May 2011 20:32:43 -0700 Subject: Reassign the copyright to the standard custodian (Bharat). #1732. --- modules/gallery/tests/System_Helper_Test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/tests/System_Helper_Test.php b/modules/gallery/tests/System_Helper_Test.php index 3d56c516..b6c00f4c 100644 --- a/modules/gallery/tests/System_Helper_Test.php +++ b/modules/gallery/tests/System_Helper_Test.php @@ -1,7 +1,7 @@ Date: Tue, 24 May 2011 20:33:36 -0700 Subject: Checkpoint --- modules/gallery/tests/xss_data.txt | 92 +++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 46 deletions(-) (limited to 'modules') diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index 7da79b23..954caf54 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -5,21 +5,22 @@ modules/comment/views/admin_block_recent_comments.html.php 4 DIRTY_ATTR text modules/comment/views/admin_block_recent_comments.html.php 5 DIRTY_ATTR $comment->author()->avatar_url(32,$theme->url(,true)) modules/comment/views/admin_block_recent_comments.html.php 10 DIRTY gallery::date_time($comment->created) modules/comment/views/admin_comments.html.php 5 DIRTY $form -modules/comment/views/admin_manage_comments.html.php 43 DIRTY $menu->render() -modules/comment/views/admin_manage_comments.html.php 107 DIRTY_ATTR $comment->id -modules/comment/views/admin_manage_comments.html.php 107 DIRTY_ATTR text::alternate("g-odd","g-even") -modules/comment/views/admin_manage_comments.html.php 110 DIRTY_ATTR $comment->author()->avatar_url(40,$theme->url(,true)) -modules/comment/views/admin_manage_comments.html.php 123 DIRTY_JS $item->url() -modules/comment/views/admin_manage_comments.html.php 125 DIRTY_ATTR $item->thumb_url() -modules/comment/views/admin_manage_comments.html.php 127 DIRTY photo::img_dimensions($item->thumb_width,$item->thumb_height,75) -modules/comment/views/admin_manage_comments.html.php 135 DIRTY gallery::date($comment->created) -modules/comment/views/admin_manage_comments.html.php 142 DIRTY_JS $comment->id -modules/comment/views/admin_manage_comments.html.php 151 DIRTY_JS $comment->id -modules/comment/views/admin_manage_comments.html.php 160 DIRTY_JS $comment->id -modules/comment/views/admin_manage_comments.html.php 169 DIRTY_JS $comment->id -modules/comment/views/admin_manage_comments.html.php 176 DIRTY_JS $comment->id -modules/comment/views/admin_manage_comments.html.php 184 DIRTY_JS $comment->id -modules/comment/views/admin_manage_comments.html.php 197 DIRTY $pager +modules/comment/views/admin_manage_comments.html.php 45 DIRTY $menu->render() +modules/comment/views/admin_manage_comments_queue.html.php 40 DIRTY $theme->paginator() +modules/comment/views/admin_manage_comments_queue.html.php 55 DIRTY_ATTR $comment->id +modules/comment/views/admin_manage_comments_queue.html.php 55 DIRTY_ATTR text::alternate("g-odd","g-even") +modules/comment/views/admin_manage_comments_queue.html.php 58 DIRTY_ATTR $comment->author()->avatar_url(40,$fallback_avatar_url) +modules/comment/views/admin_manage_comments_queue.html.php 75 DIRTY_JS $item->url() +modules/comment/views/admin_manage_comments_queue.html.php 77 DIRTY_ATTR $item->thumb_url() +modules/comment/views/admin_manage_comments_queue.html.php 79 DIRTY photo::img_dimensions($item->thumb_width,$item->thumb_height,75) +modules/comment/views/admin_manage_comments_queue.html.php 87 DIRTY gallery::date($comment->created) +modules/comment/views/admin_manage_comments_queue.html.php 94 DIRTY_JS $comment->id +modules/comment/views/admin_manage_comments_queue.html.php 103 DIRTY_JS $comment->id +modules/comment/views/admin_manage_comments_queue.html.php 116 DIRTY_JS $comment->id +modules/comment/views/admin_manage_comments_queue.html.php 125 DIRTY_JS $comment->id +modules/comment/views/admin_manage_comments_queue.html.php 132 DIRTY_JS $comment->id +modules/comment/views/admin_manage_comments_queue.html.php 141 DIRTY_JS $comment->id +modules/comment/views/admin_manage_comments_queue.html.php 155 DIRTY $theme->paginator() modules/comment/views/comment.html.php 2 DIRTY_ATTR $comment->id; modules/comment/views/comment.html.php 5 DIRTY_ATTR $comment->author()->avatar_url(40,$theme->url(,true)) modules/comment/views/comment.mrss.php 10 DIRTY $feed->uri @@ -367,7 +368,7 @@ modules/user/views/admin_users.html.php 73 DIRTY_ATTR $use modules/user/views/admin_users.html.php 74 DIRTY_ATTR $user->avatar_url(20,$theme->url(,true)) modules/user/views/admin_users.html.php 88 DIRTY ($user->last_login==0)?"":gallery::date($user->last_login) modules/user/views/admin_users.html.php 91 DIRTY db::build()->from("items")->where("owner_id","=",$user->id)->count_records() -modules/user/views/admin_users.html.php 113 DIRTY $pager +modules/user/views/admin_users.html.php 113 DIRTY $theme->paginator() modules/user/views/admin_users.html.php 132 DIRTY_ATTR $group->id modules/user/views/admin_users.html.php 132 DIRTY_ATTR ($group->special?"g-default-group":"") modules/user/views/admin_users.html.php 134 DIRTY $v @@ -378,31 +379,30 @@ modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $wid modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $height modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $url themes/admin_wind/views/admin.html.php 4 DIRTY $theme->html_attributes() -themes/admin_wind/views/admin.html.php 33 DIRTY $theme->admin_head() -themes/admin_wind/views/admin.html.php 42 DIRTY_JS $theme->url() -themes/admin_wind/views/admin.html.php 47 DIRTY $theme->get_combined("css") -themes/admin_wind/views/admin.html.php 50 DIRTY $theme->get_combined("script") -themes/admin_wind/views/admin.html.php 54 DIRTY $theme->admin_page_top() -themes/admin_wind/views/admin.html.php 62 DIRTY $theme->admin_header_top() -themes/admin_wind/views/admin.html.php 63 DIRTY_JS item::root()->url() -themes/admin_wind/views/admin.html.php 66 DIRTY $theme->user_menu() -themes/admin_wind/views/admin.html.php 69 DIRTY $theme->admin_menu() -themes/admin_wind/views/admin.html.php 72 DIRTY $theme->admin_header_bottom() -themes/admin_wind/views/admin.html.php 79 DIRTY $content -themes/admin_wind/views/admin.html.php 85 DIRTY $sidebar -themes/admin_wind/views/admin.html.php 90 DIRTY $theme->admin_footer() -themes/admin_wind/views/admin.html.php 93 DIRTY $theme->admin_credits() -themes/admin_wind/views/admin.html.php 98 DIRTY $theme->admin_page_bottom() +themes/admin_wind/views/admin.html.php 34 DIRTY $theme->admin_head() +themes/admin_wind/views/admin.html.php 46 DIRTY_JS $theme->url() +themes/admin_wind/views/admin.html.php 51 DIRTY $theme->get_combined("css") +themes/admin_wind/views/admin.html.php 54 DIRTY $theme->get_combined("script") +themes/admin_wind/views/admin.html.php 58 DIRTY $theme->admin_page_top() +themes/admin_wind/views/admin.html.php 66 DIRTY $theme->admin_header_top() +themes/admin_wind/views/admin.html.php 67 DIRTY_JS item::root()->url() +themes/admin_wind/views/admin.html.php 70 DIRTY $theme->user_menu() +themes/admin_wind/views/admin.html.php 73 DIRTY $theme->admin_menu() +themes/admin_wind/views/admin.html.php 76 DIRTY $theme->admin_header_bottom() +themes/admin_wind/views/admin.html.php 83 DIRTY $content +themes/admin_wind/views/admin.html.php 89 DIRTY $sidebar +themes/admin_wind/views/admin.html.php 94 DIRTY $theme->admin_footer() +themes/admin_wind/views/admin.html.php 97 DIRTY $theme->admin_credits() +themes/admin_wind/views/admin.html.php 102 DIRTY $theme->admin_page_bottom() themes/admin_wind/views/block.html.php 3 DIRTY_ATTR $anchor themes/admin_wind/views/block.html.php 5 DIRTY $id themes/admin_wind/views/block.html.php 5 DIRTY_ATTR $css_id themes/admin_wind/views/block.html.php 13 DIRTY $title themes/admin_wind/views/block.html.php 16 DIRTY $content -themes/admin_wind/views/pager.html.php 13 DIRTY_JS str_replace('{page}',1,$url) -themes/admin_wind/views/pager.html.php 20 DIRTY_JS str_replace('{page}',$previous_page,$url) -themes/admin_wind/views/pager.html.php 27 DIRTY $from_to_msg -themes/admin_wind/views/pager.html.php 30 DIRTY_JS str_replace('{page}',$next_page,$url) -themes/admin_wind/views/pager.html.php 37 DIRTY_JS str_replace('{page}',$last_page,$url) +themes/admin_wind/views/paginator.html.php 35 DIRTY_JS $first_page_url +themes/admin_wind/views/paginator.html.php 44 DIRTY_JS $previous_page_url +themes/admin_wind/views/paginator.html.php 70 DIRTY_JS $next_page_url +themes/admin_wind/views/paginator.html.php 79 DIRTY_JS $last_page_url themes/wind/views/album.html.php 16 DIRTY_ATTR $child->id themes/wind/views/album.html.php 16 DIRTY_ATTR $item_class themes/wind/views/album.html.php 18 DIRTY_JS $child->url() @@ -430,16 +430,16 @@ themes/wind/views/page.html.php 17 DIRTY item:: themes/wind/views/page.html.php 32 DIRTY $new_width themes/wind/views/page.html.php 33 DIRTY $new_height themes/wind/views/page.html.php 34 DIRTY $thumb_proportion -themes/wind/views/page.html.php 71 DIRTY_JS $theme->url() -themes/wind/views/page.html.php 76 DIRTY $theme->get_combined("css") -themes/wind/views/page.html.php 79 DIRTY $theme->get_combined("script") -themes/wind/views/page.html.php 89 DIRTY $header_text -themes/wind/views/page.html.php 91 DIRTY_JS item::root()->url() -themes/wind/views/page.html.php 95 DIRTY $theme->user_menu() -themes/wind/views/page.html.php 116 DIRTY_JS $parent->url($parent->id==$theme->item()->parent_id?"show={$theme->item()->id}":null) -themes/wind/views/page.html.php 137 DIRTY $content -themes/wind/views/page.html.php 143 DIRTY newView("sidebar.html") -themes/wind/views/page.html.php 150 DIRTY $footer_text +themes/wind/views/page.html.php 74 DIRTY_JS $theme->url() +themes/wind/views/page.html.php 79 DIRTY $theme->get_combined("css") +themes/wind/views/page.html.php 82 DIRTY $theme->get_combined("script") +themes/wind/views/page.html.php 92 DIRTY $header_text +themes/wind/views/page.html.php 94 DIRTY_JS item::root()->url() +themes/wind/views/page.html.php 98 DIRTY $theme->user_menu() +themes/wind/views/page.html.php 119 DIRTY_JS $parent->url($parent->id==$theme->item()->parent_id?"show={$theme->item()->id}":null) +themes/wind/views/page.html.php 140 DIRTY $content +themes/wind/views/page.html.php 146 DIRTY newView("sidebar.html") +themes/wind/views/page.html.php 153 DIRTY $footer_text themes/wind/views/paginator.html.php 33 DIRTY_JS $first_page_url themes/wind/views/paginator.html.php 42 DIRTY_JS $previous_page_url themes/wind/views/paginator.html.php 70 DIRTY_JS $next_page_url -- cgit v1.2.3 From 44247fb2d1698286e558cd6f5ee5bb87a8612f9b Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 24 May 2011 20:37:51 -0700 Subject: Allow password reset even when we're in maintenance or private gallery mode, otherwise you can't reset your password if you forgot it when the Gallery is locked down. #1735. --- modules/user/controllers/password.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'modules') diff --git a/modules/user/controllers/password.php b/modules/user/controllers/password.php index cd46bbed..ab31c6b4 100644 --- a/modules/user/controllers/password.php +++ b/modules/user/controllers/password.php @@ -18,6 +18,9 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Password_Controller extends Controller { + const ALLOW_MAINTENANCE_MODE = true; + const ALLOW_PRIVATE_GALLERY = true; + public function reset() { $form = self::_reset_form(); if (request::method() == "post") { -- cgit v1.2.3 From 5e6a6d58c2946caf54af9bb4b67f6f9a12d7449f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 24 May 2011 20:48:23 -0700 Subject: Follow on to c101151616033d53587d1435881dae0fa45aeefa -- delete all tags in setup so that we have a blank slate, otherwise create_tag() will fail because sometimes there'll be other tags in the system. #1628 --- modules/tag/tests/Tag_Test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/tag/tests/Tag_Test.php b/modules/tag/tests/Tag_Test.php index 9e10fa4a..52fd4fdd 100644 --- a/modules/tag/tests/Tag_Test.php +++ b/modules/tag/tests/Tag_Test.php @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Tag_Test extends Gallery_Unit_Test_Case { - public function teardown() { + public function setup() { ORM::factory("tag")->delete_all(); } -- cgit v1.2.3 From 61691fdf713950f704427640bc30776990768d98 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 5 Jun 2011 17:16:07 -0700 Subject: Use the strict form of mb_detect_encoding for best results. Thanks to guthy in https://github.com/gallery/gallery3/commit/fa6f233603267505c216abc4f12663d245cd23e7#commitcomment-403145 Fixes #1745. --- modules/gallery/helpers/encoding.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/encoding.php b/modules/gallery/helpers/encoding.php index c5928634..7d5add34 100644 --- a/modules/gallery/helpers/encoding.php +++ b/modules/gallery/helpers/encoding.php @@ -19,13 +19,16 @@ */ class encoding_Core { static function convert_to_utf8($value) { - if (function_exists("mb_detect_encoding") && - function_exists("mb_convert_encoding") && - mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") { - $value = mb_convert_encoding($value, "UTF-8", mb_detect_encoding($value)); - } else if (function_exists("mb_detect_encoding") && - mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") { - $value = utf8_encode($value); + if (function_exists("mb_detect_encoding")) { + // Rely on mb_detect_encoding()'s strict mode + $src_encoding = mb_detect_encoding($value, mb_detect_order(), true); + if ($src_encoding != "UTF-8") { + if (function_exists("mb_convert_encoding") && $src_encoding) { + $value = mb_convert_encoding($value, "UTF-8", $src_encoding); + } else { + $value = utf8_encode($value); + } + } } return $value; } -- cgit v1.2.3 From 142088a6353dfd051e0dc72e1e30fa51fb6d7f2b Mon Sep 17 00:00:00 2001 From: Chad Parry Date: Wed, 15 Jun 2011 20:46:23 -0600 Subject: Gracefully handle rule failures with a broken image icon. This will be especially useful as third-party modules start supporting a larger variety of image types, and as errors creep into their image processing. --- modules/gallery/helpers/graphics.php | 22 ++++++++++++++++++---- modules/gallery/images/missing_photo.png | Bin 0 -> 1570 bytes 2 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 modules/gallery/images/missing_photo.png (limited to 'modules') diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index acb11bfb..39c87fbd 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -170,23 +170,37 @@ class graphics_Core { foreach (self::_get_rules($target) as $rule) { $args = array($working_file, $output_file, unserialize($rule->args), $item); - call_user_func_array($rule->operation, $args); - $working_file = $output_file; + try { + call_user_func_array($rule->operation, $args); + $working_file = $output_file; + } catch (Exception $e) { + // Ignore this rule and move on. + Kohana_Log::add("error", "Caught exception processing image: {$item->title}\n" . + $e->getMessage() . "\n" . $e->getTraceAsString()); + } } } if (!empty($ops["thumb"])) { + if (file_exists($item->thumb_path())) { + $item->thumb_dirty = 0; + } else { + copy(MODPATH . "gallery/images/missing_photo.png", $item->thumb_path()); + } $dims = getimagesize($item->thumb_path()); $item->thumb_width = $dims[0]; $item->thumb_height = $dims[1]; - $item->thumb_dirty = 0; } if (!empty($ops["resize"])) { + if (file_exists($item->resize_path())) { + $item->resize_dirty = 0; + } else { + copy(MODPATH . "gallery/images/missing_photo.png", $item->resize_path()); + } $dims = getimagesize($item->resize_path()); $item->resize_width = $dims[0]; $item->resize_height = $dims[1]; - $item->resize_dirty = 0; } $item->save(); } catch (Exception $e) { diff --git a/modules/gallery/images/missing_photo.png b/modules/gallery/images/missing_photo.png new file mode 100644 index 00000000..67786275 Binary files /dev/null and b/modules/gallery/images/missing_photo.png differ -- cgit v1.2.3