Skip to content

Fix TypeError in schedules() from form_checkbox_cell() integer id - #77

Closed
TheWitness wants to merge 1 commit into
developfrom
fix/form-checkbox-cell-string-id
Closed

TheWitness wants to merge 1 commit into
developfrom
fix/form-checkbox-cell-string-id

Conversation

@TheWitness

Copy link
Copy Markdown
Member

Summary

Under declare(strict_types = 1) (already in effect in maint.php), Cacti core's form_checkbox_cell(string $title, string $id, ...) requires $id to be a string. The four call sites were passing the integer DB id column directly, which throws a fatal TypeError on PHP 8:

Uncaught TypeError: form_checkbox_cell(): Argument #2 ($id) must be of type string, int given,
called in .../plugins/maint/maint.php on line 1202 and defined in .../lib/html_utility.php:584

Fix

Cast the integer id to (string) at all four form_checkbox_cell() call sites:

  • schedules() (line 1202) — $schedule['id']
  • host association table (line 1805) — $host['id']
  • webseer association table (line 2085) — $url['id']
  • servcheck association table (line 2368) — $test['id']

php -l passes. No behavioral change beyond the type coercion the function already expects.

@TheWitness
TheWitness requested review from bmfmancini and xmacan and a balanced review from Copilot October 6, 2026 17:57

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.

Copilot review overview

🟢 Approval recommended

The targeted casts consistently resolve the strict-type mismatch without changing behavior.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes PHP 8 TypeError failures caused by passing integer database IDs to form_checkbox_cell() under strict typing.

Changes:

  • Casts schedule, host, WebSeer, and Servcheck IDs to strings.
File Description
maint.php Ensures all checkbox helper IDs satisfy the required string type.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@TheWitness

Copy link
Copy Markdown
Member Author

Turned out to be a Cacti develop issue.

@TheWitness TheWitness closed this Oct 6, 2026
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.

3 participants