Woocommerce-admin: [4.0] WC Admin fatal error

Created on 11 Mar 2020  Â·  13Comments  Â·  Source: woocommerce/woocommerce-admin

Describe the bug
I am not sure if this is a bug with WooCommerce but I suspect it might be.

I have this error on a customer's site:

Fatal error: Uncaught Exception: Invalid data store. in /home/xxx/yyy/wp-content/plugins/woocommerce/includes/class-wc-data-store.php:107

Stack trace:
#0 /home/xxx/yyy/wp-content/plugins/woocommerce/includes/class-wc-data-store.php(139): WC_Data_Store->__construct('admin')
woocommerce/woocommerce#1 /home/xxx/yyy/wp-content/plugins/woocommerce-admin/src/Notes/WC_Admin_Notes.php(121): WC_Data_Store::load('admin-note')
woocommerce/woocommerce#2 /home/xxx/yyy/wp-content/plugins/woocommerce-admin/src/Notes/WC_Admin_Notes_Deactivate_Plugin.php(59): Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes::delete_notes_with_name('wc-admin-deacti...')
woocommerce/woocommerce#3 /home/xxx/yyy/wp-content/plugins/woocommerce/packages/woocommerce-admin/src/Package.php(60): Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Deactivate_Plugin::delete_note()
woocommerce/woocommerce#4 [internal function]: Automattic\WooCommerce\Admin\Composer\Package::init()
woocommerce/woocommerce#5 /home/xxx/yyy/wp-content/plugins/woocommerce/src/Pac in /home/xxx/yyy/wp-content/plugins/woocommerce/includes/class-wc-data-store.php on line 107

There has been a critical error on your website. Please check your site admin email inbox for instructions.

It is shown on the plugins.php page. The site is a multisite, it's shown on the Network tab but also when opening wp-admin of some subsites.

My suspect is this line

WC_Data_Store->__construct('admin')

The Data Store admin does not seem to exist anywhere and it's causing this error to appear.

To Reproduce
Not sure.

Isolating the problem (mark completed items with an [x]):

  • [x] I have deactivated other plugins and confirmed this bug occurs when only WooCommerce plugin is active.
  • [x] This bug happens with a default WordPress theme active, or Storefront.
  • [x] I can reproduce this bug consistently using the steps above.

WordPress Environment

In the ticket. Private data are included so I cannot post it here.

2781410-zen

All 13 comments

It seems to me that inside \Automattic\WooCommerce\Admin\Composer\Package::init, add_note and delete_note is getting called before the admin-note data store is registered in FeaturePlugin::instance()->init();.

In this case, the plugin must be installed and it is up to date (judging by the fact that delete_note is in the stack trace).

WC Admin data stores are hooked to plugins_loaded, default priority in \Automattic\WooCommerce\Admin\FeaturePlugin::init via \Automattic\WooCommerce\Admin\FeaturePlugin::on_plugins_loaded, \Automattic\WooCommerce\Admin\FeaturePlugin::includes and \Automattic\WooCommerce\Admin\API\Init::__construct

However, also hooked to plugins_loaded, \Automattic\WooCommerce\Packages::on_init runs from the WC Admin package. This then calls \Automattic\WooCommerce\Admin\Composer\Package::init which is where the error happens.

So it looks like both 1. registering the data stores and 2. potentially using them runs at plugins_loaded with the default priority, which can lead to a problem.

Transferred to WC Admin repo.

btw WC_Data_Store->__construct('admin') is a bit of a red herring, WC looks for data store 'admin' if 'admin-note' has not been found, as the code is hoping the 'parent' data store might handle it.

@SiR-DanieL

I'm currently working on a fix for the issue, but in the meantime - if the customer doesn't mind WooCommerce Admin being active on all of their sites, network activating it should stop the PHP Fatal.

As a note for anyone else reading this - network activating WooCommerce Admin fixed this for one customer I chatted to

Hi,
I am reading this and I have issues since I tried to update to WooCommerce 4.0 (I am back to 3.9.3 due to even more issues). Some of it looks very similar to mine, but something doesn't.
The biggest mysterium for me is that Action Scheduler tries to access non-existing database tables with the prefix "a." Nobody so far was able to answer my question where this comes from and how to fix it. I can see the scheduled actions in the my database, but the list "Scheduled Actions" in WooCommerce is always empty. I had 700+ scheduled actions at one point, obviously because the scheduler doesn't run at all. Maybe there is some help for me as well, please have a look at the errors bloating my debug.log file every some minutes:

