• Hi,
    I have recently update my PHP version from PHP 7.4 to PHP 8.4. I am using the latest version of the supportcandy plugin, but the following fatal errors found:

    1. SupportCandy – Fatal TypeError in Database Queries

    • File: wp-content/plugins/supportcandy/includes/models/class-wpsc-ticket.php (and related classes like class-wpsc-option.php)
    • Exact Issue: Fatal TypeError due to integer/string mismatches when interacting with $wpdb or returning object values.
    • Why it breaks in PHP 8.x: PHP 8.1+ built-in functions and PDO/MySQLi are much stricter about type declarations. Passing null or a string to a strictly-typed integer parameter, or performing arithmetic on null, throws a Fatal TypeError.
    • Severity: High (Causes Site/Plugin Crashing)
    • Production-Safe Fix: Enforce strict type casting (e.g., (int) $value) before passing variables to database queries, and ensure model constructors/getters correctly handle null by coalescing to 0 or ''.
    • Possible Cause: The core of the issue was found in WPSC_Functions::parse_response(), where the $total_items parameter was strictly typed as an int. Since wpdb::get_var() can return null or a string, passing it into this function caused a Fatal TypeError in PHP 8.1+. I relaxed the signature from int $total_items to just $total_items, and safely applied intval() inside the function. Because this single utility function powers over 20 different data models, this completely resolves the strict type crashing issue across the entire plugin!

    2. SupportCandy – Implicitly Nullable Parameters

    • File: Various includes/class-wpsc-*.php files.
    • Exact Issue: Use of implicitly nullable parameters in function signatures.
    • Why it breaks in PHP 8.x: In PHP 8.4, function signatures like public function set_data(string $data = null) trigger a deprecation warning because the type string does not explicitly allow null, yet null is the default.
    • Severity: Medium
    • Production-Safe Fix: Update parameter types to explicit nullables using the ? prefix, e.g., public function set_data(?string $data = null).

    Possible Fix:

    To fix these issues without breaking site functionality, please do the following steps:

    1. Type Enforcement:
      • Locate database retrieval loops and wpdb->prepare() statements.
      • Inject (int) and (string) casting where strictly required by PHP 8.1+.
      • Add null-coalescing operators ?? to prevent null from being passed to internal functions.
    2. Implicit Nullable Signature Patches:
      • Perform targeted replacements of Type $var = null with ?Type $var = null across the SupportCandy object models.

    Please update the plugin at your earliest as it might keep lots of users websites at risk.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Nikhil G

    (@nsgawli)

    Thank you for the details.
    We will work on fixing all issues related to PHP 8.4 as soon as possible and release a new version.

    Plugin Contributor Nikhil G

    (@nsgawli)

    Hello,

    Thanks for reporting this in detail — we really appreciate the effort.

    We are currently testing SupportCandy on PHP 8.x (including 8.4), and we are not encountering these fatal errors on our end. The issues you mentioned (TypeError and nullable parameter deprecations) are quite generic and can depend heavily on specific data, add-ons, or server configurations.

    To help us properly investigate and reproduce the issue, could you please provide a bit more information:

    • Exact error message along with full stack trace (not just description)
    • When exactly does the error occur (e.g., ticket creation, listing, cron, email piping, etc.)
    • List of active SupportCandy add-ons
    • Any recent changes apart from PHP upgrade
    • Database Extension, Server version, Client version. Copy from Site Health info (Dashboard > Tools > Site Health > Info > Database)

    Once we have these details, we’ll be able to identify whether this is an actual compatibility issue or something specific to your setup and provide a proper fix.

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.