- π¬π§United Kingdom therobyouknow
Thank you for raising this issue. Here is a hot fix (I will try to remember the various steps to make a patch)
To add further info to the issue description, the location of the fatal error file is:
web/modules/contrib/forum_access/templates/forum-access-table.html.twig
The original code contents of this file, with fatal error, is below:
<table{{ attributes.addClass(classes) }}> {% if form.header %} <thead> <tr> {% for key, column in form.header if key|first != '#' %} <th> {{- column }} </th> {% endfor %} </tr> </thead> {% endif %} {% for key, column in form.rows if key|first != '#' %} <tr> {% for key2, column2 in column if key2|first != '#' %} <td> {{- column2 }} </td> {% endfor %} </tr> {% endfor %} </table>
My hot fix is to amend the code as follows:
<table{{ attributes.addClass(classes) }}> {% if form.header %} <thead> <tr> {% for key, column in form.header %} {% if key|first != '#' %} <th> {{- column }} </th> {% endif %} {% endfor %} </tr> </thead> {% endif %} {% for key, column in form.rows %} {% if key|first != '#' %} <tr> {% for key2, column2 in column %} {% if key2|first != '#' %} <td> {{- column2 }} </td> {% endif %} {% endfor %} </tr> {% endif %} {% endfor %} </table>
So that the ifs have their own structure nested in the for loop structure, rather than the apparently problematic in-line version that seemed to cause the fatal error.
With this adjustment, my site on that page now worked, without the error.
I will try to make a patch too.
my setup where I saw this error:
Drupal 10.0.9
php 8.1.18
Database Version 10.6.12-MariaDB-0ubuntu0.22.04.1theme: Olivero 10.0.9 (default theme)
- π¬π§United Kingdom therobyouknow
As request by @salvis
Please post a patch.
Attached is a patch for the fix described in my comment #6: https://www.drupal.org/project/forum_access/issues/3333087#comment-15043297 π Forum access table template breaks on Drupal 10 Closed: duplicate
I will test this in my composer.json and add the composer.json here once successful, also my steps for creating the patch.
- Open on Drupal.org βCore: 10.0.7 + Environment: PHP 8.1 & MariaDB 10.3.22last update
almost 2 years ago Waiting for branch to pass - π¬π§United Kingdom therobyouknow
And here is a patch for the dev release, 8.x-1.x-dev updated 10 Oct 2022 at 11:07 UTC
The git branch for the dev release, 8.x-1.x-dev is called 8.x-1.x as shown to the right on https://www.drupal.org/project/forum_access/releases/8.x-1.x-dev β
Following easy steps to create a patch: https://drupal.stackexchange.com/a/287849/1082
git clone --branch 8.x-1.x http://git.drupal.org/project/forum_access.git
cd forum_access
# edit template file (as per change in https://www.drupal.org/project/forum_access/issues/3333087#comment-15043297 π Forum access table template breaks on Drupal 10 Closed: duplicate )
vi templates/forum-access-table.html.twig
# create patch
git diff 8.x-1.x > ../forum_access-issue-3333087-comment-6-15043297-for-8.x-1.x-template-breaks-on-drupal-10.patch - Open on Drupal.org βCore: 10.0.7 + Environment: PHP 8.1 & MariaDB 10.3.22last update
almost 2 years ago Waiting for branch to pass - π¬π§United Kingdom therobyouknow
Tested my own patch successfully.
Ensured I had the patch facility added to my composer.json file:
./composer require cweagans/composer-patches
and I added the following lines, referencing my patch to my composer.json file:
"enable-patching": true, "patches": { "drupal/forum_access": { "Forum access table template breaks on Drupal 10. Fix for 8.x-1.0-beta1": "web/modules/patches/forum_access-issue-3333087-comment-6-15043297-template-breaks-on-drupal-10.patch" } }
I'm using the patch I made against 8.x-1.0-beta1
So my whole composer.json file, where I have tested the patch successfully looks like:
{ "name": "drupal/recommended-project", "description": "Project template for Drupal projects with a relocated document root", "type": "project", "license": "GPL-2.0-or-later", "homepage": "https://www.drupal.org/project/drupal", "support": { "docs": "https://www.drupal.org/docs/user_guide/en/index.html", "chat": "https://www.drupal.org/node/314178" }, "repositories": [ { "type": "composer", "url": "https://packages.drupal.org/8" } ], "require": { "composer/installers": "^2.0", "cweagans/composer-patches": "^1.7", "drupal/core-composer-scaffold": "^10.0", "drupal/core-project-message": "^10.0", "drupal/core-recommended": "^10.0", "drupal/forum": "^1.0", "drupal/forum_access": "^1.0@beta", "drupal/mailsystem": "^4.4", "drupal/seven": "^1.0", "drupal/smtp": "^1.2", "drupal/social_auth_facebook": "^4.0", "drupal/social_auth_google": "^4.0", "drush/drush": "^11.5" }, "conflict": { "drupal/drupal": "*" }, "minimum-stability": "dev", "prefer-stable": true, "config": { "allow-plugins": { "composer/installers": true, "drupal/core-composer-scaffold": true, "drupal/core-project-message": true, "phpstan/extension-installer": true, "dealerdirect/phpcodesniffer-composer-installer": true, "cweagans/composer-patches": true }, "sort-packages": true }, "extra": { "drupal-scaffold": { "locations": { "web-root": "web/" } }, "installer-paths": { "web/core": [ "type:drupal-core" ], "web/libraries/{$name}": [ "type:drupal-library" ], "web/modules/contrib/{$name}": [ "type:drupal-module" ], "web/profiles/contrib/{$name}": [ "type:drupal-profile" ], "web/themes/contrib/{$name}": [ "type:drupal-theme" ], "drush/Commands/contrib/{$name}": [ "type:drupal-drush" ], "web/modules/custom/{$name}": [ "type:drupal-custom-module" ], "web/profiles/custom/{$name}": [ "type:drupal-custom-profile" ], "web/themes/custom/{$name}": [ "type:drupal-custom-theme" ] }, "drupal-core-project-message": { "include-keys": [ "homepage", "support" ], "post-create-project-cmd-message": [ "<bg=blue;fg=white> </>", "<bg=blue;fg=white> Congratulations, youβve installed the Drupal codebase </>", "<bg=blue;fg=white> from the drupal/recommended-project template! </>", "<bg=blue;fg=white> </>", "", "<bg=yellow;fg=black>Next steps</>:", " * Install the site: https://www.drupal.org/docs/installing-drupal", " * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html", " * Get support: https://www.drupal.org/support", " * Get involved with the Drupal community:", " https://www.drupal.org/getting-involved", " * Remove the plugin that prints this message:", " composer remove drupal/core-project-message" ] }, "enable-patching": true, "patches": { "drupal/forum_access": { "Forum access table template breaks on Drupal 10. Fix for 8.x-1.0-beta1": "web/modules/patches/forum_access-issue-3333087-comment-6-15043297-template-breaks-on-drupal-10.patch" } } } }
- π³π¬Nigeria chike Nigeria
Patches #7 and #8 failed to apply on Drupal 10 so I made this one.
- Open on Drupal.org βCore: 10.0.7 + Environment: PHP 8.1 & MariaDB 10.3.22last update
almost 2 years ago Waiting for branch to pass - last update
almost 2 years ago Patch Failed to Apply - last update
almost 2 years ago Build Successful - π¨πSwitzerland salvis
Thank you for your patches.
#7 and #8 are identical, since 8.x-1.x-dev and 8.x-1.0beta1 are the same. Patches should always go against the -dev version. Patching against a fixed version makes sense only if you intend to provide a patch for an old version for the benefit of third parties.
I'm looking at admin/structure/forum/edit/forum/1 with Claro as admin theme.
#8 and #10 both apply to 9.5.x, but I see no difference with or without each patch.
In 10.0.x admin/structure/forum/edit/forum/1 crashes with...
The website encountered an unexpected error. Please try again later.
... and again I see no difference with or without each patch.
The error in the watchdog log is
Twig\Error\SyntaxError: Unexpected token "name" of value "if" ("end of statement block" expected). in Twig\TokenStream->expect() (line 5 of modules\forum_access\templates\forum-access-table.html.twig).
BTW, #10 has trailing spaces, which you can see if you do
git diff .
.I don't think it makes sense to patch the D8/9 branch. Let's wait for the D10 branch to fix this.
- π¬π§United Kingdom therobyouknow
Thanks @salvis for your follow up in #11.
In #6 I have explained why I got this fatal error and what I did to fix it, providing before and after code. Therefore please can you comment on that comment #6 because I would be surprised that your applying my patch did not fix the issue as I have explained what they change needed to be.
@chike thank you for your contribution also. However, to say "failed to apply on Drupal 10" is not correct because I have explained a solution in #6 and then in #7 , #8 and #9 explained how I produced my patches and documented my testing of them. You haven't provided similiar detail to explain your finding nor similar detail for your own solution. Also 2 further things: 1) You would want to detail your particular version of Drupal 10, it would appear to be 10.0.7. Myself, with my comment coming before yours, I was using 10.0.9 - a later version. 2) This issue is about a Drupal 10 module - and so were my patches for the module running on Drupal 10, therefore the patch is not for Drupal 10 itself.
The solution I have created works for my setup and I have provided everything to help someone else use it. My next step will be to look out for a new release or patch from @salvis. For the time being, I'll leave it there and that would be all I would need to comment about my solution to this issue.
- Status changed to Postponed
almost 2 years ago 8:49pm 20 July 2023 - π¨πSwitzerland salvis
It was a mistake to mark Forum Access as ready for D10.
It's not, and I will not try to fix it in the 8.x-1.x branch, because that might break it for D8/9.
- π¬π§United Kingdom therobyouknow
@salvis
Well, with my patch, it works just fine: i can now administer https://taxanotes.org/forum
(This has several members forums not publicly visible)The bug was simply a twig syntax error as I had explained. The solution also explained was to simplify that syntax. That's quite a world away from not being ready for D10, to my mind it looks fine!
Though I haven't yet tested it on 10.1.
Thank you very much for all your work on this module.
@salvis @therobyouknow I can confirm that the forum_access module works fine (so far) with your patch on Drupal 10.1.5 and ACL 2.0.0-beta1.
- π³π±Netherlands eelkeblok Netherlands π³π±
Same here. Maybe can you elaborate (in a different issue, maybe, that might serve as the plan issue to get a true D10 compatible release) why it was a mistake to mark the module as D10 compatible? Some of us are actually using the module on D10 (obviosly with patches and whatever else is needed to make it work), so I would like to know what the problem is.. Maybe I'm sitting on a time bomb.
- π³π±Netherlands eelkeblok Netherlands π³π±
Not sure what I meant with this last comment, because, yes, I have been running the module on D10, but no, not in unaltered form. I have the patch for this issue and a composer alias for ACL module, which needs to be in version 2.0.0 for D10 compatibility. I suggest maybe we go on in https://www.drupal.org/project/forum_access/issues/3410468 π¬ Drupal 10 compatibility fixes Needs review , since that focuses on D10 compatibility as a whole.
BTW, if you want to turn an MR into a patch, just attach .diff to the main URL, like so: https://git.drupalcode.org/project/forum_access/-/merge_requests/2.diff. I am hesitant to post patches, as the powers that be are pushing for GitLab.
- Status changed to Closed: duplicate
about 1 year ago 5:14pm 6 April 2024 - πΊπΈUnited States dillix
I added fix for this issue in π¬ Drupal 10 compatibility fixes Needs review , so I'm closing this issue as duplicate.
- π¬π§United Kingdom therobyouknow
Re: Comment #19: https://www.drupal.org/project/forum_access/issues/3333087#comment-15540181 π Forum access table template breaks on Drupal 10 Closed: duplicate
Thank you for providing a solution in https://www.drupal.org/project/forum_access/issues/3410468 π¬ Drupal 10 compatibility fixes Needs review
With regards marking this issue here, 3333087, as duplicate, this issue was created at the beginning of 2023, January 2023. Whereas #3410468: Drupal 10 compatibility fixes - https://www.drupal.org/project/forum_access/issues/3410468 π¬ Drupal 10 compatibility fixes Needs review was created nearly 12 months later, at the end of 2023. Therefore one way to look at it is that an issue is a duplicate if it is for a problem covered by a previously created issue. So one could say that this issue 3333087 is not the duplicate as it was created first.
Moreover, this issue 3333087 is also very specific about the problem - the site breaks with forum access enabled when creating/editing a forum with forum access enabled and this issue provides specific solutions to fix it. Whereas the other issue says "Encounter issues related to compatibility" - but doesn't state what they actually are - what is seen? error? unexpected behaviour? So those who encounter the problem may not find issue 3410468, because they may not use "compatibility" in their search for a solution, but rather "fatal error" with the error details and so land here on 3333087.
However, issue 3410468 would appear to explain @salvis's comment "It was a mistake to mark Forum Access as ready for D10." From the solving patch in comment #24 cited from comment #29 https://www.drupal.org/files/issues/2024-04-06/forum_access-3410468-24.p... β I can see that there apart from the forum access fatal error issue solution to change the twig, there are other changes e.g. as to how files are included, presumably for Drupal 10 which explains "It was a mistake to mark Forum Access as ready for D10."
Thanks again.
- πΊπΈUnited States dillix
@therobyouknow this fatal error appears only in D10. I fixed all D10 compatability issues in one and closed all others as duplicate.