WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#8658 closed enhancement (fixed)

[PATCH] wp-includes/js/autosave.js: check if properties are defined before use

Reported by: projct Owned by:
Milestone: 2.8 Priority: normal
Severity: normal Version: 2.7
Component: Autosave Keywords: has-patch
Focuses: Cc:

Description


Attachments (3)

define-post_data_content-at-declaration.diff (431 bytes) - added by projct 7 years ago.
define-post_data_content-at-declaration.2.diff (432 bytes) - added by projct 7 years ago.
check-post-data-content.diff (723 bytes) - added by projct 7 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 @projct7 years ago

  • Keywords has-patch added

typo fixed

comment:2 @projct7 years ago

whoops, need to rethink this, it didn't solve the problem I was after.

comment:3 @projct7 years ago

  • Summary changed from [PATCH] wp-includes/js/autosave.js: define content property of post_data before use to [PATCH] wp-includes/js/autosave.js: check if properties are defined before use

ok, this looks more like the right solution. please inspect.

check type of post_datacontent? and post_datapost_title? before trying to use them.

comment:4 @azaozz7 years ago

  • Component changed from General to Autosave
  • Owner anonymous deleted

Both post_data["post_title"] and post_data["content"] are defined couple of rows earlier so checking if they are undefined is redundant there. They are set to either jQuery object or empty string both of which have property "length".

Perhaps describe the problem you're having.

comment:5 @projct7 years ago

$('#post_title').val() and $('#post_content').val() will return undefined if the item does not exist on the page.

It's a minor fix that gets in the way when combining JS and CSS for #3372, which I am working on a patch for.

comment:6 @azaozz7 years ago

  • Type changed from defect (bug) to enhancement

Are you combining all js and css files into one-two large files? Generally autosave.js and editor.js need to be loaded only on pages that have an editor on them.

I'm actually looking at something similar that would concatenate and probably compress the core js and css files including TinyMCE.

comment:7 @azaozz7 years ago

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

Fixed in [10348]

comment:8 @azaozz7 years ago

  • Milestone changed from 2.7.1 to 2.8
Note: See TracTickets for help on using tickets.