stayallive / wp-sentry

A (unofficial) WordPress plugin reporting PHP and JavaScript errors to Sentry.
https://wordpress.org/plugins/wp-sentry-integration/
MIT License
300 stars 48 forks source link

`WP_SENTRY_ERROR_TYPES` set to `E_ALL & ~E_NOTICE` still logs PHP user notices #167

Closed vtwigt closed 12 months ago

vtwigt commented 1 year ago

Hi @stayallive ,

As mentioned in the title, I am using the following constant in wp-config.php:

define( 'WP_SENTRY_ERROR_TYPES', E_ALL & ~E_NOTICE );

Nevertheless, my Sentry account is being flooded by the following notices (over 1600 by now):

User Notice: Function wp_cache_flush_runtime was called incorrectly. Your object cache implementation does not support flushing the in-memory runtime cache. Please see Debugging in WordPress for more information. (This message was added in version 6.1.0.)

I am not entirely sure from the README.md, but does the Sentry constant use and support all PHP error constants, including E_USER_NOTICE? In other words, should I have changed the configuration as follows?

define( 'WP_SENTRY_ERROR_TYPES', E_ALL & ~E_NOTICE & ~E_USER_NOTICE );

And if it does, may I suggest to add this information to the README.md?

stayallive commented 1 year ago

Well, technically the E_USER_NOTICE is different from E_NOTICE so it works as intened.

If you also want to supress E_USER_NOTICE than yes you should use E_ALL & ~E_NOTICE & ~E_USER_NOTICE, you can see we have another example too in the README:

(Optionally) set the error types the PHP tracker will track:

define( 'WP_SENTRY_ERROR_TYPES', E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_USER_DEPRECATED );

You can set any combination you like there just like you kan setup error_types for PHP itself. I didn't think it to be needed to be that specific saying it is using PHP constants since it is... but maybe it's better to be more explicit.

vtwigt commented 1 year ago

I agree that it works as intended, and I also agree that it can be interpreted from the example that the PHP error constants are being used, since WordPress is not defining these constants.

My point is that it would be super clear if an extra line in the README.md explains that all PHP error constants are supported. This way everybody knows that the ones mentioned in the example are not the only possibilities.

If you prefer to leave it as is, I understand. In both cases, feel free to close this issue. 👍

stayallive commented 12 months ago

Sure, updated it: 3cc874435766d3f3dd13e2dfe293b9ab6ff82843. Thanks!