From a11bf295078656612603c1c561e9261555d0c40c Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 9 Jan 2010 23:57:16 -0800 Subject: Fix for ticket #972 and more. In Kohana 2.4, ORM::delete_all ignores any where clauses and deletes all the entries in the table unless an array of id's are passed as the parameter. This fix used the Database_builder to specify any where conditions. Thanks psvo for find the first one. :-) --- modules/comment/controllers/admin_comments.php | 5 +++-- modules/gallery/helpers/graphics.php | 5 +++-- modules/gallery/tests/Gallery_I18n_Test.php | 5 +++-- modules/notification/helpers/notification_event.php | 5 +++-- modules/rest/helpers/rest_event.php | 5 +++-- modules/search/helpers/search_event.php | 5 +++-- modules/server_add/controllers/server_add.php | 5 ++++- 7 files changed, 22 insertions(+), 13 deletions(-) (limited to 'modules') diff --git a/modules/comment/controllers/admin_comments.php b/modules/comment/controllers/admin_comments.php index 880c33a7..b7dc5fb3 100644 --- a/modules/comment/controllers/admin_comments.php +++ b/modules/comment/controllers/admin_comments.php @@ -121,9 +121,10 @@ class Admin_Comments_Controller extends Admin_Controller { public function delete_all_spam() { access::verify_csrf(); - ORM::factory("comment") + db::build() + ->delete("comments") ->where("state", "=", "spam") - ->delete_all(); + ->execute(); url::redirect("admin/comments/queue/spam"); } } diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index 7577d7ac..5a290905 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -60,11 +60,12 @@ class graphics_Core { * @param string $operation the name of the operation(::method) */ static function remove_rule($module_name, $target, $operation) { - ORM::factory("graphics_rule") + db::build() + ->delete("graphics_rules") ->where("module_name", "=", $module_name) ->where("target", "=", $target) ->where("operation", "=", $operation) - ->delete_all(); + ->execute(); self::mark_dirty($target == "thumb", $target == "resize"); } diff --git a/modules/gallery/tests/Gallery_I18n_Test.php b/modules/gallery/tests/Gallery_I18n_Test.php index 895e3051..5d2fd994 100644 --- a/modules/gallery/tests/Gallery_I18n_Test.php +++ b/modules/gallery/tests/Gallery_I18n_Test.php @@ -28,9 +28,10 @@ class Gallery_I18n_Test extends Unit_Test_Case { 'locale_dir' => VARPATH . 'locale/'); $this->i18n = Gallery_I18n::instance($config); - ORM::factory("incoming_translation") + db::build() + ->delete("incoming_translations") ->where("locale", "=", "te_ST") - ->delete_all(); + ->execute(); $messages_te_ST = array( array('Hello world', 'Hallo Welt'), diff --git a/modules/notification/helpers/notification_event.php b/modules/notification/helpers/notification_event.php index 2c7ede27..bc1303f5 100644 --- a/modules/notification/helpers/notification_event.php +++ b/modules/notification/helpers/notification_event.php @@ -89,9 +89,10 @@ class notification_event_Core { static function user_before_delete($user) { try { - ORM::factory("subscription") + db::build() + ->delete("subscriptions") ->where("user_id", "=", $user->id) - ->delete_all(); + ->execute(); } catch (Exception $e) { Kohana_Log::add("error", "@todo notification_event::user_before_delete() failed"); Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString()); diff --git a/modules/rest/helpers/rest_event.php b/modules/rest/helpers/rest_event.php index 00cea7eb..860c8e41 100644 --- a/modules/rest/helpers/rest_event.php +++ b/modules/rest/helpers/rest_event.php @@ -23,9 +23,10 @@ class rest_event { * the user_homes directory. */ static function user_before_delete($user) { - ORM::factory("user_access_token") + db::build() + ->delete("user_access_tokens") ->where("id", "=", $user->id) - ->delete_all(); + ->execute(); } /** diff --git a/modules/search/helpers/search_event.php b/modules/search/helpers/search_event.php index 1add6e5f..97041f8c 100644 --- a/modules/search/helpers/search_event.php +++ b/modules/search/helpers/search_event.php @@ -27,9 +27,10 @@ class search_event_Core { } static function item_deleted($item) { - ORM::factory("search_record") + db::build() + ->delete("search_records") ->where("item_id", "=", $item->id) - ->delete_all(); + ->execute(); } static function item_related_update($item) { diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index f6e3a4dd..d7572b52 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -266,7 +266,10 @@ class Server_Add_Controller extends Admin_Controller { $task->done = true; $task->state = "success"; $task->percent_complete = 100; - ORM::factory("server_add_file")->where("task_id", "=", $task->id)->delete_all(); + db::build() + ->delete("server_add_files") + ->where("task_id", "=", $task->id) + ->execute(); message::info(t2("Successfully added one photo / album", "Successfully added %count photos / albums", $task->get("completed_files"))); -- cgit v1.2.3