ActiveCampaign / postmark-wordpress

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

Undefined Constants Warning #99

Closed pgraham3 closed 1 year ago

pgraham3 commented 2 years ago

PHP Version: 7.4.30 WordPress Version: 5.9.3 Plugin version: 1.17.1

Tools > Site Health page:

image

pgraham3 commented 2 years ago

Hey @bhubbard - Should we be checking those constants from Postmark_Mail (postmark.php) are defined in class-postmark-debug.php or could we concatenate the constants with an empty string on these lines to resolve these warnings? I don't quite get why this warning would be shown at all since all the $debug_info['postmark-wordpress'] array keys are quoted and POSTMARK_DIR is being used for a string value.

bhubbard commented 2 years ago

@pgraham3 Hmm yeah it's not clear why those would be undefined unless the plugin was modified or running in a non-typical method. We could probably update the debug file to do a check to kill the notice, something like this:

defined( POSTMARK_DIR ) ? POSTMARK_DIR : 'NOT DEFINED';

Ideally if not defined we display the text in yellow or red to let them know it's probably an issue.

kyletaylored commented 2 years ago

I'm actually getting this as a Fatal Error vs just a warning on the Site Info page.

Fatal error: Uncaught Error: Undefined constant "POSTMARK_VERSION" in /code/wp-content/plugins/postmark-approved-wordpress-plugin/includes/class-postmark-debug.php:34

Stack trace: 
#0 /code/wp-includes/class-wp-hook.php(307): Postmark_Debug->debug_info(Array) 
#1 /code/wp-includes/plugin.php(191): WP_Hook->apply_filters(Array, Array) 
#2 /code/wp-admin/includes/class-wp-debug-data.php(1461): apply_filters('debug_informati...', Array) 
#3 /code/wp-admin/site-health-info.php(32): WP_Debug_Data::debug_data() 
#4 /code/wp-admin/includes/class-wp-site-health.php(66): require_once('/code/wp-admin/...') 
#5 /code/wp-includes/class-wp-hook.php(307): WP_Site_Health->show_site_health_tab('debug') 
#6 /code/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters('', Array) 
#7 /code/wp-includes/plugin.php(476): WP_Hook->do_action(Array) 
#8 /code/wp-admin/site-health.php(205): do_action('site_health_tab...', 'debug') 
#9 {main} thrown in /code/wp-content/plugins/postmark-approved-wordpress-plugin/includes/class-postmark-debug.php on line 34

image

PHP Version: 8.0.21 WordPress Version: 6.0.1 Plugin version: 1.17.1

pgraham3 commented 2 years ago

I have a proposed PR for this here. Mind taking a look at that @bhubbard?

I also have it up as a tag (1.17.2) on the plugin marketplace.

@kyletaylored can you try out version 1.17.2 and let me know if that resolves the error?

You can update to version 1.17.2 using the wp-cli:

$ wp plugin update postmark-approved-wordpress-plugin --version=1.17.2

kyletaylored commented 2 years ago

Error still seems to persist.

image

Fatal error: Uncaught Error: Undefined constant "POSTMARK_VERSION" in /code/wp-content/plugins/postmark-approved-wordpress-plugin/includes/class-postmark-debug.php:36 

Stack trace: 
#0 /code/wp-includes/class-wp-hook.php(307): Postmark_Debug->debug_info(Array) 
#1 /code/wp-includes/plugin.php(191): WP_Hook->apply_filters(Array, Array) 
#2 /code/wp-admin/includes/class-wp-debug-data.php(1461): apply_filters('debug_informati...', Array) 
#3 /code/wp-admin/site-health-info.php(32): WP_Debug_Data::debug_data() 
#4 /code/wp-admin/includes/class-wp-site-health.php(66): require_once('/code/wp-admin/...') 
#5 /code/wp-includes/class-wp-hook.php(307): WP_Site_Health->show_site_health_tab('debug') 
#6 /code/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters('', Array) 
#7 /code/wp-includes/plugin.php(476): WP_Hook->do_action(Array) 
#8 /code/wp-admin/site-health.php(205): do_action('site_health_tab...', 'debug') 
#9 {main} thrown in /code/wp-content/plugins/postmark-approved-wordpress-plugin/includes/class-postmark-debug.php on line 36
pgraham3 commented 2 years ago

Thanks @kyletaylored! I see the issue.

I needed to have the constants' names in quotes for the defined() check. I just updated the 1.17.2 tag with that change.

Please reinstall version 1.17.2 and let me know how it goes.

kyletaylored commented 2 years ago

Yep, that did it!

image

pgraham3 commented 2 years ago

Awesome - thanks for confirming, @kyletaylored! 🫡