Details
-
Type: Improvement
-
Status: Open
-
Priority: Trivial
-
Resolution: Unresolved
-
Affects Version/s: 4.4.5
-
Fix Version/s: Unscheduled
-
Component/s: Core CiviCRM, Extension System
-
Labels:
-
Versioning Impact:Patch (backwards-compatible bug fixes)
-
Documentation Required?:None
-
Funding Source:Needs Funding
Description
The CRM_Utils_HttpClient::fetch() function does not return an error if the source URL does not exist (HTTP 404 error). This is because it is missing a curl option: curl_setopt($ch, CURLOPT_FAILONERROR, true );
(cf. http://se2.php.net/manual/en/function.curl-error.php#87212)
Also the error messages for the function are very specific to the extensions system, making this function unusable if say you want to use it to download say ... translations, or resources from other websites.
Ideally it should return a generic status code that the caller will then translate in a specific error message. Such status codes could be:
- CONFIGURATION_ERROR: the download cannot proceed due to a system configuration error (curl not activated, etc)
- DOWNLOAD_ERROR: the file could not be downloaded (HTTP error, malformed URL, etc),
- SAVE_ERROR: the file could not be saved (permissions, etc)
- STATUS_OK: all is well