From b2db26998dbb66233962ed169531a6b2cc77c33c Mon Sep 17 00:00:00 2001 From: El RIDO Date: Wed, 1 May 2024 20:32:39 +0200 Subject: [PATCH] remove the old keys, if they are still stored --- lib/Model/Paste.php | 6 ++++++ tst/ControllerTest.php | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/Model/Paste.php b/lib/Model/Paste.php index c64f5c4f..14b8e8ac 100644 --- a/lib/Model/Paste.php +++ b/lib/Model/Paste.php @@ -47,6 +47,12 @@ class Paste extends AbstractModel $data['meta']['time_to_live'] = $data['meta']['expire_date'] - time(); unset($data['meta']['expire_date']); } + if (array_key_exists('created', $data['meta'])) { + unset($data['meta']['created']); + } + if (array_key_exists('postdate', $data['meta'])) { + unset($data['meta']['postdate']); + } // check if non-expired burn after reading paste needs to be deleted if ( diff --git a/tst/ControllerTest.php b/tst/ControllerTest.php index f0b87299..17fb9d0e 100644 --- a/tst/ControllerTest.php +++ b/tst/ControllerTest.php @@ -742,7 +742,7 @@ class ControllerTest extends TestCase $this->assertEquals($paste['adata'][1], $response['adata'][1], 'outputs formatter correctly'); $this->assertEquals($paste['adata'][2], $response['adata'][2], 'outputs opendiscussion correctly'); $this->assertEquals($paste['adata'][3], $response['adata'][3], 'outputs burnafterreading correctly'); - $this->assertFalse(array_key_exists('created', $paste['meta']), 'does not output created'); + $this->assertFalse(array_key_exists('created', $response['meta']), 'does not output created'); $this->assertEquals(0, $response['comment_count'], 'outputs comment_count correctly'); $this->assertEquals(0, $response['comment_offset'], 'outputs comment_offset correctly'); } @@ -772,7 +772,7 @@ class ControllerTest extends TestCase $this->assertStringEndsWith('?' . $response['id'], $response['url'], 'returned URL points to new paste'); $this->assertEquals($paste['data'], $response['data'], 'outputs data correctly'); $this->assertEquals('syntaxhighlighting', $response['meta']['formatter'], 'outputs format correctly'); - $this->assertEquals($paste['meta']['postdate'], $response['meta']['postdate'], 'outputs postdate correctly'); + $this->assertFalse(array_key_exists('postdate', $response['meta']), 'does not output postdate'); $this->assertEquals($paste['meta']['opendiscussion'], $response['meta']['opendiscussion'], 'outputs opendiscussion correctly'); $this->assertEquals(0, $response['comment_count'], 'outputs comment_count correctly'); $this->assertEquals(0, $response['comment_offset'], 'outputs comment_offset correctly');