X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FDatabase%2FDBStructure.php;h=92666edb89b78c42cfa3bb80bf48e701cb99ef91;hb=5a3991d4f7bc929c1087d9275716fc1c8cc299a6;hp=b24c51333633869a95690c2186eb9be11412ea52;hpb=87f3fe24f7008dd1460cec1abd3ea7f3ae16679f;p=friendica.git diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index b24c513336..92666edb89 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -28,7 +28,7 @@ class DBStructure const UPDATE_FAILED = 2; // Database check failed /** - * Database structure definition loaded from config/dbstructure.php + * Database structure definition loaded from config/dbstructure.config.php * * @var array */ @@ -57,58 +57,6 @@ class DBStructure } } - /* - * send the email and do what is needed to do on update fails - * - * @param update_id (int) number of failed update - * @param error_message (str) error message - */ - public static function updateFail($update_id, $error_message) { - $a = get_app(); - - //send the administrators an e-mail - $admin_mail_list = "'".implode("','", array_map(['Friendica\Database\DBA', 'escape'], explode(",", str_replace(" ", "", Config::get('config', 'admin_email')))))."'"; - $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)", - $admin_mail_list - ); - - // No valid result? - if (!DBA::isResult($adminlist)) { - Logger::log(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), Logger::INFO); - - // Don't continue - return; - } - - // every admin could had different language - foreach ($adminlist as $admin) { - $lang = (($admin['language'])?$admin['language']:'en'); - L10n::pushLang($lang); - - $preamble = deindent(L10n::t(" - The friendica developers released update %s recently, - but when I tried to install it, something went terribly wrong. - This needs to be fixed soon and I can't do it alone. Please contact a - friendica developer if you can not help me on your own. My database might be invalid.", - $update_id)); - $body = L10n::t("The error message is\n[pre]%s[/pre]", $error_message); - - notification([ - 'uid' => $admin['uid'], - 'type' => SYSTEM_EMAIL, - 'to_email' => $admin['email'], - 'preamble' => $preamble, - 'body' => $body, - 'language' => $lang] - ); - L10n::popLang(); - } - - //try the logger - Logger::log("CRITICAL: Database structure update failed: ".$error_message); - } - - private static function tableStructure($table) { $structures = q("DESCRIBE `%s`", $table); @@ -381,8 +329,9 @@ class DBStructure } if (isset($database[$name]["table_status"]["Comment"])) { - if ($database[$name]["table_status"]["Comment"] != $structure['comment']) { - $sql2 = "COMMENT = '".DBA::escape($structure['comment'])."'"; + $structurecomment = defaults($structure, "comment", ""); + if ($database[$name]["table_status"]["Comment"] != $structurecomment) { + $sql2 = "COMMENT = '".DBA::escape($structurecomment)."'"; if ($sql3 == "") { $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2; @@ -589,7 +538,7 @@ class DBStructure $primary_keys = []; foreach ($structure["fields"] AS $fieldname => $field) { $sql_rows[] = "`".DBA::escape($fieldname)."` ".self::FieldCommand($field); - if (x($field,'primary') && $field['primary']!='') { + if (!empty($field['primary'])) { $primary_keys[] = $fieldname; } } @@ -834,10 +783,10 @@ class DBStructure } /** - * Loads the database structure definition from the config/dbstructure.php file. + * Loads the database structure definition from the config/dbstructure.config.php file. * On first pass, defines DB_UPDATE_VERSION constant. * - * @see config/dbstructure.php + * @see config/dbstructure.config.php * @param boolean $with_addons_structure Whether to tack on addons additional tables * @return array * @throws Exception @@ -847,16 +796,16 @@ class DBStructure if (!self::$definition) { $a = \Friendica\BaseObject::getApp(); - $filename = $a->getBasePath() . '/config/dbstructure.php'; + $filename = $a->getBasePath() . '/config/dbstructure.config.php'; if (!is_readable($filename)) { - throw new Exception('Missing database structure config file config/dbstructure.php'); + throw new Exception('Missing database structure config file config/dbstructure.config.php'); } $definition = require $filename; if (!$definition) { - throw new Exception('Corrupted database structure config file config/dbstructure.php'); + throw new Exception('Corrupted database structure config file config/dbstructure.config.php'); } self::$definition = $definition;