Skip to content

[3.0] Print the registration errors that carry their own words - #9485

Open
albertlast wants to merge 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/register-error-own-words
Open

[3.0] Print the registration errors that carry their own words#9485
albertlast wants to merge 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/register-error-own-words

Conversation

@albertlast

Copy link
Copy Markdown
Collaborator

Description

Refuse a registration for a weak password and the form says "The following errors
were detected in your registration. Please correct them to continue:" above a
bullet with nothing in it.

$ # register with passwrd1=password
<div class="errorbox">
    <span>The following errors were detected in your registration…</span>
    <ul>
        <li></li>
    </ul>
</div>

Each entry in $reg_errors is [kind, text, log, args], where the kind is
'lang' for a language key and 'done' for a finished sentence. The comment
directly above the loop says so:

/* Note for each error:
    0 = 'lang' if it's an index, 'done' if it's clear text.
    1 = The text/index. … */
$message = Lang::getTxt($error[1], (array) ($error[3] ?? []), file: 'Errors');

The loop never reads $error[0]. It looks every error up in Errors, a 'done'
error is not a key there, getTxt() returns an empty string for a key it cannot
find, and that empty string is the bullet. 2.1 read the kind here.

What reaches it. Register2 builds ['done', $password_error, false]
whenever validatePassword() hands back something that is not a language key —
which is the zxcvbn feedback, so every strength rejection except short. It is
also how Security::validateUsername() reports a name already in use.

What changes

One line: a 'done' error prints its own words.

Testing

Registering with password:

This is a top-10 common password.
Add another word or two. Uncommon words are better.

with abc, unchanged: "Your password must be at least 6 characters long."
A clean registration still succeeds.

Issues References (Fixes|Related|Closes)

Related to #7933

Refuse a registration for a weak password and the form says "The following
errors were detected" above a bullet with nothing in it.

Each error is [kind, text, log, args], where the kind is 'lang' for a language
key and 'done' for a finished sentence - as the comment directly above the loop
says. The loop ignores it and looks every one of them up in Errors. A 'done'
error is not a key there, getTxt() returns an empty string for a key it cannot
find, and that empty string is the bullet.

It is the strength feedback from validatePassword() that reaches this, which is
every rejection except 'short'. 2.1 read the kind here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
@jdarwood007 jdarwood007 added this to the 3.0 Alpha 6 milestone Aug 10, 2026
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.

2 participants