[17-Mar-2020 20:56:34 UTC] PHP Notice: Undefined property: wpdb::$actionscheduler_actions in /home/univer73/public_html/universalsolder/wp-includes/wp-db.php on line 659
[17-Mar-2020 20:56:34 UTC] WordPress database error Table 'univer73_wp691.a' doesn't exist for query SELECT a.action_id FROM a WHERE a.hook='action_scheduler/migration_hook' AND a.status='in-progress' ORDER BY scheduled_date_gmt DESC LIMIT 1 made by shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, Action_Scheduler\Migration\Controller->schedule_migration, Action_Scheduler\Migration\Scheduler->is_migration_scheduled, as_next_scheduled_action, ActionScheduler_HybridStore->find_action, ActionScheduler_DBStore->find_action
[17-Mar-2020 20:56:34 UTC] WordPress database error Table 'univer73_wp691.a' doesn't exist for query SELECT a.action_id FROM a WHERE a.hook='action_scheduler/migration_hook' AND a.status='pending' ORDER BY scheduled_date_gmt ASC LIMIT 1 made by shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, Action_Scheduler\Migration\Controller->schedule_migration, Action_Scheduler\Migration\Scheduler->is_migration_scheduled, as_next_scheduled_action, ActionScheduler_HybridStore->find_action, ActionScheduler_DBStore->find_action
[17-Mar-2020 20:56:34 UTC] WordPress database error Table 'univer73_wp691.a' doesn't exist for query SELECT a.action_id FROM a WHERE a.hook='action_scheduler/migration_hook' AND a.status='in-progress' ORDER BY scheduled_date_gmt DESC LIMIT 1 made by shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, Action_Scheduler\Migration\Controller->schedule_migration, Action_Scheduler\Migration\Scheduler->schedule_migration, as_next_scheduled_action, ActionScheduler_HybridStore->find_action, ActionScheduler_DBStore->find_action
[17-Mar-2020 20:56:34 UTC] WordPress database error Table 'univer73_wp691.a' doesn't exist for query SELECT a.action_id FROM a WHERE a.hook='action_scheduler/migration_hook' AND a.status='pending' ORDER BY scheduled_date_gmt ASC LIMIT 1 made by shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, Action_Scheduler\Migration\Controller->schedule_migration, Action_Scheduler\Migration\Scheduler->schedule_migration, as_next_scheduled_action, ActionScheduler_HybridStore->find_action, ActionScheduler_DBStore->find_action
[17-Mar-2020 20:56:34 UTC] PHP Notice: Undefined property: wpdb::$actionscheduler_groups in /home/univer73/public_html/universalsolder/wp-includes/wp-db.php on line 659
[17-Mar-2020 20:56:34 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE slug='action-scheduler-migration'' at line 1 for query SELECT group_id FROM WHERE slug='action-scheduler-migration' made by shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, Action_Scheduler\Migration\Controller->schedule_migration, Action_Scheduler\Migration\Scheduler->schedule_migration, as_schedule_single_action, ActionScheduler_ActionFactory->single, ActionScheduler_ActionFactory->store, ActionScheduler_HybridStore->save_action, ActionScheduler_DBStoreMigrator->save_action, ActionScheduler_DBStore->save_action, ActionScheduler_DBStore->get_group_id
[17-Mar-2020 20:56:34 UTC] WordPress database error Incorrect table name '' for query SHOW FULL COLUMNS FROM made by shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, Action_Scheduler\Migration\Controller->schedule_migration, Action_Scheduler\Migration\Scheduler->schedule_migration, as_schedule_single_action, ActionScheduler_ActionFactory->single, ActionScheduler_ActionFactory->store, ActionScheduler_HybridStore->save_action, ActionScheduler_DBStoreMigrator->save_action, ActionScheduler_DBStore->save_action, ActionScheduler_DBStore->get_group_id, ActionScheduler_DBStore->create_group [17-Mar-2020 20:56:34 UTC] PHP Notice: Undefined property: wpdb::$actionscheduler_actions in /home/univer73/public_html/universalsolder/wp-includes/wp-db.php on line 659 [17-Mar-2020 20:56:34 UTC] WordPress database error Incorrect table name '' for query SHOW FULL COLUMNS FROM made by shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, Action_Scheduler\Migration\Controller->schedule_migration, Action_Scheduler\Migration\Scheduler->schedule_migration, as_schedule_single_action, ActionScheduler_ActionFactory->single, ActionScheduler_ActionFactory->store, ActionScheduler_HybridStore->save_action, ActionScheduler_DBStoreMigrator->save_action, ActionScheduler_DBStore->save_action
[17-Mar-2020 20:56:34 UTC] PHP Fatal error: Uncaught RuntimeException: Error saving action: Error saving action: Incorrect table name '' in /home/univer73/public_html/universalsolder/wp-content/plugins/wpforms/vendor/woocommerce/action-scheduler/classes/migration/ActionScheduler_DBStoreMigrator.php:44
Stack trace:

0 /home/univer73/public_html/universalsolder/wp-content/plugins/wpforms/vendor/woocommerce/action-scheduler/classes/data-stores/ActionScheduler_HybridStore.php(225): ActionScheduler_DBStoreMigrator->save_action(Object(ActionScheduler_Action), NULL)

1 /home/univer73/public_html/universalsolder/wp-content/plugins/wpforms/vendor/woocommerce/action-scheduler/classes/ActionScheduler_ActionFactory.php(177): ActionScheduler_HybridStore->save_action(Object(ActionScheduler_Action))

2 /home/univer73/public_html/universalsolder/wp-content/plugins/wpforms/vendor/woocommerce/action-scheduler/classes/ActionScheduler_ActionFactory.php(84): ActionScheduler_ActionFactory->store(Object(ActionScheduler_Action))

3 /home/univer73/public_html/universalsolder/w in /home/univer73/public_html/universalsolder/wp-content/plugins/wpforms/vendor/woocommerce/action-scheduler/classes/migration/ActionScheduler_DBStoreMigrator.php on line 44

Hello Support, I am experiencing the same issue on a single page installation.

My website is running on WordPress, it is a one site - not a Multisite installation. I have followed support tickets and came accross the #3869, but since it is not a Multisite insallation, the suggested fix does not solve the issue.

There is an error on the website, it says:

Fatal error: Uncaught Exception: Invalid data store. in /home/xxx/yyy/wp-content/plugins/woocommerce/includes/class-wc-data-store.php:107 Stack trace:

0 /home/xxx/yyy/wp-content/plugins/woocommerce/includes/class-wc-data-store.php(139): WC_Data_Store->__construct('admin')

1 /home/xxx/yyy/wp-content/plugins/mailchimp-for-woocommerce/admin/class-mailchimp-woocommerce-admin.php(283): WC_Data_Store::load('admin-note')

2 /home/xxx/yyy/wp-includes/class-wp-hook.php(286): MailChimp_WooCommerce_Admin->initial_notice('')

3 /home/xxx/yyy/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array) #4 /home/xxx/yyy/wp-includes/plugin.php(465): WP_Hook->do_action(Array)

