diff --git a/core/extension.php b/core/extension.php index 65d90694..82c939cd 100644 --- a/core/extension.php +++ b/core/extension.php @@ -325,6 +325,7 @@ abstract class DataHandlerExtension extends Extension $event->metadata['tags'] = $existing->get_tag_list(); $image = $this->create_image_from_data(warehouse_path(Image::IMAGE_DIR, $event->hash), $event->metadata); + $image->posted = $existing->posted; send_event(new ImageReplaceEvent($event->replace_id, $image)); $_id = $event->replace_id; assert(!is_null($_id)); diff --git a/ext/upload/test.php b/ext/upload/test.php index be099ba6..56347e16 100644 --- a/ext/upload/test.php +++ b/ext/upload/test.php @@ -56,6 +56,9 @@ class UploadTest extends ShimmiePHPUnitTestCase $this->log_in_as_admin(); $image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx computer screenshot"); + $original_posted = $database->get_one("SELECT posted FROM images WHERE id = $image_id"); + + sleep(1); // make sure the timestamp changes (see bug #903) $_FILES = [ 'data' => [ @@ -70,8 +73,13 @@ class UploadTest extends ShimmiePHPUnitTestCase $page = $this->post_page("replace/$image_id"); $this->assert_response(302); $this->assertEquals("/test/post/view/$image_id", $page->redirect); + $new_posted = $database->get_one("SELECT posted FROM images WHERE id = $image_id"); $this->assertEquals(1, $database->get_one("SELECT COUNT(*) FROM images")); + + // check that the original timestamp is left alone, despite the + // file being replaced (see bug #903) + $this->assertEquals($original_posted, $new_posted); } public function testUpload()