public function test_get_cache_path() { $properties = array('parentguid' => self::$_topic->guid, 'name' => 'attach.png'); $attachment = $this->create_object('midcom_db_attachment', $properties); $attachment->copy_from_file(self::$_filepath . 'attach.png'); $GLOBALS['midcom_config']['attachment_cache_enabled'] = false; $stat = midcom_db_attachment::get_cache_path($attachment); $this->assertNull($stat); $GLOBALS['midcom_config']['attachment_cache_enabled'] = true; $expected_path = $GLOBALS['midcom_config']['attachment_cache_root'] . '/' . substr($attachment->guid, 0, 1) . '/' . $attachment->guid . '_attach.png'; $stat = midcom_db_attachment::get_cache_path($attachment); $this->assertEquals($expected_path, $stat); }
/** * Deleted callback, triggers watches on the parent(!) object. */ public function _on_deleted() { if ($GLOBALS['midcom_config']['attachment_cache_enabled']) { // Remove attachment cache $filename = midcom_db_attachment::get_cache_path($this, false); if (!is_null($filename) && file_exists($filename)) { @unlink($filename); } } $object = $this->get_parent(); if ($object !== null) { midcom::get('componentloader')->trigger_watches(MIDCOM_OPERATION_DBA_UPDATE, $object); } }