aaemnnosttv/wp-sqlite-db

WooCommerce Fatal Errors

stefanos82 opened this issue · 14 comments

I don't know whether it relates to #3 or not, but now I get these fatal errors in WooCommerce > Status > Logs:

2020-05-28T15:39:58+00:00 CRITICAL Uncaught Error: Call to a member function format() on null in /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php:79
Stack trace:
#0 /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php(52): ActionScheduler_wcSystemStatus->get_action_status_date()
#1 /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php(27): ActionScheduler_wcSystemStatus->get_oldest_and_newest()
#2 /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_AdminView.php(50): ActionScheduler_wcSystemStatus->render()
#3 /var/www/html/peiramaSQLite/app/wp-includes/class-wp-hook.php(287): ActionScheduler_AdminView->system_status_report()
#4 /var/www/html/peiramaSQLite/app/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters()
#5 /var/www/html/peiramaSQLi in /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php on line 79

2020-05-28T15:42:11+00:00 CRITICAL Uncaught Error: Call to a member function format() on null in /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php:79
Stack trace:
#0 /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php(52): ActionScheduler_wcSystemStatus->get_action_status_date()
#1 /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php(27): ActionScheduler_wcSystemStatus->get_oldest_and_newest()
#2 /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_AdminView.php(50): ActionScheduler_wcSystemStatus->render()
#3 /var/www/html/peiramaSQLite/app/wp-includes/class-wp-hook.php(287): ActionScheduler_AdminView->system_status_report()
#4 /var/www/html/peiramaSQLite/app/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters()
#5 /var/www/html/peiramaSQLi in /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php on line 79

2020-05-28T16:52:50+00:00 CRITICAL Uncaught Error: Call to a member function format() on null in /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php:79
Stack trace:
#0 /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php(52): ActionScheduler_wcSystemStatus->get_action_status_date()
#1 /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php(27): ActionScheduler_wcSystemStatus->get_oldest_and_newest()
#2 /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_AdminView.php(50): ActionScheduler_wcSystemStatus->render()
#3 /var/www/html/peiramaSQLite/app/wp-includes/class-wp-hook.php(287): ActionScheduler_AdminView->system_status_report()
#4 /var/www/html/peiramaSQLite/app/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters()
#5 /var/www/html/peiramaSQLi in /var/www/html/peiramaSQLite/app/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php on line 79

@aaemnnosttv I forgot to check my NGINX logs; seems like there's even more errors in there that are most specific:

2020/05/30 20:53:44 [error] 7440#7440: *119644 FastCGI sent in stderr: "PHP message: WordPress database error <div style="clear:both">&nbsp;</div><div class="queries" style="clear:both; margin_bottom:2px; border: red dotted thin;">Queries made or created this session were<br/>
	<ol>
		<li>Raw query:
INSERT INTO peiramasqlitewp_woocommerce_sessions (`session_key`, `session_value`, `session_expiry`) VALUES ('1', 'a:7:{s:4:\"cart\";s:6:\"a:0:{}\";s:11:\"cart_totals\";s:367:\"a:15:{s:8:\"subtotal\";i:0;s:12:\"subtotal_tax\";i:0;s:14:\"shipping_total\";i:0;s:12:\"shipping_tax\";i:0;s:14:\"shipping_taxes\";a:0:{}s:14:\"discount_total\";i:0;s:12:\"discount_tax\";i:0;s:19:\"cart_contents_total\";i:0;s:17:\"cart_contents_tax\";i:0;s:19:\"cart_contents_taxes\";a:0:{}s:9:\"fee_total\";i:0;s:7:\"fee_tax\";i:0;s:9:\"fee_taxes\";a:0:{}s:5:\"total\";i:0;s:9:\"total_tax\";i:0;}\";s:15:\"applied_coupons\";s:6:\"a:0:{}\";s:22:\"coupon_discount_totals\";s:6:\"a:0:{}\";s:26:\"coupon_discount_tax_totals\";s:6:\"a:0:{}\";s:21:\"removed_cart_contents\";s:6:\"a:0:{}\";s:8:\"customer\";s:73" while reading upstream, client: 192.168.10.4, server: peiramasqlite.cy, request: "POST /wp-admin/admin-ajax.php HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "peiramasqlite.cy"
2020/05/30 20:55:26 [error] 7440#7440: *119775 FastCGI sent in stderr: "PHP message: WordPress database error <div style="clear:both">&nbsp;</div><div class="queries" style="clear:both; margin_bottom:2px; border: red dotted thin;">Queries made or created this session were<br/>
	<ol>
		<li>Raw query:
INSERT INTO `peiramasqlitewp_options` (`option_name`, `option_value`, `autoload`) VALUES ('_transient_doing_cron', '1590861326.5633709430694580078125', 'yes') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)</li>
		<li>Rewritten:
INSERT INTO peiramasqlitewp_options (option_name, option_value, autoload) VALUES ('_transient_doing_cron', '1590861326.5633709430694580078125', 'yes')</li>
		<li>With Placeholders:
INSERT INTO peiramasqlitewp_options (option_name, option_value, autoload) VALUES ( :param_0 ,  :param_1 ,  :param_2 )</li>
		<li>Prepare:
INSERT INTO peiramasqlitewp_options (option_name, option_value, autoload) VALUES ( :param_0 ,  :param_1 ,  :param_2 )</li>
		<li>Executing:
a" while reading response header from upstream, client: 192.168.10.4, server: peiramasqlite.cy, request: "GET /wp-json/wc-analytics/admin/notes?order=desc&orderby=date&page=1&per_page=1&type=info%2Cwarning&_locale=user HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "peiramasqlite.cy"

Oh I haven't seen that before. Looks like it's coming from this call here, which shouldn't be randomly outputting error messages.

echo $this->get_error_message();

Is it something I should worry about?

Also, based on your experience, how stable wb.php is considered for plugins like WooCommerce?

It can be quite handy for me with my tiny / small to medium customer websites.

Is it something I should worry about?

I suppose it depends on where you're using this. I haven't used it in production yet; this has mostly been for local development + testing for me so far so for that it's been great. If you're experiencing fatals as a result of using this and you're trying to run an ecommerce store, I would consider using mysql/mariadb for first-class support.

I would love for this driver to be production-ready at some point, but it clearly has a few issues to be addressed, and needs more robust test coverage before I would consider it ready.

I suppose it depends on where you're using this. I haven't used it in production yet; this has mostly been for local development + testing for me so far so for that it's been great. If you're experiencing fatals as a result of using this and you're trying to run an ecommerce store, I would consider using mysql/mariadb for first-class support.

That's exactly what I'm doing; these errors take place locally, but I would love to use this drop-in replacement on a production-ready website...eventually!

I would love for this driver to be production-ready at some point, but it clearly has a few issues to be addressed, and needs more robust test coverage before I would consider it ready.

I feel you mate.

Is there a way I could help with so we can stabilize it?

I sincerely want this database as my default option.

"use SQLite when you can, use MariaDB when you must"; this is concept.

In addition to getting these errors, I'm seeing that on activating a new WooCommerce install that the Status page is reporting none of the WooCommerce custom tables exist in the database. It seems like the current version of WooCommerce is not functional at all with the Sqlite plugin.

@vying1 works just fine for me, but to clarify a thing: I don't use the plugin; I use the db.php only as a drop-in replacement.

You're right, it does work. The setup wizard fails because it says it can't save the inputs, and when I checked the status I assumed it was because the missing database tables. But after manual setup it does seem to be functional.

Same error message on my Debian 10, Nginx, PHP-FPM setup.
http://192.168.117.155/wp-admin/admin.php?page=wc-status

From the Nginx log, it seems action-scheduler is the one causing the issue.

2020/07/07 23:02:02 [error] 497#497: *2058 FastCGI sent in stderr: "PHP message: PHP Warning:  Invalid argument supplied for foreach() in /var/www/wpwcsqlitetest/public/wp-content/plugins/woocommerce/packages/woocommerce-rest-api/src/Controllers/Version2/class-wc-rest-system-status-v2-controller.php on line 836PHP message: PHP Warning:  Invalid argument supplied for foreach() in /var/www/wpwcsqlitetest/public/wp-content/plugins/woocommerce/packages/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php on line 428PHP message: PHP Fatal error:  Uncaught Error: Call to a member function format() on null in /var/www/wpwcsqlitetest/public/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php:79
Stack trace:
#0 /var/www/wpwcsqlitetest/public/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php(52): ActionScheduler_wcSystemStatus->get_action_status_date()
#1 /var/www/wpwcsqlitetest/public/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_wcSystemStatus.php(27): ActionScheduler_wcSystemStatus->get_oldest_and_newest()
#2 /var/www/wpwcsqlitetest/public/wp-content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_AdminView.php(50): ActionScheduler_wcSystemStatus->render()
#3 /var/www/wpwcsqlitetest/public/wp-includes/class-wp-hook.php(287): ActionScheduler_AdminView->system_status_report()
#4 /var/www/wpwcsqlitetest/public/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters()
#5 /var/www/sup" while reading response header from upstream, client: 192.168.117.1, server: www.wpwcsqlitetest.com, request: "GET /wp-admin/admin.php?page=wc-status HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "www.wpwcsqlitetest.com", referrer: "https://www.wpwcsqlitetest.com/wp-admin/admin.php?page=wc-settings"

I was looking at my wp-content/uploads/wc-logs/ and have found the following error message(s):

2020-07-24T12:55:23+00:00 CRITICAL Uncaught Error: Class 'WP_SQLite_DB\Datetime' not found in /var/www/html/peiramaSQLite/app/wp-content/db.php:515
Stack trace:
#0 [internal function]: WP_SQLite_DB\PDOSQLiteUDFS->date_sub()
#1 /var/www/html/peiramaSQLite/app/wp-content/db.php(1691): PDOStatement->execute()
#2 /var/www/html/peiramaSQLite/app/wp-content/db.php(1407): WP_SQLite_DB\PDOEngine->execute_query()
#3 /var/www/html/peiramaSQLite/app/wp-content/db.php(2739): WP_SQLite_DB\PDOEngine->query()
#4 /var/www/html/peiramaSQLite/app/wp-includes/wp-db.php(2605): WP_SQLite_DB\wpsqlitedb->query()
#5 /var/www/html/peiramaSQLite/app/wp-includes/post.php(6987): wpdb->get_col()
#6 /var/www/html/peiramaSQLite/app/wp-includes/class-wp-hook.php(287): wp_delete_auto_drafts()
#7 /var/www/html/peiramaSQLite/app/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters()
#8 /var/www/html/peiramaSQLite/app/wp-includes/plugin.php(544): WP_Hook->do_action()
#9 /var/www/html/peiramaSQLite/app/wp-cron.php(138): do_action_ref_array()
#10 {main}
  thrown in /var/www/html/peiramaSQLite/app/wp-content/db.php on line 515

I said to myself "weird; Datetime is part of PHP itself" and I looked it up.

@aaemnnosttv seems like we have a typo in that class name; Datetime it should be DateTime

https://github.com/aaemnnosttv/wp-sqlite-db/blob/master/src/db.php#L505-L517

The above typo in DateTime has been resolved: #8

Now we need to find a solution with the new tables WooCommerce needs to create so it can stop complaining.

Is this still a problem?

Is this still a problem?

Haven't tested it since then; I have uninstall WC from my local website and use SQLite for plain website only.

Feel free to close it for now and in future time I will test it again unless anyone else reports the same issues as mine.

Feel free to close it for now and in future time I will test it again unless anyone else reports the same issues as mine.

Sounds good to me. This may still be a problem, but I'd prefer to focus the issue on the underlying cause rather than an incompatibility with a specific plugin 🙂