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