Opened 9 years ago
Closed 8 years ago
#35878 closed defect (bug) (wontfix)
In `wp.media.view.Attachment.render` tested parameter is missing a default.
Reported by: | georgestephanis | Owned by: | |
---|---|---|---|
Milestone: | Priority: | lowest | |
Severity: | minor | Version: | 4.2 |
Component: | Media | Keywords: | has-patch 2nd-opinion |
Focuses: | javascript | Cc: |
Description (last modified by )
I'm still familiarizing myself with Media, so please feel free to just close/wontfix if this is silly.
On line ~116 in wp-includes/js/media/views/attachment.js
we're testing:
if ( options.nonces ) {
but options.nonces
isn't initialized above in the options
defaults.
For clarity's sake, should we initialize it to false
? (also, it keeps my IDE from getting cranky about it)
Patch attached.
Also -- options.percent
isn't initialized either -- but as that seems to be conditionally initialized down below (only initialized if options.uploading
is truthy), I didn't muck around with it in this patch.
Attachments (1)
Change History (11)
#1
@
9 years ago
- Description modified (diff)
- Summary changed from In `wp.media.view.Attachment.render` tested parameter is missing an initialization. to In `wp.media.view.Attachment.render` tested parameter is missing a default.
#5
@
9 years ago
@adamsilverstein It's PHPStorm --
I guess at the least, I'd like to see the conditional changed to something like if ( 'undefined' !== typeof options.nonces ) {
to make it explicit we're testing for something that may be unset?
Maybe it's just my PHP brain throwing up danger signals about testing undefined indices.
#7
@
9 years ago
@georgestephanis This SO article suggested adding a doc block, which fixed the warning for me.
@georgestephanis Thanks for the bug report, glad to see you tinkering in the media JS.
I'm not sure we need to define nonces here or what the default would be. nonces are passed in the options (as are many other fields missing from the defaults ), but do they really have a logical default except null or undefined?
your IDE settings may need some adjusting :) what specifically is its cranky complaint and what are you linting with?