10up / simple-podcasting

A simple podcasting solution for WordPress.
https://wordpress.org/plugins/simple-podcasting/
GNU General Public License v2.0
185 stars 30 forks source link

Fatal Error: Two few arguments passed to `tenup_podcasting\block\latest_episode_check()` #276

Closed peterwilsoncc closed 9 months ago

peterwilsoncc commented 9 months ago

Describe the bug

The following fatal error can be thrown upon saving a podcast in WordPress 5.8 and earlier:

[12-Feb-2024 02:28:53 UTC] PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function tenup_podcasting\block\latest_episode_check(), 2 passed in /vagrant/wp-build/wp-includes/class-wp-hook.php on line 292 and exactly 3 expected in /vagrant/content/plugins/simple-podcasting/includes/blocks.php:394
Stack trace:
#0 /vagrant/wp-build/wp-includes/class-wp-hook.php(292): tenup_podcasting\block\latest_episode_check(NULL, Array)
#1 /vagrant/wp-build/wp-includes/plugin.php(212): WP_Hook->apply_filters(NULL, Array)
#2 /vagrant/wp-build/wp-includes/blocks.php(766): apply_filters('pre_render_bloc...', NULL, Array)
#3 /vagrant/wp-build/wp-includes/blocks.php(854): render_block(Array)
#4 /vagrant/wp-build/wp-includes/class-wp-hook.php(292): do_blocks('<!-- wp:podcast...')
#5 /vagrant/wp-build/wp-includes/plugin.php(212): WP_Hook->apply_filters('<!-- wp:podcast...', Array)
#6 /vagrant/wp-build/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php(1768): apply_filters('the_content', '<!-- wp:podcast...')
#7 /vagrant/wp-build/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php(881): WP_REST_Posts_Controller->prepare_item_for_response(Object(WP_Post), Object(WP_REST_Request))
#8 /vagrant/wp-build/wp-includes/rest-api/class-wp-rest-server.php(1145): WP_REST_Posts_Controller->update_item(Object(WP_REST_Request))
#9 /vagrant/wp-build/wp-includes/rest-api/class-wp-rest-server.php(991): WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/wp/v2/posts/(?...', Array, NULL)
#10 /vagrant/wp-build/wp-includes/rest-api/class-wp-rest-server.php(396): WP_REST_Server->dispatch(Object(WP_REST_Request))
#11 /vagrant/wp-build/wp-includes/rest-api.php(354): WP_REST_Server->serve_request('/wp/v2/posts/10')
#12 /vagrant/wp-build/wp-includes/class-wp-hook.php(292): rest_api_loaded(Object(WP))
#13 /vagrant/wp-build/wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters('', Array)
#14 /vagrant/wp-build/wp-includes/plugin.php(551): WP_Hook->do_action(Array)
#15 /vagrant/wp-build/wp-includes/class-wp.php(388): do_action_ref_array('parse_request', Array)
#16 /vagrant/wp-build/wp-includes/class-wp.php(750): WP->parse_request('')
#17 /vagrant/wp-build/wp-includes/functions.php(1291): WP->main('')
#18 /vagrant/wp-build/wp-blog-header.php(16): wp()
#19 /vagrant/index.php(7): require('/vagrant/wp-bui...')
#20 {main}
  thrown in /vagrant/content/plugins/simple-podcasting/includes/blocks.php on line 394

The code in question runs on the pre_render_block filter. The third parameter, $parent_block, was introduced in WordPress 5.9 so triggers a fatal error in earlier versions of WordPress.

Steps to Reproduce

  1. Install WordPress 5.8
  2. On board this plugin (set up a taxononmy)
  3. Create a post
  4. Insert a simple podcasting block and add media
  5. Save post

The post will fail to save due to 500 error.

Screenshots, screen recording, code snippet

Screen Shot 2024-02-12 at 1 38 44 pm

Environment information

WordPress information

No response

Code of Conduct