public static function get_timelines4foreign_table_and_id($foreign_table, $foreign_id) { if ($foreign_table == 'timeline') { if (!($timeline = \Timeline\Model_Timeline::find($foreign_id))) { return false; } return array($timeline->id => $timeline); } if (!in_array($foreign_table, \Timeline\Site_Util::get_accept_timeline_foreign_tables())) { return false; } return \Timeline\Model_Timeline::get4foreign_table_and_foreign_ids($foreign_table, $foreign_id); }
public function after_delete(\Orm\Model $obj) { if (!($timeline = \Timeline\Model_Timeline::find($obj->timeline_id))) { return; } $is_cache_delete = false; if (!\Timeline\Model_TimelineChildData::get4timeline_id($obj->timeline_id)) { $timeline->delete(); $is_cache_delete = true; } elseif ($timeline->update_public_flag_with_check_child_data()) { $is_cache_delete = true; } if (\Config::get('timeline.articles.cache.is_use') && !$is_cache_delete) { \Timeline\Site_Util::delete_cache($timeline->id, $timeline->type); } }
/** * @dataProvider save_comment_provider */ public function test_save_comment($member_id, $body) { // note_comment save \Util_Develop::sleep(); $note_comment = $this->save_comment($member_id, $body); $note_id = self::$note_id; $note = \DB::select()->from('note')->where('id', $note_id)->execute()->current(); // 件数 $comment_count = \Util_Orm::get_count_all('\\Note\\Model_NoteComment', array('note_id' => $note_id)); $this->assertEquals(self::$note_comment_count + 1, $comment_count); // 値 $this->assertEquals($comment_count, $note['comment_count']); $this->assertEquals($note_comment->created_at, $note['sort_datetime']); // timeline 関連 if (is_enabled('timeline')) { $timeline_id = self::$timeline_id; $timeline = \Timeline\Model_Timeline::find($timeline_id); // 値 $this->assertEquals($comment_count, $timeline->comment_count); $this->assertEquals($note_comment->created_at, $timeline->sort_datetime); $this->assertEquals($note['sort_datetime'], $timeline->sort_datetime); $timeline_caches = \DB::select()->from('timeline_cache')->where('timeline_id', $timeline_id)->execute(); // timeline_caches $this->assertCount(2, $timeline_caches); foreach ($timeline_caches as $timeline_cache) { $this->assertEquals($comment_count, $timeline_cache['comment_count']); } // timeline_cache が最新レコードになっているか $timeline_cache = \Util_Orm::get_last_row('\\Timeline\\Model_TimelineCache'); $this->assertEquals($timeline_id, $timeline_cache->timeline_id); // timeline view cache check if (self::$is_check_view_cache) { $timeline_view_cache = \Cache::get(\Timeline\Site_Util::get_cache_key($timeline_id), \Config::get('timeline.articles.cache.expir')); $this->assertEquals(self::$view_cache_before, $timeline_view_cache); } } }