From bde5802a3aff22c3144277defc5f0a3fed35bab0 Mon Sep 17 00:00:00 2001
From: "Felix J. Ogris" <fjo@core7.intra.ogris.net>
Date: Tue, 1 Nov 2022 16:38:06 +0100
Subject: [PATCH] syntax fix, changelog

---
 CHANGELOG.md                    |  1 +
 lib/Data/Database.php           |  2 +-
 lib/Data/Filesystem.php         | 14 +++++++-------
 lib/Data/GoogleCloudStorage.php |  4 ++--
 lib/Data/S3Storage.php          |  8 ++++----
 lib/Model.php                   |  2 +-
 tst/ModelTest.php               |  2 +-
 7 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index b897b676..61d258c1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
 # PrivateBin version history
 
   * **1.4.1 (not yet released)**
+    * ADDED: script for data storage backend migrations (#1012)
     * ADDED: Translations for Turkish, Slovak and Greek
     * ADDED: S3 Storage backend (#994)
     * CHANGED: Avoid `SUPER` privilege for setting the `sql_mode` for MariaDB/MySQL (#919)
diff --git a/lib/Data/Database.php b/lib/Data/Database.php
index 05952a95..f4318589 100644
--- a/lib/Data/Database.php
+++ b/lib/Data/Database.php
@@ -481,7 +481,7 @@ class Database extends AbstractData
             // migrate filesystem based salt into database
             $file = 'data' . DIRECTORY_SEPARATOR . 'salt.php';
             if ($namespace === 'salt' && is_readable($file)) {
-                $fs = new Filesystem(array('dir' => 'data'));
+                $fs    = new Filesystem(array('dir' => 'data'));
                 $value = $fs->getValue('salt');
                 $this->setValue($value, 'salt');
                 @unlink($file);
diff --git a/lib/Data/Filesystem.php b/lib/Data/Filesystem.php
index 3dd69578..2d082144 100644
--- a/lib/Data/Filesystem.php
+++ b/lib/Data/Filesystem.php
@@ -409,29 +409,29 @@ class Filesystem extends AbstractData
      */
     public function getAllPastes()
     {
-        $pastes = array();
+        $pastes  = array();
         $subdirs = scandir($this->_path);
         if ($subdirs === false) {
-            dieerr("Unable to list directory " . $this->_path);
+            dieerr('Unable to list directory ' . $this->_path);
         }
-        $subdirs = preg_grep("/^[^.].$/", $subdirs);
+        $subdirs = preg_grep('/^[^.].$/', $subdirs);
 
         foreach ($subdirs as $subdir) {
             $subpath = $this->_path . DIRECTORY_SEPARATOR . $subdir;
 
             $subsubdirs = scandir($subpath);
             if ($subsubdirs === false) {
-                dieerr("Unable to list directory " . $subpath);
+                dieerr('Unable to list directory ' . $subpath);
             }
-            $subsubdirs = preg_grep("/^[^.].$/", $subsubdirs);
+            $subsubdirs = preg_grep('/^[^.].$/', $subsubdirs);
             foreach ($subsubdirs as $subsubdir) {
                 $subsubpath = $subpath . DIRECTORY_SEPARATOR . $subsubdir;
 
                 $files = scandir($subsubpath);
                 if ($files === false) {
-                    dieerr("Unable to list directory " . $subsubpath);
+                    dieerr('Unable to list directory ' . $subsubpath);
                 }
-                $files = preg_grep("/\.php$/", $files);
+                $files = preg_grep('/\.php$/', $files);
 
                 foreach ($files as $file) {
                     if (substr($file, 0, 4) === $subdir . $subsubdir) {
diff --git a/lib/Data/GoogleCloudStorage.php b/lib/Data/GoogleCloudStorage.php
index e271e2f8..dd2aff39 100644
--- a/lib/Data/GoogleCloudStorage.php
+++ b/lib/Data/GoogleCloudStorage.php
@@ -353,7 +353,7 @@ class GoogleCloudStorage extends AbstractData
     public function getAllPastes()
     {
         $pastes = array();
-        $prefix  = $this->_prefix;
+        $prefix = $this->_prefix;
         if ($prefix != '') {
             $prefix .= '/';
         }
@@ -361,7 +361,7 @@ class GoogleCloudStorage extends AbstractData
         try {
             foreach ($this->_bucket->objects(array('prefix' => $prefix)) as $object) {
                 $candidate = substr($object->name(), strlen($prefix));
-                if (strpos($candidate, "/") === false) {
+                if (strpos($candidate, '/') === false) {
                     $pastes[] = $candidate;
                 }
             }
diff --git a/lib/Data/S3Storage.php b/lib/Data/S3Storage.php
index c59aaaeb..f2746507 100644
--- a/lib/Data/S3Storage.php
+++ b/lib/Data/S3Storage.php
@@ -78,7 +78,7 @@ class S3Storage extends AbstractData
      *
      * @access public
      * @param array $options
-     * @return 
+     * @return
      */
     public function __construct(array $options)
     {
@@ -453,15 +453,15 @@ class S3Storage extends AbstractData
     public function getAllPastes()
     {
         $pastes = array();
-        $prefix  = $this->_prefix;
+        $prefix = $this->_prefix;
         if ($prefix != '') {
             $prefix .= '/';
         }
 
         try {
             foreach ($this->_listAllObjects($prefix) as $object) {
-                $candidate = substr($object["Key"], strlen($prefix));
-                if (strpos($candidate, "/") === false) {
+                $candidate = substr($object['Key'], strlen($prefix));
+                if (strpos($candidate, '/') === false) {
                     $pastes[] = $candidate;
                 }
             }
diff --git a/lib/Model.php b/lib/Model.php
index 94f77007..f7fdc232 100644
--- a/lib/Model.php
+++ b/lib/Model.php
@@ -81,7 +81,7 @@ class Model
     public function getStore()
     {
         if ($this->_store === null) {
-            $class = 'PrivateBin\\Data\\' . $this->_conf->getKey('class', 'model');
+            $class        = 'PrivateBin\\Data\\' . $this->_conf->getKey('class', 'model');
             $this->_store = new $class($this->_conf->getSection('model_options'));
         }
         return $this->_store;
diff --git a/tst/ModelTest.php b/tst/ModelTest.php
index 0d715c2a..cf04b4db 100644
--- a/tst/ModelTest.php
+++ b/tst/ModelTest.php
@@ -156,7 +156,7 @@ class ModelTest extends PHPUnit_Framework_TestCase
 
     public function testCommentDefaults()
     {
-        $class = 'PrivateBin\\Data\\' . $this->_conf->getKey('class', 'model');
+        $class   = 'PrivateBin\\Data\\' . $this->_conf->getKey('class', 'model');
         $comment = new Comment(
             $this->_conf,
             new $class(