Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 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:


Attachments (3)

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

Download all attachments as: .zip

Change History (11)

#1 @projct
9 years ago

  • Keywords has-patch added

typo fixed

#2 @projct
9 years ago

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

#3 @projct
9 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.

#4 @azaozz
9 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.

#5 @projct
9 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.

#6 @azaozz
9 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.

#7 @azaozz
9 years ago

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

Fixed in [10348]

#8 @azaozz
9 years ago

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