Skip to content

Fix: Resetting forgotten password#3732

Merged
bobvandevijver merged 3 commits into
bolt:6.1from
Vondry:fix/reset-password-config-type
Jul 12, 2026
Merged

Fix: Resetting forgotten password#3732
bobvandevijver merged 3 commits into
bolt:6.1from
Vondry:fix/reset-password-config-type

Conversation

@Vondry

@Vondry Vondry commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Bug

Requesting a password reset at /bolt/reset-password returned HTTP 500 with a TypeError: buildResetEmail() declared an array $config parameter, but config->get('general/reset_password_settings') returns a Bolt\Collection\DeepCollection. Under strict_types=1 PHP refuses the object→array coercion.

image

Fix

1. Primary fix

Fixed by changing the parameter type hint to DeepCollection, which extends Laravel's Collection and implements ArrayAccess, so the existing $config['mail_from'] lookups still work unchanged.

2. Test Environment Configuration

  • Added MAILER_DSN=null://null to phpunit.xml.dist to prevent mailer configuration errors during tests.
  • Hardened URL parsing in src/Canonical.php to safely handle malformed URLs and incomplete parse_url() results.

3. Test Coverage

Added ResetPasswordControllerTest.php to verify that:

  • The password reset page loads successfully

  • The reset form renders correctly

  • Requests are handled without triggering TypeError exceptions

    Testing

Screen.Recording.2026-06-04.at.15.03.04.mov

@Vondry Vondry changed the title Fix TypeError in ResetPasswordController buildResetEmail Fix: Resetting forgotten password Jun 4, 2026
@Vondry Vondry force-pushed the fix/reset-password-config-type branch 2 times, most recently from 9edebaf to 2a53d3e Compare June 8, 2026 09:25
Comment thread src/Canonical.php Outdated
Comment thread src/Canonical.php Outdated
@bobvandevijver bobvandevijver added this to the Bolt 6.1 milestone Jul 4, 2026
@bobvandevijver bobvandevijver added the 🐛 tag: bug This is a bug. label Jul 4, 2026
@Vondry Vondry requested a review from bobvandevijver July 5, 2026 10:40
@bobvandevijver bobvandevijver changed the base branch from 6.2 to 6.1 July 12, 2026 13:48
@bobvandevijver bobvandevijver changed the base branch from 6.1 to 6.2 July 12, 2026 13:50
Vondry added 3 commits July 12, 2026 15:52
config->get() returns a DeepCollection, not an array. With strict_types
enabled this caused a TypeError on the array type hint. Accept
DeepCollection, which supports ArrayAccess for the key lookups used.
- Add MAILER_DSN environment variable to phpunit.xml.dist for test environment
- Add defensive handling in Canonical.php for malformed URLs in test environment
- Add comprehensive test coverage for ResetPasswordController
Early-return on malformed URLs instead of forcing http://localhost,
which could rewrite the canonical host in production.
@bobvandevijver bobvandevijver force-pushed the fix/reset-password-config-type branch from b3152dc to 0b9cb94 Compare July 12, 2026 13:54
@bobvandevijver bobvandevijver changed the base branch from 6.2 to 6.1 July 12, 2026 13:54
@bobvandevijver bobvandevijver merged commit 1365565 into bolt:6.1 Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 tag: bug This is a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants