Hello,
I’m not a PHP developer, so I asked an AI assistant to help me draft this report in a clear and structured way.
The following is an AI-assisted summary of the issue and the relevant findings.
Summary
On a Joomla site using the T4 System Plugin + t4_bs5_blank template, the frontend fails with multiple PHP fatal errors such as:
• Undefined constant "T4\Helper\T4PATH_BASE"
• Undefined constant "T4\Helper\T4PATH_LOCAL"
• Undefined constant "T4\Document\T4PATH_BASE_URI"
Switching the site template to Cassiopeia avoids the error, so this appears to be specific to T4.
Environment
• Joomla: 5.4.2
• PHP: 8.2.20
• T4 System Plugin: 2.5.4
• Template: t4_bs5_blank: 1.3.0
• Other relevant extensions: Regular Labs System Plugin is enabled (seen in stack trace), but the crash happens inside T4 code before output.
What happens (Actual behavior)
The site throws a fatal error and stops rendering. Example stack traces:
1) Undefined constant T4PATH_BASE
Exception Type: Error
File: /plugins/system/t4/src/t4/Helper/Asset.php
Message: Undefined constant "T4\Helper\T4PATH_BASE"
2) Undefined constant T4PATH_LOCAL
Exception Type: Error
File: /plugins/system/t4/src/t4/Helper/Path.php
Message: Undefined constant "T4\Helper\T4PATH_LOCAL"
3) Undefined constant T4PATH_BASE_URI
Exception Type: Error
File: /plugins/system/t4/src/t4/Document/Template.php
Line: 203
Message: Undefined constant "T4\Document\T4PATH_BASE_URI"
In Template.php, the fatal is triggered by this line inside renderHead():
$this->doc->addScript(T4PATH_BASE_URI . '/js/base.js', ['version' => 'auto']);
Technical analysis (why this looks like a T4 bug)
From the errors and the namespace-qualified constant names shown in the messages (e.g., T4\Document\T4PATH_BASE_URI), PHP is treating these as constants that are referenced before they are defined.
This suggests either:
1. The constants are not defined at all in this execution path, or
2. The constants are defined somewhere in T4, but initialization order / load order causes them to be referenced too early.
Because multiple files fail in the same way (Asset.php, Path.php, Template.php), it looks systemic rather than a single typo.
Temporary workaround (not a real fix)
As a temporary workaround, we can prevent the fatal by adding fallbacks like:
$t4BaseUri = defined('T4PATH_BASE_URI') ? T4PATH_BASE_URI : \Joomla\CMS\Uri\Uri::root(true);
and replacing direct constant usage with the computed variables.
However, this is clearly not ideal: it is patching core plugin files and does not address the underlying cause.
Request
Could you please:
1. Confirm where and when T4 defines the T4PATH* and T4PATH*_URI constants, and
2. Fix the initialization order (or always-define logic) so these constants are guaranteed to exist before T4 classes reference them?
Thanks