Skip to content

Fix html_nav_bar() TypeError on the maintenance list pages - #76

Merged
TheWitness merged 1 commit into
developfrom
fix/html-nav-bar-int-args
Oct 6, 2026
Merged

TheWitness merged 1 commit into
developfrom
fix/html-nav-bar-int-args

Conversation

@TheWitness

Copy link
Copy Markdown
Member

Problem

Opening the Maintenance Schedules list (and the Devices/WebSeer/Servcheck association tabs) fatals:

Uncaught TypeError: html_nav_bar(): Argument #3 ($current_page) must be of type int, string given,
called in .../plugins/maint/maint.php on line 1150 and defined in .../lib/html.php:613
#0 maint.php(1150): html_nav_bar()
#1 maint.php(111): schedules()

maint.php declares strict_types = 1. The core signature is:

function html_nav_bar(string $base_url, int $max_pages, int $current_page, int $rows_per_page, int $total_rows, ...)

The $current_page, $rows_per_page and $total_rows arguments were passed straight from get_request_var('page'), $rows (read_config_option() / get_request_var('rows')) and $total_rows (db_fetch_cell_prepared()) — all strings. PHP reports only the first failure (#3), but #4/#5 are strings too, so casting only page would just surface the next error.

Fix

Cast all three paging arguments to int at each of the four html_nav_bar() call sites (schedules, hosts, webseer, servcheck), matching the (int) grv('page') pattern used throughout Cacti core.

Testing

  • php -l maint.php passes.

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

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 comprehensively address all affected call sites and typed arguments.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes strict-type failures when rendering maintenance pagination.

Changes:

  • Casts all pagination arguments to integers at four list-page call sites.
  • Documents the fix in the changelog.
File Description
maint.php Adds required integer casts for pagination.
CHANGELOG.md Records the resolved TypeError.

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

@TheWitness
TheWitness merged commit 44d2754 into develop Oct 6, 2026
4 checks passed
@TheWitness
TheWitness deleted the fix/html-nav-bar-int-args branch October 6, 2026 17:45
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