From 15d42de647803df58767ed014b842299c458f1b7 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 14 Dec 2017 21:13:02 +0000 Subject: [PATCH] Class moved, changes applied --- boot.php | 16 ++++++++++++---- include/dba.php | 7 ++++--- mod/admin.php | 11 +++++------ mod/install.php | 5 ++--- scripts/dbstructure.php | 11 +++++------ .../Database/DBStructure.php | 6 ------ update.php | 6 +++--- 7 files changed, 31 insertions(+), 31 deletions(-) rename include/dbstructure.php => src/Database/DBStructure.php (99%) diff --git a/boot.php b/boot.php index d9a64e570..bfdf7db84 100644 --- a/boot.php +++ b/boot.php @@ -28,6 +28,7 @@ use Friendica\Core\PConfig; use Friendica\Core\Worker; use Friendica\Database\DBM; use Friendica\Model\Contact; +use Friendica\Database\DBStructure; require_once 'include/network.php'; require_once 'include/plugin.php'; @@ -37,13 +38,20 @@ require_once 'include/pgettext.php'; require_once 'include/nav.php'; require_once 'include/identity.php'; require_once 'update.php'; -require_once 'include/dbstructure.php'; define('FRIENDICA_PLATFORM', 'Friendica'); define('FRIENDICA_CODENAME', 'Asparagus'); define('FRIENDICA_VERSION', '3.6-dev'); define('DFRN_PROTOCOL_VERSION', '2.23'); define('DB_UPDATE_VERSION', 1236); +define('NEW_UPDATE_ROUTINE_VERSION', 1170); + +/** + * @brief Constants for the database update check + */ +const DB_UPDATE_NOT_CHECKED = 0; // Database check wasn't executed before +const DB_UPDATE_SUCCESSFUL = 1; // Database check was successful +const DB_UPDATE_FAILED = 2; // Database check failed /** * @brief Constant with a HTML line break. @@ -694,9 +702,9 @@ function update_db(App $a) // run new update routine // it update the structure in one call - $retval = update_structure(false, true); + $retval = DBStructure::updateStructure(false, true); if ($retval) { - update_fail( + DBStructure::updateFail( DB_UPDATE_VERSION, $retval ); @@ -742,7 +750,7 @@ function run_update_function($x) if ($retval) { //send the administrator an e-mail - update_fail( + DBStructure::updateFail( $x, sprintf(t('Update %s failed. See error logs.'), $x) ); diff --git a/include/dba.php b/include/dba.php index e08880c60..dd4272c99 100644 --- a/include/dba.php +++ b/include/dba.php @@ -1,6 +1,7 @@ $structure) { foreach ($structure['fields'] AS $field => $field_struct) { diff --git a/mod/admin.php b/mod/admin.php index af6150460..7af3f246d 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -10,6 +10,7 @@ use Friendica\Core\System; use Friendica\Core\Config; use Friendica\Core\Worker; use Friendica\Database\DBM; +use Friendica\Database\DBStructure; use Friendica\Model\Contact; use Friendica\Model\User; @@ -708,7 +709,7 @@ function admin_page_summary(App $a) $warningtext = array(); if (DBM::is_result($r)) { $showwarning = true; - $warningtext[] = sprintf(t('Your DB still runs with MyISAM tables. You should change the engine type to InnoDB. As Friendica will use InnoDB only features in the future, you should change this! See here for a guide that may be helpful converting the table engines. You may also use the command php include/dbstructure.php toinnodb of your Friendica installation for an automatic conversion.
'), 'https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html'); + $warningtext[] = sprintf(t('Your DB still runs with MyISAM tables. You should change the engine type to InnoDB. As Friendica will use InnoDB only features in the future, you should change this! See here for a guide that may be helpful converting the table engines. You may also use the command php scripts/dbstructure.php toinnodb of your Friendica installation for an automatic conversion.
'), 'https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html'); } // Check if github.com/friendica/master/VERSION is higher then // the local version of Friendica. Check is opt-in, source may be master or devel branch @@ -721,12 +722,11 @@ function admin_page_summary(App $a) } if (Config::get('system', 'dbupdate', DB_UPDATE_NOT_CHECKED) == DB_UPDATE_NOT_CHECKED) { - require_once("include/dbstructure.php"); - update_structure(false, true); + DBStructure::updateStructure(false, true); } if (Config::get('system', 'dbupdate') == DB_UPDATE_FAILED) { $showwarning = true; - $warningtext[] = t('The database update failed. Please run "php include/dbstructure.php update" from the command line and have a look at the errors that might appear.'); + $warningtext[] = t('The database update failed. Please run "php scripts/dbstructure.php update" from the command line and have a look at the errors that might appear.'); } $last_worker_call = Config::get('system', 'last_poller_execution', false); @@ -1385,8 +1385,7 @@ function admin_page_dbsync(App $a) } if (($a->argc > 2) && (intval($a->argv[2]) || ($a->argv[2] === 'check'))) { - require_once("include/dbstructure.php"); - $retval = update_structure(false, true); + $retval = DBStructure::updateStructure(false, true); if (!$retval) { $o .= sprintf(t("Database structure update %s was successfully applied."), DB_UPDATE_VERSION) . "
"; Config::set('database', 'dbupdate_' . DB_UPDATE_VERSION, 'success'); diff --git a/mod/install.php b/mod/install.php index 8df5d0935..f2edf6498 100644 --- a/mod/install.php +++ b/mod/install.php @@ -5,6 +5,7 @@ use Friendica\App; use Friendica\Core\System; use Friendica\Database\DBM; +use Friendica\Database\DBStructure; use Friendica\Object\Image; $install_wizard_pass = 1; @@ -535,9 +536,7 @@ function load_database_rem($v, $i) { } function load_database() { - - require_once("include/dbstructure.php"); - $errors = update_structure(false, true); + $errors = DBStructure::updateStructure(false, true); return $errors; } diff --git a/scripts/dbstructure.php b/scripts/dbstructure.php index 9444d010f..19e2830b0 100755 --- a/scripts/dbstructure.php +++ b/scripts/dbstructure.php @@ -5,10 +5,9 @@ * @brief Does database updates from the command line */ -require_once 'include/dbstructure.php'; - use Friendica\App; use Friendica\Core\Config; +use Friendica\Database\DBStructure; $a = new App(dirname(__DIR__)); @@ -20,10 +19,10 @@ unset($db_host, $db_user, $db_pass, $db_data); if ($_SERVER["argc"] == 2) { switch ($_SERVER["argv"][1]) { case "dryrun": - update_structure(true, false); + DBStructure::updateStructure(true, false); return; case "update": - update_structure(true, true); + DBStructure::updateStructure(true, true); $build = Config::get('system','build'); if (!x($build)) { @@ -45,10 +44,10 @@ if ($_SERVER["argc"] == 2) { Config::set('system','build',DB_UPDATE_VERSION); return; case "dumpsql": - print_structure(db_definition()); + DBStructure::printStructure(db_definition()); return; case "toinnodb": - convert_to_innodb(); + DBStructure::convertToInnoDB(); return; } } diff --git a/include/dbstructure.php b/src/Database/DBStructure.php similarity index 99% rename from include/dbstructure.php rename to src/Database/DBStructure.php index 5e60d38b5..5c41adfea 100644 --- a/include/dbstructure.php +++ b/src/Database/DBStructure.php @@ -10,12 +10,6 @@ use Friendica\Database\DBM; require_once "boot.php"; require_once "include/text.php"; -define('NEW_UPDATE_ROUTINE_VERSION', 1170); - -const DB_UPDATE_NOT_CHECKED = 0; // Database check wasn't executed before -const DB_UPDATE_SUCCESSFUL = 1; // Database check was successful -const DB_UPDATE_FAILED = 2; // Database check failed - /* * Converts all tables from MyISAM to InnoDB */ diff --git a/update.php b/update.php index 751e15b58..6bb99af57 100644 --- a/update.php +++ b/update.php @@ -33,14 +33,14 @@ use Friendica\Object\Image; * The DB_UPDATE_VERSION will always be one greater than the last numbered script in this file. * * If you change the database schema, the following are required: - * 1. Update the file include/dbstructure.php to match the new schema. + * 1. Update the file src/Database/DBStructure.php to match the new schema. * 2. If there is a need for a post procession, update this file by adding a new function at the end with the number of the current DB_UPDATE_VERSION. * This function should perform some post procession steps but no database updates. * 3. Increment the DB_UPDATE_VERSION in boot.php *AND* the UPDATE_VERSION in this file to match it * 4. TEST the upgrade prior to checkin and filing a pull request. * * IMPORTANT! - * NEVER do a database change anymore in the update functions! Only do this in the file include/dbstructure.php! + * NEVER do a database change anymore in the update functions! Only do this in the file src/Database/DBStructure.php! */ @@ -1609,7 +1609,7 @@ ATTENTION! All following update functions are ONLY for jobs that need to run AFTER the database changes are applied. -Database changes are ONLY applied in the file include/dbstructure.php. +Database changes are ONLY applied in the file src/Database/DBStructure.php. */ function update_1177() {