elementor / static-html-output

Static HTML Output Plugin for WordPress
https://statichtmloutput.com
The Unlicense
124 stars 33 forks source link

Fix DB table creation on update;check deactivation, deletion and attempted install on < PHP 7.3 #102

Open crstauf opened 4 years ago

crstauf commented 4 years ago
WordPress database error Table 'local.wp_statichtmloutput_urls' doesn't exist for query TRUNCATE TABLE wp_statichtmloutput_urls made by do_action('toplevel_page_statichtmloutput'), WP_Hook->do_action, WP_Hook->apply_filters, StaticHTMLOutput\Controller::renderOptionsPage, StaticHTMLOutput\Controller->detect_urls, StaticHTMLOutput\CrawlQueue::truncate, QM_DB->query
WordPress database error Table 'local.wp_statichtmloutput_urls' doesn't exist for query SELECT COUNT(*) FROM wp_statichtmloutput_urls made by do_action('toplevel_page_statichtmloutput'), WP_Hook->do_action, WP_Hook->apply_filters, StaticHTMLOutput\Controller::renderOptionsPage, StaticHTMLOutput\Controller->detect_urls, StaticHTMLOutput\CrawlQueue::truncate, StaticHTMLOutput\CrawlQueue::getTotalCrawlableURLs, QM_DB->query
PHP Fatal error:  Uncaught TypeError: Return value of StaticHTMLOutput\CrawlQueue::getTotalCrawlableURLs() must be of the type int, null returned in /app/public/wp-content/plugins/static-html-output-plugin/src/CrawlQueue.php:86
Stack trace:
#0 /app/public/wp-content/plugins/static-html-output-plugin/src/CrawlQueue.php(99): StaticHTMLOutput\CrawlQueue::getTotalCrawlableURLs()
#1 /app/public/wp-content/plugins/static-html-output-plugin/src/Controller.php(189): StaticHTMLOutput\CrawlQueue::truncate()
#2 /app/public/wp-content/plugins/static-html-output-plugin/src/Controller.php(218): StaticHTMLOutput\Controller->detect_urls()
#3 /app/public/wp-includes/class-wp-hook.php(287): StaticHTMLOutput\Controller::renderOptionsPage('')
#4 /app/public/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters('', Array)
#5 /app/public/wp-includes/plugin.php(478): WP_Hook->do_action(Array)
#6 /app/public/wp-admin/admin.php(254): do_action('toplevel_page_s...')
#7 {main}
  thrown in /app/public/wp-content/plugins/static-html-output-plugin/src/CrawlQueue.php on line 86
crstauf commented 4 years ago

@leonstafford Critical errors with 6.6.19 (after upgrading from 6.6.17).

crstauf commented 4 years ago

Confirmed in local WordPress of portfolio site, and in my plugin development environment: upgrading from 6.6.17 to 6.6.19 results in the above errors.

crstauf commented 4 years ago

It seems that the tables are only created on plugin activation, which a plugin update it seems does not fire the activation hook.

Deactivating and reactivating the plugin seems to fix the problem.

leonstafford commented 4 years ago

@crstauf ah, thanks! I had hoped it was for update, too. I'll need to do some comprehensive testing before release to ensure smooth updates and deactivation, uninstall all work

leonstafford commented 4 years ago

tracking in https://github.com/WP2Static/static-html-output-plugin/pull/105