Skip to content

fix(clients): show accurate discussion count on client detail page#3428

Merged
marcelfolaron merged 1 commit into
masterfrom
fix/client-discussion-count
May 30, 2026
Merged

fix(clients): show accurate discussion count on client detail page#3428
marcelfolaron merged 1 commit into
masterfrom
fix/client-discussion-count

Conversation

@marcelfolaron

Copy link
Copy Markdown
Collaborator

Context

Follow-up to #3423.

#3423 fixed the 500 on /clients/showClient/{id} (PHP 8 fatal from count($submodules.generalComment). concatenation + undefined constant, plus an undefined $submodules variable). The merged fix guards it with count($submodules['generalComment'] ?? []), which stops the fatal but, as the PR author noted, leaves the Discussion tab permanently showing "(0)" because $submodules is never passed to the view (regressed in the Blade migration #3362).

Change

The Clients controller already supplies the comments: ShowClient::getClientPageData() assigns $comments via CommentService::getComments('client', $id). So count that directly:

- count($submodules['generalComment'] ?? [])
+ count($comments)

This shows the real comment count and drops the dependency on the missing $submodules variable entirely. It mirrors how Tickets and Wiki compute their tab counts (count($comments) / numComments).

Scope

I swept all ~469 Blade and legacy .tpl.php templates for the same dot-as-array-access bug class — it was isolated to this one line, no other occurrences.

Testing

Open a client detail page (/clients/showClient/{id}) with and without comments; the Discussion tab now reflects the actual count instead of always "(0)".

🤖 Generated with Claude Code

Follow-up to #3423. That PR stopped the fatal on /clients/showClient/{id}
by guarding the never-passed $submodules variable with `?? []`, but as a
result the Discussion tab always rendered "(0)".

The Clients controller (ShowClient::getClientPageData) already assigns
$comments via CommentService::getComments('client', $id). Count that
instead, so the tab shows the real number and no longer depends on the
$submodules variable that the Blade migration (#3362) dropped. Matches how
Tickets/Wiki compute their tab counts.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 30, 2026 00:38
@marcelfolaron marcelfolaron requested a review from a team as a code owner May 30, 2026 00:38
@marcelfolaron marcelfolaron requested review from broskees and removed request for a team May 30, 2026 00:38

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.

Pull request overview

Fixes the Discussion tab count on the client detail page by using the $comments variable already passed to the view, instead of the missing $submodules['generalComment'].

Changes:

  • Replace count($submodules['generalComment'] ?? []) with count($comments) in the discussion tab label.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@marcelfolaron marcelfolaron merged commit b1c096f into master May 30, 2026
12 checks passed
@marcelfolaron marcelfolaron deleted the fix/client-discussion-count branch May 30, 2026 02:16
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.

2 participants