Skip to content

feat(fenom): Name the source in compile errors - #25

Merged
Ibochkarev merged 3 commits into
masterfrom
feat/fenom-error-logs
Sep 2, 2026
Merged

feat(fenom): Name the source in compile errors#25
Ibochkarev merged 3 commits into
masterfrom
feat/fenom-error-logs

Conversation

@Ibochkarev

@Ibochkarev Ibochkarev commented Sep 2, 2026

Copy link
Copy Markdown
Member

What

Fenom put an md5 of the template source into compile errors. A line like in ee058690d9fd7413748b95b0960e006b line 6 did not say which chunk, file, or resource failed.

That hash is Fenom's internal template name, not a MODX snippet include cache file. Cache keys stay on the hash. The log adds a readable label beside it.

ErrorLog owns the label and the full message. Compile and runtime failures go through it. CoreTools and Parser pass facts only (origin, elementName, sourceFile, plus resource id/uri/context/template). Fenom builds the label in the catch path, not on every successful render.

The MODX error log and &showLog get the element or page, the current resource when useful, a few source lines, and a compiled-file path when that file exists. If the broken line still has [[+...]], the log suggests the Fenom placeholder.

Cache keys, getStore('fenom'), compiled template names, and source($name, $content) stay the same. Parser still hashes trimmed content.

Before:

Unexpected token '+' in expression in ee058690d9fd7413748b95b0960e006b line 6, near '{var $limit = [[+' <- there

After, for a DB chunk:

[pdoTools][Fenom] compile error in chunk:tpl.product.row (#12)
resource:#42 (web:catalog/item)
cache name: modchunk/12
Unexpected token '+' in expression in chunk:tpl.product.row (#12) line 6, near '{var $limit = [[+' <- there
> 6: {var $limit = [[+limit]]}
Unprocessed MODX tag inside Fenom. Use {$limit} or parse MODX before Fenom.

After, for Fenom on the page (pdotools_fenom_parser):

[pdoTools][Fenom] compile error in resource:#42 (web:catalog/item), template:#5
cache name: ee058690d9fd7413748b95b0960e006b
Unexpected token '+' in expression in resource:#42 (web:catalog/item), template:#5 line 6, near '{var $limit = [[+' <- there
> 6: {var $limit = [[+limit]]}
Unprocessed MODX tag inside Fenom. Use {$limit} or parse MODX before Fenom.

@FILE logs file:core/elements/chunks/item.tpl. @INLINE logs inline. With pdotools_fenom_save_on_errors, a compile error also lists source dump: core/cache/pdotools/error/{name}.

The old compiled PHP dump at INFO is gone. Use the excerpt or the save-on-errors dump.

Why

A syntax error in a chunk or on a page could not be traced from the MODX log. Changing the hash would break Fenom's compile cache, so the label stays next to it.

Fixes #21

@Ibochkarev
Ibochkarev marked this pull request as ready for review September 2, 2026 02:46
Fenom logged a content hash as the template name, so a syntax error
could not be traced to a chunk, file, or resource. Keep the same
cache keys and add a readable label, excerpt, and cache path.

Fixes #21
@Ibochkarev Ibochkarev self-assigned this Sep 2, 2026
Assert labels, excerpts, MODX-tag hints, and that the Fenom cache
name stays a hash or binding/id.
@Ibochkarev
Ibochkarev force-pushed the feat/fenom-error-logs branch from 7b75a59 to f972045 Compare September 2, 2026 06:25
@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.34171% with 63 lines in your changes missing coverage. Please review.
✅ Project coverage is 20.74%. Comparing base (1b9c02b) to head (1fe9d14).

Files with missing lines Patch % Lines
...re/components/pdotools/src/Parsing/Fenom/Fenom.php 58.13% 18 Missing ⚠️
core/components/pdotools/src/Parsing/Parser.php 0.00% 17 Missing ⚠️
...components/pdotools/src/Parsing/Fenom/ErrorLog.php 87.40% 16 Missing ⚠️
core/components/pdotools/src/CoreTools.php 0.00% 12 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master      #25      +/-   ##
============================================
+ Coverage     16.07%   20.74%   +4.67%     
- Complexity     1060     1171     +111     
============================================
  Files            14       15       +1     
  Lines          2774     2964     +190     
============================================
+ Hits            446      615     +169     
- Misses         2328     2349      +21     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

One label/format owner; CoreTools and Parser pass origin and resource
facts only. Drop duplicate builders and happy-path label work.
@Ibochkarev Ibochkarev added documentation Improvements or additions to documentation enhancement New feature or request labels Sep 2, 2026
@Ibochkarev
Ibochkarev merged commit 2ab402d into master Sep 2, 2026
15 checks passed
@Ibochkarev
Ibochkarev deleted the feat/fenom-error-logs branch September 2, 2026 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make logs more understandable

1 participant