[upload] keep original post date when replacing image, fixes #903
This commit is contained in:
parent
30bcfed964
commit
502d50c57d
2 changed files with 9 additions and 0 deletions
|
@ -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));
|
||||
|
|
|
@ -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()
|
||||
|
|
Reference in a new issue