Problem/Motivation

The following error occurs in Drupal 10.4.3 with Twig v3.19.0:

The website encountered an unexpected error. Try again later.

Twig\Error\SyntaxError: Unexpected token "name" of value "if" ("end of statement block" expected). in Twig\TokenStream->expect() (line 5 of modules/contrib/forum_access/templates/forum-access-table.html.twig).

Twig\TokenParser\ForTokenParser->parse(Object) (Line: 202)
Twig\Parser->subparse(Array) (Line: 42)
Twig\TokenParser\IfTokenParser->parse(Object) (Line: 202)
Twig\Parser->subparse(NULL, ) (Line: 95)
Twig\Parser->parse(Object) (Line: 559)
Twig\Environment->parse(Object) (Line: 590)
Twig\Environment->compileSource(Object) (Line: 131)
Drupal\Core\Template\TwigEnvironment->compileSource(Object) (Line: 409)
Twig\Environment->loadTemplate('__TwigTemplate_82e7ac16ef626a053af3fefb7f6232d9', 'modules/contrib/forum_access/templates/forum-access-table.html.twig') (Line: 371)
Twig\Environment->load('modules/contrib/forum_access/templates/forum-access-table.html.twig') (Line: 33)
twig_render_template('modules/contrib/forum_access/templates/forum-access-table.html.twig', Array) (Line: 348)
Drupal\Core\Theme\ThemeManager->render('forum_access_table', Array) (Line: 491)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 504)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 504)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 248)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 231)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 53)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

Install the module in a Drupal 10+ installation using twig 3+ and try to edit a forum or a container.

Proposed resolution

Modify the forum-access-table.html.twig template to make it work with twig 3 by separating if clauses from for loops as for if is deprecated since Twig 2.10 (see https://twig.symfony.com/doc/2.x/deprecated.html#tags).

Remaining tasks

  • Update the template file

User interface changes

N/A

API changes

N/A

Data model changes

N/A

CommentFileSizeAuthor
#3 forum_access-3517929-3.patch1.45 KBvoleger
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

semiaddict created an issue. See original summary.

voleger’s picture

StatusFileSize
new1.45 KB

Upload the static patch from MR

voleger’s picture

Version: 2.0.1 » 2.0.x-dev
Status: Active » Reviewed & tested by the community

Works for Drupal ~10 setup.

lee56’s picture

Installed the Forum Access version 2.0.1 / ACL version 2.0.1 modules on 5/15/2025 on test site.

Had same error issues described for Drupal version 10.4.3 with 11.1.7 - Reported by "semiaddict"

Twig\Error\SyntaxError:
Unexpected token "name" of value "if" ("end of statement block" expected). in Twig\TokenStream->expect() (line 5 of modules/contrib/forum_access/templates/forum-access-table.html.twig).

Applied the patch:
forum_access-3517929-3.patch

The patch also works without any known issues for Drupal 11.1.7

Thanks to "voleger" for the patch and to "semiaddict" for reporting the issue.

jefflogan’s picture

Tested. +1 from me.

nevergone’s picture

Issue tags: -need +Needs tests
eelkeblok’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

Looks like a duplicate of #3333087: Forum access table template breaks on Drupal 10. Feel free to review that and/or make changes if required.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

nevergone’s picture

I'm not sure if this should have been closed as a duplicate, is already in RTBC status.

eelkeblok’s picture

Status: Closed (duplicate) » Reviewed & tested by the community

I guess you’re right, if this gets fixed one way or the other. I do agree it is a duplicate and the other issue has more history. Maybe that’s the problem. This one is more concise.

nevergone’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.