WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#36820 closed defect (bug) (duplicate)

Missing data.attachment.sizes property causes javascript error and subsequent blank customization preview

Reported by: Fabio A Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.5.2
Component: Customize Keywords:
Focuses: javascript, template Cc:
PR Number:

Description

Suddenly, one of the sites I co-administer stopped showing the customizaton preview. Upon investigation, it appeared the problem was related to a missing javascript propery property causing the javascript engine to stop executing, which lead to a blank customization preview.

The property is data.attachment.sizes which is accessed at lines 70 and 74 of wp-includes/customize/class-wp-customize-site-icon-control.php.

I'm not at all into wordpress source code hacking, so I didn't have much luck in the short timespan I could allocate for this issue in discovering where data actually gets instantiated, and how. I was however able to conclude that the already uploaded favicon lacked the multiple sizes the javascript code was expecting, which causes the problem. Indeed, removing the old favicon and uploading a new one fixed the issue.

As workaround (or you might perhaps consider it a fix) a fake data.attachment.sizes could be created if it doesn't exist, filling it with the relevant data taken from data.attachment.

Such a workaround could look like this. Inject this line right after line 62 in wp-includes/customize/class-wp-customize-site-icon-control.php.

<# if ( !data.attachment.sizes ) { data.attachment.sizes = { 'full': { 'url': data.attachment.url } } }  #>

I tested it before trying to delete and reupload the favicon and it worked.

Change History (1)

#1 @ocean90
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #36749.

Note: See TracTickets for help on using tickets.