diff options
| author | Bharat Mediratta <bharat@menalto.com> | 2009-08-27 16:11:47 -0700 |
|---|---|---|
| committer | Bharat Mediratta <bharat@menalto.com> | 2009-08-27 16:11:47 -0700 |
| commit | 74363ced870d4114e7570729636875e0258917b3 (patch) | |
| tree | 61bc27831a362994fc96ea90172d50e25d5c76cb /modules/comment/helpers/comment_installer.php | |
| parent | 98e9a96ba4d2419e02717369be8c0d886bc35ef7 (diff) | |
| parent | 4828db003f3ee505eb9e6d056cdb142da34b78ff (diff) | |
Merge branch 'master' of git@github.com:gallery/gallery3 into HEAD
Conflicts:
modules/slideshow/helpers/slideshow_event.php
Diffstat (limited to 'modules/comment/helpers/comment_installer.php')
| -rw-r--r-- | modules/comment/helpers/comment_installer.php | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php index f54913c3..80594c16 100644 --- a/modules/comment/helpers/comment_installer.php +++ b/modules/comment/helpers/comment_installer.php @@ -44,7 +44,7 @@ class comment_installer { `text` text, `updated` int(9) NOT NULL, PRIMARY KEY (`id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + DEFAULT CHARSET=utf8;"); block_manager::add("dashboard_center", "comment", "recent_comments"); module::set_var("comment", "spam_caught", 0); @@ -52,8 +52,8 @@ class comment_installer { } static function upgrade($version) { + $db = Database::instance(); if ($version == 1) { - $db = Database::instance(); $db->query("ALTER TABLE {comments} CHANGE `state` `state` varchar(15) default 'unpublished'"); module::set_version("comment", 2); } @@ -61,9 +61,16 @@ class comment_installer { static function uninstall() { $db = Database::instance(); - $sql = "SELECT `item_id` FROM {comments}"; - module::event("item_related_update_batch", $sql); + // Notify listeners that we're deleting some data. This is probably going to be very + // inefficient for large uninstalls, and we could make it better by doing things like passing + // a SQL fragment through so that the listeners could use subselects. But by using a single, + // simple event API we lighten the load on module developers. + foreach (ORM::factory("item") + ->join("comments", "items.id", "comments.item_id") + ->find_all() as $item) { + module::event("item_related_update", $item); + } $db->query("DROP TABLE IF EXISTS {comments};"); } } |
