Closed skilver-io closed 1 year ago
Solution
We solved the issue by defining the global variables in a mu-plugin, so that the variables are available once the regular plugins load.
closed
Thanks for the feedback @skilver-io
Since the underlying issue here is about global PHP constants, and not really about Sentry, I changed the title. By the way, Sentry looks really cool, we definitely want to support plugins like this, although it's probably not something we would want to bundle with SlickStack by default.
This issue has been discussed several times in our Discord chat room during the past few years, and it's been difficult for me to get much feedback from developers on how to solve it.
A few years ago, SlickStack included a file at /wp-content/functions.php
that was include_once
by our wp-config.php
boilerplate so that teams could define any PHP constants they wanted in that file, and it would load early on in the WordPress loading sequence as per this chart:
However, recently we removed that file due to:
functions.php
Of course, LittleBizzy has always been a fan of hardcoding with PHP constants instead of MySQL queries whenever possible, so I understand if developers don't want to use a theme or plugin for every case.
My concerns are as follows:
wp-config.php
hardcoded and uneditable to achieve true stability with SlickStackWhat I had proposed in Discord a few times (with zero feedback from users) is maybe conditionally loading a file from within the wp-config.php
using a PHP if statement like this:
is_file($file) AND include $file;
Ref: https://stackoverflow.com/questions/4604965/how-to-include-only-if-file-exists Ref: https://stackoverflow.com/questions/792899/is-file-or-file-exists-in-php Ref: https://stackoverflow.com/questions/4099103/is-file-file-exists-performance-and-cache Ref: https://www.php.net/manual/en/function.is-file.php
Here's what I'm thinking maybe at the bottom of wp-config.php
to conditionally load something:
$custom_functions = '/var/www/html/wp-content/custom-functions.php';
is_file($custom_functions) AND include $custom_functions;
A few years ago LittleBizzy had a free plugin called Custom Functions that could be edited inside WP Admin (kind of) but the hooks for editing PHP files are not available by default in WordPress Core so it took a lot of jiggery hackery and is not something that would be secure long-term, so we abandoned that approach.
So, this file would be something really only available to SSH or maybe SFTP users to edit, which is maybe okay since this should only be messed with by advanced users anyways.
I've added this now, feedback desired:
https://github.com/littlebizzy/slickstack/commit/9f61304b82be7f7ad95e1872f886c6842979214b https://github.com/littlebizzy/slickstack/commit/807750dcd6c813b47994f51b9818865e69d15107 https://github.com/littlebizzy/slickstack/commit/aa383b4814efe581638e7c42750a3b3138586003
It should work on all 3 environments (production, staging, dev). If you use this feature and it works well for you, please be sure to tell us because this has been a recurring discussion the past few years... thanks!
Hi @jessuppi,
Have you every considered to support sentry.io as an additional error tracking system?
What is sentry.io? Sentry.io is an open-source full-stack error tracking system which allows to track errors and performance issues on WordPress in PHP and Javascript and helps developers to monitor and fix crashes in real time. Client side error and performance tracking is possible.
Why we need to integrate We are running multiple slickstack instances across almost all regions and we are having issues to track client side errors as well as performance issues on our custom product pages, cart and checkout. Sentry.io would allow us to track errors across all instances in a single system.
Slickstack integration The integration would be fairly simple via global variables in the wp-config file + a lightweight plugin by Alex Bouma to get started right out of the box:
Plugin: https://wordpress.org/plugins/wp-sentry-integration/#description Git: https://github.com/stayallive/wp-sentry/blob/v5.1.0/README.md
Necessary global variables
If no support possible In case a support for sentry.io is not possible: Is it possible to define the global variables in the wp-config file on our own?
I am not sure if slickstack will override the wp-config file on ss-install or on updates, etc.. Can you please give some details if there could be any issues coming up when integrating and changing the global variables on our own. Thanks you for your help.
Looking forward to hearing from you.
Best, Dennis