5 /home/xxx/yyy/wp-admin/admin-header.php(276): do_action('admin_notices')

6 /home/xxx/yyy/wp-admin/index in /home/xxx/yyy/wp-content/plugins/woocommerce/includes/class-wc-data-store.php on line 107

—
Steps I took:

  1. Enabled WP_DEBUG;
  2. Deactivated all othe plugins one by one checking the status in the meantime;
  3. Deactivated the theme;
  4. Activated everything back, updated Woocommerce.

Despite the fact, that the plugins were disabled, the error still persisted.

Would you know how to fix this, please?

Hello Support, I am experiencing the same issue on a single page installation.

My website is running on WordPress, it is a one site - not a Multisite installation. I have followed support tickets and came accross the #3869, but since it is not a Multisite insallation, the suggested fix does not solve the issue.

There is an error on the website, it says:

Fatal error: Uncaught Exception: Invalid data store. in /home/xxx/yyy/wp-content/plugins/woocommerce/includes/class-wc-data-store.php:107 Stack trace:

0 /home/xxx/yyy/wp-content/plugins/woocommerce/includes/class-wc-data-store.php(139): WC_Data_Store->__construct('admin')

1 /home/xxx/yyy/wp-content/plugins/mailchimp-for-woocommerce/admin/class-mailchimp-woocommerce-admin.php(283): WC_Data_Store::load('admin-note')

2 /home/xxx/yyy/wp-includes/class-wp-hook.php(286): MailChimp_WooCommerce_Admin->initial_notice('')

3 /home/xxx/yyy/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array) #4 /home/xxx/yyy/wp-includes/plugin.php(465): WP_Hook->do_action(Array)

5 /home/xxx/yyy/wp-admin/admin-header.php(276): do_action('admin_notices')

6 /home/xxx/yyy/wp-admin/index in /home/xxx/yyy/wp-content/plugins/woocommerce/includes/class-wc-data-store.php on line 107

—
Steps I took:

  1. Enabled WP_DEBUG;
  2. Deactivated all othe plugins one by one checking the status in the meantime;
  3. Deactivated the theme;
  4. Activated everything back, updated Woocommerce.

Despite the fact, that the plugins were disabled, the error still persisted.

Would you know how to fix this, please?

I also have the same issue as well. if you manage to come across a fix, please let me know.

@eikiiz and @lukedskywalker it looks like from that stack track, the bug you are experiencing is in the MailChimp for WooCommerce plugin. I would suggest you opening an issue on their support forum

Just a note for any fellas looking for solutions:

I've got the same error messages. Explanation turned out to be a database issue, whereas after restoring an SQL backup for some reason the id column of the tables were not configured to auto-increment. This is an obscure way for such an issue to bubble up, but eventually this was the reason.
So if you face the same after doing a database import/restoration, ensure that all tables have their id column set to auto-increment.
Hope this may help someone some time.

Was this page helpful?
0 / 5 - 0 ratings