X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=boot.php;h=7654d261c3c5b0576511a5a26209c69237ee7b92;hb=ea24ac9d950125d83e3b6a8f2abcaa24a0f316f9;hp=bececa9470f19a2a6601c91339b8629d70d7b0c9;hpb=2503660f97c3f9588f1965c23b98d0c78109ee0b;p=friendica.git diff --git a/boot.php b/boot.php index bececa9470..7654d261c3 100644 --- a/boot.php +++ b/boot.php @@ -41,7 +41,7 @@ define('FRIENDICA_PLATFORM', 'Friendica'); define('FRIENDICA_CODENAME', 'The Tazmans Flax-lily'); define('FRIENDICA_VERSION', '2018.08-dev'); define('DFRN_PROTOCOL_VERSION', '2.23'); -define('DB_UPDATE_VERSION', 1277); +define('DB_UPDATE_VERSION', 1279); define('NEW_UPDATE_ROUTINE_VERSION', 1170); /** @@ -113,11 +113,12 @@ define('SSL_POLICY_SELFSIGN', 2); * log levels * @{ */ -define('LOGGER_NORMAL', 0); -define('LOGGER_TRACE', 1); -define('LOGGER_DEBUG', 2); -define('LOGGER_DATA', 3); -define('LOGGER_ALL', 4); +define('LOGGER_WARNING', 0); +define('LOGGER_INFO', 1); +define('LOGGER_TRACE', 2); +define('LOGGER_DEBUG', 3); +define('LOGGER_DATA', 4); +define('LOGGER_ALL', 5); /* @}*/ /** @@ -508,14 +509,7 @@ if (!defined('CURLE_OPERATION_TIMEDOUT')) { */ function get_app() { - global $a; - - if (empty($a)) { - $a = new App(dirname(__DIR__)); - BaseObject::setApp($a); - } - - return $a; + return BaseObject::getApp(); } /** @@ -710,10 +704,17 @@ function update_db() return; } + // run the pre_update_nnnn functions in update.php + for ($x = $stored + 1; $x <= $current; $x++) { + $r = run_update_function($x, 'pre_update'); + if (!$r) { + break; + } + } + Config::set('database', 'dbupdate_' . DB_UPDATE_VERSION, time()); - // run update routine - // it update the structure in one call + // update the structure in one call $retval = DBStructure::update(false, true); if ($retval) { DBStructure::updateFail( @@ -725,9 +726,9 @@ function update_db() Config::set('database', 'dbupdate_' . DB_UPDATE_VERSION, 'success'); } - // run any left update_nnnn functions in update.php + // run the update_nnnn functions in update.php for ($x = $stored + 1; $x <= $current; $x++) { - $r = run_update_function($x); + $r = run_update_function($x, 'update'); if (!$r) { break; } @@ -738,9 +739,11 @@ function update_db() return; } -function run_update_function($x) +function run_update_function($x, $prefix) { - if (function_exists('update_' . $x)) { + $funcname = $prefix . '_' . $x; + + if (function_exists($funcname)) { // There could be a lot of processes running or about to run. // We want exactly one process to run the update command. // So store the fact that we're taking responsibility @@ -748,16 +751,14 @@ function run_update_function($x) // If the update fails or times-out completely you may need to // delete the config entry to try again. - $t = Config::get('database', 'update_' . $x); + $t = Config::get('database', $funcname); if (!is_null($t)) { return false; } - Config::set('database', 'update_' . $x, time()); + Config::set('database', $funcname, time()); // call the specific update - - $func = 'update_' . $x; - $retval = $func(); + $retval = $funcname(); if ($retval) { //send the administrator an e-mail @@ -767,13 +768,21 @@ function run_update_function($x) ); return false; } else { - Config::set('database', 'update_' . $x, 'success'); - Config::set('system', 'build', $x); + Config::set('database', $funcname, 'success'); + + if ($prefix == 'update') { + Config::set('system', 'build', $x); + } + return true; } } else { - Config::set('database', 'update_' . $x, 'success'); - Config::set('system', 'build', $x); + Config::set('database', $funcname, 'success'); + + if ($prefix == 'update') { + Config::set('system', 'build', $x); + } + return true; } } @@ -781,7 +790,7 @@ function run_update_function($x) /** * @brief Synchronise addons: * - * $a->config['system']['addon'] contains a comma-separated list of names + * system.addon contains a comma-separated list of names * of addons which are used on this system. * Go through the database list of already installed addons, and if we have * an entry, but it isn't in the config list, call the uninstall procedure @@ -964,17 +973,6 @@ function info($s) } } -/** - * @brief Wrapper around config to limit the text length of an incoming message - * - * @return int - */ -function get_max_import_size() -{ - $a = get_app(); - return (x($a->config, 'max_import_size') ? $a->config['max_import_size'] : 0); -} - function feed_birthday($uid, $tz) { /** @@ -1030,14 +1028,11 @@ function is_site_admin() { $a = get_app(); - $adminlist = explode(",", str_replace(" ", "", $a->config['admin_email'])); + $admin_email = Config::get('config', 'admin_email'); - //if(local_user() && x($a->user,'email') && x($a->config,'admin_email') && ($a->user['email'] === $a->config['admin_email'])) - /// @TODO This if() + 2 returns can be shrinked into one return - if (local_user() && x($a->user, 'email') && x($a->config, 'admin_email') && in_array($a->user['email'], $adminlist)) { - return true; - } - return false; + $adminlist = explode(',', str_replace(' ', '', $admin_email)); + + return local_user() && $admin_email && in_array(defaults($a->user, 'email', ''), $adminlist); } /**