From 19ffc0510b71096442de0456c805543378dd42d6 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 21 Oct 2018 01:58:10 -0400 Subject: [PATCH] Move DB_UPDATE_VERSION from boot.php to config/dbstructure.php --- boot.php | 1 - config/dbstructure.php | 5 +++++ src/App.php | 6 +++++- src/Database/DBStructure.php | 3 ++- update.php | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/boot.php b/boot.php index a1154cf75..7fb87ca4e 100644 --- a/boot.php +++ b/boot.php @@ -41,7 +41,6 @@ define('FRIENDICA_PLATFORM', 'Friendica'); define('FRIENDICA_CODENAME', 'The Tazmans Flax-lily'); define('FRIENDICA_VERSION', '2018.12-dev'); define('DFRN_PROTOCOL_VERSION', '2.23'); -define('DB_UPDATE_VERSION', 1289); define('NEW_UPDATE_ROUTINE_VERSION', 1170); /** diff --git a/config/dbstructure.php b/config/dbstructure.php index 7a96c0077..96f90fb82 100644 --- a/config/dbstructure.php +++ b/config/dbstructure.php @@ -27,11 +27,16 @@ * ], * ], * + * If you need to make any change, make sure to increment the DB_UPDATE_VERSION constant value below. * */ use Friendica\Database\DBA; +if (!defined('DB_UPDATE_VERSION')) { + define('DB_UPDATE_VERSION', 1289); +} + return [ "addon" => [ "comment" => "registered addons", diff --git a/src/App.php b/src/App.php index d8d6439d7..6ec61db72 100644 --- a/src/App.php +++ b/src/App.php @@ -573,7 +573,11 @@ class App $stamp1 = microtime(true); - DBA::connect($db_host, $db_user, $db_pass, $db_data, $charset); + if (DBA::connect($db_host, $db_user, $db_pass, $db_data, $charset)) { + // Loads DB_UPDATE_VERSION constant + Database\DBStructure::definition(); + } + unset($db_host, $db_user, $db_pass, $db_data, $charset); $this->saveTimestamp($stamp1, 'network'); diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 4e4c69b1d..f9335da8e 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -5,8 +5,8 @@ namespace Friendica\Database; use Exception; -use Friendica\Core\Hook; use Friendica\Core\Config; +use Friendica\Core\Hook; use Friendica\Core\L10n; use Friendica\Util\DateTimeFormat; @@ -830,6 +830,7 @@ class DBStructure /** * Loads the database structure definition from the config/dbstructure.php file. + * On first pass, defines DB_UPDATE_VERSION constant. * * @see config/dbstructure.php * @return array diff --git a/update.php b/update.php index 0b5dfeef4..6a0ed1af2 100644 --- a/update.php +++ b/update.php @@ -32,7 +32,7 @@ require_once 'include/dba.php'; * * 1. Create a function "update_4712()" here in the update.php * 2. Apply the needed structural changes in config/dbStructure.php - * 3. Set DB_UPDATE_VERSION in boot.php to 4712. + * 3. Set DB_UPDATE_VERSION in config/dbstructure.php to 4712. * * If you need to run a script before the database update, name the function "pre_update_4712()" */