Merge pull request #6740 from nupplaphil/issue/6503-force_update

Fixing force-flag for lock-release
This commit is contained in:
Hypolite Petovan 2019-02-24 07:04:54 -05:00 committed by GitHub
commit 4e3f780621
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 37 additions and 25 deletions

View file

@ -52,19 +52,20 @@ 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) {
Lock::release('dbupdate');
if ($override) {
Lock::release('dbupdate', true);
}
$build = Config::get('system', 'build');
@ -74,12 +75,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);
@ -130,8 +131,6 @@ class Update
Lock::release('dbupdate');
}
}
} elseif ($force) {
DBStructure::update($basePath, $verbose, true);
}
return '';