remove more v1 legacy

- document removed unused columns in database schema of tables `paste` & `comment`
- amended misleading comments
- nickname is part of the encrypted payload in v2 comments and therefore there is nothing to store separately
This commit is contained in:
El RIDO
2025-07-05 18:19:38 +02:00
parent e2859e9a35
commit b79ae4e929
5 changed files with 11 additions and 15 deletions

View File

@@ -6,6 +6,7 @@
* CHANGED: Removed support for ZeroBin & v1 pastes - since release 1.3 the v2 format is used (#551) * 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 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 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: Name mismatches in attached files (#1584)
* FIXED: Unable to paste attachments from clipboard (#1589) * FIXED: Unable to paste attachments from clipboard (#1589)

View File

@@ -186,7 +186,6 @@ CREATE TABLE prefix_comment (
pasteid CHAR(16), pasteid CHAR(16),
parentid CHAR(16), parentid CHAR(16),
data BLOB, data BLOB,
nickname BLOB,
vizhash BLOB, vizhash BLOB,
postdate INT, postdate INT,
PRIMARY KEY (dataid) PRIMARY KEY (dataid)

View File

@@ -256,22 +256,18 @@ class Database extends AbstractData
return false; return false;
} }
$meta = $comment['meta']; $meta = $comment['meta'];
unset($comment['meta']); if (!array_key_exists('icon', $meta)) {
foreach (array('nickname', 'icon') as $key) { $meta['icon'] = null;
if (!array_key_exists($key, $meta)) {
$meta[$key] = null;
}
} }
try { try {
return $this->_exec( return $this->_exec(
'INSERT INTO "' . $this->_sanitizeIdentifier('comment') . 'INSERT INTO "' . $this->_sanitizeIdentifier('comment') .
'" VALUES(?,?,?,?,?,?,?)', '" VALUES(?,?,?,?,?,?)',
array( array(
$commentid, $commentid,
$pasteid, $pasteid,
$parentid, $parentid,
$data, $data,
$meta['nickname'],
$meta['icon'], $meta['icon'],
$meta['created'], $meta['created'],
) )
@@ -304,10 +300,8 @@ class Database extends AbstractData
$comments[$i]['id'] = $row['dataid']; $comments[$i]['id'] = $row['dataid'];
$comments[$i]['parentid'] = $row['parentid']; $comments[$i]['parentid'] = $row['parentid'];
$comments[$i]['meta'] = array('created' => (int) $row['postdate']); $comments[$i]['meta'] = array('created' => (int) $row['postdate']);
foreach (array('nickname' => 'nickname', 'vizhash' => 'icon') as $rowKey => $commentKey) { if (array_key_exists('vizhash', $row) && !empty($row['vizhash'])) {
if (array_key_exists($rowKey, $row) && !empty($row[$rowKey])) { $comments[$i]['meta']['icon'] = $row['vizhash'];
$comments[$i]['meta'][$commentKey] = $row[$rowKey];
}
} }
} }
ksort($comments); ksort($comments);
@@ -677,7 +671,6 @@ class Database extends AbstractData
'"pasteid" CHAR(16), ' . '"pasteid" CHAR(16), ' .
'"parentid" CHAR(16), ' . '"parentid" CHAR(16), ' .
"\"data\" $dataType, " . "\"data\" $dataType, " .
"\"nickname\" $dataType, " .
"\"vizhash\" $dataType, " . "\"vizhash\" $dataType, " .
"\"postdate\" INT$after_key )" "\"postdate\" INT$after_key )"
); );
@@ -872,6 +865,10 @@ class Database extends AbstractData
'ALTER TABLE "' . $this->_sanitizeIdentifier('paste') . 'ALTER TABLE "' . $this->_sanitizeIdentifier('paste') .
'" DROP COLUMN "attachmentname"' '" DROP COLUMN "attachmentname"'
); );
$this->_db->exec(
'ALTER TABLE "' . $this->_sanitizeIdentifier('comment') .
'" DROP COLUMN "nickname"'
);
} }
} }
$this->_exec( $this->_exec(

View File

@@ -93,7 +93,6 @@ class DatabaseTest extends TestCase
public function testDatabaseBasedAttachmentStoreWorks() public function testDatabaseBasedAttachmentStoreWorks()
{ {
// this assumes a version 1 formatted paste
$this->_model->delete(Helper::getPasteId()); $this->_model->delete(Helper::getPasteId());
$original = $paste = Helper::getPaste(array('expire_date' => 1344803344)); $original = $paste = Helper::getPaste(array('expire_date' => 1344803344));
$paste['meta']['burnafterreading'] = $original['meta']['burnafterreading'] = true; $paste['meta']['burnafterreading'] = $original['meta']['burnafterreading'] = true;

View File

@@ -485,6 +485,6 @@ class ModelTest extends TestCase
$vz = new Vizhash16x16(); $vz = new Vizhash16x16();
$pngdata = 'data:image/png;base64,' . base64_encode($vz->generate(TrafficLimiter::getHash())); $pngdata = 'data:image/png;base64,' . base64_encode($vz->generate(TrafficLimiter::getHash()));
$comment = current($this->_model->getPaste(Helper::getPasteId())->get()['comments']); $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');
} }
} }