-
-
Notifications
You must be signed in to change notification settings - Fork 452
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
Search for curl_init() only in root namespace #1632
Conversation
This triggered a code style rule that functions shouldn't have the leading backslash, but it's quite useful at least here IMHO. |
Hmm. In theory we require In practice; I do understand the error is unfortunate here. Might be better to throw a Edit: When this is not installed via composer because it's bundled in a plugin like for WordPress this can also easily happen where this requirement cannot be enforced by composer so it would be good to throw an exception so it's logged but won't break. |
Those platform requirements are for composer only. Meanwhile, the app, let's say it's a WordPress site, could have a long lifespan after composer runs, with PHP extensions being enabled and disabled in a control panel, code being moved around, etc. I updated the branch to allow the leading backslash on curl_init(), so at least the existing error message is improved. |
We catch all exceptions thrown in the client here https://github.com/getsentry/sentry-php/blob/master/src/Transport/HttpTransport.php#L86-L95 I'm also not in favour of checking the requirement during runtime, this can cause a bad day for people deploying stuff when we suddenly throw exceptions because cURL is not installed. Before we add hacks to the code style, let's add a new logger entry, please. |
if (!function_exists('curl_init')) {
throw new \RuntimeException('The cURL extension must be enabled to use the HttpClient.');
} Put this below the DSN check and we're good. Or maybe even |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I was assuming that extension_loaded is faster than function_exists() - it has less to search, but idk :) |
Yeah, makes sense, good change! |
A few years ago it made negligible difference in speed so Thanks! |
If curl is missing at runtime, the curl_init() function call searches the Sentry\HttpClient namespace, which results in a confusing error message: "Call to undefined function Sentry\HttpClient\curl_init()". We only want to search the root namespace.