From da516de3e2f74c36a83025bb0c82a4075593886e Mon Sep 17 00:00:00 2001 From: albertlast Date: Tue, 28 Jul 2026 23:04:00 +0200 Subject: [PATCH] Loads the current user before finalize() records dates Install::finalize() called Time::strftime() to build the log_activity date, and later Logging::updateStats(), which does the same thing. Both end up in Time::__construct(), which reads User::$me to resolve the time zone. But User::setMe()/User::loadMe() were not called until much later in the same method, so installation died with: Error: Typed static property SMF\User::$me must not be accessed before initialization in Sources/Time.php:191 The installer therefore aborted on its last step, leaving the forum without the member, topic and message stats that finalize() is responsible for writing, including latestMember and latestRealName. Moves the user initialisation up to just after the settings are reloaded, which is the first point at which it can run, and leaves the rest of the "we've just installed" block where it was. Co-Authored-By: Claude Opus 5 Signed-off-by: albertlast --- Sources/Maintenance/Tools/Install.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Sources/Maintenance/Tools/Install.php b/Sources/Maintenance/Tools/Install.php index 51c1879883..171fd99fa2 100644 --- a/Sources/Maintenance/Tools/Install.php +++ b/Sources/Maintenance/Tools/Install.php @@ -1131,6 +1131,14 @@ public function finalize(): bool // Reload $modSettings. Config::reloadModSettings(); + // Everything below needs a current user: Time and Logging both read + // User::$me to work out which time zone to record dates in. + if (isset(Maintenance::$context['id_member'])) { + User::setMe((int) Maintenance::$context['id_member']); + } else { + User::loadMe(); + } + // Bring a warning over. if (!empty(Maintenance::$context['account_existed'])) { Maintenance::$warnings = Maintenance::$context['account_existed']; @@ -1247,12 +1255,6 @@ public function finalize(): bool // We've just installed! $_SERVER['BAN_CHECK_IP'] = IP::getUserIPAlternative(); - if (isset(Maintenance::$context['id_member'])) { - User::setMe((int) Maintenance::$context['id_member']); - } else { - User::loadMe(); - } - User::$me->ip = IP::getUserIP(); Logging::logAction('install', ['version' => SMF_FULL_VERSION], 'admin');