Skip to content

fix(php85): drop deprecated curl_close() calls - #153

Open
mambax7 wants to merge 1 commit into
XOOPS:masterfrom
mambax7:feature/drop_deprecated_curl_close_calls
Open

fix(php85): drop deprecated curl_close() calls#153
mambax7 wants to merge 1 commit into
XOOPS:masterfrom
mambax7:feature/drop_deprecated_curl_close_calls

Conversation

@mambax7

@mambax7 mambax7 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

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).

Summary by Sourcery

Remove deprecated and unnecessary cURL handle closing and correct duplicate request behavior in stopForumSpam lookup.

Bug Fixes:

  • Decode the existing cURL response in stopForumSpam lookup instead of issuing a second request via curl_exec().

Enhancements:

  • Eliminate redundant curl_close() calls now deprecated and ineffective on supported PHP versions.

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).
Copilot AI review requested due to automatic review settings August 3, 2026 02:34
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6d06f0d9-2408-43a3-b22c-dc01fe29556c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Remove 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 handling

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Adjust stopForumSpam lookup to correctly decode the already-fetched cURL response instead of re-executing the request, and remove the redundant curl_close() call.
  • Use the existing $result value from the prior curl_exec() call as the input to json_decode instead of calling curl_exec() again.
  • Add an explanatory comment describing the previous double-request behavior and the correction.
  • Remove the trailing curl_close($ch) call after response handling.
htdocs/xoops_lib/modules/protector/class/protector.php
Simplify Snoopy HTTPS request handling by relying on response/error/info data without explicitly closing the cURL handle.
  • On cURL error, set the error message from curl_error($ch) and return false without calling curl_close().
  • After successfully getting the response, compute the header size via curl_getinfo($ch, CURLINFO_HEADER_SIZE) without closing the handle.
  • Retain header/body splitting logic based on the computed header size.
htdocs/class/snoopy.php
Update ReCaptcha v2 verification to drop the explicit curl_close() call while preserving response parsing logic.
  • Keep json_decode of the $curlReturn response to build $recaptchaCheck.
  • Remove the explicit curl_close($curlHandle) after using the curl handle.
  • Leave the file_get_contents() fallback logic unchanged.
htdocs/class/captcha/recaptcha2.php
Update XOOPS HTTP GET cURL fetch implementation to rely on captured response and info without explicitly closing the cURL handle.
  • Retain extraction of HTTP status code, redirect URL, and error string via curl_getinfo() and curl_error().
  • Remove the explicit curl_close($curlHandle) call after gathering response and meta data.
  • Keep the error assignment and subsequent handling based on whether the response is false.
htdocs/class/xoopshttpget.php

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@gitar-bot

gitar-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 19.29%. Comparing base (d2b5bde) to head (9ce8a52).
⚠️ Report is 4 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +1216 to +1220
// 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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants