fix(php85): drop deprecated curl_close() calls - #153
Conversation
curl_close() is deprecated as of PHP 8.5 and has been a no-op since PHP 8.0,
when the curl handle became a CurlHandle object released by refcount:
Function curl_close() is deprecated since 8.5, as it has no effect since PHP 8.0
Removed all seven call sites across class/ and xoops_lib/. In each case the
handle is not referenced after the removed line -- curl_error()/curl_getinfo()
already ran and captured into locals -- so behaviour is unchanged on every
supported version (PHP_MIN 8.2).
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRemove deprecated no-op curl_close() calls and correct misuse of curl_exec() result handling, ensuring behavior is preserved or improved across supported PHP versions (>= 8.2). Sequence diagram for updated stopForumSpamLookup cURL handlingsequenceDiagram
participant Protector
participant Curl
participant StopForumSpamAPI
Protector->>Curl: curl_init()
Protector->>Curl: curl_setopt(ch, options)
Protector->>StopForumSpamAPI: HTTP request via curl_exec(ch)
StopForumSpamAPI-->>Curl: HTTP response body
Curl-->>Protector: result
alt result is false
Protector->>Curl: curl_getinfo(ch)
Curl-->>Protector: info array
Protector-->Protector: result = info
else result is string
Protector-->Protector: result = json_decode(result, true)
end
Protector-->>Protector: return result
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #153 +/- ##
=========================================
Coverage 19.29% 19.29%
Complexity 8227 8227
=========================================
Files 672 672
Lines 44266 44262 -4
=========================================
Hits 8539 8539
+ Misses 35727 35723 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This pull request updates XOOPS 2.7.x HTTP/cURL usage to remain clean on PHP 8.5+ by removing deprecated curl_close() calls (a no-op since PHP 8.0), and fixes a real behavioral bug in Protector’s StopForumSpam lookup where a second curl_exec() was unintentionally issuing an extra HTTP request.
Changes:
- Remove deprecated
curl_close()calls from multiple cURL call sites. - Fix
stopForumSpamLookup()to decode the already-fetched response instead of performing a second request. - Add clarifying inline comments explaining the StopForumSpam double-request bug.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| htdocs/xoops_lib/modules/protector/class/protector.php | Fixes StopForumSpam lookup to decode the existing response and removes the curl_close() call. |
| htdocs/class/xoopshttpget.php | Drops deprecated curl_close() in the SSRF-hardened cURL fetch path. |
| htdocs/class/snoopy.php | Removes curl_close() calls from HTTPS request handling. |
| htdocs/class/captcha/recaptcha2.php | Removes curl_close() after reCAPTCHA verification request. |
| // Decode the response already in hand. This line previously called | ||
| // curl_exec($ch) a second time, issuing another request to | ||
| // stopforumspam.com on every successful lookup and decoding that | ||
| // second response instead of the one just tested for failure. | ||
| $result = json_decode($result, true); |
Greptile SummaryThis PR removes deprecated, ineffective
Confidence Score: 5/5The PR appears safe to merge with no actionable regressions identified. The removed close calls are ineffective on supported PHP versions, and the StopForumSpam change preserves the decoded response contract while eliminating an unnecessary and potentially inconsistent second request.
|
| Filename | Overview |
|---|---|
| htdocs/class/captcha/recaptcha2.php | Removes an ineffective curl_close() after all response and error data have been consumed. |
| htdocs/class/snoopy.php | Removes ineffective cURL handle-close calls from both failure and success paths without changing response processing. |
| htdocs/class/xoopshttpget.php | Removes an ineffective handle-close call after response, status, redirect, and error information have been captured. |
| htdocs/xoops_lib/modules/protector/class/protector.php | Removes the deprecated close call and correctly decodes the first successful StopForumSpam response rather than issuing a second request. |
Reviews (1): Last reviewed commit: "fix(php85): drop deprecated curl_close()..." | Re-trigger Greptile
curl_close() is deprecated as of PHP 8.5 and has been a no-op since PHP 8.0, when the curl handle became a CurlHandle object released by refcount:
Removed all seven call sites across class/ and xoops_lib/. In each case the handle is not referenced after the removed line -- curl_error()/curl_getinfo() already ran and captured into locals -- so behaviour is unchanged on every supported version (PHP_MIN 8.2).
Summary by Sourcery
Remove deprecated and unnecessary cURL handle closing and correct duplicate request behavior in stopForumSpam lookup.
Bug Fixes:
Enhancements: