private function execute(\Orm\Model $obj) { // 親記事削除時 if (empty($this->_conditions['type'])) { // delete member_watch_content self::delete_member_watch_content($obj, $this->_conditions); } $notices = \Site_Model::get4relation('\\Notice\\Model_Notice', $this->_conditions, $obj); foreach ($notices as $notice) { // 親記事削除時 if (empty($this->_conditions['type'])) { $notice->delete(); } else { // delete notice_member_from if (self::delete_notice_member_from($notice->id, $obj->member_id)) { $parent_content_member_id = \Site_Model::get_value4table_and_id($notice->foreign_table, $notice->foreign_id, 'member_id'); if (!\Notice\Model_NoticeMemberFrom::get_count4notice_id($notice->id, $parent_content_member_id)) { $notice->delete(); } } } } // 親記事削除時 if (empty($this->_conditions['type'])) { $foreign_table = \Util_Array::get_first_key($this->_conditions['foreign_table']); $foreign_id = $obj->id; $notices = \Notice\Model_Notice::get4parent_data($foreign_table, $foreign_id); foreach ($notices as $notice) { $notice->delete(); } } else { $type = \Util_Array::get_first_key($this->_conditions['type']); // comment 削除時 if ($type == \Notice\Site_Util::get_notice_type('comment')) { $foreign_table = \Util_Array::get_first_key($this->_conditions['foreign_table']) . '_comment'; $foreign_id = $obj->id; $notices = \Notice\Model_Notice::get4foreign_data($foreign_table, $foreign_id); foreach ($notices as $notice) { $notice->delete(); } } } }
public function test_delete_album_image_multiple4ids() { $timeline_ids = array_unique(\Util_Orm::conv_col2array(\Timeline\Model_TimelineChildData::get4foreign_table_and_foreign_ids('album_image_id', self::$album_image->id), 'timeline_id')); $notices = array(); if (is_enabled('notice')) { $notice_ids = \Util_Orm::conv_col2array(\Notice\Model_Notice::get4foreign_data('album_image', self::$album_image->id), 'id'); $notice_ids += \Util_Orm::conv_col2array(\Notice\Model_Notice::get4parent_data('album_image', self::$album_image->id), 'id'); $notice_ids = array_unique($notice_ids); } $notice_statuses = \Notice\Model_NoticeStatus::query()->where('notice_id', 'in', $notice_ids)->get(); $file_name = self::$album_image->file_name; $file = \Model_File::get4name($file_name); $file_size = $file->filesize; $member_filesize_before = self::$member->filesize_total; // timeline view cache 作成 if (self::$is_check_timeline_view_cache) { $timeline_view_cache_before = \Timeline\Site_Util::make_view_cache4foreign_table_and_foreign_id('album', $album->id, \Config::get('timeline.types.album_image')); } // file if (conf('upload.storageType') == 'db') { $this->assertNotNull(\Model_FileBin::get4name(self::$album_image->file_name)); } // album_image delete. Site_NoOrmModel::delete_album_image_multiple4ids(self::$album_image->id, true); // 件数 $this->assertEmpty(Model_AlbumImage::query()->where('id', self::$album_image->id)->get()); $this->assertEmpty(Model_AlbumImageLike::query()->where('album_image_id', self::$album_image_comment->id)->get()); $this->assertEmpty(Model_AlbumImageComment::query()->where('album_image_id', self::$album_image->id)->get()); $this->assertEmpty(Model_AlbumImageCommentLike::query()->where('album_image_comment_id', self::$album_image_comment->id)->get()); // file $this->assertEmpty(\Model_File::get4name($file_name)); // meber_filesize $this->assertEquals($member_filesize_before - $file_size, self::get_member_filesize_total(self::$member_id)); // timeline if (is_enabled('timeline')) { $timeline_child_datas = \Timeline\Model_TimelineChildData::get4foreign_table_and_foreign_ids('album_image', self::$album_image->id); $this->assertEmpty($timeline_child_datas); if ($timeline_ids) { $this->assertEmpty(\Timeline\Model_Timeline::query()->where('id', 'in', $timeline_ids)->get()); } // timeline view cache check if (self::$is_check_timeline_view_cache && $timeline_ids) { foreach ($timeline_ids as ${$timeline_id}) { $this->assertEmpty(\Timeline\Site_Util::get_view_cache($timeline_id)); } } } // notice if (is_enabled('notice')) { $this->assertEmpty(\Notice\Model_MemberWatchContent::get4foreign_data('album_image', self::$album_image->id)); if ($notice_ids) { $this->assertEmpty(\Notice\Model_Notice::query()->where('id', 'in', $notice_ids)->get()); $this->assertEmpty(\Notice\Model_NoticeStatus::query()->where('notice_id', 'in', $notice_ids)->get()); $this->assertEmpty(\Notice\Model_NoticeMemberFrom::query()->where('notice_id', 'in', $notice_ids)->get()); } if (self::$is_check_notice_cache) { foreach ($notice_statuses as $notice_statuse) { $this->assertEmpty(\Notice\Site_Util::get_unread_count_cache($notice_statuse->member_id)); } } } }