502 errors when saving a post — broken recursive call in update_thumbnails.php for 'stack' elements
-
Hi,
I've been getting 502 errors when saving certain projects in the WordPress admin. After digging into the nginx error logs I traced the issue to a PHP warning cascade in
wp-content/themes/lay/updatejson/update_thumbnails.php, lines 428–444:PHP Warning: Trying to access array offset on int in update_thumbnails.php on line 428 PHP Warning: Trying to access array offset on int in update_thumbnails.php on line 429 ... (repeats for every line in the unpack block)The warnings flood the FastCGI response headers until nginx rejects the response with a 502.
Bug cause
update_thumbnail_in_json_recursive()accepts a single$thumb_dataarray as its third parameter. However, thestackbranch calls it passing individual positional arguments instead:else if ($array[$i]['type'] == 'stack' ) { LayUpdateThumbnails::update_thumbnail_in_json_recursive( $array[$i]['cont'], $needsUpdate, $post_id, $permalink, $title, $featuredImgId, $featuredImgUrl, $ar, $sizesArr, ... ); }This means
$thumb_datareceives the value of$post_id(an integer) inside the recursive call. When the function then tries to unpack$thumb_data['post_id'],$thumb_data['permalink'], etc., PHP fires a warning on every single line of the unpack block.For reference, the
carouselandelementgridbranches in the same function call it correctly:else if ($array[$i]['type'] == 'carousel') { LayUpdateThumbnails::update_thumbnail_in_json_recursive( $array[$i]['carousel'], $needsUpdate, $thumb_data ); }Hope this helps. Happy to provide any additional info if needed.
-
oh yes, will release an update now that fixes this
-
im going to release the update now!
-
well in a few minutes
I also code custom websites or custom Lay features.
💿 Email me here: 💿
info@laytheme.com
Our Web Development company: 100k.studio
Want to tip me? https://www.paypal.com/paypalme/arminunruh
Before you post:
- When using a WordPress Cache plugin, disable it or clear your cache.
- Update Lay Theme and all Lay Theme Addons
- Disable all Plugins
- Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"
This often solves issues you might run into
When you post:
- Post a link to where the problem is
- Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
- If the problem is difficult to explain, post screenshots / link to a video to explain it