ActiveCampaign / postmark-wordpress

The Official Postmark Wordpress Plugin
GNU General Public License v2.0
17 stars 17 forks source link

1.10.1 PHP error #38

Closed EatonZ closed 5 years ago

EatonZ commented 5 years ago

After upgrading to the new 1.10.1 version and going to Settings -> Postmark in wp-admin, the following error appears in PHP error logs:

WordPress database error Table 'ts.wp_postmark_log' doesn't exist for query SELECT COUNT(*) FROM wp_postmark_log made by require_once('C:\inetpub\TS\wwwroot\wp-admin\admin.php'), do_action('settings_page_pm_admin'), WP_Hook->do_action, WP_Hook->apply_filters, Postmark_Mail->settings_html, include('C:\inetpub\TS\wwwroot\wp-content\plugins\postmark-approved-wordpress-plugin\page-settings.php')

Looks like it's trying to load the new log table, but it's not created on upgrade.

This happens every time I load the settings page.

pgraham3 commented 5 years ago

@EatonZ I just released version 1.10.2 which handles creating the db after an upgrade. Please upgrade to this latest version and let me know if it resolves this.

EatonZ commented 5 years ago

@pgraham3 Thanks for the quick response. Unfortunately, 1.10.2 does not fix it. It still happens.

pgraham3 commented 5 years ago

@EatonZ Thanks for trying that - looks like it may have been an issue with version definition in the constructor being off. Please try 1.10.3 and let me know if that does the trick.

EatonZ commented 5 years ago

@pgraham3 I got this error after upgrading, but it only happened once. Loading the settings page doesn't trigger it. I assume you will publish another version to fix this - should I drop this bad table?

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 ''pmlogdateindex' ON wp_postmark_log('log_entry_date')' at line 1 for query CREATE INDEX 'pmlogdateindex' ON wp_postmark_log('log_entry_date') made by Plugin_Upgrader->bulk_upgrade, do_action('upgrader_process_complete'), WP_Hook->do_action, WP_Hook->apply_filters, upgrade_completed, pm_log_create_db

pgraham3 commented 5 years ago

@EatonZ Yes, please drop that table and then try to disable/enable logging again in the settings. Let me know if you continue to get a db error after trying to enable/disable the new logging option. Thanks for working with me on this.

EatonZ commented 5 years ago

@pgraham3 It happens when toggling the setting too. So it looks like the table creation is bugged.

pgraham3 commented 5 years ago

Got it - I will work on a new version that fixes that index creation error and let you know when it is available.

pgraham3 commented 5 years ago

@EatonZ Removed the indexing to resolve that last error for now (see v1.10.4). Will look into adding the index step back in a future release. Let me know if anything else comes up with the new release.

EatonZ commented 5 years ago

@pgraham3 Since the upgrade didn't create that table again, I still get the error in the first post every time I view the settings. When I toggle the log option on, it creates the table which fixes it, but when toggling off, the error comes back since that apparently drops the table. You should try to stop that error from showing if the table isn't there.

I am not getting the index error anymore, so that is fixed.

pgraham3 commented 5 years ago

@EatonZ I updated v1.10.4 again with a change to how the settings page checks for the enable logs setting to ensure that variable is set before trying to check that table.

I went through the upgrade process to double check (going from v1.9.6, which was the last release before this new logs option was added, to v1.10.4) and did not get any PHP errors or MySQL related errors.

This last change should fix it for sure but let me know if you still see anything funny.

EatonZ commented 5 years ago

@pgraham3 I think we're good now - not noticing any further errors. Thank you for the quick fixes.

pgraham3 commented 5 years ago

@EatonZ Glad to hear it! Thanks for confirming it's all good now.

EatonZ commented 5 years ago

@pgraham3 Just got another error out of nowhere. I do not have logging enabled. Looks like some sort of scheduled task?

WordPress database error Table 'ts.wp_postmark_log' doesn't exist for query SELECT COUNT(*) FROM wp_postmark_log
          WHERE 'log_entry_date' < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 7 DAY)) LIMIT 500
          made by do_action_ref_array, WP_Hook->do_action, WP_Hook->apply_filters, pm_clear_old_logs
pgraham3 commented 5 years ago

Thanks for the report @EatonZ. Looks like it might be trying to run the cron job to delete the old logs. I'll get a fix out.

pgraham3 commented 5 years ago

@EatonZ Just pushed a fix for it (noticed a typo in my cron job deactivation step when the logs feature is disabled). Please update and then toggle logs on, then off again.

If you use a cron manager plugin, you should see a cron job called pm_log_cron_job when the logs setting is enabled and it should be removed from your scheduled cron jobs after disabling the logs feature.

Thanks for helping me get these kinks worked out with this new logs feature 👍

EatonZ commented 5 years ago

@pgraham3 Will that fix this one too? PHP Notice: Undefined index: enable_logs in C:\inetpub\ts\wwwroot\wp-content\plugins\postmark-approved-wordpress-plugin\wp-mail.php on line 200

pgraham3 commented 5 years ago

@EatonZ Latest version, 1.10.6 has a fix for that as well.

EatonZ commented 5 years ago

@pgraham3 Getting a similar error now with the latest update: PHP Notice: Undefined index: track_links in C:\inetpub\ts\wwwroot\wp-content\plugins\postmark-approved-wordpress-plugin\wp-mail.php on line 150

pgraham3 commented 5 years ago

Thanks for the report @EatonZ, checking now.

pgraham3 commented 5 years ago

@EatonZ Can you give 1.11.2 a shot? Let me know if it still pops up, added an isset check when setting track_links that should fix it.