stayallive / wp-sentry

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

Issues with custom ABSPATH #135

Closed uhlhosting closed 2 years ago

uhlhosting commented 2 years ago

Hi,

Deployed the plugin and added this in the wp-config.php:

/** Configures WP Sentry */
define('WP_SENTRY_ERROR_TYPES', E_ALL & ~E_NOTICE);
define('WP_SENTRY_ENV', 'production');
define('WP_SENTRY_BROWSER_DSN', 'https://c619403a9a954e7b8ef733be87165480@sentry.uhlhost.net/4');
define('WP_SENTRY_PHP_DSN', 'https://4e4325ee942a4a388dec8acc314824fd@sentry.uhlhost.net/3');
define('WP_SENTRY_SEND_DEFAULT_PII', true);
define('WP_SENTRY_VERSION', 'v5.1.0');
require_once ABSPATH . 'wp-content/plugins/wp-sentry-integration/wp-sentry.php';

Yet my panel records this error:

failed to obtain WP configuration for `/var/www/html': PHP Warning: Use of undefined constant ABSPATH - assumed 'ABSPATH' (this will throw an Error in a future version of PHP) in /var/www/html/wp-config.php on line 97 PHP Warning: require_once(ABSPATHwp-content/plugins/wp-sentry-integration/wp-sentry.php): failed to open stream: No such file or directory in /var/www/html/wp-config.php on line 97 PHP Fatal error: require_once(): Failed opening required 'ABSPATHwp-content/plugins/wp-sentry-integration/wp-sentry.php' (include_path='.:/usr/share/pear') in /var/www/html/wp-config.php on line 97
stayallive commented 2 years ago

Hi @uhlhosting, yeah that's unfortunate instructions and I'll see if that can be improved reliably 😄

You should either remove ABSPATH and make sure the path is correct or you need to place the require_once a little lower but still before the last require_once of you wp-config.php.

uhlhosting commented 2 years ago

I managed to solve it, after adding it bellow ABSPATH was defined. Thanks.

stayallive commented 2 years ago

Updated the README so hopefully the next person will not have issues.

Thanks for reporting!