]> git.mxchange.org Git - friendica.git/commitdiff
making update really work ...
authornupplaPhil <admin@philipp.info>
Mon, 6 Jan 2020 20:14:01 +0000 (21:14 +0100)
committernupplaPhil <admin@philipp.info>
Fri, 10 Jan 2020 12:21:59 +0000 (13:21 +0100)
database.sql
static/dbstructure.config.php
update.php

index 6252f8057944ec49a396896f731776dd12a55754..8db6c1d6f02725d461550d0a12a960e80452e884 100644 (file)
@@ -1,6 +1,6 @@
 -- ------------------------------------------
 -- Friendica 2020.03-dev (Dalmatian Bellflower)
--- DB_UPDATE_VERSION 1329
+-- DB_UPDATE_VERSION 1330
 -- ------------------------------------------
 
 
index 20bd93769031d44f795e77f97378e170311f500d..49934c63cf2324ea86d6e5d40b175e4f45e59cba 100755 (executable)
@@ -34,7 +34,7 @@
 use Friendica\Database\DBA;
 
 if (!defined('DB_UPDATE_VERSION')) {
-       define('DB_UPDATE_VERSION', 1329);
+       define('DB_UPDATE_VERSION', 1330);
 }
 
 return [
index 145446bae0c6e79acee436efe340234998c0491b..180cd96ecbd747285f2fe18e65bd63f133e0cdc9 100644 (file)
@@ -12,6 +12,7 @@ use Friendica\Model\Contact;
 use Friendica\Model\GContact;
 use Friendica\Model\Item;
 use Friendica\Model\User;
+use Friendica\Model\Storage;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Worker\Delivery;
 
@@ -408,24 +409,30 @@ function update_1327()
        return Update::SUCCESS;
 }
 
-function update_1329()
+function update_1330()
 {
        $currStorage = Config::get('storage', 'class', '');
 
        if (!empty($currStorage)) {
                $storageName = array_key_first(\Friendica\Core\StorageManager::DEFAULT_BACKENDS, $currStorage);
-               Config::set('storage', 'name', $storageName);
-               Config::delete('storage', 'class');
+               if (!Config::set('storage', 'name', $storageName) ||
+                   !Config::delete('storage', 'class')) {
+                       return Update::FAILED;
+               };
        }
 
-       $photos = DBA::select('photos', ['backend-class', 'id'], ['backend-class IS NOT NULL']);
-       foreach ($photos as $photo) {
-               DBA::update('photos', ['backend-class' => $photo['backend-class']::NAME], ['id' => $photo['id']]);
-       }
-
-       $attachs = DBA::select('attach', ['backend-class', 'id'], ['backend-class IS NOT NULL']);
-       foreach ($attachs as $attach) {
-               DBA::update('photos', ['backend-class' => $attach['backend-class']::NAME], ['id' => $attach['id']]);
+       // Update photos
+       if (!DBA::update('photo', ['backend-class' => Storage\Filesystem::NAME],     ['backend-class' => 'Friendica\Model\Storage\Filesystem']) ||
+           !DBA::update('photo', ['backend-class' => Storage\Database::NAME],       ['backend-class' => 'Friendica\Model\Storage\Database']) ||
+           !DBA::update('photo', ['backend-class' => Storage\SystemResource::NAME], ['backend-class' => 'Friendica\Model\Storage\SystemResource'])) {
+               return Update::FAILED;
+       };
+
+       // update attachments
+       if (!DBA::update('attach', ['backend-class' => Storage\Filesystem::NAME],     ['backend-class' => 'Friendica\Model\Storage\Filesystem']) ||
+           !DBA::update('attach', ['backend-class' => Storage\Database::NAME],       ['backend-class' => 'Friendica\Model\Storage\Database']) ||
+           !DBA::update('attach', ['backend-class' => Storage\SystemResource::NAME], ['backend-class' => 'Friendica\Model\Storage\SystemResource'])) {
+               return Update::FAILED;
        }
 
        return Update::SUCCESS;