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
-
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login