From 48a356dba20237253d1180072ed3cef83ac2e5b1 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 23 Dec 2018 15:32:23 -0500 Subject: [PATCH 01/10] Fix formatting in Database\DBStructure --- src/Database/DBStructure.php | 666 ++++++++++++++++++----------------- 1 file changed, 341 insertions(+), 325 deletions(-) diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 92666edb89..5374e11d57 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -2,6 +2,7 @@ /** * @file src/Database/DBStructure.php */ + namespace Friendica\Database; use Exception; @@ -27,6 +28,9 @@ class DBStructure const UPDATE_SUCCESSFUL = 1; // Database check was successful const UPDATE_FAILED = 2; // Database check failed + const RENAME_COLUMN = 0; + const RENAME_PRIMARY_KEY = 1; + /** * Database structure definition loaded from config/dbstructure.config.php * @@ -37,18 +41,19 @@ class DBStructure /* * Converts all tables from MyISAM to InnoDB */ - public static function convertToInnoDB() { + public static function convertToInnoDB() + { $r = q("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `engine` = 'MyISAM' AND `table_schema` = '%s'", DBA::escape(DBA::databaseName())); if (!DBA::isResult($r)) { - echo L10n::t('There are no tables on MyISAM.')."\n"; + echo L10n::t('There are no tables on MyISAM.') . "\n"; return; } foreach ($r AS $table) { $sql = sprintf("ALTER TABLE `%s` engine=InnoDB;", DBA::escape($table['TABLE_NAME'])); - echo $sql."\n"; + echo $sql . "\n"; $result = DBA::e($sql); if (!DBA::isResult($result)) { @@ -57,80 +62,28 @@ class DBStructure } } - private static function tableStructure($table) { - $structures = q("DESCRIBE `%s`", $table); + /** + * @brief Print out database error messages + * + * @param string $message Message to be added to the error message + * + * @return string Error message + */ + private static function printUpdateError($message) + { + echo L10n::t("\nError %d occurred during database update:\n%s\n", + DBA::errorNo(), DBA::errorMessage()); - $full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table); - - $indexes = q("SHOW INDEX FROM `%s`", $table); - - $table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table); - - if (DBA::isResult($table_status)) { - $table_status = $table_status[0]; - } else { - $table_status = []; - } - - $fielddata = []; - $indexdata = []; - - if (DBA::isResult($indexes)) { - foreach ($indexes AS $index) { - if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) { - $indexdata[$index["Key_name"]] = ['UNIQUE']; - } - - $column = $index["Column_name"]; - - if ($index["Sub_part"] != "") { - $column .= "(".$index["Sub_part"].")"; - } - - $indexdata[$index["Key_name"]][] = $column; - } - } - if (DBA::isResult($structures)) { - foreach ($structures AS $field) { - // Replace the default size values so that we don't have to define them - $search = ['tinyint(1)', 'tinyint(3) unsigned', 'tinyint(4)', 'smallint(5) unsigned', 'smallint(6)', 'mediumint(8) unsigned', 'mediumint(9)', 'bigint(20)', 'int(10) unsigned', 'int(11)']; - $replace = ['boolean', 'tinyint unsigned', 'tinyint', 'smallint unsigned', 'smallint', 'mediumint unsigned', 'mediumint', 'bigint', 'int unsigned', 'int']; - $field["Type"] = str_replace($search, $replace, $field["Type"]); - - $fielddata[$field["Field"]]["type"] = $field["Type"]; - if ($field["Null"] == "NO") { - $fielddata[$field["Field"]]["not null"] = true; - } - - if (isset($field["Default"])) { - $fielddata[$field["Field"]]["default"] = $field["Default"]; - } - - if ($field["Extra"] != "") { - $fielddata[$field["Field"]]["extra"] = $field["Extra"]; - } - - if ($field["Key"] == "PRI") { - $fielddata[$field["Field"]]["primary"] = true; - } - } - } - if (DBA::isResult($full_columns)) { - foreach ($full_columns AS $column) { - $fielddata[$column["Field"]]["Collation"] = $column["Collation"]; - $fielddata[$column["Field"]]["comment"] = $column["Comment"]; - } - } - - return ["fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status]; + return L10n::t('Errors encountered performing database changes: ') . $message . EOL; } - public static function printStructure() { + public static function printStructure() + { $database = self::definition(false); echo "-- ------------------------------------------\n"; - echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n"; - echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n"; + echo "-- " . FRIENDICA_PLATFORM . " " . FRIENDICA_VERSION . " (" . FRIENDICA_CODENAME, ")\n"; + echo "-- DB_UPDATE_VERSION " . DB_UPDATE_VERSION . "\n"; echo "-- ------------------------------------------\n\n\n"; foreach ($database AS $name => $structure) { echo "--\n"; @@ -143,17 +96,155 @@ class DBStructure } /** - * @brief Print out database error messages + * Loads the database structure definition from the config/dbstructure.config.php file. + * On first pass, defines DB_UPDATE_VERSION constant. * - * @param string $message Message to be added to the error message - * - * @return string Error message + * @see config/dbstructure.config.php + * @param boolean $with_addons_structure Whether to tack on addons additional tables + * @return array + * @throws Exception */ - private static function printUpdateError($message) { - echo L10n::t("\nError %d occurred during database update:\n%s\n", - DBA::errorNo(), DBA::errorMessage()); + public static function definition($with_addons_structure = true) + { + if (!self::$definition) { + $a = \Friendica\BaseObject::getApp(); - return L10n::t('Errors encountered performing database changes: ').$message.EOL; + $filename = $a->getBasePath() . '/config/dbstructure.config.php'; + + if (!is_readable($filename)) { + 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.config.php'); + } + + self::$definition = $definition; + } else { + $definition = self::$definition; + } + + if ($with_addons_structure) { + Hook::callAll('dbstructure_definition', $definition); + } + + return $definition; + } + + private static function createTable($name, $structure, $verbose, $action) + { + $r = true; + + $engine = ""; + $comment = ""; + $sql_rows = []; + $primary_keys = []; + foreach ($structure["fields"] AS $fieldname => $field) { + $sql_rows[] = "`" . DBA::escape($fieldname) . "` " . self::FieldCommand($field); + if (!empty($field['primary'])) { + $primary_keys[] = $fieldname; + } + } + + if (!empty($structure["indexes"])) { + foreach ($structure["indexes"] AS $indexname => $fieldnames) { + $sql_index = self::createIndex($indexname, $fieldnames, ""); + if (!is_null($sql_index)) { + $sql_rows[] = $sql_index; + } + } + } + + if (isset($structure["engine"])) { + $engine = " ENGINE=" . $structure["engine"]; + } + + if (isset($structure["comment"])) { + $comment = " COMMENT='" . DBA::escape($structure["comment"]) . "'"; + } + + $sql = implode(",\n\t", $sql_rows); + + $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", DBA::escape($name)) . $sql . + "\n)" . $engine . " DEFAULT COLLATE utf8mb4_general_ci" . $comment; + if ($verbose) { + echo $sql . ";\n"; + } + + if ($action) { + $r = DBA::e($sql); + } + + return $r; + } + + private static function FieldCommand($parameters, $create = true) + { + $fieldstruct = $parameters["type"]; + + if (isset($parameters["Collation"])) { + $fieldstruct .= " COLLATE " . $parameters["Collation"]; + } + + if (isset($parameters["not null"])) { + $fieldstruct .= " NOT NULL"; + } + + if (isset($parameters["default"])) { + if (strpos(strtolower($parameters["type"]), "int") !== false) { + $fieldstruct .= " DEFAULT " . $parameters["default"]; + } else { + $fieldstruct .= " DEFAULT '" . $parameters["default"] . "'"; + } + } + if (isset($parameters["extra"])) { + $fieldstruct .= " " . $parameters["extra"]; + } + + if (isset($parameters["comment"])) { + $fieldstruct .= " COMMENT '" . DBA::escape($parameters["comment"]) . "'"; + } + + /*if (($parameters["primary"] != "") && $create) + $fieldstruct .= " PRIMARY KEY";*/ + + return ($fieldstruct); + } + + private static function createIndex($indexname, $fieldnames, $method = "ADD") + { + $method = strtoupper(trim($method)); + if ($method != "" && $method != "ADD") { + throw new Exception("Invalid parameter 'method' in self::createIndex(): '$method'"); + } + + if ($fieldnames[0] == "UNIQUE") { + array_shift($fieldnames); + $method .= ' UNIQUE'; + } + + $names = ""; + foreach ($fieldnames AS $fieldname) { + if ($names != "") { + $names .= ","; + } + + if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) { + $names .= "`" . DBA::escape($matches[1]) . "`(" . intval($matches[2]) . ")"; + } else { + $names .= "`" . DBA::escape($fieldname) . "`"; + } + } + + if ($indexname == "PRIMARY") { + return sprintf("%s PRIMARY KEY(%s)", $method, $names); + } + + + $sql = sprintf("%s INDEX `%s` (%s)", $method, DBA::escape($indexname), $names); + return ($sql); } /** @@ -166,10 +257,11 @@ class DBStructure * @param array $definition An array of the definition tables * @return string Empty string if the update is successful, error messages otherwise */ - public static function update($verbose, $action, $install = false, array $tables = null, array $definition = null) { + public static function update($verbose, $action, $install = false, array $tables = null, array $definition = null) + { if ($action && !$install) { Config::set('system', 'maintenance', 1); - Config::set('system', 'maintenance_reason', L10n::t('%s: Database update', DateTimeFormat::utcNow().' '.date('e'))); + Config::set('system', 'maintenance_reason', L10n::t('%s: Database update', DateTimeFormat::utcNow() . ' ' . date('e'))); } $errors = ''; @@ -221,16 +313,16 @@ class DBStructure } else { foreach ($structure["indexes"] AS $indexname => $fieldnames) { if (isset($database[$name]["indexes"][$indexname])) { - $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]); + $current_index_definition = implode(",", $database[$name]["indexes"][$indexname]); } else { $current_index_definition = "__NOT_SET__"; } - $new_index_definition = implode(",",$fieldnames); + $new_index_definition = implode(",", $fieldnames); if ($current_index_definition != $new_index_definition) { if ($fieldnames[0] == "UNIQUE") { $is_unique = true; if ($ignore == "") { - $temp_name = "temp-".$name; + $temp_name = "temp-" . $name; } } } @@ -242,29 +334,29 @@ class DBStructure * and index name doesn't start with "local_" */ foreach ($database[$name]["indexes"] as $indexname => $fieldnames) { - $current_index_definition = implode(",",$fieldnames); + $current_index_definition = implode(",", $fieldnames); if (isset($structure["indexes"][$indexname])) { - $new_index_definition = implode(",",$structure["indexes"][$indexname]); + $new_index_definition = implode(",", $structure["indexes"][$indexname]); } else { $new_index_definition = "__NOT_SET__"; } if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') { - $sql2=self::dropIndex($indexname); + $sql2 = self::dropIndex($indexname); if ($sql3 == "") { - $sql3 = "ALTER".$ignore." TABLE `".$temp_name."` ".$sql2; + $sql3 = "ALTER" . $ignore . " TABLE `" . $temp_name . "` " . $sql2; } else { - $sql3 .= ", ".$sql2; + $sql3 .= ", " . $sql2; } } } // Compare the field structure field by field foreach ($structure["fields"] AS $fieldname => $parameters) { if (!isset($database[$name]["fields"][$fieldname])) { - $sql2=self::addTableField($fieldname, $parameters); + $sql2 = self::addTableField($fieldname, $parameters); if ($sql3 == "") { - $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2; + $sql3 = "ALTER" . $ignore . " TABLE `" . $temp_name . "` " . $sql2; } else { - $sql3 .= ", ".$sql2; + $sql3 .= ", " . $sql2; } } else { // Compare the field definition @@ -289,9 +381,9 @@ class DBStructure if ($current_field_definition != $new_field_definition) { $sql2 = self::modifyTableField($fieldname, $parameters); if ($sql3 == "") { - $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2; + $sql3 = "ALTER" . $ignore . " TABLE `" . $temp_name . "` " . $sql2; } else { - $sql3 .= ", ".$sql2; + $sql3 .= ", " . $sql2; } } } @@ -306,11 +398,11 @@ class DBStructure if (!$is_new_table) { foreach ($structure["indexes"] AS $indexname => $fieldnames) { if (isset($database[$name]["indexes"][$indexname])) { - $current_index_definition = implode(",",$database[$name]["indexes"][$indexname]); + $current_index_definition = implode(",", $database[$name]["indexes"][$indexname]); } else { $current_index_definition = "__NOT_SET__"; } - $new_index_definition = implode(",",$fieldnames); + $new_index_definition = implode(",", $fieldnames); if ($current_index_definition != $new_index_definition) { $sql2 = self::createIndex($indexname, $fieldnames); @@ -320,9 +412,9 @@ class DBStructure } if ($sql2 != "") { if ($sql3 == "") { - $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2; + $sql3 = "ALTER" . $ignore . " TABLE `" . $temp_name . "` " . $sql2; } else { - $sql3 .= ", ".$sql2; + $sql3 .= ", " . $sql2; } } } @@ -331,24 +423,24 @@ class DBStructure if (isset($database[$name]["table_status"]["Comment"])) { $structurecomment = defaults($structure, "comment", ""); if ($database[$name]["table_status"]["Comment"] != $structurecomment) { - $sql2 = "COMMENT = '".DBA::escape($structurecomment)."'"; + $sql2 = "COMMENT = '" . DBA::escape($structurecomment) . "'"; if ($sql3 == "") { - $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2; + $sql3 = "ALTER" . $ignore . " TABLE `" . $temp_name . "` " . $sql2; } else { - $sql3 .= ", ".$sql2; + $sql3 .= ", " . $sql2; } } } if (isset($database[$name]["table_status"]["Engine"]) && isset($structure['engine'])) { if ($database[$name]["table_status"]["Engine"] != $structure['engine']) { - $sql2 = "ENGINE = '".DBA::escape($structure['engine'])."'"; + $sql2 = "ENGINE = '" . DBA::escape($structure['engine']) . "'"; if ($sql3 == "") { - $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2; + $sql3 = "ALTER" . $ignore . " TABLE `" . $temp_name . "` " . $sql2; } else { - $sql3 .= ", ".$sql2; + $sql3 .= ", " . $sql2; } } } @@ -358,9 +450,9 @@ class DBStructure $sql2 = "DEFAULT COLLATE utf8mb4_general_ci"; if ($sql3 == "") { - $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2; + $sql3 = "ALTER" . $ignore . " TABLE `" . $temp_name . "` " . $sql2; } else { - $sql3 .= ", ".$sql2; + $sql3 .= ", " . $sql2; } } } @@ -385,9 +477,9 @@ class DBStructure if ($field_definition['Collation'] != $parameters['Collation']) { $sql2 = self::modifyTableField($fieldname, $parameters); if (($sql3 == "") || (substr($sql3, -2, 2) == "; ")) { - $sql3 .= "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2; + $sql3 .= "ALTER" . $ignore . " TABLE `" . $temp_name . "` " . $sql2; } else { - $sql3 .= ", ".$sql2; + $sql3 .= ", " . $sql2; } } } @@ -412,27 +504,27 @@ class DBStructure if ($ignore != "") { echo "SET session old_alter_table=1;\n"; } else { - echo "DROP TABLE IF EXISTS `".$temp_name."`;\n"; - echo "CREATE TABLE `".$temp_name."` LIKE `".$name."`;\n"; + echo "DROP TABLE IF EXISTS `" . $temp_name . "`;\n"; + echo "CREATE TABLE `" . $temp_name . "` LIKE `" . $name . "`;\n"; } } - echo $sql3."\n"; + echo $sql3 . "\n"; if ($is_unique && ($temp_name != $name)) { if ($ignore != "") { echo "SET session old_alter_table=0;\n"; } else { - echo "INSERT INTO `".$temp_name."` SELECT ".DBA::anyValueFallback($field_list)." FROM `".$name."`".$group_by.";\n"; - echo "DROP TABLE `".$name."`;\n"; - echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n"; + echo "INSERT INTO `" . $temp_name . "` SELECT " . DBA::anyValueFallback($field_list) . " FROM `" . $name . "`" . $group_by . ";\n"; + echo "DROP TABLE `" . $name . "`;\n"; + echo "RENAME TABLE `" . $temp_name . "` TO `" . $name . "`;\n"; } } } if ($action) { if (!$install) { - Config::set('system', 'maintenance_reason', L10n::t('%s: updating %s table.', DateTimeFormat::utcNow().' '.date('e'), $name)); + Config::set('system', 'maintenance_reason', L10n::t('%s: updating %s table.', DateTimeFormat::utcNow() . ' ' . date('e'), $name)); } // Ensure index conversion to unique removes duplicates @@ -440,13 +532,13 @@ class DBStructure if ($ignore != "") { DBA::e("SET session old_alter_table=1;"); } else { - $r = DBA::e("DROP TABLE IF EXISTS `".$temp_name."`;"); + $r = DBA::e("DROP TABLE IF EXISTS `" . $temp_name . "`;"); if (!DBA::isResult($r)) { $errors .= self::printUpdateError($sql3); return $errors; } - $r = DBA::e("CREATE TABLE `".$temp_name."` LIKE `".$name."`;"); + $r = DBA::e("CREATE TABLE `" . $temp_name . "` LIKE `" . $name . "`;"); if (!DBA::isResult($r)) { $errors .= self::printUpdateError($sql3); return $errors; @@ -462,17 +554,17 @@ class DBStructure if ($ignore != "") { DBA::e("SET session old_alter_table=0;"); } else { - $r = DBA::e("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";"); + $r = DBA::e("INSERT INTO `" . $temp_name . "` SELECT " . $field_list . " FROM `" . $name . "`" . $group_by . ";"); if (!DBA::isResult($r)) { $errors .= self::printUpdateError($sql3); return $errors; } - $r = DBA::e("DROP TABLE `".$name."`;"); + $r = DBA::e("DROP TABLE `" . $name . "`;"); if (!DBA::isResult($r)) { $errors .= self::printUpdateError($sql3); return $errors; } - $r = DBA::e("RENAME TABLE `".$temp_name."` TO `".$name."`;"); + $r = DBA::e("RENAME TABLE `" . $temp_name . "` TO `" . $name . "`;"); if (!DBA::isResult($r)) { $errors .= self::printUpdateError($sql3); return $errors; @@ -497,133 +589,95 @@ class DBStructure return $errors; } - private static function FieldCommand($parameters, $create = true) { - $fieldstruct = $parameters["type"]; + private static function tableStructure($table) + { + $structures = q("DESCRIBE `%s`", $table); - if (isset($parameters["Collation"])) { - $fieldstruct .= " COLLATE ".$parameters["Collation"]; + $full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table); + + $indexes = q("SHOW INDEX FROM `%s`", $table); + + $table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table); + + if (DBA::isResult($table_status)) { + $table_status = $table_status[0]; + } else { + $table_status = []; } - if (isset($parameters["not null"])) { - $fieldstruct .= " NOT NULL"; - } + $fielddata = []; + $indexdata = []; - if (isset($parameters["default"])) { - if (strpos(strtolower($parameters["type"]),"int")!==false) { - $fieldstruct .= " DEFAULT ".$parameters["default"]; - } else { - $fieldstruct .= " DEFAULT '".$parameters["default"]."'"; + if (DBA::isResult($indexes)) { + foreach ($indexes AS $index) { + if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) { + $indexdata[$index["Key_name"]] = ['UNIQUE']; + } + + $column = $index["Column_name"]; + + if ($index["Sub_part"] != "") { + $column .= "(" . $index["Sub_part"] . ")"; + } + + $indexdata[$index["Key_name"]][] = $column; } } - if (isset($parameters["extra"])) { - $fieldstruct .= " ".$parameters["extra"]; - } + if (DBA::isResult($structures)) { + foreach ($structures AS $field) { + // Replace the default size values so that we don't have to define them + $search = ['tinyint(1)', 'tinyint(3) unsigned', 'tinyint(4)', 'smallint(5) unsigned', 'smallint(6)', 'mediumint(8) unsigned', 'mediumint(9)', 'bigint(20)', 'int(10) unsigned', 'int(11)']; + $replace = ['boolean', 'tinyint unsigned', 'tinyint', 'smallint unsigned', 'smallint', 'mediumint unsigned', 'mediumint', 'bigint', 'int unsigned', 'int']; + $field["Type"] = str_replace($search, $replace, $field["Type"]); - if (isset($parameters["comment"])) { - $fieldstruct .= " COMMENT '".DBA::escape($parameters["comment"])."'"; - } + $fielddata[$field["Field"]]["type"] = $field["Type"]; + if ($field["Null"] == "NO") { + $fielddata[$field["Field"]]["not null"] = true; + } - /*if (($parameters["primary"] != "") && $create) - $fieldstruct .= " PRIMARY KEY";*/ + if (isset($field["Default"])) { + $fielddata[$field["Field"]]["default"] = $field["Default"]; + } - return($fieldstruct); - } + if ($field["Extra"] != "") { + $fielddata[$field["Field"]]["extra"] = $field["Extra"]; + } - private static function createTable($name, $structure, $verbose, $action) { - $r = true; - - $engine = ""; - $comment = ""; - $sql_rows = []; - $primary_keys = []; - foreach ($structure["fields"] AS $fieldname => $field) { - $sql_rows[] = "`".DBA::escape($fieldname)."` ".self::FieldCommand($field); - if (!empty($field['primary'])) { - $primary_keys[] = $fieldname; - } - } - - if (!empty($structure["indexes"])) { - foreach ($structure["indexes"] AS $indexname => $fieldnames) { - $sql_index = self::createIndex($indexname, $fieldnames, ""); - if (!is_null($sql_index)) { - $sql_rows[] = $sql_index; + if ($field["Key"] == "PRI") { + $fielddata[$field["Field"]]["primary"] = true; } } } - - if (isset($structure["engine"])) { - $engine = " ENGINE=" . $structure["engine"]; + if (DBA::isResult($full_columns)) { + foreach ($full_columns AS $column) { + $fielddata[$column["Field"]]["Collation"] = $column["Collation"]; + $fielddata[$column["Field"]]["comment"] = $column["Comment"]; + } } - if (isset($structure["comment"])) { - $comment = " COMMENT='" . DBA::escape($structure["comment"]) . "'"; - } - - $sql = implode(",\n\t", $sql_rows); - - $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", DBA::escape($name)).$sql. - "\n)" . $engine . " DEFAULT COLLATE utf8mb4_general_ci" . $comment; - if ($verbose) { - echo $sql.";\n"; - } - - if ($action) { - $r = DBA::e($sql); - } - - return $r; + return ["fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status]; } - private static function addTableField($fieldname, $parameters) { - $sql = sprintf("ADD `%s` %s", DBA::escape($fieldname), self::FieldCommand($parameters)); - return($sql); - } - - private static function modifyTableField($fieldname, $parameters) { - $sql = sprintf("MODIFY `%s` %s", DBA::escape($fieldname), self::FieldCommand($parameters, false)); - return($sql); - } - - private static function dropIndex($indexname) { + private static function dropIndex($indexname) + { $sql = sprintf("DROP INDEX `%s`", DBA::escape($indexname)); - return($sql); + return ($sql); } - private static function createIndex($indexname, $fieldnames, $method = "ADD") { - $method = strtoupper(trim($method)); - if ($method!="" && $method!="ADD") { - throw new Exception("Invalid parameter 'method' in self::createIndex(): '$method'"); - } - - if ($fieldnames[0] == "UNIQUE") { - array_shift($fieldnames); - $method .= ' UNIQUE'; - } - - $names = ""; - foreach ($fieldnames AS $fieldname) { - if ($names != "") { - $names .= ","; - } - - if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) { - $names .= "`".DBA::escape($matches[1])."`(".intval($matches[2]).")"; - } else { - $names .= "`".DBA::escape($fieldname)."`"; - } - } - - if ($indexname == "PRIMARY") { - return sprintf("%s PRIMARY KEY(%s)", $method, $names); - } - - - $sql = sprintf("%s INDEX `%s` (%s)", $method, DBA::escape($indexname), $names); - return($sql); + private static function addTableField($fieldname, $parameters) + { + $sql = sprintf("ADD `%s` %s", DBA::escape($fieldname), self::FieldCommand($parameters)); + return ($sql); } - private static function groupBy($indexname, $fieldnames) { + private static function modifyTableField($fieldname, $parameters) + { + $sql = sprintf("MODIFY `%s` %s", DBA::escape($fieldname), self::FieldCommand($parameters, false)); + return ($sql); + } + + private static function groupBy($indexname, $fieldnames) + { if ($fieldnames[0] != "UNIQUE") { return ""; } @@ -637,9 +691,9 @@ class DBStructure } if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) { - $names .= "`".DBA::escape($matches[1])."`"; + $names .= "`" . DBA::escape($matches[1]) . "`"; } else { - $names .= "`".DBA::escape($fieldname)."`"; + $names .= "`" . DBA::escape($fieldname) . "`"; } } @@ -647,92 +701,21 @@ class DBStructure return $sql; } - /** - * Check if a table exists - * - * @param string $table Table name - * - * @return boolean Does the table exist? - */ - public static function existsTable($table) - { - if (empty($table)) { - return false; - } - - $table = DBA::escape($table); - - $sql = "SHOW TABLES LIKE '" . $table . "';"; - - $stmt = DBA::p($sql); - - if (is_bool($stmt)) { - $retval = $stmt; - } else { - $retval = (DBA::numRows($stmt) > 0); - } - - DBA::close($stmt); - - return $retval; - } - - /** - * Check if the columns of the table exists - * - * @param string $table Table name - * @param array $columns Columns to check ( Syntax: [ $col1, $col2, .. ] ) - * - * @return boolean Does the table exist? - */ - public static function existsColumn($table, $columns = []) { - if (empty($table)) { - return false; - } - - if (is_null($columns) || empty($columns)) { - return self::existsTable($table); - } - - $table = DBA::escape($table); - - foreach ($columns AS $column) { - $sql = "SHOW COLUMNS FROM `" . $table . "` LIKE '" . $column . "';"; - - $stmt = DBA::p($sql); - - if (is_bool($stmt)) { - $retval = $stmt; - } else { - $retval = (DBA::numRows($stmt) > 0); - } - - DBA::close($stmt); - - if (!$retval) { - return false; - } - } - - return true; - } - - const RENAME_COLUMN = 0; - const RENAME_PRIMARY_KEY = 1; - /** * Renames columns or the primary key of a table + * * @todo You cannot rename a primary key if "auto increment" is set * - * @param string $table Table name - * @param array $columns Columns Syntax for Rename: [ $old1 => [ $new1, $type1 ], $old2 => [ $new2, $type2 ], ... ] ) + * @param string $table Table name + * @param array $columns Columns Syntax for Rename: [ $old1 => [ $new1, $type1 ], $old2 => [ $new2, $type2 ], ... ] ) * Syntax for Primary Key: [ $col1, $col2, ...] ) - * @param int $type The type of renaming (Default is Column) + * @param int $type The type of renaming (Default is Column) * * @return boolean Was the renaming successful? * */ - public static function rename($table, $columns, $type = self::RENAME_COLUMN) { + public static function rename($table, $columns, $type = self::RENAME_COLUMN) + { if (empty($table) || empty($columns)) { return false; } @@ -783,40 +766,73 @@ class DBStructure } /** - * Loads the database structure definition from the config/dbstructure.config.php file. - * On first pass, defines DB_UPDATE_VERSION constant. + * Check if the columns of the table exists * - * @see config/dbstructure.config.php - * @param boolean $with_addons_structure Whether to tack on addons additional tables - * @return array - * @throws Exception + * @param string $table Table name + * @param array $columns Columns to check ( Syntax: [ $col1, $col2, .. ] ) + * + * @return boolean Does the table exist? */ - public static function definition($with_addons_structure = true) + public static function existsColumn($table, $columns = []) { - if (!self::$definition) { - $a = \Friendica\BaseObject::getApp(); + if (empty($table)) { + return false; + } - $filename = $a->getBasePath() . '/config/dbstructure.config.php'; + if (is_null($columns) || empty($columns)) { + return self::existsTable($table); + } - if (!is_readable($filename)) { - throw new Exception('Missing database structure config file config/dbstructure.config.php'); + $table = DBA::escape($table); + + foreach ($columns AS $column) { + $sql = "SHOW COLUMNS FROM `" . $table . "` LIKE '" . $column . "';"; + + $stmt = DBA::p($sql); + + if (is_bool($stmt)) { + $retval = $stmt; + } else { + $retval = (DBA::numRows($stmt) > 0); } - $definition = require $filename; + DBA::close($stmt); - if (!$definition) { - throw new Exception('Corrupted database structure config file config/dbstructure.config.php'); + if (!$retval) { + return false; } + } - self::$definition = $definition; + return true; + } + + /** + * Check if a table exists + * + * @param string $table Table name + * + * @return boolean Does the table exist? + */ + public static function existsTable($table) + { + if (empty($table)) { + return false; + } + + $table = DBA::escape($table); + + $sql = "SHOW TABLES LIKE '" . $table . "';"; + + $stmt = DBA::p($sql); + + if (is_bool($stmt)) { + $retval = $stmt; } else { - $definition = self::$definition; + $retval = (DBA::numRows($stmt) > 0); } - if ($with_addons_structure) { - Hook::callAll('dbstructure_definition', $definition); - } + DBA::close($stmt); - return $definition; + return $retval; } } From 21783f61b48727b1bc06d28f005e6a8f58b39fb8 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 23 Dec 2018 15:32:38 -0500 Subject: [PATCH 02/10] [Composer] Add ext-curl dependency --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2f12d076d4..5b30459734 100644 --- a/composer.json +++ b/composer.json @@ -14,6 +14,7 @@ }, "require": { "php": ">=5.6.1", + "ext-curl": "*", "ext-dom": "*", "ext-json": "*", "ext-xml": "*", @@ -41,7 +42,7 @@ "npm-asset/fullcalendar": "^3.0.1", "npm-asset/cropperjs": "1.2.2", "npm-asset/imagesloaded": "4.1.4" - }, + }, "repositories": [ { "type": "vcs", From d53ff9c34d86ee4b7650ae82af458b7dad6cf4fb Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 23 Dec 2018 15:40:49 -0500 Subject: [PATCH 03/10] Add support for FULLTEXT indices in Database\DBStructure --- src/Database/DBStructure.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 5374e11d57..1a556b7bc7 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -220,9 +220,9 @@ class DBStructure throw new Exception("Invalid parameter 'method' in self::createIndex(): '$method'"); } - if ($fieldnames[0] == "UNIQUE") { - array_shift($fieldnames); - $method .= ' UNIQUE'; + if (in_array($fieldnames[0], ["UNIQUE", "FULLTEXT"])) { + $index_type = array_shift($fieldnames); + $method .= " " . $index_type; } $names = ""; @@ -407,9 +407,7 @@ class DBStructure $sql2 = self::createIndex($indexname, $fieldnames); // Fetch the "group by" fields for unique indexes - if ($fieldnames[0] == "UNIQUE") { - $group_by = self::groupBy($indexname, $fieldnames); - } + $group_by = self::groupBy($fieldnames); if ($sql2 != "") { if ($sql3 == "") { $sql3 = "ALTER" . $ignore . " TABLE `" . $temp_name . "` " . $sql2; @@ -610,8 +608,12 @@ class DBStructure if (DBA::isResult($indexes)) { foreach ($indexes AS $index) { - if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) { - $indexdata[$index["Key_name"]] = ['UNIQUE']; + if ($index["Key_name"] != "PRIMARY" && $index["Non_unique"] == "0" && !isset($indexdata[$index["Key_name"]])) { + $indexdata[$index["Key_name"]] = ["UNIQUE"]; + } + + if ($index["Index_type"] == "FULLTEXT" && !isset($indexdata[$index["Key_name"]])) { + $indexdata[$index["Key_name"]] = ["FULLTEXT"]; } $column = $index["Column_name"]; @@ -676,7 +678,13 @@ class DBStructure return ($sql); } - private static function groupBy($indexname, $fieldnames) + /** + * Constructs a GROUP BY clause from a UNIQUE index definition. + * + * @param array $fieldnames + * @return string + */ + private static function groupBy(array $fieldnames) { if ($fieldnames[0] != "UNIQUE") { return ""; From c15fd9beb89a6cdb5a458a1086c46fbdeb88b1f3 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 23 Dec 2018 18:54:06 -0500 Subject: [PATCH 04/10] Add expected FULLTEXT index to profile table --- config/dbstructure.config.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/dbstructure.config.php b/config/dbstructure.config.php index ca34936065..61f0780dc4 100644 --- a/config/dbstructure.config.php +++ b/config/dbstructure.config.php @@ -34,7 +34,7 @@ use Friendica\Database\DBA; if (!defined('DB_UPDATE_VERSION')) { - define('DB_UPDATE_VERSION', 1291); + define('DB_UPDATE_VERSION', 1292); } return [ @@ -1059,6 +1059,7 @@ return [ "indexes" => [ "PRIMARY" => ["id"], "uid_is-default" => ["uid", "is-default"], + "pub_keywords" => ["FULLTEXT", "pub_keywords"], ] ], "profile_check" => [ From 1938ec3ebecd71c806d1cddf2400786a649a8c40 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 23 Dec 2018 19:42:50 -0500 Subject: [PATCH 05/10] Rework mod/match - Replace classic pager with a start index - Remove q() calls - Ensure template is still loaded even with no results. - Improve Minimal Pager display of next link --- mod/match.php | 158 ++++++++++++++++++++++-------------------- src/Content/Pager.php | 2 +- 2 files changed, 84 insertions(+), 76 deletions(-) diff --git a/mod/match.php b/mod/match.php index 0ec7534662..451821f9f1 100644 --- a/mod/match.php +++ b/mod/match.php @@ -12,11 +12,9 @@ use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Model\Contact; +use Friendica\Model\Profile; use Friendica\Util\Network; use Friendica\Util\Proxy as ProxyUtils; -use Friendica\Util\Strings; - -require_once 'include/text.php'; /** * @brief Controller for /match. @@ -26,13 +24,12 @@ require_once 'include/text.php'; * * @param App $a App * - * @return void|string + * @return string */ function match_content(App $a) { - $o = ''; - if (! local_user()) { - return; + if (!local_user()) { + return ''; } $a->page['aside'] .= Widget::findPeople(); @@ -40,91 +37,102 @@ function match_content(App $a) $_SESSION['return_path'] = $a->cmd; - $r = q( - "SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", - intval(local_user()) - ); - if (! DBA::isResult($r)) { - return; + $profile = Profile::getByUID(local_user()); + + if (!DBA::isResult($profile)) { + return ''; } - if (! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) { + if (!$profile['pub_keywords'] && (!$profile['prv_keywords'])) { notice(L10n::t('No keywords to match. Please add keywords to your default profile.') . EOL); - return; + return ''; } $params = []; - $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']); + $tags = trim($profile['pub_keywords'] . ' ' . $profile['prv_keywords']); - if ($tags) { - $pager = new Pager($a->query_string); + $params['s'] = $tags; + $params['n'] = 100; - $params['s'] = $tags; - if ($pager->getPage() != 1) { - $params['p'] = $pager->getPage(); - } + if (strlen(Config::get('system', 'directory'))) { + $host = get_server(); + } else { + $host = System::baseUrl(); + } - if (strlen(Config::get('system', 'directory'))) { - $x = Network::post(get_server().'/msearch', $params)->getBody(); - } else { - $x = Network::post(System::baseUrl() . '/msearch', $params)->getBody(); - } + $msearch_json = Network::post($host . '/msearch', $params)->getBody(); - $j = json_decode($x); + $msearch = json_decode($msearch_json); - if (count($j->results)) { - $pager->setItemsPerPage($j->items_page); + $start = defaults($_GET, 'start', 0); + $entries = []; + $paginate = ''; - $id = 0; + if (!empty($msearch->results)) { + for ($i = $start;count($entries) < 10 && $i < $msearch->total; $i++) { + $profile = $msearch->results[$i]; - foreach ($j->results as $jj) { - $match_nurl = Strings::normaliseLink($jj->url); - $match = q( - "SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1", - intval(local_user()), - DBA::escape($match_nurl) - ); - - if (!count($match)) { - $jj->photo = str_replace("http:///photo/", get_server()."/photo/", $jj->photo); - $connlnk = System::baseUrl() . '/follow/?url=' . $jj->url; - $photo_menu = [ - 'profile' => [L10n::t("View Profile"), Contact::magicLink($jj->url)], - 'follow' => [L10n::t("Connect/Follow"), $connlnk] - ]; - - $contact_details = Contact::getDetailsByURL($jj->url, local_user()); - - $entry = [ - 'url' => Contact::magicLink($jj->url), - 'itemurl' => defaults($contact_details, 'addr', $jj->url), - 'name' => $jj->name, - 'details' => defaults($contact_details, 'location', ''), - 'tags' => defaults($contact_details, 'keywords', ''), - 'about' => defaults($contact_details, 'about', ''), - 'account_type' => Contact::getAccountType($contact_details), - 'thumb' => ProxyUtils::proxifyUrl($jj->photo, false, ProxyUtils::SIZE_THUMB), - 'inttxt' => ' ' . L10n::t('is interested in:'), - 'conntxt' => L10n::t('Connect'), - 'connlnk' => $connlnk, - 'img_hover' => $jj->tags, - 'photo_menu' => $photo_menu, - 'id' => ++$id, - ]; - $entries[] = $entry; - } + // Already known contact + if (Contact::getIdForURL($profile->url, local_user(), true)) { + continue; } - $tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl'); + // Workaround for wrong directory photo URL + $profile->photo = str_replace('http:///photo/', get_server() . '/photo/', $profile->photo); - $o .= Renderer::replaceMacros($tpl, [ - '$title' => L10n::t('Profile Match'), - '$contacts' => $entries, - '$paginate' => $pager->renderFull($j->total) - ]); - } else { - info(L10n::t('No matches') . EOL); + $connlnk = System::baseUrl() . '/follow/?url=' . $profile->url; + $photo_menu = [ + 'profile' => [L10n::t("View Profile"), Contact::magicLink($profile->url)], + 'follow' => [L10n::t("Connect/Follow"), $connlnk] + ]; + + $contact_details = Contact::getDetailsByURL($profile->url, 0); + + $entry = [ + 'url' => Contact::magicLink($profile->url), + 'itemurl' => defaults($contact_details, 'addr', $profile->url), + 'name' => $profile->name, + 'details' => defaults($contact_details, 'location', ''), + 'tags' => defaults($contact_details, 'keywords', ''), + 'about' => defaults($contact_details, 'about', ''), + 'account_type' => Contact::getAccountType($contact_details), + 'thumb' => ProxyUtils::proxifyUrl($profile->photo, false, ProxyUtils::SIZE_THUMB), + 'conntxt' => L10n::t('Connect'), + 'connlnk' => $connlnk, + 'img_hover' => $profile->tags, + 'photo_menu' => $photo_menu, + 'id' => $i, + ]; + $entries[] = $entry; } + + $data = [ + 'class' => 'pager', + 'first' => [ + 'url' => 'match', + 'text' => L10n::t('first'), + 'class' => 'previous' . ($start == 0 ? 'disabled' : '') + ], + 'next' => [ + 'url' => 'match?start=' . $i, + 'text' => L10n::t('next'), + 'class' => 'next' . ($i >= $msearch->total ? ' disabled' : '') + ] + ]; + + $tpl = Renderer::getMarkupTemplate('paginate.tpl'); + $paginate = Renderer::replaceMacros($tpl, ['pager' => $data]); } + if (empty($entries)) { + info(L10n::t('No matches') . EOL); + } + + $tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl'); + $o = Renderer::replaceMacros($tpl, [ + '$title' => L10n::t('Profile Match'), + '$contacts' => $entries, + '$paginate' => $paginate + ]); + return $o; } diff --git a/src/Content/Pager.php b/src/Content/Pager.php index 098d8e8796..0a1766fe59 100644 --- a/src/Content/Pager.php +++ b/src/Content/Pager.php @@ -169,7 +169,7 @@ class Pager 'next' => [ 'url' => $this->ensureQueryParameter($this->baseQueryString . '&page=' . ($this->getPage() + 1)), 'text' => L10n::t('older'), - 'class' => 'next' . ($displayedItemCount <= 0 ? ' disabled' : '') + 'class' => 'next' . ($displayedItemCount < $this->getItemsPerPage() ? ' disabled' : '') ] ]; From b962fc989a03083d50e55f96bbcf2349ab390bb0 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 23 Dec 2018 19:45:03 -0500 Subject: [PATCH 06/10] Rework mod/msearch - Remove deprecated q()/killme() calls - Ensure an output on empty search string - Fix page number nonsense (-1, +1,...) --- mod/msearch.php | 85 ++++++++++++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 33 deletions(-) diff --git a/mod/msearch.php b/mod/msearch.php index d3477b0d59..64c6ce3cf8 100644 --- a/mod/msearch.php +++ b/mod/msearch.php @@ -4,45 +4,64 @@ use Friendica\App; use Friendica\Core\System; use Friendica\Database\DBA; -function msearch_post(App $a) { - - $perpage = (($_POST['n']) ? $_POST['n'] : 80); - $page = (($_POST['p']) ? intval($_POST['p'] - 1) : 0); - $startrec = (($page+1) * $perpage) - $perpage; - - $search = $_POST['s']; - if(! strlen($search)) - killme(); - - $r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') ", - DBA::escape($search) - ); - - if (DBA::isResult($r)) - $total = $r[0]['total']; +function msearch_post(App $a) +{ + $search = defaults($_POST, 's', ''); + $perpage = intval(defaults($_POST, 'n', 80)); + $page = intval(defaults($_POST, 'p', 1)); + $startrec = ($page - 1) * $perpage; + $total = 0; $results = []; - $r = q("SELECT `pub_keywords`, `username`, `nickname`, `user`.`uid` FROM `user` LEFT JOIN `profile` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') LIMIT %d , %d ", - DBA::escape($search), - intval($startrec), - intval($perpage) - ); - - if (DBA::isResult($r)) { - foreach($r as $rr) - $results[] = [ - 'name' => $rr['name'], - 'url' => System::baseUrl() . '/profile/' . $rr['nickname'], - 'photo' => System::baseUrl() . '/photo/avatar/' . $rr['uid'] . '.jpg', - 'tags' => str_replace([',',' '],[' ',' '],$rr['pub_keywords']) - ]; + if (!strlen($search)) { + $output = ['total' => 0, 'items_page' => $perpage, 'page' => $page, 'results' => $results]; + echo json_encode($output); + exit(); } - $output = ['total' => $total, 'items_page' => $perpage, 'page' => $page + 1, 'results' => $results]; + $count_stmt = DBA::p( + "SELECT COUNT(*) AS `total` + FROM `profile` + JOIN `user` ON `user`.`uid` = `profile`.`uid` + WHERE `is-default` = 1 + AND `user`.`hidewall` = 0 + AND MATCH(`pub_keywords`) AGAINST (?)", + $search + ); + + if (DBA::isResult($count_stmt)) { + $row = DBA::fetch($count_stmt); + $total = $row['total']; + } + + DBA::close($count_stmt); + + $search_stmt = DBA::p( + "SELECT `pub_keywords`, `username`, `nickname`, `user`.`uid` + FROM `user` + JOIN `profile` ON `user`.`uid` = `profile`.`uid` + WHERE `is-default` = 1 + AND `user`.`hidewall` = 0 + AND MATCH(`pub_keywords`) AGAINST (?) + LIMIT ?, ?", + $search, + $startrec, + $perpage + ); + + while($search_result = DBA::fetch($search_stmt)) { + $results[] = [ + 'name' => $search_result['name'], + 'url' => System::baseUrl() . '/profile/' . $search_result['nickname'], + 'photo' => System::baseUrl() . '/photo/avatar/' . $search_result['uid'] . '.jpg', + 'tags' => str_replace([',', ' '], [' ', ' '], $search_result['pub_keywords']) + ]; + } + + $output = ['total' => $total, 'items_page' => $perpage, 'page' => $page, 'results' => $results]; echo json_encode($output); - killme(); - + exit(); } From 35a6e33e0dc0331961520d4ce2bdd45402016852 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 23 Dec 2018 19:45:33 -0500 Subject: [PATCH 07/10] [Composer] Add global libraries to autoload --- composer.json | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 5b30459734..1d7348d84a 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "npm-asset/fullcalendar": "^3.0.1", "npm-asset/cropperjs": "1.2.2", "npm-asset/imagesloaded": "4.1.4" - }, + }, "repositories": [ { "type": "vcs", @@ -56,7 +56,15 @@ }, "psr-0": { "": "library/" - } + }, + "files": [ + "include/conversation.php", + "include/dba.php", + "include/enotify.php", + "include/items.php", + "include/text.php", + "boot.php" + ] }, "config": { "autoloader-suffix": "Friendica", From acaee626f5f23f4c1dc19c31896a0797a251b58f Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 24 Dec 2018 09:56:25 -0500 Subject: [PATCH 08/10] Remove include/ requires that are now done directly from Composer --- bin/auth_ejabberd.php | 1 - bin/daemon.php | 1 - boot.php | 2 -- include/api.php | 1 - include/items.php | 3 --- include/text.php | 2 -- mod/acl.php | 2 -- mod/admin.php | 4 ---- mod/allfriends.php | 2 -- mod/attach.php | 2 -- mod/bookmarklet.php | 3 --- mod/common.php | 2 -- mod/community.php | 2 -- mod/dfrn_confirm.php | 3 --- mod/dfrn_notify.php | 2 -- mod/dfrn_poll.php | 2 -- mod/dfrn_request.php | 2 -- mod/display.php | 2 -- mod/events.php | 2 -- mod/feedtest.php | 4 ---- mod/filer.php | 2 -- mod/item.php | 5 ----- mod/like.php | 2 -- mod/lostpass.php | 4 ---- mod/manage.php | 2 -- mod/message.php | 2 -- mod/network.php | 3 --- mod/nodeinfo.php | 2 -- mod/notes.php | 2 -- mod/parse_url.php | 2 -- mod/photos.php | 4 ---- mod/phpinfo.php | 2 -- mod/ping.php | 2 -- mod/poke.php | 2 -- mod/profile.php | 3 --- mod/pubsub.php | 2 -- mod/register.php | 2 -- mod/regmod.php | 2 -- mod/removeme.php | 2 -- mod/salmon.php | 2 -- mod/search.php | 1 - mod/subthread.php | 2 -- mod/tagger.php | 2 -- mod/videos.php | 4 ---- src/App.php | 3 --- src/BaseObject.php | 2 -- src/Content/ForumManager.php | 2 -- src/Content/Nav.php | 3 --- src/Content/OEmbed.php | 2 -- src/Content/Widget.php | 3 --- src/Content/Widget/CalendarExport.php | 3 --- src/Content/Widget/TagCloud.php | 2 -- src/Core/Config.php | 2 -- src/Core/Config/JITConfigAdapter.php | 2 -- src/Core/Config/JITPConfigAdapter.php | 2 -- src/Core/Config/PreloadConfigAdapter.php | 2 -- src/Core/Config/PreloadPConfigAdapter.php | 2 -- src/Core/Console/AutomaticInstallation.php | 2 -- src/Core/Console/DatabaseStructure.php | 3 --- src/Core/Console/GlobalCommunitySilence.php | 2 -- src/Core/Console/Maintenance.php | 3 --- src/Core/Installer.php | 1 - src/Core/L10n.php | 3 --- src/Core/NotificationsManager.php | 2 -- src/Core/PConfig.php | 2 -- src/Core/Session/CacheSessionHandler.php | 3 --- src/Core/Session/DatabaseSessionHandler.php | 4 ---- src/Core/Theme.php | 2 -- src/Core/UserImport.php | 2 -- src/Core/Worker.php | 2 -- src/Database/DBA.php | 2 -- src/Database/DBStructure.php | 5 ----- src/Database/PostUpdate.php | 2 -- src/Model/APContact.php | 2 -- src/Model/Contact.php | 6 ------ src/Model/Conversation.php | 2 -- src/Model/Event.php | 4 ---- src/Model/GContact.php | 2 -- src/Model/Group.php | 4 ---- src/Model/Item.php | 4 ---- src/Model/ItemContent.php | 4 ---- src/Model/ItemURI.php | 2 -- src/Model/Mail.php | 2 -- src/Model/PermissionSet.php | 2 -- src/Model/Photo.php | 2 -- src/Model/Process.php | 2 -- src/Model/Profile.php | 2 -- src/Model/PushSubscriber.php | 2 -- src/Model/Queue.php | 2 -- src/Model/Term.php | 4 ---- src/Model/User.php | 4 ---- src/Module/Hashtag.php | 3 --- src/Module/Login.php | 3 --- src/Module/Logout.php | 2 -- src/Network/FKOAuthDataStore.php | 2 -- src/Network/Probe.php | 2 -- src/Object/Post.php | 5 ----- src/Object/Thread.php | 3 --- src/Protocol/DFRN.php | 6 ------ src/Protocol/Diaspora.php | 3 --- src/Protocol/Feed.php | 3 --- src/Protocol/OStatus.php | 3 --- src/Protocol/PortableContact.php | 2 -- src/Util/ExAuth.php | 2 -- src/Util/ParseUrl.php | 2 -- src/Util/Temporal.php | 3 --- src/Worker/Cron.php | 2 -- src/Worker/CronJobs.php | 1 - src/Worker/DBClean.php | 2 -- src/Worker/Delivery.php | 2 -- src/Worker/Expire.php | 4 ---- src/Worker/Notifier.php | 3 --- src/Worker/OnePoll.php | 4 ---- src/Worker/PubSubPublish.php | 2 -- src/Worker/Queue.php | 3 --- src/Worker/RemoveContact.php | 2 -- src/Worker/RemoveUser.php | 2 -- src/Worker/SpoolPost.php | 2 -- tests/src/Core/InstallerTest.php | 3 --- tests/src/Network/CurlResultTest.php | 8 -------- update.php | 2 -- view/theme/frio/php/scheme.php | 2 -- 122 files changed, 312 deletions(-) diff --git a/bin/auth_ejabberd.php b/bin/auth_ejabberd.php index 1f03b94af9..fc57a74204 100755 --- a/bin/auth_ejabberd.php +++ b/bin/auth_ejabberd.php @@ -50,7 +50,6 @@ $directory = realpath($directory . DIRECTORY_SEPARATOR . ".."); chdir($directory); require_once "boot.php"; -require_once "include/dba.php"; $a = new App(dirname(__DIR__)); diff --git a/bin/daemon.php b/bin/daemon.php index 9df8b8957a..de76c99efd 100755 --- a/bin/daemon.php +++ b/bin/daemon.php @@ -31,7 +31,6 @@ if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) { } require_once "boot.php"; -require_once "include/dba.php"; $a = new App(dirname(__DIR__)); diff --git a/boot.php b/boot.php index 222011f6b7..d44cf24bee 100644 --- a/boot.php +++ b/boot.php @@ -35,8 +35,6 @@ use Friendica\Model\Contact; use Friendica\Model\Conversation; use Friendica\Util\DateTimeFormat; -require_once 'include/text.php'; - define('FRIENDICA_PLATFORM', 'Friendica'); define('FRIENDICA_CODENAME', 'The Tazmans Flax-lily'); define('FRIENDICA_VERSION', '2018.12-rc'); diff --git a/include/api.php b/include/api.php index 77dfb7462b..1676748f75 100644 --- a/include/api.php +++ b/include/api.php @@ -46,7 +46,6 @@ use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Strings; use Friendica\Util\XML; -require_once 'include/conversation.php'; require_once 'mod/share.php'; require_once 'mod/item.php'; require_once 'mod/wall_upload.php'; diff --git a/include/items.php b/include/items.php index b4793b888f..ddec2231d8 100644 --- a/include/items.php +++ b/include/items.php @@ -24,10 +24,7 @@ use Friendica\Util\ParseUrl; use Friendica\Util\Strings; use Friendica\Util\Temporal; -require_once 'include/text.php'; require_once 'mod/share.php'; -require_once 'include/enotify.php'; - function add_page_info_data(array $data, $no_photos = false) { Addon::callHooks('page_info_data', $data); diff --git a/include/text.php b/include/text.php index ee83345c09..ff9fa5511a 100644 --- a/include/text.php +++ b/include/text.php @@ -30,8 +30,6 @@ use Friendica\Util\Strings; use Friendica\Util\XML; use Friendica\Content\Text\HTML; -require_once "include/conversation.php"; - /** * Turn user/group ACLs stored as angle bracketed text into arrays * diff --git a/mod/acl.php b/mod/acl.php index 86eafe2902..e91919265b 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -14,8 +14,6 @@ use Friendica\Model\Item; use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Strings; -require_once 'include/dba.php'; - function acl_content(App $a) { if (!local_user()) { diff --git a/mod/admin.php b/mod/admin.php index 89514397f0..db66eabbc4 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -33,10 +33,6 @@ use Friendica\Util\Network; use Friendica\Util\Strings; use Friendica\Util\Temporal; -require_once 'include/enotify.php'; -require_once 'include/text.php'; -require_once 'include/items.php'; - /** * @brief Process send data from the admin panels subpages * diff --git a/mod/allfriends.php b/mod/allfriends.php index b233a46182..80da130480 100644 --- a/mod/allfriends.php +++ b/mod/allfriends.php @@ -15,8 +15,6 @@ use Friendica\Module; use Friendica\Util\Proxy as ProxyUtils; -require_once 'include/dba.php'; - function allfriends_content(App $a) { $o = ''; diff --git a/mod/attach.php b/mod/attach.php index 9ca701ba35..cf2c8cc6dd 100644 --- a/mod/attach.php +++ b/mod/attach.php @@ -8,8 +8,6 @@ use Friendica\Core\L10n; use Friendica\Database\DBA; use Friendica\Util\Security; -require_once 'include/dba.php'; - function attach_init(App $a) { if ($a->argc != 2) { diff --git a/mod/bookmarklet.php b/mod/bookmarklet.php index d9c2f52f82..be3e1fd336 100644 --- a/mod/bookmarklet.php +++ b/mod/bookmarklet.php @@ -11,9 +11,6 @@ use Friendica\Core\System; use Friendica\Module\Login; use Friendica\Util\Strings; -require_once 'include/conversation.php'; -require_once 'include/items.php'; - function bookmarklet_init() { $_GET["mode"] = "minimal"; diff --git a/mod/common.php b/mod/common.php index c88d6ee77c..5d98f07321 100644 --- a/mod/common.php +++ b/mod/common.php @@ -14,8 +14,6 @@ use Friendica\Module; use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Strings; -require_once 'include/dba.php'; - function common_content(App $a) { $o = ''; diff --git a/mod/community.php b/mod/community.php index 3666881732..063e1c693e 100644 --- a/mod/community.php +++ b/mod/community.php @@ -93,8 +93,6 @@ function community_content(App $a, $update = 0) } } - require_once 'include/conversation.php'; - if (!$update) { $tabs = []; diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 6f365c5315..c78cf45e72 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -36,9 +36,6 @@ use Friendica\Util\Network; use Friendica\Util\Strings; use Friendica\Util\XML; -require_once 'include/enotify.php'; -require_once 'include/items.php'; - function dfrn_confirm_post(App $a, $handsfree = null) { $node = null; diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 51576b3b4e..b911a27e21 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -16,8 +16,6 @@ use Friendica\Protocol\DFRN; use Friendica\Protocol\Diaspora; use Friendica\Util\Strings; -require_once 'include/items.php'; - function dfrn_notify_post(App $a) { Logger::log(__function__, Logger::TRACE); diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index 001202d5e5..a46d215e76 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -17,8 +17,6 @@ use Friendica\Util\Network; use Friendica\Util\Strings; use Friendica\Util\XML; -require_once 'include/items.php'; - function dfrn_poll_init(App $a) { Login::sessionAuth(); diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 16a2da5560..35e308531d 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -30,8 +30,6 @@ use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; use Friendica\Util\Strings; -require_once 'include/enotify.php'; - function dfrn_request_init(App $a) { if ($a->argc > 1) { diff --git a/mod/display.php b/mod/display.php index 2a4d2abf43..054ba1924f 100644 --- a/mod/display.php +++ b/mod/display.php @@ -214,8 +214,6 @@ function display_content(App $a, $update = false, $update_uid = 0) return; } - require_once 'include/conversation.php'; - $o = ''; if ($update) { diff --git a/mod/events.php b/mod/events.php index f147e00545..c61ad9dd34 100644 --- a/mod/events.php +++ b/mod/events.php @@ -22,8 +22,6 @@ use Friendica\Util\DateTimeFormat; use Friendica\Util\Strings; use Friendica\Util\Temporal; -require_once 'include/items.php'; - function events_init(App $a) { if (!local_user()) { diff --git a/mod/feedtest.php b/mod/feedtest.php index edb75aefc1..8508b93e47 100644 --- a/mod/feedtest.php +++ b/mod/feedtest.php @@ -12,10 +12,6 @@ use Friendica\Model\Contact; use Friendica\Protocol\Feed; use Friendica\Util\Network; -require_once 'boot.php'; -require_once 'include/dba.php'; -require_once 'include/text.php'; - function feedtest_content(App $a) { if (!local_user()) { diff --git a/mod/filer.php b/mod/filer.php index 3508079400..4580dc6f67 100644 --- a/mod/filer.php +++ b/mod/filer.php @@ -10,8 +10,6 @@ use Friendica\Core\Renderer; use Friendica\Model\FileTag; use Friendica\Util\XML; -require_once 'include/items.php'; - function filer_content(App $a) { if (! local_user()) { diff --git a/mod/item.php b/mod/item.php index cc801df57c..02a61ebefc 100644 --- a/mod/item.php +++ b/mod/item.php @@ -38,10 +38,6 @@ use Friendica\Util\Emailer; use Friendica\Util\Security; use Friendica\Util\Strings; -require_once 'include/enotify.php'; -require_once 'include/text.php'; -require_once 'include/items.php'; - function item_post(App $a) { if (!local_user() && !remote_user()) { return 0; @@ -668,7 +664,6 @@ function item_post(App $a) { // preview mode - prepare the body for display and send it via json if ($preview) { - require_once 'include/conversation.php'; // We set the datarray ID to -1 because in preview mode the dataray // doesn't have an ID. $datarray["id"] = -1; diff --git a/mod/like.php b/mod/like.php index 5ea30a3ffe..7ce7b1a1b9 100644 --- a/mod/like.php +++ b/mod/like.php @@ -5,8 +5,6 @@ use Friendica\Core\System; use Friendica\Model\Item; use Friendica\Util\Strings; -require_once 'include/items.php'; - function like_content(App $a) { if (!local_user() && !remote_user()) { return false; diff --git a/mod/lostpass.php b/mod/lostpass.php index 42a1764bf9..39209af951 100644 --- a/mod/lostpass.php +++ b/mod/lostpass.php @@ -13,10 +13,6 @@ use Friendica\Model\User; use Friendica\Util\DateTimeFormat; use Friendica\Util\Strings; -require_once 'boot.php'; -require_once 'include/enotify.php'; -require_once 'include/text.php'; - function lostpass_post(App $a) { $loginame = Strings::escapeTags(trim($_POST['login-name'])); diff --git a/mod/manage.php b/mod/manage.php index b42b990aad..4d0b65de15 100644 --- a/mod/manage.php +++ b/mod/manage.php @@ -10,8 +10,6 @@ use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Database\DBA; -require_once "include/text.php"; - function manage_post(App $a) { if (! local_user()) { diff --git a/mod/message.php b/mod/message.php index af19487990..b812f5cdd5 100644 --- a/mod/message.php +++ b/mod/message.php @@ -21,8 +21,6 @@ use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Strings; use Friendica\Util\Temporal; -require_once 'include/conversation.php'; - function message_init(App $a) { $tabs = ''; diff --git a/mod/network.php b/mod/network.php index 46861e3943..2c5a54ce5d 100644 --- a/mod/network.php +++ b/mod/network.php @@ -30,9 +30,6 @@ use Friendica\Util\DateTimeFormat; use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Strings; -require_once 'include/conversation.php'; -require_once 'include/items.php'; - function network_init(App $a) { if (!local_user()) { diff --git a/mod/nodeinfo.php b/mod/nodeinfo.php index ca4a622fbb..d1df217040 100644 --- a/mod/nodeinfo.php +++ b/mod/nodeinfo.php @@ -12,8 +12,6 @@ use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Util\Network; -require_once 'include/dba.php'; - function nodeinfo_wellknown(App $a) { $nodeinfo = ['links' => [['rel' => 'http://nodeinfo.diaspora.software/ns/schema/1.0', 'href' => System::baseUrl().'/nodeinfo/1.0']]]; diff --git a/mod/notes.php b/mod/notes.php index 90afa16ca5..6ecc819240 100644 --- a/mod/notes.php +++ b/mod/notes.php @@ -34,8 +34,6 @@ function notes_content(App $a, $update = false) return; } - require_once 'include/conversation.php'; - $o = Profile::getTabs($a, true); if (!$update) { diff --git a/mod/parse_url.php b/mod/parse_url.php index 07f319fdca..02fbfa1b7d 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -15,8 +15,6 @@ use Friendica\Core\Logger; use Friendica\Util\Network; use Friendica\Util\ParseUrl; -require_once 'include/items.php'; - function parse_url_content(App $a) { $text = null; diff --git a/mod/photos.php b/mod/photos.php index d1dffd4d05..05943352ba 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -34,8 +34,6 @@ use Friendica\Util\Temporal; use Friendica\Util\Strings; use Friendica\Util\XML; -require_once 'include/items.php'; - function photos_init(App $a) { if ($a->argc > 1) { @@ -946,8 +944,6 @@ function photos_content(App $a) return; } - require_once 'include/conversation.php'; - if (empty($a->data['user'])) { notice(L10n::t('No photos selected') . EOL); return; diff --git a/mod/phpinfo.php b/mod/phpinfo.php index ec2897dc6d..0155609abd 100644 --- a/mod/phpinfo.php +++ b/mod/phpinfo.php @@ -3,8 +3,6 @@ * @file mod/phpinfo.php */ -require_once 'boot.php'; - function phpinfo_content() { if (!is_site_admin()) { diff --git a/mod/ping.php b/mod/ping.php index 40700f36f8..b315ecf4b9 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -22,8 +22,6 @@ use Friendica\Util\Temporal; use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\XML; -require_once 'include/enotify.php'; - /** * @brief Outputs the counts and the lists of various notifications * diff --git a/mod/poke.php b/mod/poke.php index f1bad7742b..fb1fae85d6 100644 --- a/mod/poke.php +++ b/mod/poke.php @@ -25,8 +25,6 @@ use Friendica\Model\Item; use Friendica\Util\Strings; use Friendica\Util\XML; -require_once 'include/items.php'; - function poke_init(App $a) { if (!local_user()) { diff --git a/mod/profile.php b/mod/profile.php index f84a4be190..593e2ee19f 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -135,9 +135,6 @@ function profile_content(App $a, $update = 0) return Login::form(); } - require_once 'include/conversation.php'; - require_once 'include/items.php'; - $groups = []; $remote_cid = null; diff --git a/mod/pubsub.php b/mod/pubsub.php index cd2f21dd67..8d6e81a685 100644 --- a/mod/pubsub.php +++ b/mod/pubsub.php @@ -9,8 +9,6 @@ use Friendica\Protocol\OStatus; use Friendica\Util\Strings; use Friendica\Core\System; -require_once 'include/items.php'; - function hub_return($valid, $body) { if ($valid) { diff --git a/mod/register.php b/mod/register.php index 03d4cb02f6..b13ec22509 100644 --- a/mod/register.php +++ b/mod/register.php @@ -18,8 +18,6 @@ use Friendica\Model; use Friendica\Module\Tos; use Friendica\Util\Strings; -require_once 'include/enotify.php'; - function register_post(App $a) { BaseModule::checkFormSecurityTokenRedirectOnError('/register', 'register'); diff --git a/mod/regmod.php b/mod/regmod.php index a7aebf6b0a..a772a78ce7 100644 --- a/mod/regmod.php +++ b/mod/regmod.php @@ -13,8 +13,6 @@ use Friendica\Model\Register; use Friendica\Model\User; use Friendica\Module\Login; -require_once 'include/enotify.php'; - function user_allow($hash) { $a = get_app(); diff --git a/mod/removeme.php b/mod/removeme.php index 19bf0bc851..741a67598a 100644 --- a/mod/removeme.php +++ b/mod/removeme.php @@ -12,8 +12,6 @@ use Friendica\Database\DBA; use Friendica\Model\User; use Friendica\Util\Strings; -require_once 'include/enotify.php'; - function removeme_post(App $a) { if (!local_user()) { diff --git a/mod/salmon.php b/mod/salmon.php index 02339c7779..eef2510762 100644 --- a/mod/salmon.php +++ b/mod/salmon.php @@ -14,8 +14,6 @@ use Friendica\Protocol\Salmon; use Friendica\Util\Crypto; use Friendica\Util\Strings; -require_once 'include/items.php'; - function salmon_post(App $a, $xml = '') { if (empty($xml)) { diff --git a/mod/search.php b/mod/search.php index b40fe07157..2cdfd6e128 100644 --- a/mod/search.php +++ b/mod/search.php @@ -18,7 +18,6 @@ use Friendica\Database\DBA; use Friendica\Model\Item; use Friendica\Util\Strings; -require_once 'include/conversation.php'; require_once 'mod/dirfind.php'; function search_saved_searches() { diff --git a/mod/subthread.php b/mod/subthread.php index 90ab5a3aab..bd7fee534e 100644 --- a/mod/subthread.php +++ b/mod/subthread.php @@ -13,8 +13,6 @@ use Friendica\Util\Security; use Friendica\Util\Strings; use Friendica\Util\XML; -require_once 'include/items.php'; - function subthread_content(App $a) { if (!local_user() && !remote_user()) { diff --git a/mod/tagger.php b/mod/tagger.php index f8979ae6ca..78133a9e18 100644 --- a/mod/tagger.php +++ b/mod/tagger.php @@ -13,8 +13,6 @@ use Friendica\Model\Item; use Friendica\Util\Strings; use Friendica\Util\XML; -require_once 'include/items.php'; - function tagger_content(App $a) { if (!local_user() && !remote_user()) { diff --git a/mod/videos.php b/mod/videos.php index 9e64321f3e..d8aac18210 100644 --- a/mod/videos.php +++ b/mod/videos.php @@ -18,8 +18,6 @@ use Friendica\Model\Profile; use Friendica\Protocol\DFRN; use Friendica\Util\Security; -require_once 'include/items.php'; - function videos_init(App $a) { if ($a->argc > 1) { @@ -195,8 +193,6 @@ function videos_content(App $a) return; } - require_once 'include/conversation.php'; - if (empty($a->data['user'])) { notice(L10n::t('No videos selected') . EOL ); return; diff --git a/src/App.php b/src/App.php index 261c3e74cb..57d61d04bb 100644 --- a/src/App.php +++ b/src/App.php @@ -11,9 +11,6 @@ use Exception; use Friendica\Database\DBA; use Friendica\Network\HTTPException\InternalServerErrorException; -require_once 'boot.php'; -require_once 'include/text.php'; - /** * * class: App diff --git a/src/BaseObject.php b/src/BaseObject.php index d006c249de..33ed677546 100644 --- a/src/BaseObject.php +++ b/src/BaseObject.php @@ -4,8 +4,6 @@ */ namespace Friendica; -require_once 'boot.php'; - /** * Basic object * diff --git a/src/Content/ForumManager.php b/src/Content/ForumManager.php index 7b947359a6..ac745c50ff 100644 --- a/src/Content/ForumManager.php +++ b/src/Content/ForumManager.php @@ -15,8 +15,6 @@ use Friendica\Database\DBA; use Friendica\Model\Contact; use Friendica\Util\Proxy as ProxyUtils; -require_once 'include/dba.php'; - /** * @brief This class handles methods related to the forum functionality */ diff --git a/src/Content/Nav.php b/src/Content/Nav.php index 5166d5848e..81985ed5ba 100644 --- a/src/Content/Nav.php +++ b/src/Content/Nav.php @@ -15,9 +15,6 @@ use Friendica\Database\DBA; use Friendica\Model\Contact; use Friendica\Model\Profile; -require_once 'boot.php'; -require_once 'include/text.php'; - class Nav { private static $selected = [ diff --git a/src/Content/OEmbed.php b/src/Content/OEmbed.php index 6eb11c7b3b..243b2d949d 100644 --- a/src/Content/OEmbed.php +++ b/src/Content/OEmbed.php @@ -23,8 +23,6 @@ use Friendica\Util\ParseUrl; use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Strings; -require_once 'include/dba.php'; - /** * Handles all OEmbed content fetching and replacement * diff --git a/src/Content/Widget.php b/src/Content/Widget.php index d4d4ff5494..2a11cc5919 100644 --- a/src/Content/Widget.php +++ b/src/Content/Widget.php @@ -21,9 +21,6 @@ use Friendica\Model\Profile; use Friendica\Util\Strings; use Friendica\Util\XML; -require_once 'boot.php'; -require_once 'include/dba.php'; - class Widget { /** diff --git a/src/Content/Widget/CalendarExport.php b/src/Content/Widget/CalendarExport.php index e8bec0b95a..7bfa73c607 100644 --- a/src/Content/Widget/CalendarExport.php +++ b/src/Content/Widget/CalendarExport.php @@ -10,9 +10,6 @@ use Friendica\Content\Feature; use Friendica\Core\L10n; use Friendica\Core\Renderer; -require_once 'boot.php'; -require_once 'include/text.php'; - /** * TagCloud widget * diff --git a/src/Content/Widget/TagCloud.php b/src/Content/Widget/TagCloud.php index 23aac19eb7..f214ba7999 100644 --- a/src/Content/Widget/TagCloud.php +++ b/src/Content/Widget/TagCloud.php @@ -13,8 +13,6 @@ use Friendica\Database\DBA; use Friendica\Model\Item; use Friendica\Util\Security; -require_once 'include/dba.php'; - /** * TagCloud widget * diff --git a/src/Core/Config.php b/src/Core/Config.php index a07bbd31c9..f191c10a0e 100644 --- a/src/Core/Config.php +++ b/src/Core/Config.php @@ -12,8 +12,6 @@ use Friendica\App; use Friendica\BaseObject; use Friendica\Core\Config; -require_once 'include/dba.php'; - /** * @brief Arbitrary system configuration storage * diff --git a/src/Core/Config/JITConfigAdapter.php b/src/Core/Config/JITConfigAdapter.php index 2018f583d6..ed5f1a3f67 100644 --- a/src/Core/Config/JITConfigAdapter.php +++ b/src/Core/Config/JITConfigAdapter.php @@ -4,8 +4,6 @@ namespace Friendica\Core\Config; use Friendica\BaseObject; use Friendica\Database\DBA; -require_once 'include/dba.php'; - /** * JustInTime Configuration Adapter * diff --git a/src/Core/Config/JITPConfigAdapter.php b/src/Core/Config/JITPConfigAdapter.php index 512004b508..bdaca407ff 100644 --- a/src/Core/Config/JITPConfigAdapter.php +++ b/src/Core/Config/JITPConfigAdapter.php @@ -4,8 +4,6 @@ namespace Friendica\Core\Config; use Friendica\BaseObject; use Friendica\Database\DBA; -require_once 'include/dba.php'; - /** * JustInTime User Configuration Adapter * diff --git a/src/Core/Config/PreloadConfigAdapter.php b/src/Core/Config/PreloadConfigAdapter.php index 67cf30845c..ac59d94558 100644 --- a/src/Core/Config/PreloadConfigAdapter.php +++ b/src/Core/Config/PreloadConfigAdapter.php @@ -6,8 +6,6 @@ use Exception; use Friendica\BaseObject; use Friendica\Database\DBA; -require_once 'include/dba.php'; - /** * Preload Configuration Adapter * diff --git a/src/Core/Config/PreloadPConfigAdapter.php b/src/Core/Config/PreloadPConfigAdapter.php index ebccb018bc..6658efa3f6 100644 --- a/src/Core/Config/PreloadPConfigAdapter.php +++ b/src/Core/Config/PreloadPConfigAdapter.php @@ -6,8 +6,6 @@ use Exception; use Friendica\BaseObject; use Friendica\Database\DBA; -require_once 'include/dba.php'; - /** * Preload User Configuration Adapter * diff --git a/src/Core/Console/AutomaticInstallation.php b/src/Core/Console/AutomaticInstallation.php index e6065dfb87..c2f9df383b 100644 --- a/src/Core/Console/AutomaticInstallation.php +++ b/src/Core/Console/AutomaticInstallation.php @@ -11,8 +11,6 @@ use Friendica\Database\DBA; use Friendica\Database\DBStructure; use RuntimeException; -require_once 'include/dba.php'; - class AutomaticInstallation extends Console { protected function getHelp() diff --git a/src/Core/Console/DatabaseStructure.php b/src/Core/Console/DatabaseStructure.php index f3badc1969..47e6af5eb1 100644 --- a/src/Core/Console/DatabaseStructure.php +++ b/src/Core/Console/DatabaseStructure.php @@ -8,9 +8,6 @@ use Friendica\Database\DBA; use Friendica\Database\DBStructure; use RuntimeException; -require_once 'boot.php'; -require_once 'include/dba.php'; - /** * @brief Performs database updates from the command line * diff --git a/src/Core/Console/GlobalCommunitySilence.php b/src/Core/Console/GlobalCommunitySilence.php index 01413cab13..a1753ede25 100644 --- a/src/Core/Console/GlobalCommunitySilence.php +++ b/src/Core/Console/GlobalCommunitySilence.php @@ -8,8 +8,6 @@ use Friendica\Network\Probe; use Friendica\Util\Strings; use RuntimeException; -require_once 'include/text.php'; - /** * @brief tool to silence accounts on the global community page * diff --git a/src/Core/Console/Maintenance.php b/src/Core/Console/Maintenance.php index c8214b1614..0cb0da9c60 100644 --- a/src/Core/Console/Maintenance.php +++ b/src/Core/Console/Maintenance.php @@ -4,9 +4,6 @@ namespace Friendica\Core\Console; use Friendica\Core; -require_once 'boot.php'; -require_once 'include/dba.php'; - /** * @brief Sets maintenance mode for this node * diff --git a/src/Core/Installer.php b/src/Core/Installer.php index b84bcd916e..0169f7292b 100644 --- a/src/Core/Installer.php +++ b/src/Core/Installer.php @@ -578,7 +578,6 @@ class Installer */ public function checkDB($dbhost, $dbuser, $dbpass, $dbdata) { - require_once 'include/dba.php'; if (!DBA::connect($dbhost, $dbuser, $dbpass, $dbdata)) { $this->addCheck(L10n::t('Could not connect to database.'), false, true, ''); diff --git a/src/Core/L10n.php b/src/Core/L10n.php index 1283f87284..aa36c2e4f9 100644 --- a/src/Core/L10n.php +++ b/src/Core/L10n.php @@ -10,9 +10,6 @@ use Friendica\Core\Addon; use Friendica\Core\Logger; use Friendica\Core\System; -require_once 'boot.php'; -require_once 'include/dba.php'; - /** * Provide Language, Translation, and Localization functions to the application * Localization can be referred to by the numeronym L10N (as in: "L", followed by ten more letters, and then "N"). diff --git a/src/Core/NotificationsManager.php b/src/Core/NotificationsManager.php index d11fea03a1..5a2efe297b 100644 --- a/src/Core/NotificationsManager.php +++ b/src/Core/NotificationsManager.php @@ -19,8 +19,6 @@ use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Temporal; use Friendica\Util\XML; -require_once 'include/dba.php'; - /** * @brief Methods for read and write notifications from/to database * or for formatting notifications diff --git a/src/Core/PConfig.php b/src/Core/PConfig.php index 2080f716ce..752d919199 100644 --- a/src/Core/PConfig.php +++ b/src/Core/PConfig.php @@ -11,8 +11,6 @@ namespace Friendica\Core; use Friendica\App; use Friendica\BaseObject; -require_once 'include/dba.php'; - /** * @brief Management of user configuration storage * Note: diff --git a/src/Core/Session/CacheSessionHandler.php b/src/Core/Session/CacheSessionHandler.php index 1baf111e93..08490818ce 100644 --- a/src/Core/Session/CacheSessionHandler.php +++ b/src/Core/Session/CacheSessionHandler.php @@ -8,9 +8,6 @@ use Friendica\Core\Logger; use Friendica\Core\Session; use SessionHandlerInterface; -require_once 'boot.php'; -require_once 'include/text.php'; - /** * SessionHandler using Friendica Cache * diff --git a/src/Core/Session/DatabaseSessionHandler.php b/src/Core/Session/DatabaseSessionHandler.php index c4f23b1bfc..1c3da6eb3a 100644 --- a/src/Core/Session/DatabaseSessionHandler.php +++ b/src/Core/Session/DatabaseSessionHandler.php @@ -8,10 +8,6 @@ use Friendica\Core\Session; use Friendica\Database\DBA; use SessionHandlerInterface; -require_once 'boot.php'; -require_once 'include/dba.php'; -require_once 'include/text.php'; - /** * SessionHandler using database * diff --git a/src/Core/Theme.php b/src/Core/Theme.php index e5026904b8..1524c29bac 100644 --- a/src/Core/Theme.php +++ b/src/Core/Theme.php @@ -9,8 +9,6 @@ namespace Friendica\Core; use Friendica\Core\Logger; use Friendica\Core\System; -require_once 'boot.php'; - /** * Some functions to handle themes */ diff --git a/src/Core/UserImport.php b/src/Core/UserImport.php index 70d93b0cc0..59ab7af4aa 100644 --- a/src/Core/UserImport.php +++ b/src/Core/UserImport.php @@ -13,8 +13,6 @@ use Friendica\Model\Photo; use Friendica\Object\Image; use Friendica\Util\Strings; -require_once "include/dba.php"; - /** * @brief UserImport class */ diff --git a/src/Core/Worker.php b/src/Core/Worker.php index f3736d2573..2c811e3bda 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -11,8 +11,6 @@ use Friendica\Model\Process; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; -require_once 'include/dba.php'; - /** * @file src/Core/Worker.php * diff --git a/src/Database/DBA.php b/src/Database/DBA.php index af0c25d0dd..f1c0ead6af 100644 --- a/src/Database/DBA.php +++ b/src/Database/DBA.php @@ -16,8 +16,6 @@ use PDO; use PDOException; use PDOStatement; -require_once 'include/dba.php'; - /** * @class MySQL database class * diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 1a556b7bc7..3043ae1322 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -12,11 +12,6 @@ use Friendica\Core\L10n; use Friendica\Core\Logger; use Friendica\Util\DateTimeFormat; -require_once 'boot.php'; -require_once 'include/dba.php'; -require_once 'include/enotify.php'; -require_once 'include/text.php'; - /** * @brief This class contain functions for the database management * diff --git a/src/Database/PostUpdate.php b/src/Database/PostUpdate.php index 94c02013e7..9329e31cac 100644 --- a/src/Database/PostUpdate.php +++ b/src/Database/PostUpdate.php @@ -13,8 +13,6 @@ use Friendica\Model\ItemURI; use Friendica\Model\PermissionSet; use Friendica\Database\DBA; -require_once 'include/dba.php'; - /** * Post update functions */ diff --git a/src/Model/APContact.php b/src/Model/APContact.php index c306b3e007..bbaf6dad62 100644 --- a/src/Model/APContact.php +++ b/src/Model/APContact.php @@ -16,8 +16,6 @@ use Friendica\Util\JsonLD; use Friendica\Util\DateTimeFormat; use Friendica\Util\Strings; -require_once 'boot.php'; - class APContact extends BaseObject { /** diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 5894814ea6..4a63a6b49a 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -27,10 +27,6 @@ use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; use Friendica\Util\Strings; -require_once 'boot.php'; -require_once 'include/dba.php'; -require_once 'include/text.php'; - /** * @brief functions for interacting with a contact */ @@ -1376,8 +1372,6 @@ class Contact extends BaseObject { $a = self::getApp(); - require_once 'include/conversation.php'; - $cid = Self::getIdForURL($contact_url); $contact = DBA::selectFirst('contact', ['contact-type', 'network'], ['id' => $cid]); diff --git a/src/Model/Conversation.php b/src/Model/Conversation.php index 159cd2f20f..b8e55e5b96 100644 --- a/src/Model/Conversation.php +++ b/src/Model/Conversation.php @@ -10,8 +10,6 @@ use Friendica\Core\Protocol; use Friendica\Database\DBA; use Friendica\Util\DateTimeFormat; -require_once "include/dba.php"; - class Conversation { /* diff --git a/src/Model/Event.php b/src/Model/Event.php index 886f124153..784a9ffee8 100644 --- a/src/Model/Event.php +++ b/src/Model/Event.php @@ -19,10 +19,6 @@ use Friendica\Util\DateTimeFormat; use Friendica\Util\Map; use Friendica\Util\XML; -require_once 'boot.php'; -require_once 'include/dba.php'; -require_once 'include/items.php'; - /** * @brief functions for interacting with the event database table */ diff --git a/src/Model/GContact.php b/src/Model/GContact.php index 44d1edecd7..c3d58aae74 100644 --- a/src/Model/GContact.php +++ b/src/Model/GContact.php @@ -19,8 +19,6 @@ use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; use Friendica\Util\Strings; -require_once 'include/dba.php'; - /** * @brief This class handles GlobalContact related functions */ diff --git a/src/Model/Group.php b/src/Model/Group.php index 5424b77dcf..9a4fc23407 100644 --- a/src/Model/Group.php +++ b/src/Model/Group.php @@ -12,10 +12,6 @@ use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\Util\Security; -require_once 'boot.php'; -require_once 'include/dba.php'; -require_once 'include/text.php'; - /** * @brief functions for interacting with the group database table */ diff --git a/src/Model/Item.php b/src/Model/Item.php index 9acff3bfa8..939ee43bf4 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -36,10 +36,6 @@ use Friendica\Util\Security; use Friendica\Util\Strings; use Text_LanguageDetect; -require_once 'boot.php'; -require_once 'include/items.php'; -require_once 'include/text.php'; - class Item extends BaseObject { // Posting types, inspired by https://www.w3.org/TR/activitystreams-vocabulary/#object-types diff --git a/src/Model/ItemContent.php b/src/Model/ItemContent.php index c51f471d85..25ae6b8424 100644 --- a/src/Model/ItemContent.php +++ b/src/Model/ItemContent.php @@ -11,10 +11,6 @@ use Friendica\Content\Text; use Friendica\Core\PConfig; use Friendica\Core\Protocol; -require_once 'boot.php'; -require_once 'include/items.php'; -require_once 'include/text.php'; - class ItemContent extends BaseObject { /** diff --git a/src/Model/ItemURI.php b/src/Model/ItemURI.php index 452f7e57c8..56e9e1caae 100644 --- a/src/Model/ItemURI.php +++ b/src/Model/ItemURI.php @@ -9,8 +9,6 @@ namespace Friendica\Model; use Friendica\BaseObject; use Friendica\Database\DBA; -require_once 'boot.php'; - class ItemURI extends BaseObject { /** diff --git a/src/Model/Mail.php b/src/Model/Mail.php index 815b0051d9..ec02311078 100644 --- a/src/Model/Mail.php +++ b/src/Model/Mail.php @@ -13,8 +13,6 @@ use Friendica\Database\DBA; use Friendica\Network\Probe; use Friendica\Util\DateTimeFormat; -require_once 'include/dba.php'; - /** * Class to handle private messages */ diff --git a/src/Model/PermissionSet.php b/src/Model/PermissionSet.php index 6506c70940..ab6c46afb2 100644 --- a/src/Model/PermissionSet.php +++ b/src/Model/PermissionSet.php @@ -7,8 +7,6 @@ namespace Friendica\Model; use Friendica\BaseObject; use Friendica\Database\DBA; -require_once 'include/dba.php'; - /** * @brief functions for interacting with the permission set of an object (item, photo, event, ...) */ diff --git a/src/Model/Photo.php b/src/Model/Photo.php index a87730087f..4a9e11c554 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -16,8 +16,6 @@ use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; use Friendica\Util\Security; -require_once 'include/dba.php'; - /** * Class to handle photo dabatase table */ diff --git a/src/Model/Process.php b/src/Model/Process.php index 40f0c52bdb..4d50ecd4eb 100644 --- a/src/Model/Process.php +++ b/src/Model/Process.php @@ -8,8 +8,6 @@ use Friendica\BaseObject; use Friendica\Database\DBA; use Friendica\Util\DateTimeFormat; -require_once 'include/dba.php'; - /** * @brief functions for interacting with a process */ diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 8267674e52..c0ee3ec6bb 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -28,8 +28,6 @@ use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Strings; use Friendica\Util\Temporal; -require_once 'include/dba.php'; - class Profile { /** diff --git a/src/Model/PushSubscriber.php b/src/Model/PushSubscriber.php index 44495daeef..fb34bb55f4 100644 --- a/src/Model/PushSubscriber.php +++ b/src/Model/PushSubscriber.php @@ -9,8 +9,6 @@ use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\Util\DateTimeFormat; -require_once 'include/dba.php'; - class PushSubscriber { /** diff --git a/src/Model/Queue.php b/src/Model/Queue.php index 7ffc64bf9e..b2c002574c 100644 --- a/src/Model/Queue.php +++ b/src/Model/Queue.php @@ -9,8 +9,6 @@ use Friendica\Core\Logger; use Friendica\Database\DBA; use Friendica\Util\DateTimeFormat; -require_once 'include/dba.php'; - class Queue { /** diff --git a/src/Model/Term.php b/src/Model/Term.php index 0d44acd2c9..7f494fc4af 100644 --- a/src/Model/Term.php +++ b/src/Model/Term.php @@ -7,10 +7,6 @@ namespace Friendica\Model; use Friendica\Core\System; use Friendica\Database\DBA; -require_once 'boot.php'; -require_once 'include/conversation.php'; -require_once 'include/dba.php'; - class Term { public static function tagTextFromItemId($itemid) diff --git a/src/Model/User.php b/src/Model/User.php index a6a9fc9525..c71ae475e9 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -24,10 +24,6 @@ use Friendica\Util\Network; use Friendica\Util\Strings; use LightOpenID; -require_once 'boot.php'; -require_once 'include/dba.php'; -require_once 'include/enotify.php'; -require_once 'include/text.php'; /** * @brief This class handles User related functions */ diff --git a/src/Module/Hashtag.php b/src/Module/Hashtag.php index 4d09183529..411da5ce5e 100644 --- a/src/Module/Hashtag.php +++ b/src/Module/Hashtag.php @@ -9,9 +9,6 @@ use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Util\Strings; -require_once 'include/dba.php'; -require_once 'include/text.php'; - /** * Hashtag module. */ diff --git a/src/Module/Login.php b/src/Module/Login.php index 82d7049828..b312a7879d 100644 --- a/src/Module/Login.php +++ b/src/Module/Login.php @@ -20,9 +20,6 @@ use Friendica\Util\Network; use Friendica\Util\Strings; use LightOpenID; -require_once 'boot.php'; -require_once 'include/text.php'; - /** * Login module * diff --git a/src/Module/Logout.php b/src/Module/Logout.php index f212a89402..7024fc110a 100644 --- a/src/Module/Logout.php +++ b/src/Module/Logout.php @@ -10,8 +10,6 @@ use Friendica\Core\Authentication; use Friendica\Core\L10n; use Friendica\Core\System; -require_once 'boot.php'; - /** * Logout module * diff --git a/src/Network/FKOAuthDataStore.php b/src/Network/FKOAuthDataStore.php index 44e14f2156..276ba2fcbe 100644 --- a/src/Network/FKOAuthDataStore.php +++ b/src/Network/FKOAuthDataStore.php @@ -19,8 +19,6 @@ use OAuthToken; define('REQUEST_TOKEN_DURATION', 300); define('ACCESS_TOKEN_DURATION', 31536000); -require_once 'include/dba.php'; - /** * @brief OAuthDataStore class */ diff --git a/src/Network/Probe.php b/src/Network/Probe.php index b4e297afa2..f61eed4192 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -28,8 +28,6 @@ use Friendica\Util\Strings; use Friendica\Util\XML; use DomXPath; -require_once 'include/dba.php'; - /** * @brief This class contain functions for probing URL * diff --git a/src/Object/Post.php b/src/Object/Post.php index 1ca1e222eb..dd2628d3ee 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -24,11 +24,6 @@ use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Strings; use Friendica\Util\Temporal; -require_once 'include/dba.php'; -require_once 'include/text.php'; -require_once 'boot.php'; -require_once 'include/conversation.php'; - /** * An item */ diff --git a/src/Object/Thread.php b/src/Object/Thread.php index b6d92e743c..0068fa2fb9 100644 --- a/src/Object/Thread.php +++ b/src/Object/Thread.php @@ -10,9 +10,6 @@ use Friendica\Core\Protocol; use Friendica\Object\Post; use Friendica\Util\Security; -require_once 'boot.php'; -require_once 'include/text.php'; - /** * A list of threads * diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 7c807b921e..c3366f5bcc 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -37,12 +37,6 @@ use Friendica\Util\XML; use HTMLPurifier; use HTMLPurifier_Config; -require_once 'boot.php'; -require_once 'include/dba.php'; -require_once "include/enotify.php"; -require_once "include/items.php"; -require_once "include/text.php"; - /** * @brief This class contain functions to create and send DFRN XML files */ diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index d59eb7a0ad..4ce6ef7010 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -38,9 +38,6 @@ use Friendica\Util\Strings; use Friendica\Util\XML; use SimpleXMLElement; -require_once 'include/dba.php'; -require_once 'include/items.php'; - /** * @brief This class contain functions to create and send Diaspora XML files * diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php index 5939e5ce1a..67e5412e25 100644 --- a/src/Protocol/Feed.php +++ b/src/Protocol/Feed.php @@ -17,9 +17,6 @@ use Friendica\Model\Item; use Friendica\Util\Network; use Friendica\Util\XML; -require_once 'include/dba.php'; -require_once 'include/items.php'; - /** * @brief This class contain functions to import feeds * diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index 361d333b40..1a6f748d16 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -29,10 +29,7 @@ use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Strings; use Friendica\Util\XML; -require_once 'include/dba.php'; -require_once 'include/items.php'; require_once 'mod/share.php'; -require_once 'include/enotify.php'; require_once 'include/api.php'; /** diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php index cd85c1c0ae..f446461f66 100644 --- a/src/Protocol/PortableContact.php +++ b/src/Protocol/PortableContact.php @@ -26,8 +26,6 @@ use Friendica\Util\Network; use Friendica\Util\Strings; use Friendica\Util\XML; -require_once 'include/dba.php'; - class PortableContact { /** diff --git a/src/Util/ExAuth.php b/src/Util/ExAuth.php index 8d38b33661..aa163f6a9e 100644 --- a/src/Util/ExAuth.php +++ b/src/Util/ExAuth.php @@ -39,8 +39,6 @@ use Friendica\Core\PConfig; use Friendica\Database\DBA; use Friendica\Model\User; -require_once 'include/dba.php'; - class ExAuth { private $bDebug; diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index 1188214200..79d8d2897e 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -14,8 +14,6 @@ use Friendica\Database\DBA; use Friendica\Object\Image; use Friendica\Util\Strings; -require_once 'include/dba.php'; - /** * @brief Class with methods for extracting certain content from an url */ diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php index 44b9601164..d121d59770 100644 --- a/src/Util/Temporal.php +++ b/src/Util/Temporal.php @@ -14,9 +14,6 @@ use Friendica\Core\PConfig; use Friendica\Core\Renderer; use Friendica\Database\DBA; -require_once 'boot.php'; -require_once 'include/text.php'; - /** * @brief Temporal class */ diff --git a/src/Worker/Cron.php b/src/Worker/Cron.php index 9b8eb1cfec..0e4b40bf66 100644 --- a/src/Worker/Cron.php +++ b/src/Worker/Cron.php @@ -15,8 +15,6 @@ use Friendica\Database\DBA; use Friendica\Model\Contact; use Friendica\Util\DateTimeFormat; -require_once 'include/dba.php'; - class Cron { public static function execute($parameter = '', $generation = 0) diff --git a/src/Worker/CronJobs.php b/src/Worker/CronJobs.php index 164b1cf4d2..b13afffd9a 100644 --- a/src/Worker/CronJobs.php +++ b/src/Worker/CronJobs.php @@ -20,7 +20,6 @@ use Friendica\Network\Probe; use Friendica\Protocol\PortableContact; use Friendica\Util\Proxy as ProxyUtils; -require_once 'include/dba.php'; require_once 'mod/nodeinfo.php'; class CronJobs diff --git a/src/Worker/DBClean.php b/src/Worker/DBClean.php index a722fa23b6..67f073b10f 100644 --- a/src/Worker/DBClean.php +++ b/src/Worker/DBClean.php @@ -11,8 +11,6 @@ use Friendica\Core\Logger; use Friendica\Core\Worker; use Friendica\Database\DBA; -require_once 'include/dba.php'; - class DBClean { public static function execute($stage = 0) { diff --git a/src/Worker/Delivery.php b/src/Worker/Delivery.php index 0d56bfa5d1..459660f4ea 100644 --- a/src/Worker/Delivery.php +++ b/src/Worker/Delivery.php @@ -21,8 +21,6 @@ use Friendica\Protocol\Email; use Friendica\Util\Strings; use Friendica\Util\Network; -require_once 'include/items.php'; - class Delivery extends BaseObject { const MAIL = 'mail'; diff --git a/src/Worker/Expire.php b/src/Worker/Expire.php index 21e873502b..cb6bdbacbc 100644 --- a/src/Worker/Expire.php +++ b/src/Worker/Expire.php @@ -14,16 +14,12 @@ use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\Model\Item; -require_once 'include/dba.php'; - class Expire { public static function execute($param = '', $hook_function = '') { $a = BaseObject::getApp(); - require_once 'include/items.php'; - Hook::loadHooks(); if ($param == 'delete') { diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index 00ad1543d6..d82e294d95 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -24,9 +24,6 @@ use Friendica\Protocol\Diaspora; use Friendica\Protocol\OStatus; use Friendica\Protocol\Salmon; -require_once 'include/dba.php'; -require_once 'include/items.php'; - /* * The notifier is typically called with: * diff --git a/src/Worker/OnePoll.php b/src/Worker/OnePoll.php index f254596720..0579bfa245 100644 --- a/src/Worker/OnePoll.php +++ b/src/Worker/OnePoll.php @@ -21,16 +21,12 @@ use Friendica\Util\Network; use Friendica\Util\Strings; use Friendica\Util\XML; -require_once 'include/dba.php'; - class OnePoll { public static function execute($contact_id = 0, $command = '') { $a = BaseObject::getApp(); - require_once 'include/items.php'; - Logger::log('start'); $manual_id = 0; diff --git a/src/Worker/PubSubPublish.php b/src/Worker/PubSubPublish.php index 801bdc8880..9f5fcdcc5f 100644 --- a/src/Worker/PubSubPublish.php +++ b/src/Worker/PubSubPublish.php @@ -13,8 +13,6 @@ use Friendica\Model\PushSubscriber; use Friendica\Protocol\OStatus; use Friendica\Util\Network; -require_once 'include/items.php'; - class PubSubPublish { public static function execute($pubsubpublish_id = 0) diff --git a/src/Worker/Queue.php b/src/Worker/Queue.php index 8dc34a594a..7ba18ae1c2 100644 --- a/src/Worker/Queue.php +++ b/src/Worker/Queue.php @@ -20,9 +20,6 @@ use Friendica\Protocol\Diaspora; use Friendica\Protocol\PortableContact; use Friendica\Protocol\Salmon; -require_once 'include/dba.php'; -require_once 'include/items.php'; - class Queue { public static function execute($queue_id = 0) diff --git a/src/Worker/RemoveContact.php b/src/Worker/RemoveContact.php index 2e3f16db3e..00027dca40 100644 --- a/src/Worker/RemoveContact.php +++ b/src/Worker/RemoveContact.php @@ -9,8 +9,6 @@ use Friendica\Database\DBA; use Friendica\Core\Protocol; use Friendica\Model\Item; -require_once 'include/dba.php'; - class RemoveContact { public static function execute($id) { diff --git a/src/Worker/RemoveUser.php b/src/Worker/RemoveUser.php index 10ede55763..c7179a4e3d 100644 --- a/src/Worker/RemoveUser.php +++ b/src/Worker/RemoveUser.php @@ -8,8 +8,6 @@ namespace Friendica\Worker; use Friendica\Database\DBA; use Friendica\Model\Item; -require_once 'include/dba.php'; - class RemoveUser { public static function execute($uid) { diff --git a/src/Worker/SpoolPost.php b/src/Worker/SpoolPost.php index 2efd77d553..bb01deace1 100644 --- a/src/Worker/SpoolPost.php +++ b/src/Worker/SpoolPost.php @@ -9,8 +9,6 @@ use Friendica\Core\Config; use Friendica\Core\Logger; use Friendica\Model\Item; -require_once "include/items.php"; - class SpoolPost { public static function execute() { $path = get_spoolpath(); diff --git a/tests/src/Core/InstallerTest.php b/tests/src/Core/InstallerTest.php index 32a80a77e0..b15b91e14c 100644 --- a/tests/src/Core/InstallerTest.php +++ b/tests/src/Core/InstallerTest.php @@ -239,9 +239,6 @@ class InstallerTest extends MockedTest // Mocking that we can use CURL $this->setFunctions(['curl_init' => true]); - // needed because of "normalise_link" - require_once __DIR__ . '/../../../include/text.php'; - $install = new Installer(); $this->assertFalse($install->checkHtAccess('https://test')); diff --git a/tests/src/Network/CurlResultTest.php b/tests/src/Network/CurlResultTest.php index 13a14d985e..775c4179f3 100644 --- a/tests/src/Network/CurlResultTest.php +++ b/tests/src/Network/CurlResultTest.php @@ -7,14 +7,6 @@ use PHPUnit\Framework\TestCase; class CurlResultTest extends TestCase { - public function setUp() - { - parent::setUp(); - - require_once __DIR__.'/../../../boot.php'; - require_once __DIR__.'/../../../include/text.php'; - } - /** * @small */ diff --git a/update.php b/update.php index 41b6fa96f2..22d1809fea 100644 --- a/update.php +++ b/update.php @@ -12,8 +12,6 @@ use Friendica\Model\Item; use Friendica\Model\User; use Friendica\Util\DateTimeFormat; -require_once 'include/dba.php'; - /** * * update.php - automatic system update diff --git a/view/theme/frio/php/scheme.php b/view/theme/frio/php/scheme.php index 05829bb21f..ddce673105 100644 --- a/view/theme/frio/php/scheme.php +++ b/view/theme/frio/php/scheme.php @@ -19,8 +19,6 @@ */ use Friendica\Core\PConfig; -require_once 'boot.php'; - function get_scheme_info($scheme) { $theme = get_app()->getCurrentTheme(); From ed7bada71eb7e5d1c2953e94abb47b531781306d Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 24 Dec 2018 09:56:48 -0500 Subject: [PATCH 09/10] Move Composer autoload require out of boot.php --- bin/auth_ejabberd.php | 2 +- bin/console.php | 2 +- bin/daemon.php | 2 +- bin/worker.php | 2 +- boot.php | 2 -- index.php | 6 ++---- 6 files changed, 6 insertions(+), 10 deletions(-) diff --git a/bin/auth_ejabberd.php b/bin/auth_ejabberd.php index fc57a74204..e8a7b4963f 100755 --- a/bin/auth_ejabberd.php +++ b/bin/auth_ejabberd.php @@ -49,7 +49,7 @@ $directory = realpath($directory . DIRECTORY_SEPARATOR . ".."); chdir($directory); -require_once "boot.php"; +require dirname(__DIR__) . '/vendor/autoload.php'; $a = new App(dirname(__DIR__)); diff --git a/bin/console.php b/bin/console.php index 9c25279d37..c39df953f2 100755 --- a/bin/console.php +++ b/bin/console.php @@ -1,7 +1,7 @@ #!/usr/bin/env php runFrontend(); From 3ddd622f8da44f599f93afb04e68ae7f7f9a3880 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 24 Dec 2018 09:57:06 -0500 Subject: [PATCH 10/10] [Composer] Update lock file --- composer.lock | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.lock b/composer.lock index d0ce1c4e72..5d46466d86 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "11efc727fd6cae00c1230616e31ad2a2", + "content-hash": "9e0c66963fa451c1c317569c89c1b278", "packages": [ { "name": "asika/simple-console", @@ -3563,6 +3563,7 @@ "prefer-lowest": false, "platform": { "php": ">=5.6.1", + "ext-curl": "*", "ext-dom": "*", "ext-json": "*", "ext-xml": "*"