Skip to content

Use is_int() in stats to fix PHP 8.6 deprecation - #3192

Open
faisalahammad wants to merge 1 commit into
Automattic:trunkfrom
faisalahammad:fix/php86-is-integer
Open

faisalahammad wants to merge 1 commit into
Automattic:trunkfrom
faisalahammad:fix/php86-is-integer

Conversation

@faisalahammad

Copy link
Copy Markdown
Contributor

Changes Proposed in this Pull Request

  • PHP 8.6 deprecates the is_integer() alias. Stats::parse_stats() uses it to check the stat count, so every logged stat (job view, search impression, apply click) writes this notice:

    PHP Deprecated: Function is_integer() is deprecated since 8.6, use is_int() instead in includes/class-stats.php on line 222
    
  • Replaced it with is_int(). It is the same function, so the behavior does not change.

  • Added test_log_stat_rejects_non_integer_count to check that a string or float count is still rejected and nothing is logged.

Repro on PHP 8.6: php -r 'is_integer(1);' prints the deprecation.

Testing Instructions

  1. On PHP 8.6, set WP_DEBUG and WP_DEBUG_LOG to true.
  2. Go to Job Listings > Settings > General and turn on Enable Stats.
  3. Open a published job listing in a private window.
  4. Check wp-content/debug.log. On trunk you see the is_integer() is deprecated line.
  5. Switch to this branch, empty debug.log, and open a different job in a new private window.
  6. Expected: no is_integer() line in debug.log, and the job view is still counted on the job dashboard.

Automated: phpunit passes on PHP 8.2 (1258 tests, 3 Geocode tests skipped), and PHPCS is clean.

Release Notes

  • Fix PHP 8.6 deprecation notice for is_integer() when logging stats.

This branch has not been deployed

No deployments
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.

1 participant