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

Use wpinc constant #120

Closed kkmuffme closed 2 years ago

kkmuffme commented 2 years ago

also ABSPATH has a trailing slash, so path had duplicate slashes

stayallive commented 2 years ago

You are correct that ABSPATH has a trailing / so that is fixed: 054ad7a4f1d8b3fd516f7e669c3b2e7f024538f0.

What is the point of using WPINC?

Since we can be loaded from the wp-config.php it's possible that WPINC is not yet defined and from the looks of it there is no point in using WPINC over wp-includes since the user cannot modify it's value, but please correct me if I'm wrong!

kkmuffme commented 2 years ago

Yeah that might be an issue if we use it in wp-config.php, if there is a wp-config there. Can make it conditional?

Even though WP does not officially support modifying WPINC to something else, there are people who have changed it and it would require keeping a fork of this repo, even though this change is minor.

Also in wp-core all places that use wp-includes use the WPINC constant (currently: some are still old, but there are Trac PRs for all places, which will release with WP 6.0 later this year)

EDIT: added a condition for it now. I support a installation that has WPINC defined in a PHP global prepend file, which is why currently I use a fork. Since the change really is minor (and WP core is also consistently using WPINC finally in the coming months), I thought I propose this here too, so I can remove my fork.

stayallive commented 2 years ago

So I'm guessing you are modifying the WPINC constant in your projects? :)

And with this change everything works? We use wp-includes in more places, that's why I'm asking 😄

stayallive commented 2 years ago

I have given it a go myself, how about #121? Would that work?

kkmuffme commented 2 years ago

Perfect, thanks! :)

stayallive commented 2 years ago

Should be fixed in release 4.12.0!

Thank you for suggesting it and taking the time to make a PR even 💪