Upgrading to version 3.1.22 breaks the website.

Versión de Drupal 9.5.7
---
Servidor web
LiteSpeed
---
PHP
Versión
8.1.17 (más información)
Límite de memoria
1G
---
Base de datos
Versión
10.3.38-MariaDB
Sistema
MariaDB
---

New fresh or existing installation when updating to version 3.1.22 breaks the website.

Cannot add any content, error:

Twig\Error\LoaderError: Template "__TwigTemplate_f69815c0a1e71e7a1db5a98e881cd2a6" is not defined. in Twig\Loader\ChainLoader->getCacheKey() (line 98 of /home/***user***/public_html/***site***/vendor/twig/twig/src/Loader/ChainLoader.php).

***user*** -> fake folder
***site*** -> fake folder
for security reazon.

Downgrading to version 3.1.21 solves the problem.

All make with composer.

Thancks.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

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

ady1503 created an issue. See original summary.

goz’s picture

Title: Upgrading to version 3.1.22 breaks the website. » Regression updating to 3.1.22 for Drupal 9.x
Related issues: +#3289053: Automated Drupal 10 compatibility fixes for Permissions by Term

This error occures on D9 installation, after updating to 3.1.22.
Here is the issue which introduce the regression https://www.drupal.org/node/3289053, especially https://www.drupal.org/project/permissions_by_term/issues/3289053#commen...

In src/Service/NodeEntityBundleInfo.php

      $users = User::loadMultiple($uids);
    }

-    $template = $this->twig->loadTemplate($viewFilePath);
+    $templateClass = $this->twig->getTemplateClass($viewFilePath);
+    $template = $this->twig->loadTemplate($templateClass, $viewFilePath);

    return $template->render(['roles' => $roles, 'users' => $users]);

Change has been made to follow Twig update in version 3.x. used by D10, which is different from D9 using version 2.x of Twig

loadTemplate definition for D10 using twig 3.x :

    public function loadTemplate(string $cls, string $name, int $index = null): Template

previous loadTemplate definition for D9 using twig 2.x :

    public function loadTemplate($name, $index = null)

In any cases loadTemplate method is defined as internal and should not be used by modules.

I suggest to use Drupal templates instead of low level integration.

goz’s picture

Status: Active » Needs review
izus’s picture

Status: Needs review » Reviewed & tested by the community

patch in MR #3 worked well for me.
thanks

ady1503’s picture

Thank you very much for the reply.

pgn5qs’s picture

Same issue. Site broken by this update.

emmguyot’s picture

The patch fixes the crash for me

goz’s picture

Title: Regression updating to 3.1.22 for Drupal 9.x » Regression updating to 3.1.22 for Drupal 9.x using loadTemplate from twig

@emmguyot can you create another issue for your case, so it can be resolved in it?
This issue is relative to twig update and loadTemplate method.

Thanks

greatmatter’s picture

The patch works beautifully. Please roll this as a release; if anyone had the same issues we had, you'll save hours of debug time for other folks...

wheelercreek’s picture

I'm not seeing a patch here for version 3.1.22, is there one?

This is same issue I'm seeing as reported here:
https://www.drupal.org/project/permissions_by_term/issues/3289053#commen...

steveoriol’s picture

I confirm that the patch : https://git.drupalcode.org/project/permissions_by_term/-/merge_requests/...
Works for me, thank you !

protitude’s picture

Confirmed this patch works on my site. Thanks!

zany’s picture

Confirmed this fix works with D9.5.8

@wheelercreek the patch is the drupalcode link above, or as plain diff it's
https://git.drupalcode.org/issue/permissions_by_term-3354478/-/commit/4d...

E.g. in composer.json under extras patches insert:

"drupal/permissions_by_term": {
  "Fix Twig regression patch": "https://git.drupalcode.org/issue/permissions_by_term-3354478/-/commit/4daf422f379585da550a05d23d4c77aa8dc328ca.diff"
}
shyam-sawhney’s picture

jepster_’s picture

Assigned: Unassigned » fathima.asmat

@fathima.asmat Would you please take a look on this?

rwam’s picture

Patch https://git.drupalcode.org/project/permissions_by_term/-/merge_requests/... worked for me too on D 9.5.9

Interesting finding: the issue only exists on our production environment. I've dumped the database from live for local investigation but cannot reproduce it locally. Sorry for confusion: I was on an outdated branch locally with version 3.1.21.

somersoft’s picture

ambient.impact’s picture

Status: Reviewed & tested by the community » Needs work
Related issues: +#3361318: Fatal error from Twig when creating default target module in Drupal 10

I ran into a similar issue in #3361318: Fatal error from Twig when creating default target module in Drupal 10 where another maintainer had previously used the same Twig loadTemplate() method and it failed spectacularly when moving to Drupal 10, which bumped the major Twig version from 2 to 3 and the method changed. While the merge request is a definite improvement, I'm a bit baffled about why the template file is still left in the src/View, or why it was put there in the first place, when it should be under a templates directory. If the problem is that it could conflict with other templates, then name it something like permissions-by-term-node-details.html.twig and then just reference the template name without having to grab the path. That way it's possible for a theme or other module to build on the template and it keeps things tidy and where they should live.

kris77’s picture

I think it is necessary to update the module immediately with this patch.

marcoliver’s picture

Status: Needs work » Reviewed & tested by the community

While https://www.drupal.org/project/permissions_by_term/issues/3354478#commen... is a valid remark, I think a release including the patch should be prioritized to get the regression fixed.

Rethinking / renaming the template can be done as a followup task.

adrianliegmann made their first commit to this issue’s fork.

adrianliegmann’s picture

StatusFileSize
new100.16 KB

Hello,
I tested https://git.drupalcode.org/project/permissions_by_term/-/merge_requests/... patch and it works, but generate error in JS after select something, like on the screen.
JS error

I created a fix including a item type element: https://git.drupalcode.org/project/permissions_by_term/-/merge_requests/...

adrianliegmann’s picture

Status: Reviewed & tested by the community » Needs review
joelseguin’s picture

Thanks @adrianliegmann - I've run into the same issue and applied the latest merge request (#25) and all seems to work perfectly fine now.

srinivasraod’s picture

StatusFileSize
new175.45 KB

After upgrading permissions_by_term to 3.1.22 and applying the patch https://git.drupalcode.org/project/permissions_by_term/-/merge_requests/...

I see JS error
js_error

srinivasraod’s picture

StatusFileSize
new147.85 KB
leducdubleuet’s picture

@srinivasraod I believe you did not apply the right patch. Can you try this one?

https://git.drupalcode.org/project/permissions_by_term/-/merge_requests/...

srinivasraod’s picture

@LeDucDuBleuet Thank you!!
#30 worked for me

leducdubleuet’s picture

Status: Needs review » Reviewed & tested by the community

@srinivasraod Great, glad I could help!

So I also reviewed and tested the merge request !25 with success and I think it is safe to put this issue to RTBC.

Thanks!

kreatil’s picture

3.1.22 breaks functionality also in my case with drupal 9.5.10. Cannot review the proposed solution because there is no patch provided here.
Found it at last :-) The patch https://git.drupalcode.org/project/permissions_by_term/-/merge_requests/25.patch fixes it. Thanks.

davedg629’s picture

It's been over a month since a working patch was posted. Is one of the maintainers available to get this patch released?

marcoliver’s picture

Status: Reviewed & tested by the community » Fixed

Fixed in 3.1.24, thanks everyone!

Status: Fixed » Closed (fixed)

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