From a90a4e6212ae6b34cbe7bca0507c8b501952dcd1 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 1 Nov 2025 21:34:03 -0600 Subject: [PATCH] Pass the database object to the schema object --- core/upgrade/index.php | 2 +- core/upgrade/upgrade.php | 17 ++++++++--------- core/upgrade/upgrade_menu.php | 3 +-- core/upgrade/upgrade_schema.php | 2 +- resources/classes/schema.php | 8 ++++---- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/core/upgrade/index.php b/core/upgrade/index.php index ee675e903e..a2ae223736 100644 --- a/core/upgrade/index.php +++ b/core/upgrade/index.php @@ -130,7 +130,7 @@ //load an array of the database schema and compare it with the active database if (!empty($action["upgrade_schema"]) && permission_exists("upgrade_schema")) { - $obj = new schema(); + $obj = new schema(['database' => $database]); if (isset($action["data_types"]) && $action["data_types"] == 'true') { $obj->data_types = true; } diff --git a/core/upgrade/upgrade.php b/core/upgrade/upgrade.php index 2b1af92690..3d46baac08 100644 --- a/core/upgrade/upgrade.php +++ b/core/upgrade/upgrade.php @@ -172,6 +172,9 @@ } } +//initiliaze the schema object + $schema = new schema(['database' => $database]); + //use upgrade language file $language = new text; $text = $language->get(null, 'core/upgrade'); @@ -230,11 +233,10 @@ } //get the database schema put it into an array then compare and update the database as needed. - $obj = new schema; if (isset($argv[2]) && $argv[2] == 'data_types') { - $obj->data_types = true; + $schema->data_types = true; } - $response = $obj->schema($format ?? ''); + $response = $schema->schema($format ?? ''); if ($display_type === 'text') { foreach(explode("\n", $response) as $row) { echo " ".trim($row)."\n"; @@ -250,9 +252,8 @@ } //get the database schema put it into an array then compare and update the database as needed. - $obj = new schema; - $obj->data_types = true; - $response = $obj->schema($format ?? ''); + $schema->data_types = true; + $response = $schema->schema($format ?? ''); if ($display_type === 'text') { foreach(explode("\n", $response) as $row) { echo " ".trim($row)."\n"; @@ -323,7 +324,6 @@ // upgrade application defaults $domain = new domains; - $domain->display_type = $display_type; $domain->upgrade(); } @@ -439,8 +439,7 @@ } //Update the table and field structure. - $obj = new schema; - $response = $obj->schema("text"); + $response = $schema->schema("text"); if ($display_type === 'text') { foreach(explode("\n", $response) as $row) { echo " ".trim($row)."\n"; diff --git a/core/upgrade/upgrade_menu.php b/core/upgrade/upgrade_menu.php index e22d27b594..558bdf2688 100644 --- a/core/upgrade/upgrade_menu.php +++ b/core/upgrade/upgrade_menu.php @@ -316,7 +316,6 @@ function do_upgrade_code_submodules() { */ function do_upgrade_domains() { $domain = new domains; - $domain->display_type = 'text'; $domain->upgrade(); } @@ -325,7 +324,7 @@ function do_upgrade_domains() { */ function do_upgrade_schema(bool $data_types = false) { //get the database schema put it into an array then compare and update the database as needed. - $obj = new schema; + $obj = new schema(); $obj->data_types = $data_types; echo $obj->schema('text'); } diff --git a/core/upgrade/upgrade_schema.php b/core/upgrade/upgrade_schema.php index 807631d935..eb33dcc07b 100644 --- a/core/upgrade/upgrade_schema.php +++ b/core/upgrade/upgrade_schema.php @@ -59,7 +59,7 @@ $text = $language->get(); //get the database schema put it into an array then compare and update the database as needed. - $obj = new schema; + $obj = new schema(['database' => $database]); if (isset($argv[1]) && $argv[1] == 'data_types') { $obj->data_types = true; } diff --git a/resources/classes/schema.php b/resources/classes/schema.php index 5b21a45b1d..546e6e2528 100644 --- a/resources/classes/schema.php +++ b/resources/classes/schema.php @@ -36,7 +36,7 @@ public $data_types; //class constructor - public function __construct($setting_array) { + public function __construct($setting_array = []) { //includes files require dirname(__DIR__, 2) . "/resources/require.php"; @@ -879,8 +879,8 @@ } //example use -//$obj = new schema; -//$obj->db_type = $db_type; -//$obj->schema(); +//$schema = new schema(); +//$schema->db_type = $db_type; +//$schema->schema(); //$result_array = $schema->obj['sql']; //print_r($result_array);