Skip to content

Template limits per article, and templates that give table rows - #50

Merged
bonelifer merged 1 commit into
mainfrom
fix/template-limits
Oct 13, 2026
Merged

bonelifer merged 1 commit into
mainfrom
fix/template-limits

Conversation

@bonelifer

Copy link
Copy Markdown
Contributor

Two fixes from a review of the template system.

The limits now count for the whole article. The limits of 2000 calls and functions and 500 template calls were reset at each template call, so an article with many calls could do a full render for each. They now count for the whole article, there is a 500,000-character output budget, and once a limit is used up the remaining calls are answered with a "Too many templates" message without rendering anything. A page with 1500 calls of a nested template went from 1.6 s to 0.24 s. #ifexist answers are also kept for the request, so repeated checks do not repeat the query.

Templates can give table rows and cells. <table>{{Row|a|1}}{{Row|b|2}}</table> left the braces as text, because the placeholder for a call was a <span>, which cannot sit between table tags. It is now a <template> element, which can. A template whose text starts with <tr>, <tbody>, <td> and so on is parsed inside a table that is then taken off, since rows do not parse on their own. A new migration clears the cached text formatter configuration so existing boards pick up the new tag.

Measured (MySQL 8.0 board): about 1 ms for each template call written in an article, and one extra query for the template pages however many calls there are. A cache of rendered articles is still not needed; the TODO plan has the numbers.

Docs. README: template rows and the limits. TODO plan: the measurements.

Tests

  • Unit tests: 220 tests, 511 assertions, all pass, including the fan-out, the per-article counting and the table wrapper.
  • Two new browser tests pass 6 of 6 on phpBB 3.3.19 with SQLite, 4.0.0-a3-dev with SQLite, MySQL 8.0 and PostgreSQL 16: rows and cells from templates, and abuse (fan-out, 1500 calls, 700 calls to one template, #expr and date abuse, loops) with a time limit.
  • The template, parser function, table and headings browser tests still pass on all four boards.

Investigated and written by Claude on behalf of William Jacoby (bonelifer).

The limits (500 calls, 2000 calls and functions, 500,000 characters of output) now
count for the whole article, not each call, and a refused call is answered without
rendering anything. A template call is rendered as a <template> element so it can sit
between table tags, and a template that gives rows or cells is parsed inside a table
that is taken off again. #ifexist answers are kept for the request.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@bonelifer
bonelifer merged commit 15e4b85 into main Oct 13, 2026
58 checks passed
@bonelifer
bonelifer deleted the fix/template-limits branch October 13, 2026 01:08
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.

1 participant