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