Repository navigation
fix: declare PHP 8.1 as the minimum and accept non-array payloads in chained hooks - #973
Merged
TheWitness merged 3 commits intoDec 5, 2026
Conversation
…chained hooks The native types added in Cacti#970 do not parse on PHP 7.4, which Cacti 1.2.29 to 1.2.31 still accept, and setup.php loads on every page. Declare php = 8.1 in INFO and the README, and make plugin_thold_install(), plugin_thold_check_config() and thold_check_dependencies() refuse on an older PHP that can still read the file, logging the reason. Cacti hands each plugin the previous plugin's return value, so a plugin earlier in the chain that returns nothing made the array-typed callbacks throw a TypeError. The navigation, device action and clog regex callbacks now start from an empty array; the data source table, graph options, device save, user save and data source remove callbacks return a non-array unchanged. Fixes Cacti#972 Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…1.2.31 Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…rray hooks Core chains data_source_action_array and graphs_action_array with api_plugin_hook_function(), so a plugin earlier in the chain that returns nothing leaves null for these callbacks. Start from an empty array, as the device action callback does. The other registered hooks are either typed nullable already, take no payload, or are called with api_plugin_hook() and a fresh array, which does not chain. Refs Cacti#972 Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
|
TheWitness
approved these changes
Dec 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Problem
Two regressions from the type clean-up in #970, described in #972.
setup.phploads on every page, so such a site shows a blank page after updating.INFOdeclares only the Cacti version and the README defers to Cacti.arraythrow a TypeError when a plugin earlier in Cacti's hook chain returns nothing, becauseapi_plugin_hook_function()passes each plugin the previous plugin's return value.thold_draw_navigation_text()runs on every page.Change
php = 8.1inINFO, a README requirements section and CHANGELOG entries. Linting every production PHP file gives 22 failures on PHP 7.4 and none on 8.0, 8.1 or 8.2; theneverreturn type makes 8.1 the real minimum. Cacti has no PHP requirement field, but it honours a false return fromplugin_thold_install()(hooks left disabled) andplugin_thold_check_config()(enable refused). Both, andthold_check_dependencies(), now refuse throughthold_php_supported()and log why. This can only act wheresetup.phpstill parses (PHP 8.0); on PHP 7.4 nothing in the plugin can run, so that case is covered by documentation only. The CI matrix covers PHP 8.2 and later, so 8.1 is the declared floor rather than a tested one.mixedin the ten chained callbacks (the eight named in PHP minimum undeclared after #970; chained hook callbacks throw TypeError on a non-array #972 plusthold_data_source_action_array()andthold_graphs_action_array()).thold_draw_navigation_text(), the three action array callbacks andthold_clog_regex_array()start from an empty array;thold_data_sources_table(),thold_rrd_graph_graph_options(),thold_api_device_save(),thold_user_admin_setup_sql_save()andthold_data_source_remove()return a non-array unchanged and do no work. No other types are loosened.Verification
tests/Unit/PhpFloorTest.phpandtests/Unit/HookChainTolerantInputTest.phpwere written first: 44 failed againstdevelop(10 more for the two action array callbacks, added later) (undefined floor functions, TypeError on null, false, a string and an int in each callback), all pass with the change.Unitsuite 1035 passed andBehavioursuite 1430 passed (22 skipped) on PHP 8.2 and on PHP 8.6.setup.phpgets false from all three checks and a log line naming 8.1 and the running version.php -lover the 48 production PHP files: 22 failures on 7.4, none on 8.0, 8.1 or 8.2.Fixes #972