Fix builder rendering failures when stored widget or row style is null (#1366) - #1367
Fix builder rendering failures when stored widget or row style is null (#1366)#1367AlexGStapleton wants to merge 3 commits into
Conversation
Update toggleVisibilityFade() in js/siteorigin-panels/view/widget.js and js/siteorigin-panels/view/row.js to return early if styles is null or not an object. Guard checkIfStyleExists() against non-object and null style values to prevent runtime exceptions when checking visibility disable flags.
…efault models Update loadPanelsData() in js/siteorigin-panels/model/builder.js to verify that panels_info.style and data.grids[i].style are non-null objects before assigning them to model attributes.
Update SiteOrigin_Panels_Styles_Admin::sanitize_all() in inc/styles-admin.php to check if widget, grid, or cell style values are null or non-arrays, and unset/remove them instead of skipping, ensuring null values do not survive save operations.
|
Reviewed this while deciding whether it lets us close siteorigin/siteorigin-premium#1293. The JS half looks right to me: Two things about the 1. The null branch is unreachable. if ( isset( $panels_data['widgets'][ $i ]['panels_info']['style'] ) ) {
if ( is_null( $panels_data['widgets'][ $i ]['panels_info']['style'] ) || ! is_array( ... ) ) {
unset( ... );
Running the block against that input leaves 2. Ordering means this hook can't catch the null we actually hit. Page Builder sanitises before it applies the pre-save filter: $panels_data = SiteOrigin_Panels_Styles_Admin::single()->sanitize_all( $panels_data );
$panels_data = apply_filters( 'siteorigin_panels_data_pre_save', $panels_data, $post, $post_id );
What I'm asking for:
Why, and what it means for premium#1293: with only this PR applied, the builder stops crashing, but Toggle Visibility keeps writing Not asking you to change that judgement, just explaining why #1293 isn't being closed. Happy to be told I've read the ordering wrong. |
Misplon
left a comment
There was a problem hiding this comment.
Thanks, mate. Please, see my requested changes above.
|
The two changes requested above are the first two commits of #1374, which is now stacked on this branch: |
…r can add them A style that is not an array cannot be sanitized or rendered, and a null one crashes the builder's style checks when the layout loads. The removal now lives in one helper, remove_invalid_styles(), which sanitize_all() runs on the output of the data migration filter; the per-list checks it replaces used isset(), which is false for a key holding null, so the null case they were written for never reached them. The three save paths also run the helper on the output of the siteorigin_panels_data_pre_save filter. sanitize_all() runs before that filter, so a callback on it could store a null style that nothing cleaned; the Toggle Visibility migration in SiteOrigin Premium did exactly that. Refs #1366, #1367.
Resolve #1366