]> git.mxchange.org Git - friendica.git/commitdiff
Adjust update parameters:
authorPhilipp Holzer <admin@philipp.info>
Sun, 24 Feb 2019 11:24:09 +0000 (12:24 +0100)
committerPhilipp Holzer <admin@philipp.info>
Sun, 24 Feb 2019 11:24:09 +0000 (12:24 +0100)
-f|--force         Force the update command (Even if the database structure matches)
-o|--override      Override running or stalling updates

src/Core/Console/DatabaseStructure.php
src/Core/Console/PostUpdate.php
src/Core/Lock.php
src/Core/Lock/CacheLockDriver.php
src/Core/Lock/DatabaseLockDriver.php
src/Core/Lock/ILockDriver.php
src/Core/Lock/SemaphoreLockDriver.php
src/Core/Update.php

index 1ec108d2e61cfd2f0d5d2fc07502b733ba3843b3..dededa9b3a4321e09fcd3ea31ea6d07c6f026b07 100644 (file)
@@ -31,9 +31,10 @@ Commands
        toinnodb Convert all tables from MyISAM to InnoDB
 
 Options
-    -h|--help|-? Show help information
-    -v           Show more debug information.
-    -f|--force   Force the command in case of "update" (Ignore failed updates/running updates)
+    -h|--help|-?       Show help information
+    -v                 Show more debug information.
+    -f|--force         Force the update command (Even if the database structure matches)
+    -o|--override      Override running or stalling updates
 HELP;
                return $help;
        }
@@ -68,8 +69,9 @@ HELP;
                                $output = DBStructure::update($a->getBasePath(), true, false);
                                break;
                        case "update":
-                               $force = $this->getOption(['f', 'force'], false);
-                               $output = Update::run($a->getBasePath(), $force, true, false);
+                               $force    = $this->getOption(['f', 'force'], false);
+                               $override = $this->getOption(['o', 'override'], false);
+                               $output = Update::run($a->getBasePath(), $force, $override,true, false);
                                break;
                        case "dumpsql":
                                ob_start();
@@ -89,5 +91,4 @@ HELP;
 
                return 0;
        }
-
 }
index 103d0fef7e68062928cdfd79100234a8dfd0187d..a34fc0bcf75ce6a73227ea3fe0006c744399eb74 100644 (file)
@@ -56,7 +56,7 @@ HELP;
                }
 
                echo L10n::t('Check for pending update actions.') . "\n";
-               Update::run($a->getBasePath(), true, true, false);
+               Update::run($a->getBasePath(), true, false,true, false);
                echo L10n::t('Done.') . "\n";
 
                echo L10n::t('Execute pending post updates.') . "\n";
index adff049dce304c4908fe3b323280d1d1d2074d90..8bc2c242d18a588d984bb10be0c8daebd4e8e69e 100644 (file)
@@ -122,13 +122,13 @@ class Lock
        /**
         * @brief Releases a lock if it was set by us
         *
-        * @param string $key   Name of the lock
-        * @param bool   $force Force the lock to get releases
+        * @param string $key      Name of the lock
+        * @param bool   $override Overrides the lock to get releases
         * @return void
         */
-       public static function release($key, $force = false)
+       public static function release($key, $override = false)
        {
-               self::getDriver()->releaseLock($key, $force);
+               self::getDriver()->releaseLock($key, $override);
        }
 
        /**
index a5c34bbdde5f6683d7debdfdd115a09407273498..c1cd8ffb43a3ab407324c757e2cbd0190737ed75 100644 (file)
@@ -61,11 +61,11 @@ class CacheLockDriver extends AbstractLockDriver
        /**
         * (@inheritdoc)
         */
-       public function releaseLock($key, $force = false)
+       public function releaseLock($key, $override = false)
        {
                $cachekey = self::getLockKey($key);
 
-               if ($force) {
+               if ($override) {
                        $this->cache->delete($cachekey);
                } else {
                        $this->cache->compareDelete($cachekey, getmypid());
index 73b97dc4b76b43cc8ccdd29d687478f7f85ba74c..a137ef12edcac6e6766af4f704128e3ce97085d3 100644 (file)
@@ -68,9 +68,9 @@ class DatabaseLockDriver extends AbstractLockDriver
        /**
         * (@inheritdoc)
         */
-       public function releaseLock($key, $force = false)
+       public function releaseLock($key, $override = false)
        {
-               if ($force) {
+               if ($override) {
                        $where = ['name' => $key];
                } else {
                        $where = ['name' => $key, 'pid' => $this->pid];
index 2ee145980c5bae0bf5572f548d958f8fe3cca621..7cbaa4fc6908a701721c1886705a3a85c2ff3fae 100644 (file)
@@ -33,12 +33,12 @@ interface ILockDriver
        /**
         * Releases a lock if it was set by us
         *
-        * @param string $key   The Name of the lock
-        * @param bool   $force Force the lock to get released
+        * @param string $key      The Name of the lock
+        * @param bool   $override Overrides the lock to get released
         *
         * @return void
         */
-       public function releaseLock($key, $force = false);
+       public function releaseLock($key, $override = false);
 
        /**
         * Releases all lock that were set by us
index 5ce03b2c39a02a77ef6ed391afe9abe04542dac6..781e110b1708a83633d1497296448ba639632595 100644 (file)
@@ -50,7 +50,7 @@ class SemaphoreLockDriver extends AbstractLockDriver
        /**
         * (@inheritdoc)
         */
-       public function releaseLock($key, $force = false)
+       public function releaseLock($key, $override = false)
        {
                if (empty(self::$semaphore[$key])) {
                        return false;
index 7f825f384c0fdf39c5878b09d073cee5d5fcbf8a..86e481cf1d98e6dd7f460a2df7e7d570ea2f8391 100644 (file)
@@ -48,18 +48,19 @@ class Update
         * Automatic database updates
         *
         * @param string $basePath The base path of this application
-        * @param bool $force      Force the Update-Check even if the lock is set
+        * @param bool $force      Force the Update-Check even if the database version doesn't match
+        * @param bool $override   Overrides any running/stuck updates
         * @param bool $verbose    Run the Update-Check verbose
         * @param bool $sendMail   Sends a Mail to the administrator in case of success/failure
         *
         * @return string Empty string if the update is successful, error messages otherwise
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public static function run($basePath, $force = false, $verbose = false, $sendMail = true)
+       public static function run($basePath, $force = false, $override = false, $verbose = false, $sendMail = true)
        {
                // In force mode, we release the dbupdate lock first
                // Necessary in case of an stuck update
-               if ($force) {
+               if ($override) {
                        Lock::release('dbupdate', true);
                }
 
@@ -70,12 +71,12 @@ class Update
                        Config::set('system', 'build', $build);
                }
 
-               if ($build != DB_UPDATE_VERSION) {
+               if ($build != DB_UPDATE_VERSION || $force) {
                        require_once 'update.php';
 
                        $stored = intval($build);
                        $current = intval(DB_UPDATE_VERSION);
-                       if ($stored < $current) {
+                       if ($stored < $current || $force) {
                                Config::load('database');
 
                                Logger::log('Update from \'' . $stored . '\'  to \'' . $current . '\' - starting', Logger::DEBUG);
@@ -126,8 +127,6 @@ class Update
                                        Lock::release('dbupdate');
                                }
                        }
-               } elseif ($force) {
-                       DBStructure::update($basePath, $verbose, true);
                }
 
                return '';