fix(clients): show accurate discussion count on client detail page#3428
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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'] ?? [])withcount($comments)in the discussion tab label.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Context
Follow-up to #3423.
#3423 fixed the 500 on
/clients/showClient/{id}(PHP 8 fatal fromcount($submodules.generalComment)—.concatenation + undefined constant, plus an undefined$submodulesvariable). The merged fix guards it withcount($submodules['generalComment'] ?? []), which stops the fatal but, as the PR author noted, leaves the Discussion tab permanently showing "(0)" because$submodulesis never passed to the view (regressed in the Blade migration #3362).Change
The Clients controller already supplies the comments:
ShowClient::getClientPageData()assigns$commentsviaCommentService::getComments('client', $id). So count that directly:This shows the real comment count and drops the dependency on the missing
$submodulesvariable entirely. It mirrors how Tickets and Wiki compute their tab counts (count($comments)/numComments).Scope
I swept all ~469 Blade and legacy
.tpl.phptemplates 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