Commit Graph
1 Commits
Author SHA1 Message Date
d27c2a8779 fix: Fix php deprecation of spl_object_hash in php 8.6 (#8567)
* fix: Fix php deprecation of spl_object_hash in php 8.6

Replaces spl_object_hash() calls to address the PHP 8.6 deprecation.

Adds cacti_object_hash(), which uses spl_object_id() to produce a stable 32 character hash string, and migrates the database connection and affected-row tracking in lib/database.php to the helper. Boost already keys its per-connection packet-limit cache on spl_object_id() on develop, so no change is needed there.

Adds tests/Unit/CactiObjectHashTest.php covering hash format, determinism, uniqueness, and the non-object false return.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* tests: Cover cacti_object_hash connection-tracking paths in database.php

The changed-PHP-lines coverage gate fell below 80 percent because the cacti_object_hash() swaps in db_check_reconnect(), db_close(), and db_execute_prepared() (the DEBUG_SQL_CONNECT branches) were not exercised. Adds a unit test that drives those paths with a real PDO handle registered in \, raising changed-line coverage of lib/database.php to 7 of 8 lines (overall 10 of 11, 90.9 percent).

Every connection global these functions assign to is snapshotted and restored around each test so the shared connection state the rest of the suite relies on is not corrupted.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* tests: Move CactiObjectHashTest into the Core category folder

AGENTS.md requires unit tests to live in a category subfolder rather than the tests/Unit/ root. Moves the cacti_object_hash() helper test to tests/Unit/Core/ alongside the other core utility tests and updates its lib/functions.php include to dirname(__DIR__, 3) so it still resolves to the repository root.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: TheWitness <copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-02 15:54:54 +00:00