diff --git a/Sources/PackageManager/PackageManager.php b/Sources/PackageManager/PackageManager.php index 4db0c4960d..72e29f1e94 100644 --- a/Sources/PackageManager/PackageManager.php +++ b/Sources/PackageManager/PackageManager.php @@ -1229,8 +1229,12 @@ public function install(): void Db::$db->query( '', 'UPDATE {db_prefix}log_packages - SET install_state = {int:not_installed}, member_removed = {string:member_name}, - id_member_removed = {int:current_member}, time_removed = {int:current_time}, sha256_hash = {string:package_hash} + SET + install_state = {int:not_installed}, + member_removed = {string:member_name}, + id_member_removed = {int:current_member}, + time_removed = {int:current_time}, + sha256_hash = {string:package_hash} WHERE package_id = {string:package_id} AND id_install = {int:install_id}', [ @@ -1253,8 +1257,12 @@ public function install(): void Db::$db->query( '', 'UPDATE {db_prefix}log_packages - SET install_state = {int:not_installed}, member_removed = {string:member_name}, - id_member_removed = {int:current_member}, time_removed = {int:current_time}, sha256_hash = {string:package_hash} + SET + install_state = {int:not_installed}, + member_removed = {string:member_name}, + id_member_removed = {int:current_member}, + time_removed = {int:current_time}, + sha256_hash = {string:package_hash} WHERE package_id = {string:package_id} AND version = {string:old_version}', [ @@ -1322,21 +1330,44 @@ public function install(): void // Credits tag? $credits_tag = (empty($credits_tag)) ? '' : Utils::jsonEncode($credits_tag); + + // Log that we installed it. Db::$db->insert( '', '{db_prefix}log_packages', [ - 'filename' => 'string', 'name' => 'string', 'package_id' => 'string', 'version' => 'string', - 'id_member_installed' => 'int', 'member_installed' => 'string', 'time_installed' => 'int', - 'install_state' => 'int', 'failed_steps' => 'string', 'themes_installed' => 'string', - 'member_removed' => 'int', 'db_changes' => 'string', 'credits' => 'string', + 'filename' => 'string', + 'name' => 'string', + 'package_id' => 'string', + 'version' => 'string', + 'id_member_installed' => 'int', + 'member_installed' => 'string', + 'time_installed' => 'int', + 'install_state' => 'int', + 'failed_steps' => 'string', + 'themes_installed' => 'string', + 'member_removed' => 'int', + 'db_changes' => 'string', + 'credits' => 'string', 'sha256_hash' => 'string', + 'smf_version' => 'string', ], [ - $package_filename, $package_name, $package_id, $package_version, - User::$me->id, User::$me->name, time(), - $is_upgrade ? 2 : 1, $failed_step_insert, $themes_installed, - 0, $db_changes, $credits_tag, Utils::$context['package_sha256_hash'], + $package_filename, + $package_name, + $package_id, + $package_version, + User::$me->id, + User::$me->name, + time(), + $is_upgrade ? 2 : 1, + $failed_step_insert, + $themes_installed, + 0, + $db_changes, + $credits_tag, + Utils::$context['package_sha256_hash'], + Utils::$context['smf_version'], ], ['id_install'], ); diff --git a/Sources/PackageManager/SubsPackage.php b/Sources/PackageManager/SubsPackage.php index 7b9925b8aa..7ed12b1e6d 100644 --- a/Sources/PackageManager/SubsPackage.php +++ b/Sources/PackageManager/SubsPackage.php @@ -1144,6 +1144,9 @@ public static function parsePackageInfo(XmlArray &$packageXML, bool $testing_onl return []; } + // Keep track of what version of SMF we are emulating (if any). + Utils::$context['smf_version'] = preg_replace('/^(\d+\.\d+).*/', '$1', $the_version); + // Find all the actions in this method - in theory, these should only be allowed actions. (* means all.) $actions = $script->set('*'); $return = []; diff --git a/other/install_3-0_MySQL.sql b/other/install_3-0_MySQL.sql index 8f6a2087df..fe85f30832 100644 --- a/other/install_3-0_MySQL.sql +++ b/other/install_3-0_MySQL.sql @@ -462,6 +462,7 @@ CREATE TABLE {$db_prefix}log_packages ( db_changes TEXT NOT NULL, credits TEXT NOT NULL, sha256_hash TEXT, + smf_version VARCHAR(5) NOT NULL DEFAULT '', PRIMARY KEY (id_install), INDEX idx_filename (filename(15)) ) ENGINE={$engine}; diff --git a/other/install_3-0_PostgreSQL.sql b/other/install_3-0_PostgreSQL.sql index 1f4fa4a35f..a079b2e323 100644 --- a/other/install_3-0_PostgreSQL.sql +++ b/other/install_3-0_PostgreSQL.sql @@ -722,6 +722,7 @@ CREATE TABLE {$db_prefix}log_packages ( db_changes text NOT NULL, credits text NOT NULL, sha256_hash TEXT, + smf_version varchar(5) NOT NULL DEFAULT '', PRIMARY KEY (id_install) ); diff --git a/other/upgrade_3-0_MySQL.sql b/other/upgrade_3-0_MySQL.sql index 68c365b5d9..50cf5cd53e 100644 --- a/other/upgrade_3-0_MySQL.sql +++ b/other/upgrade_3-0_MySQL.sql @@ -968,4 +968,13 @@ Db::$db->add_index( ---# Adding new "spoofdetector_censor" setting INSERT IGNORE INTO {$db_prefix}settings (variable, value) VALUES ('spoofdetector_censor', '1'); +---# + +/******************************************************************************/ +--- Adding SMF version information to log_packages +/******************************************************************************/ + +---# Adding a new column "smf_version" to log_packages table +ALTER TABLE {$db_prefix}log_packages +ADD COLUMN smf_version VARCHAR(5) NOT NULL DEFAULT ''; ---# \ No newline at end of file diff --git a/other/upgrade_3-0_PostgreSQL.sql b/other/upgrade_3-0_PostgreSQL.sql index efd767c83e..2aad556bed 100644 --- a/other/upgrade_3-0_PostgreSQL.sql +++ b/other/upgrade_3-0_PostgreSQL.sql @@ -850,4 +850,13 @@ CREATE INDEX {$db_prefix}idx_spoofdetector_name_id ON {$db_prefix}members (spoof ---# Adding new "spoofdetector_censor" setting INSERT INTO {$db_prefix}settings (variable, value) VALUES ('spoofdetector_censor', '1') ON CONFLICT DO NOTHING; +---# + +/******************************************************************************/ +--- Adding SMF version information to log_packages +/******************************************************************************/ + +---# Adding a new column "smf_version" to log_packages table +ALTER TABLE {$db_prefix}log_packages +ADD COLUMN IF NOT EXISTS smf_version VARCHAR(5) NOT NULL DEFAULT ''; ---# \ No newline at end of file