-
Notifications
You must be signed in to change notification settings - Fork 297
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. |
QA Update ⚠Hi @techanvil , I wanted to drill down a bit more on the following QAB steps:
|
Hi @kelvinballoo - apologies, that was actually a typo and should have read "install the build for PR #9913", by which I do mean changing to the branch for that PR instead of Examining your site's With that branch installed, examine the result of a request to the await googlesitekit.api.get('core','site','fpm-server-requirement-status', undefined, { useCache: false }); |
QA Update ⚠Hi @techanvil , thanks for the clarification. From my understanding, we have 3 main scenarios here:
In case I'm missing any scenario or detail, leading to my wrong result, please let me know. |
Hi @kelvinballoo, thanks for your further testing. To answer your questions:
As per the QAB, the only error that we're expecting to fix as a result of using Curl is the one where the error message indicates that the healthcheck has failed due to the As you've surmised the healthcheck for the Btw, reviewing the QAB I've realised it would be useful to test this healthcheck still fails and the warning does appear for a site with Curl both enabled and disabled. I've updated the QAB as follows to clarify this:
As for a site where the
Taking a look at
@jamesozzie might want to try this, or I'd be happy to do so myself or with James on a call, or to look into this further as needs be. Please take another look and let me know how you get on, I'd be happy to sync to discuss this further if that would help. |
QA Update ⚠Thanks @techanvil . I was able to verify:
|
Hi @kelvinballoo, thanks for the update.
Yup, as the error message in your screenshot indicates, you don't have view access to the connected property and this is what's will be causing the enhanced measurement control/value to be stuck in the loading state. It's out of scope for this issue, but please do go ahead and create a new issue where we can consider how to improve the UX for this scenario. |
QA Update ✅Thanks @techanvil , new ticket is attached here: #9988 As for this ticket, it's good to be moved to approval.
|
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, verify the warning notice still does appear.allow_url_fopen
is disabled on the server, 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. The expectation is that it will be installed because Site Kit relies on it in order to use WordPress' HTTP request utilities:

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 #9913 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: