From 8668e7b366324b44384627b5fe85a769114c4952 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 5 Jul 2025 17:45:02 +0200 Subject: [PATCH] removed support for `privatebin_data`, `privatebin_db` & `zerobin_db` model class configurations kudos @Ribas160 for suggesting this --- CHANGELOG.md | 1 + lib/Configuration.php | 30 ++++++------------------------ tst/ConfigurationTest.php | 14 -------------- 3 files changed, 7 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d75a2a71..8e3af201 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * CHANGED: Removed page template (#265) * 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 * FIXED: Name mismatches in attached files (#1584) * FIXED: Unable to paste attachments from clipboard (#1589) diff --git a/lib/Configuration.php b/lib/Configuration.php index 13c37a30..375e7621 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -162,10 +162,8 @@ class Configuration } // provide different defaults for database model elseif ( - $section == 'model_options' && in_array( - $this->_configuration['model']['class'], - array('Database', 'privatebin_db', 'zerobin_db') - ) + $section == 'model_options' && + $this->_configuration['model']['class'] === 'Database' ) { $values = array( 'dsn' => 'sqlite:' . PATH . 'data' . DIRECTORY_SEPARATOR . 'db.sq3', @@ -175,10 +173,8 @@ class Configuration 'opt' => array(), ); } elseif ( - $section == 'model_options' && in_array( - $this->_configuration['model']['class'], - array('GoogleCloudStorage') - ) + $section == 'model_options' && + $this->_configuration['model']['class'] === 'GoogleCloudStorage' ) { $values = array( 'bucket' => getenv('PRIVATEBIN_GCS_BUCKET') ? getenv('PRIVATEBIN_GCS_BUCKET') : null, @@ -186,10 +182,8 @@ class Configuration 'uniformacl' => false, ); } elseif ( - $section == 'model_options' && in_array( - $this->_configuration['model']['class'], - array('S3Storage') - ) + $section == 'model_options' && + $this->_configuration['model']['class'] === 'S3Storage' ) { $values = array( 'region' => null, @@ -250,18 +244,6 @@ class Configuration } } - // support for old config file format, before the fork was renamed and PSR-4 introduced - $this->_configuration['model']['class'] = str_replace( - 'zerobin_', 'privatebin_', - $this->_configuration['model']['class'] - ); - - $this->_configuration['model']['class'] = str_replace( - array('privatebin_data', 'privatebin_db'), - array('Filesystem', 'Database'), - $this->_configuration['model']['class'] - ); - // ensure a valid expire default key is set if (!array_key_exists($this->_configuration['expire']['default'], $this->_configuration['expire_options'])) { $this->_configuration['expire']['default'] = key($this->_configuration['expire_options']); diff --git a/tst/ConfigurationTest.php b/tst/ConfigurationTest.php index d3e87387..5a7a11f2 100644 --- a/tst/ConfigurationTest.php +++ b/tst/ConfigurationTest.php @@ -132,20 +132,6 @@ class ConfigurationTest extends TestCase $this->assertEquals($options, $conf->get(), 'not overriding "missing" subkeys'); } - public function testHandlePreRenameConfig() - { - $options = $this->_options; - $options['model']['class'] = 'zerobin_data'; - Helper::createIniFile(CONF, $options); - $conf = new Configuration; - $this->assertEquals('Filesystem', $conf->getKey('class', 'model'), 'old data class gets renamed'); - - $options['model']['class'] = 'zerobin_db'; - Helper::createIniFile(CONF, $options); - $conf = new Configuration; - $this->assertEquals('Database', $conf->getKey('class', 'model'), 'old db class gets renamed'); - } - public function testConfigPath() { // setup