Closed fiskhandlarn closed 1 year ago
a possible workaround for this would of course be to set all options in the database upon install. since it's possible to set the other options via filters i think it's dangerous to assume that all users will submit the form on /wp-admin/options-general.php?page=bugsnag
(and thus invoke Bugsnag_Wordpress::updateNetworkSettings
setting the default values). this will of course not solve the problem with newlines as described above though.
Thanks for the report and workaround @fiskhandlarn !
This issue was resolved via a support ticket, but for the benefit of future travellers: it should be possible to work around the issue by setting the option to ""
it was me who filed the support ticket, and the issue still persists in the current version of this plugin, although i got great help by the support staff. :)
my tip for future travellers: try and implement https://github.com/bugsnag/bugsnag-php into your application instead.
Describe the bug
if the 'bugsnag_filterfields' option isn't set,
get_option('bugsnag_filterfields')
will returnfalse
. this will makeBugsnag_Wordpress::filterFields
return[""]
(i.e. an array with one item containing an empty string (array(1) { [0]=> string(0) "" }
)). further down the line this array will makeError::cleanupObj
believe that all values should be filtered, because https://github.com/bugsnag/bugsnag-php/blob/2.10/src/Bugsnag/Error.php#L386 will always be true (sincestrpos($key, "")
will always return 0, and 0 is !==false
).my suggestion would be to rewrite https://github.com/bugsnag/bugsnag-wordpress/blob/master/bugsnag.php#L156 to
if ($filter_fields === '' || $filter_fields === false) {
or maybe even betterif (empty(trim($filter_fields ?? ''))) {
(to catch the case where the user has written just whitespace in the wp-admin (perhaps this line must be rewritten to support older php versions though). i could make a pr for this if you want?pls note that setting 'bugsnag_filterfields' to
"whatever\n"
will yield the same problems sinceBugsnag_Wordpress::filterFields
then will return["whatever",""]
and then filter everything out based on the second item in the array. you should probably take a look at https://github.com/bugsnag/bugsnag-wordpress/blob/master/bugsnag.php#L160 and make sure it doesn't return any empty strings in the array.Steps to reproduce
[FILTERED]
Environment