Skip to content

Commit

Permalink
Fix unable to publish edited legacy widgets in the customizer (#31484)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin940726 authored May 5, 2021
1 parent 451baad commit b519a76
Showing 1 changed file with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ function blockToWidget( block, existingWidget = null ) {
id: block.attributes.id,
};
} else {
const { encoded, hash, raw, ...rest } = block.attributes.instance;

// Widget that extends WP_Widget.
widget = {
idBase: block.attributes.idBase,
instance: {
encoded_serialized_instance:
block.attributes.instance.encoded,
instance_hash_key: block.attributes.instance.hash,
raw_instance: block.attributes.instance.raw,
...existingWidget.instance,

This comment has been minimized.

Copy link
@talldan

talldan May 5, 2021

Contributor

This seems to be throwing an error for new widgets.

I tried adding a SiteOrigin Button, and this line throws because existingWidget is null.

encoded_serialized_instance: encoded,
instance_hash_key: hash,
raw_instance: raw,
...rest,
},
};
}
Expand All @@ -55,17 +58,15 @@ function blockToWidget( block, existingWidget = null ) {
};
}

function widgetToBlock( {
id,
idBase,
number,
instance: {
function widgetToBlock( { id, idBase, number, instance } ) {
let block;

const {
encoded_serialized_instance: encoded,
instance_hash_key: hash,
raw_instance: raw,
},
} ) {
let block;
...rest
} = instance;

if ( idBase === 'block' ) {
const parsedBlocks = parse( raw.content );
Expand All @@ -80,6 +81,7 @@ function widgetToBlock( {
encoded,
hash,
raw,
...rest,
},
} );
} else {
Expand Down

0 comments on commit b519a76

Please sign in to comment.