plugin-check icon indicating copy to clipboard operation
plugin-check copied to clipboard

Plugins Fail to Create Custom Tables in Database During Runtime Check

Open mukeshpanchal27 opened this issue 1 year ago • 4 comments

Describe the bug

I am encountering a persistent issue with both WooCommerce and Yoast SEO plugins. These plugins are expected to create custom tables in the WordPress database during installation or activation. However, I have noticed that sometimes, the tables are not being created, leading to "table not found" errors during runtime checks.

Steps to Reproduce

  1. Setup Plugin Checker in you local system using steps outline here
  2. Install and activate WooCommerce plugin
  3. Go to Admin Panel > Tools > Plugin Check
  4. Open The Browsers Network tab
  5. Select "WooCommerce" and click on "Check it!" button
  6. Check "enqueued_scripts_size" and "enqueued_styles_scope" check output in network tab.

Screenshots, screen recording, code snippet

Screenshot 2023-07-21 at 11 02 17 AM

Environment information

No response

WordPress information

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

mukeshpanchal27 avatar Jul 21 '23 05:07 mukeshpanchal27

cc. @felixarntz @spacedmonkey @eclarke1

mukeshpanchal27 avatar Jul 21 '23 06:07 mukeshpanchal27

Thanks @mukeshpanchal27, good catch. I think in order to find a way to fix it, we need to investigate how these two plugins add their custom database tables. For example is it in the plugin activation hook? Or in some other action in WP Admin? Or completely custom logic? Let's check that.

felixarntz avatar Jul 21 '23 16:07 felixarntz

Hi @felixarntz, I've spent some time investigating how plugins add custom tables in WordPress, and I noticed that both plugins add their custom tables in the plugin activation hook. Specifically, I tried to activate the Yoast SEO plugin using activate_plugin('wordpress-seo/wp-seo.php'); and the WooCommerce plugin using activate_plugin('woocommerce/woocommerce.php');, but unfortunately, they didn't add the custom tables in my dummy database.

I'm facing this issue and I'm not sure why it's happening. Could you please guide me on how to move forward and troubleshoot this problem? Your insights would be greatly appreciated! cc. @joemcgill

mukeshpanchal27 avatar Jul 26 '23 10:07 mukeshpanchal27

This also seems to happen for GatherPress, see https://github.com/GatherPress/gatherpress/blob/9cc072252d9b167793d97a7174ef1436b16eecf7/includes/core/classes/class-setup.php#L149 and https://github.com/GatherPress/gatherpress/actions/runs/10134308384/job/28020387857#step:8:214

[28-Jul-2024 19:49:47 UTC] WordPress database error Table 'wordpress.wp_pc_gatherpress_events' doesn't exist for query DELETE FROM `wp_pc_gatherpress_events` WHERE `post_id` = 7 made by include('phar:///usr/local/bin/wp/php/boot-phar.php'), include('phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php'), WP_CLI\bootstrap, WP_CLI\Bootstrap\LaunchRunner->process, WP_CLI\Runner->start, WP_CLI\Runner->run_command_and_exit, WP_CLI\Runner->run_command, WP_CLI\Dispatcher\Subcommand->invoke, call_user_func, WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}, call_user_func, WordPress\Plugin_Check\CLI\Plugin_Check_Command->check, WordPress\Plugin_Check\Checker\Abstract_Check_Runner->run, WordPress\Plugin_Check\Checker\Preparations\Demo_Posts_Creation_Preparation->WordPress\Plugin_Check\Checker\Preparations\{closure}, wp_delete_post, do_action('delete_post'), WP_Hook->do_action, WP_Hook->apply_filters, GatherPress\Core\Event_Setup->delete_event

swissspidy avatar Jul 29 '24 08:07 swissspidy