WordPress.org

Make WordPress Core

Opened 5 months ago

Last modified 4 days ago

#52086 new defect (bug)

user-profile.min.js issue on Firefox

Reported by: adi64bit Owned by:
Milestone: Future Release Priority: normal
Severity: critical Version: 5.6
Component: Users Keywords: needs-patch
Focuses: javascript, administration Cc:

Description

Hi Guys,

We found an issue no WordPress 5.6 when creating a new user on the firefox but on other browser it's normal.

-. can't click on the "hide/show" password button
-. can't click on the "generated password" button
-. can't create a user when the password are manually type (i think because #pass2 element doesn't fill the same value with #pass1 element because of JS error)

jQuery.Deferred exception: o is undefined w@http://localhost/wp-admin/js/user-profile.min.js?ver=5.6:2:180
m@http://localhost/wp-admin/js/user-profile.min.js?ver=5.6:2:935
@http://localhost/wp-admin/js/user-profile.min.js?ver=5.6:2:4841
e@http://localhost/wp-includes/js/jquery/jquery.min.js?ver=3.5.1:2:30005
l/</t<@http://localhost/wp-includes/js/jquery/jquery.min.js?ver=3.5.1:2:30307
setTimeout handler*l/<@http://localhost/wp-includes/js/jquery/jquery.min.js?ver=3.5.1:2:30516
c@http://localhost/wp-includes/js/jquery/jquery.min.js?ver=3.5.1:2:28294
fireWith@http://localhost/wp-includes/js/jquery/jquery.min.js?ver=3.5.1:2:29039
fire@http://localhost/wp-includes/js/jquery/jquery.min.js?ver=3.5.1:2:29075
c@http://localhost/wp-includes/js/jquery/jquery.min.js?ver=3.5.1:2:28294
fireWith@http://localhost/wp-includes/js/jquery/jquery.min.js?ver=3.5.1:2:29039
ready@http://localhost/wp-includes/js/jquery/jquery.min.js?ver=3.5.1:2:32012
B@http://localhost/wp-includes/js/jquery/jquery.min.js?ver=3.5.1:2:31791
EventListener.handleEvent*@http://localhost/wp-includes/js/jquery/jquery.min.js?ver=3.5.1:2:32160
@http://localhost/wp-includes/js/jquery/jquery.min.js?ver=3.5.1:2:220
@http://localhost/wp-includes/js/jquery/jquery.min.js?ver=3.5.1:2:225
Uncaught TypeError: o is undefined
    w user-profile.min.js:16
    m user-profile.min.js:35
    <anonymous> user-profile.min.js:166
    jQuery 13
        e
        t
        setTimeout handler*l/<
        c
        fireWith
        fire
        c
        fireWith
        ready
        B
        EventListener.handleEvent*
        <anonymous>
        <anonymous>

Change History (22)

#1 @adi64bit
5 months ago

it can be fixed by adding

$toggleButton = $pass1Row.find('.wp-hide-pw');

right after

 $pass1Row = $( '.user-pass1-wrap, .user-pass-wrap' );

on user-profile.js::98

#2 @SergeyBiryukov
5 months ago

  • Milestone changed from Awaiting Review to 5.6.1

#3 @SergeyBiryukov
5 months ago

#52096 was marked as a duplicate.

#4 @brookedot
5 months ago

This bug is preventing users from being added as well. I'm getting the error:

Error: Passwords don’t match. Please enter the same password in both password fields.

Of course, there's only one password field but sounds like the underlying issue is the same. I was able to add a new user in Chromium just fine but not Firefox. Both on Ubuntu 20.10 can't seem to replicate on Firefox 84 on macOS 11.

Last edited 5 months ago by brookedot (previous) (diff)

#5 @poena
5 months ago

I have not been able to reproduce these problems with WordPress 5.6 and Firefox version 84 on Windows 10.
Tested both adding new users and editing passwords for existing users.

#6 follow-up: @cbigler
4 months ago

Same problem here ... Firefox 84 doesn't work, but Chrome does (Win 10). I tried the edit on user-profile.js mentioned in post https://core.trac.wordpress.org/ticket/52086#comment:1 from @adi64bit ... still doesn't work.

#7 in reply to: ↑ 6 @cbigler
4 months ago

Replying to cbigler:

Same problem here ... Firefox 84 doesn't work, but Chrome does (Win 10). I tried the edit on user-profile.js mentioned in post https://core.trac.wordpress.org/ticket/52086#comment:1 from @adi64bit ... still doesn't work.

For me, the issue is resolved by deactivating a plugin named Smart Sections at https://codecanyon.net/item/smart-sections-wpbakery-page-builder-formerly-visual-composer-addon/21641422 which I use extensively ... I'll alert them to this.

Last edited 4 months ago by cbigler (previous) (diff)

#8 @cbigler
4 months ago

Update for my particular issue / environment ...

Issues surrounding this involved jQuery Manager plugin not just Smart Sections, so playing with the settings alleviated the problem with Firefox.

In particular, a Smart Sections plugin update helped, and I wasn't running jQuery Migrate, so I enabled that.

#9 follow-up: @brookedot
4 months ago

I think the next step here is to see if we can get steps to reproduce the problem with as vanilla of setup as possible. For example, with just core plugin and themes. I've seen this happen twice now across sites but never been able to narrow down the root cause. Once we have a way to reproduce we can take a look into a fix for 5.6.1.

#10 in reply to: ↑ 9 @cbigler
4 months ago

Replying to brookedot:

I think the next step here is to see if we can get steps to reproduce the problem with as vanilla of setup as possible. For example, with just core plugin and themes. I've seen this happen twice now across sites but never been able to narrow down the root cause. Once we have a way to reproduce we can take a look into a fix for 5.6.1.

Agreed, and should anyone stumble across this and their website uses Smart Sections for WPBakery ... their team was very responsive ... much appreciated!

#11 @sbossarte
4 months ago

I am experiencing the same here on a fresh install of WordPress, though it seems more of a race condition, as it will sometimes error out, and sometimes work just fine.

I don't want to assume too much, but from what I see here it looks like this happens because in user-profile.js, generatePassword() looks for the $toggleButton before it has been set with bindToggleButton(). This seems to be because of zxcvbn being loaded fast enough, otherwise the generatePassword gets held off until later with a timeout as seen here:

if ( typeof zxcvbn !== 'function' ) {
	setTimeout( generatePassword, 50 );
	return;
}

if bindToggleButton() is bumped up higher in bindPasswordForm(), before bindPass1 can be called, it seems like this might fix the issue.

This ticket was mentioned in Slack in #core by metalandcoffee. View the logs.


4 months ago

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


3 months ago

#14 @audrasjb
3 months ago

  • Milestone changed from 5.6.1 to 5.6.2

Given 5.6.1 is slated to next week, let's move this ticket to 5.6.2 to give it some more time.

#15 @charlyox
3 months ago

  • Focuses administration added

Hello there, I 'm reproducing this exact issue on Firefox for Ubuntu 84.0.2 (64 bits).
Cannot add a user nor changing an existing user's password.

Reproduction :

  • Open user account (or whatever it is in english) > add
  • get straight to the already filled password section.
  • Click the open eye to see the generated password => Does not work
  • Ask to regenerate => Nothing works
  • try to submit => Error because the passwords don't match (of course I've regenerated it)

In the console :

Uncaught TypeError: o is undefined

Strangely enough: when I then resubmit, no error. No JS error.

#16 @jadpm
3 months ago

We are experiencing the same problem especialy when using one of our pro plugins. We managed to minimize (although not remove) this by movin gone script to be enqueued in the footer, but the error is somehow erratic and happens from time to time anyway.

If this helps someone, the script we moved to the footer loads a bunch on underscore templates and relies on jQuery UI dialogs for a lot of things, but I doubt this is really relevant.

IMHO, the problem here is in any case the flawed logic for user-profile.js around the generatePassword function. It simply assumes that by the time zxcvbnis defined then $toggleButton will also be defined, which seems to be risky.

As stated above, a minimal change would be defining $toggleButton before we might try to use it on bindPass1().

#17 @desrosj
3 months ago

I spent some time investigating this today and I am also unable to reproduce this issue.

Some questions for those that are still able to reproduce:

  • Does the issue happen with all plugins disabled or on a fresh install using the latest version of WordPress (currently 5.6.1), or using trunk?
  • Does the issue persist if you place define( 'SCRIPT_DEBUG', true ); in your wp-config.php file? (this will load the un-minified versions of all JS files)

#18 @jadpm
3 months ago

I managed to reproduce this on the following cases:

  • Using SCRIPT_DEBUG always turned on, as I experience this in my local development setup.
  • With multiple versions of WordPress, since I also use the beta tester plugin and this has been happening for some time using a number of versions, both stable and nightly builds.
  • Never tried with a vanila installation, but I find it slightly irrelevant since this is not a pure compatibility issue (no other libary from a third party is causing this), but probably a side effect due to a loading race and some natural but probably wrong assumption.

While SCRIPT_DEBUG is on, the error mentions precisely that $toggleButton is not dfined. I my local debug, I noticed that the loading on the zxcvbn script changed and got loaded and executed at an early point, not sure why as this is a dynamically loaded asset injected directly on the header on windo.load.

I assume this might be triggered by some browser combination with some parties loading things on document.ready and whatnot, but it is indeed not easy to replicate and as I stated it does nto even happen all times.

But in the end, besides tryig to understand the why, the fact is that the logid pointed in the above comments show that there is a logic assuption an flow which can cause a problem because it is possible to enter a decision tree which uses undefined variables. I would suggest focusing on that.

We have a fairly large installation with a medium sized list of plugins running with this problem, preventing users from updating their own profile.

#19 @desrosj
3 months ago

  • Keywords needs-patch added
  • Milestone changed from 5.6.2 to Future Release

I did some more testing on this today, and though I do see the issue in logic being pointed out, I still want to completely understand and replicate the conditions that cause this to happen before making a change.

5.6.2 RC is going to be packaged in a few hours. Since this one still requires some investigation and lacks a patch, I'm going to punt to Future Release.

#20 @lkraav
3 weeks ago

I just ran into this on Firefox 87 Linux, WP 5.7. Somewhat surprisingly, loading user-new.php with SCRIPT_DEBUG succeeded with no errors, and I was able to complete add new user operation.

#21 @drago239
6 days ago

I found that in WP 5.7.1 issue remains on Firefox, but problem is that it's not always so it may be difficult to ran into this. I managed to reproduce this on fresh installation, with twentytwentyone theme, without any plugins at all. This error is showing sometimes, not always, so to reproduce this try refreshing Add New User page. In my case in some 10-20 refreshes, it shows 1 or 2 times.

I tried this on few websites, and issue is the same, WP 5.7+, Firefox 88.

Last edited 6 days ago by drago239 (previous) (diff)

#22 @sebastienserre
4 days ago

Hello All,

I confirm I reproduce this error on Ubuntu 20.04, WP 5.7.1. It disappears with define( 'SCRIPT_DEBUG', true );

Note: See TracTickets for help on using tickets.