-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Curl for the FPM health check requests if it's available #9916
Comments
If we have more control over measurement.php we could extract the RequestHandler class and import it later within the plugin and measurements.php. With the above approach we could contribute back the additional conditional logic so that this change is included in future updates. |
Thanks @benbowler, SGTM. It would be good to feed this back to the FPM library developers... Tagging @aaemnnosttv, who's had a hand in the development. IB ✅ |
Actually, further on the above I've noticed this comment in site-kit-wp/fpm/measurement.php Lines 146 to 156 in bb6bf17
Of course even if it wasn't a separate file we could extract it ourselves, but the fact that it is would make the exercise more within the spirit of just copying things over without modifying them. |
Feature Description
At the moment we're unconditionally using
file_get_contents()
to request the FPM health check URLs.As discussed on Slack, there can be scenarios where
file_get_contents()
doesn't work, but using Curl does.It should also be noted that the
measurement.php
script itself uses Curl in preference tofile_get_contents()
if it's installed:site-kit-wp/fpm/measurement.php
Lines 193 to 201 in 1ea478e
We should therefore apply the same logic to the health check requests, using Curl to make the request if it's installed on the server.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation Brief
Note that the implementation should use code from
measurement.php
to make the requests, in order to keep the health check logic as close to the proxy behaviour as possible. This will involve reusing theRequestHelper
class, as well as possibly routing a request throughmeasurement.php
itself.Update
includes/Core/Tags/First_Party_Mode/First_Party_Mode.php
:Google\FirstPartyLibrary\RequestHelper;
.is_endpoint_healthy
method:RequestHelper
.$response
by calling thesendRequest
method onRequestHelper
.Update
composer.json
adding afiles
key to theautoload
key with the value[ 'fpm/measurement.php' ]
to autoload the classes in this file.Update
fpm/measurement.php
:site-kit-wp/fpm/measurement.php
Line 285 in d1c9ec6
!defined( 'WPINC' )
, this prevents the code from being executed when the classes are included via autoload within the plugin rather than being called directly.Test Coverage
QA Brief
firstPartyMode
feature flag enabled and Analytics connected (and/or test with the Ads module).allow_url_fopen
PHP setting being disabled on the server, and where Curl is not installed, verify the warning notice still does appear.allow_url_fopen
is disabled on the server and the Curl extension is installed, the warning should no longer appear because Curl doesn't rely on theallow_url_fopen
setting.If Curl is installed, it will be listed in the Server section of Site Health:
To see if the health checks are failing due to the
allow_url_fopen
setting, either examine your site'sphp.ini
settings directly to see if the setting is enabled, or install the build for PR #9914 and examine the response of a request tofpm-server-requirement-status
:See this Asana task for more details, and ask @jamesozzie for access to his sites with health check failures which meet the criteria listed above if necessary.
Changelog entry
The text was updated successfully, but these errors were encountered: