Fix release download failure when allow_url_fopen is disabled#8127
Fix release download failure when allow_url_fopen is disabled#8127
allow_url_fopen is disabled#8127Conversation
Co-authored-by: DawoudIO <554959+DawoudIO@users.noreply.github.com>
allow_url_fopen is disabled
There was a problem hiding this comment.
Pull request overview
Updates the upgrade ZIP download logic to work on hosts where allow_url_fopen is disabled by switching the primary transport from file_get_contents() to cURL (with improved logging and retry behavior), ensuring the release download step succeeds in common shared-hosting configurations.
Changes:
- Use cURL as the primary download mechanism for GitHub release assets (SSL verification, redirects, timeout, actionable error details).
- Keep existing retry loop/backoff while improving error propagation to logs/exceptions.
- Retain
file_get_contents()as a fallback when cURL is unavailable.
| if (function_exists('curl_init')) { | ||
| // Use cURL for download (works even when allow_url_fopen is disabled) | ||
| $ch = curl_init($url); | ||
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
There was a problem hiding this comment.
function_exists('curl_init') doesn’t guarantee curl_init($url) returns a valid CurlHandle. If curl_init returns false (e.g., malformed/empty URL), the subsequent curl_setopt calls will raise a TypeError and bypass the retry/exception flow. Handle the false return explicitly (set an error message and either retry or fall back to file_get_contents).
Guard against curl_init() returning false (e.g. malformed URL) before passing the handle to curl_setopt(), which would raise a TypeError in PHP 8 and bypass the retry/exception flow. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Addressed the Copilot reviewer feedback in c1633ba: added an explicit |
Servers with
allow_url_fopen = Off(common on shared hosting) fail to download upgrade ZIPs viafile_get_contents(), producing "no suitable wrapper could be found". SincecURLis already a declared ChurchCRM prerequisite, it's the correct transport to use here.Changes
src/ChurchCRM/dto/ChurchCRMReleaseManager.php—downloadRelease()now uses cURL as the primary download method:CURLOPT_SSL_VERIFYPEER,CURLOPT_SSL_VERIFYHOST)CURLOPT_FOLLOWLOCATION) — needed for GitHub's release asset CDNcurl_errno()+curl_error()+ HTTP status code for actionable failure logsfile_get_contentsonly ifcurl_initis somehow unavailableOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.