Make WordPress Core

Opened 5 months ago

Closed 5 months ago

#61519 closed defect (bug) (fixed)

Unable to pick a featured image due to JS error

Reported by: davidbinda's profile david.binda Owned by: desrosj's profile desrosj
Milestone: 6.6 Priority: normal
Severity: normal Version: 6.6
Component: Build/Test Tools Keywords: commit dev-reviewed
Focuses: Cc:

Description

After r58563 there is a JS error in the media picker which results in just the first single from the media library being loaded upon clicking to "Set featured image" in the post editor.

The JS error is as follows:

TypeError: t.get is not a function
    at n.comparator (media-models.min.js?ver=6.6-RC1:2:5566)
    at e.comparator (media-views.min.js?ver=6.6-RC1:2:7240)
    at Array.sort (<anonymous>)
    at n.sort (backbone.min.js?ver=1.5.0:2:11690)
    at n.set (backbone.min.js?ver=1.5.0:2:10286)
    at n.add (backbone.min.js?ver=1.5.0:2:8973)
    at n.validate (media-models.min.js?ver=6.6-RC1:2:2960)
    at n._validateHandler (media-models.min.js?ver=6.6-RC1:2:3953)
    at p (backbone.min.js?ver=1.5.0:2:3818)
    at f (backbone.min.js?ver=1.5.0:2:3497)

While I'm still not sure what the root cause is, it seems like reverting the mentioned changeset for the wp-includes/js/media-views.min.js file only fixes the issue.

Steps to reproduce:

  1. make sure the minified versions of the JS files are being loaded ( eg.: no SCRIPT_DEBUG )
  2. have more than 1 image uploaded in a media library (eg.: 2)
  3. go to wp-admin/post-new.php
  4. click the "Set featured image" in the right hand side panel (on the Post level)
  5. see that just a single image got loaded, observe the JS error in the console

Change History (10)

#1 @mukesh27
5 months ago

  • Component changed from General to Editor
  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 6.6

Thanks @davidbinda for raising. I also replicate same issue in RC1

Moving to 6.6

#2 @alshakero
5 months ago

  • Component changed from Editor to General
  • Keywords needs-patch removed

Thanks for the ticket! I investigated this last night and most probably it stems from updating uglify-js here. The source code of media-models.js hasn't changed in the past 4 years, yet the minified file is slightly logically different.

I suspect the output code is not logically equivalent to the source. To see the minification issue, you can see the diff I created here. The left side is the new minified code, the right side is the old (pre-change set) minified code.

https://www.diffchecker.com/aeLriFRa/

There may be other minification issues that we missed.

#3 @david.binda
5 months ago

  • Component changed from General to Editor
  • Keywords needs-patch added

#4 @desrosj
5 months ago

  • Component changed from Editor to Build/Test Tools
  • Keywords needs-patch removed
  • Owner set to desrosj
  • Status changed from new to reviewing

#5 @desrosj
5 months ago

  • Keywords commit dev-feedback added
  • Status changed from reviewing to accepted

Thanks everyone! This should be fixed by [58585], which is not showing here because of a typo in the commit message.

Could everyone test this against trunk to confirm it fixes the problem? I've also rebuilt the nightly so that you can test using the Beta Tester plugin as well.

Also marking for a second committer sign off to backport once we're confident with the amount of testing.

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


5 months ago

#7 follow-up: @jorbin
5 months ago

  • Keywords dev-reviewed added; dev-feedback removed

[58585] Looks good for backport.

For testing, I built the change checked:

  1. Uploading new images, was able to select different featured ones
  2. Loading an existing post, was able to select and change the featured image
  3. On a new post, was able to select any image from the media library

#8 @david.binda
5 months ago

I've tested the proposed patch on WordPress.com using the same steps as mentioned in the original ticket. The [58585] addresses the described issue. Thanks for working on it!

#9 in reply to: ↑ 7 @hellofromTonya
5 months ago

Replying to jorbin:

[58585] Looks good for backport.

For testing, I built the change checked:

  1. Uploading new images, was able to select different featured ones
  2. Loading an existing post, was able to select and change the featured image
  3. On a new post, was able to select any image from the media library

Tested before and after [58585].

I can reproduce the reported issue.
Using @jorbin's approach, I can also confirm [58585] resolves the issue.

I 2nd [58585] looks good for backport to the 6.5 branch.

#10 @desrosj
5 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 58586:

Build/Test Tools: Revert uglify-js update.

This partially reverts [58563], which applied an update of the uglify-js devDependency from 3.17.4 to 3.18.0.

The 3.18.0 update is causing some JavaScript errors in the media-views.min.js file, so needs to be investigated further.

Reviewed by jorbin, hellofromTonya.
Merges [58585] to the 6.6 branch.

Props david.binda, mukesh27, alshakero, jorbin, hellofromTonya.
Fixes #61519.

Note: See TracTickets for help on using tickets.