WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 3 years ago

#38052 new defect (bug)

wp-utility.js misses function argument null

Reported by: wiardvanrij Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version: 4.6
Component: General Keywords: has-patch needs-unit-tests needs-testing
Focuses: javascript Cc:

Description

Since 4.6 the wp-utility is updated. The null parameter has been removed here:

 compiled = compiled || _.template( $( '#tmpl-' + id ).html(), null, options );

to

 compiled = compiled || _.template( $( '#tmpl-' + id ).html(), options );

Which can give the following error:

wp-util.min.js:1 Uncaught TypeError: (intermediate value)(intermediate value) is not a function

This is fixed by adding that null value again like this:

 compiled = compiled || _.template( $( '#tmpl-' + id ).html(), null, options );

Affects version 4.6 and 4.6.1

Attachments (1)

wp-util.js.patch (412 bytes) - added by ross_ritchey 4 years ago.
Patch file to bring back null in the _.template call

Download all attachments as: .zip

Change History (7)

#1 @wiardvanrij
4 years ago

  • Keywords needs-patch added
  • Severity changed from normal to major

This ticket was mentioned in Slack in #slackhelp by dewinter. View the logs.


4 years ago

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


4 years ago

#4 @Presskopp
4 years ago

This was introduced in #36695

@ross_ritchey
4 years ago

Patch file to bring back null in the _.template call

#5 @ross_ritchey
4 years ago

  • Keywords has-patch needs-unit-tests needs-testing added; needs-patch removed

Just added a patch to bring back the null in the _.template call. Per #36695 this was removed to update _.template to the most current syntax - so this will need tested fairly thoroughly to make sure we aren't fixing one issue to create another.

#6 @euthelup
3 years ago

Some info that might help. I'm working on a plugin which bundles( with webpack) a NPM package with a Lodash 2.x.x dependency. Now when this script is enqueued in the admin dashboard somehow _.template inherits the old behavior and this error is triggered when I try the Add Media button or any other modal.

Note: See TracTickets for help on using tickets.