Skip to content

Fix 500 on client detail page: undefined constant generalComment#3423

Merged
marcelfolaron merged 1 commit into
Leantime:masterfrom
Roark1138:fix/client-detail-500-generalcomment
May 30, 2026
Merged

Fix 500 on client detail page: undefined constant generalComment#3423
marcelfolaron merged 1 commit into
Leantime:masterfrom
Roark1138:fix/client-detail-500-generalcomment

Conversation

@Roark1138

Copy link
Copy Markdown
Contributor

Problem

Opening a client's detail page (/clients/showClient/{id}) returns a 500 on PHP 8. The client record saves fine; rendering its detail view fatals. Same symptom as #3407.

Root cause

app/Domain/Clients/Templates/showClient.blade.php (line 28):
count($submodules.generalComment)

  1. $submodules.generalComment uses . (concatenation) instead of array access. On PHP 8 the bareword generalComment is read as an undefined constant → fatal Error.
  2. $submodules is also not passed to this view (regressed in the Blade migration,refactor: migrate all .tpl.php/.sub.php/.inc.php templates to Blade #3362), so array access alone still throws Undefined variable $submodules.
Stack trace (PHP 8.3 — paths redacted) Before the fix: production.ERROR: Undefined constant "generalComment" (View: app/Domain/Clients/Templates/showClient.blade.php) at /storage/framework/views/.php:28 After correcting the `.` to array access, the unpassed variable surfaces: production.ERROR: Undefined variable $submodules (View: app/Domain/Clients/Templates/showClient.blade.php) at /storage/framework/views/.php:28 Both originate at showClient.blade.php line 28.
## Fix count($submodules['generalComment'] ?? []) Correct array access plus a null-coalescing guard so the page renders. The discussion tab count shows 0 until `$submodules` is supplied by the controller (the comments themselves still load via the `comments::submodules.generalComment` include). ## Notes A more complete fix would pass `$submodules` from the Clients controller so the count is accurate. happy to follow up if preferred. Tested on v3.8.0 / PHP 8.3. Fixes #3407

showClient.blade.php used count($submodules.generalComment); the dot makes PHP 8 read generalComment as an undefined constant (fatal Error), and $submodules is not passed to the view. Use array access with a null guard: count($submodules['generalComment'] ?? []).

Fixes Leantime#3407
Copilot AI review requested due to automatic review settings May 29, 2026 22:00
@Roark1138 Roark1138 requested a review from a team as a code owner May 29, 2026 22:00
@Roark1138 Roark1138 requested review from marcelfolaron and removed request for a team May 29, 2026 22:00
@CLAassistant

CLAassistant commented May 29, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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

Note

Copilot was unable to run its full agentic suite in this review.

Fixes a Blade template syntax error where $submodules.generalComment (invalid PHP) was used instead of proper array access.

Changes:

  • Replace invalid dot notation with array key access on $submodules
  • Add null-coalescing fallback to an empty array to avoid count() errors when the key is missing

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

@marcelfolaron marcelfolaron merged commit 2fc068d into Leantime:master May 30, 2026
1 check was pending
yonas pushed a commit to yonasBSD/leantime that referenced this pull request May 30, 2026
Follow-up to Leantime#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 (Leantime#3362) dropped. Matches how
Tickets/Wiki compute their tab counts.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

500 when accessing Clients

4 participants