diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e3af201..673cd2a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * CHANGED: Removed support for ZeroBin & v1 pastes - since release 1.3 the v2 format is used (#551) * CHANGED: Removed use of base64 & rawinflate libraries (#551) * CHANGED: Removed support for `privatebin_data`, `privatebin_db` & `zerobin_db` model class configurations, must be replaced with `Filesystem` or `Database` in `cfg/conf.php`, if still present +* CHANGED: Removed unused columns in database schema of tables `paste` & `comment` * FIXED: Name mismatches in attached files (#1584) * FIXED: Unable to paste attachments from clipboard (#1589) diff --git a/doc/Installation.md b/doc/Installation.md index 3dd342e0..ec246c09 100644 --- a/doc/Installation.md +++ b/doc/Installation.md @@ -186,7 +186,6 @@ CREATE TABLE prefix_comment ( pasteid CHAR(16), parentid CHAR(16), data BLOB, - nickname BLOB, vizhash BLOB, postdate INT, PRIMARY KEY (dataid) diff --git a/lib/Data/Database.php b/lib/Data/Database.php index 3949b3ba..245cda7e 100644 --- a/lib/Data/Database.php +++ b/lib/Data/Database.php @@ -256,22 +256,18 @@ class Database extends AbstractData return false; } $meta = $comment['meta']; - unset($comment['meta']); - foreach (array('nickname', 'icon') as $key) { - if (!array_key_exists($key, $meta)) { - $meta[$key] = null; - } + if (!array_key_exists('icon', $meta)) { + $meta['icon'] = null; } try { return $this->_exec( 'INSERT INTO "' . $this->_sanitizeIdentifier('comment') . - '" VALUES(?,?,?,?,?,?,?)', + '" VALUES(?,?,?,?,?,?)', array( $commentid, $pasteid, $parentid, $data, - $meta['nickname'], $meta['icon'], $meta['created'], ) @@ -304,10 +300,8 @@ class Database extends AbstractData $comments[$i]['id'] = $row['dataid']; $comments[$i]['parentid'] = $row['parentid']; $comments[$i]['meta'] = array('created' => (int) $row['postdate']); - foreach (array('nickname' => 'nickname', 'vizhash' => 'icon') as $rowKey => $commentKey) { - if (array_key_exists($rowKey, $row) && !empty($row[$rowKey])) { - $comments[$i]['meta'][$commentKey] = $row[$rowKey]; - } + if (array_key_exists('vizhash', $row) && !empty($row['vizhash'])) { + $comments[$i]['meta']['icon'] = $row['vizhash']; } } ksort($comments); @@ -677,7 +671,6 @@ class Database extends AbstractData '"pasteid" CHAR(16), ' . '"parentid" CHAR(16), ' . "\"data\" $dataType, " . - "\"nickname\" $dataType, " . "\"vizhash\" $dataType, " . "\"postdate\" INT$after_key )" ); @@ -872,6 +865,10 @@ class Database extends AbstractData 'ALTER TABLE "' . $this->_sanitizeIdentifier('paste') . '" DROP COLUMN "attachmentname"' ); + $this->_db->exec( + 'ALTER TABLE "' . $this->_sanitizeIdentifier('comment') . + '" DROP COLUMN "nickname"' + ); } } $this->_exec( diff --git a/tst/Data/DatabaseTest.php b/tst/Data/DatabaseTest.php index 303d780b..ac735bdc 100644 --- a/tst/Data/DatabaseTest.php +++ b/tst/Data/DatabaseTest.php @@ -93,7 +93,6 @@ class DatabaseTest extends TestCase public function testDatabaseBasedAttachmentStoreWorks() { - // this assumes a version 1 formatted paste $this->_model->delete(Helper::getPasteId()); $original = $paste = Helper::getPaste(array('expire_date' => 1344803344)); $paste['meta']['burnafterreading'] = $original['meta']['burnafterreading'] = true; diff --git a/tst/ModelTest.php b/tst/ModelTest.php index 00cc378e..09c17802 100644 --- a/tst/ModelTest.php +++ b/tst/ModelTest.php @@ -485,6 +485,6 @@ class ModelTest extends TestCase $vz = new Vizhash16x16(); $pngdata = 'data:image/png;base64,' . base64_encode($vz->generate(TrafficLimiter::getHash())); $comment = current($this->_model->getPaste(Helper::getPasteId())->get()['comments']); - $this->assertEquals($pngdata, $comment['meta']['icon'], 'nickname triggers vizhash to be set'); + $this->assertEquals($pngdata, $comment['meta']['icon'], 'vizhash was generated'); } }