Skip to content

[3.0] Misc fixes - #9302

Open
Sesquipedalian wants to merge 20 commits into
SimpleMachines:release-3.0from
Sesquipedalian:3.0/upgrader_login
Open

[3.0] Misc fixes#9302
Sesquipedalian wants to merge 20 commits into
SimpleMachines:release-3.0from
Sesquipedalian:3.0/upgrader_login

Conversation

@Sesquipedalian

@Sesquipedalian Sesquipedalian commented Jul 18, 2026

Copy link
Copy Markdown
Member
  1. Security fix: uses hash_equals() in SMF\Maintenance\Maintenance::loginAdmin() and SMF\Maintenance\Maintenance::loginWithDatabasePassword() methods.
  2. Logs correct info about who ran the upgrader. Previously, we were doing some silly things with loading and unloading User::$me. Not only was that unnecessary, and not only could it produce inaccurate info in the logs under certain circumstances, but it also further complicated the problems with getting the admin's login cookie right by the time the upgrade was complete.
  3. Moves SMF\Actions\Login2::validatePasswordFlood() to SMF\Security::validatePasswordFlood().
  4. Implements SMF\Security::checkPassword().
  5. Fixes bugs with handling login security tokens in the upgrader.
  6. Point 5 ultimately led to replacing Maintenance::$context with just plain old Utils::$context. Upon closer inspection, I realized that there was neither any need nor any benefit to having a separate version of $context; it just caused headaches when using other code, such as SecurityToken::create(), that is already designed to work with Utils::$context.

@Sesquipedalian
Sesquipedalian force-pushed the 3.0/upgrader_login branch 4 times, most recently from cbac018 to a73718e Compare July 18, 2026 21:42
@jdarwood007 jdarwood007 added this to the 3.0 Alpha 5 milestone Jul 18, 2026
@Sesquipedalian

Copy link
Copy Markdown
Member Author

Okay, I think I am done messing with this PR.

@sbulen, would you care to test whether it solves the problem of not being logged after the upgrader exits?

@Sesquipedalian
Sesquipedalian force-pushed the 3.0/upgrader_login branch 10 times, most recently from 8be3518 to 1f2c789 Compare July 19, 2026 19:10
@sbulen

sbulen commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

2.1 => 3.0

Fatal error: Uncaught Error: Cannot access uninitialized non-nullable property SMF\User::$username by reference in D:\wamp64\www\van2130\Sources\User.php:807 Stack trace: # 0 [internal function]: SMF\User->$member_name::get() # 1 D:\wamp64\www\van2130\Sources\Utils.php(1539): json_encode(Array, 0, 512) # 2 D:\wamp64\www\van2130\Sources\Services\ErrorHandlerService.php(286): SMF\Utils::jsonEncode(Array) # 3 D:\wamp64\www\van2130\Sources\Services\ErrorHandlerService.php(185): SMF\Services\ErrorHandlerService->log('Cannot access u...', 'general', 'D:/wamp64/www/v...', 807, Array) # 4 D:\wamp64\www\van2130\Sources\ErrorHandler.php(104): SMF\Services\ErrorHandlerService->catch(Object(Error)) # 5 [internal function]: SMF\ErrorHandler::catch(Object(Error)) # 6 {main} thrown in D:\wamp64\www\van2130\Sources\User.php on line 807

  • PHP, MySQL, Apache logs: nothing
  • Upgrader log: nothing

@Sesquipedalian

Sesquipedalian commented Jul 24, 2026

Copy link
Copy Markdown
Member Author

Well, phooey. I must have broken something in my tinkering after I first pushed. I suppose that's what I get for trying to code while sleepy.

@Sesquipedalian

Sesquipedalian commented Aug 5, 2026

Copy link
Copy Markdown
Member Author

@sbulen:

  1. I've made changes to this PR. Have they fixed the error about uninitialized properties?
  2. If so, does this PR solve the problem of not being logged after the upgrader exits?

@sbulen

sbulen commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

2.1 => 3.0

Getting a different WSOD:

Fatal error: Uncaught Error: Call to a member function allowedTo() on array in D:\wamp64\www\van2130\Sources\Maintenance\Maintenance.php:661 Stack trace: 0 D:\wamp64\www\van2130\Sources\Maintenance\Tools\Upgrade.php(819): SMF\Maintenance\Maintenance::loginAdmin('admin_shawnb', Object(SensitiveParameterValue), false) 1 D:\wamp64\www\van2130\Sources\Maintenance\Maintenance.php(294): SMF\Maintenance\Tools\Upgrade->welcomeLogin() 2 D:\wamp64\www\van2130\upgrade.php(24): SMF\Maintenance\Maintenance->execute(2) 3 {main} thrown in D:\wamp64\www\van2130\Sources\Maintenance\Maintenance.php on line 661

PHP error log reflects the above. MySQL & Apache logs clear.

Upgrade.log:

2026-08-08T17:11:08+00:00
Step 1: Login
Making sure SMF can write to "D:\wamp64\www\van2130\Settings.php"... done.
Making sure SMF can write to "D:\wamp64\www\van2130\Settings_bak.php"... done.
Making sure SMF can write to "D:\wamp64\www\van2130/custom_avatar"... done.
Making sure SMF can write to "D:/wamp64/www/van2130/cache/db_last_error.php"... done.

@Sesquipedalian

Copy link
Copy Markdown
Member Author

That should be fixed now. The cause was just a silly mistake on my part. If you could test again, @sbulen, that would be lovely!

@sbulen

sbulen commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Note this branch currently has merge conflicts.

@sbulen

sbulen commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

For a fun romp down memory lane...
#6942 (comment)

@sbulen

sbulen commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Let me know if you want me to retest now, or if you want to think about the attachment directory...

@sbulen

sbulen commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Maybe a 2.1 cleanup task that ensures it's ready for the json conversion?

@Sesquipedalian

Sesquipedalian commented Aug 22, 2026

Copy link
Copy Markdown
Member Author

There, that should fix the attachments stuff.

  1. The AttachmentDirectory migration step is now idempotent (meaning, running the step again won't change anything) and can handle every possible format that the value might have been in before.
  2. The RemoveTempAttachments task uses much more robust logic when figuring out the paths to the attachment directories.

Test away, @sbulen!

@sbulen

sbulen commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

2.1 => 3.0:

image

Upgrader log (bottom):

+++ Adding new settings... done.
+++ Removing karma... skipped.
+++ Fixing dates... done.
+++ Creating login history table... done.
+++ Converting collapsed categories... skipped.
+++ Fixing attachment directory setting... failed with error: "Class "SMF\Maintenance\Migration\v2_1\Maintenance" not found"

This looks like something simple - I'll hold off repeating the other tests for the moment.

@Sesquipedalian

Copy link
Copy Markdown
Member Author

Derp. Yeah, looks like I forgot a use statement. I'll fix it when I'm back at a computer.

Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>

# Conflicts:
#	Sources/Maintenance/Tools/Install.php
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Can be used to allow us to check a password without automatically updating it. This matters for the upgrader, where we don't want to write to the members table before it is ready to receive new data.

Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Is now idempotent (meaning, running the step again won't change anything) and can handle every possible format that the value might have been in before.

Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
@Sesquipedalian

Copy link
Copy Markdown
Member Author

Fixed now, @sbulen. Ready for a retest whenever you are able.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants