Compatibility Issue When Updating to Twig v3.9

Hi,

I just updated my recent project from 3.5.0 to 3.6.11 from the admin platform (Settings → System Updates → Check for Updates → Update).

It was successful, but when I opened the frontend, I faced the following error: An exception has been thrown during the rendering of a template (“Call to undefined function twig_get_attribute()”).

Could anyone help me please? What could be the issue?

Kind regards,
Zsolt

1 Like

Afaik this.locale should not work on October MultiSite. Rainlab.Translate provided this initially, but now it’s this.site.locale

If I change to this.site.locale, still have a probleme. Event if I remove this part of code. Then the following part when I use twig, I face the issue:

{% set recaptchaUrl = newsletter.recaptchaUrl %}

We have discussed this in Discord, and it does not appear to be anything related to October CMS.

PHP reports an error about a missing file (and function) when the file exists…

One way to repair your installation when vendor libraries are corrupt:

  1. Rename ~/vendor to ~/vendor2

  2. Delete the ~/.composer.lock file

  3. Run composer update in the command line

  4. If it works, delete the vendor2 directory

1 Like

I’m having exactly the same problem when updating a project from 3.5.14 to 3.6.13. I already did what you suggested (remove vendor and run composer update again) and I keep having the same problem, Call to undefined function twig_get_attribute(). I tried executing composer clear-cache. I even deleted ALL the files in the project, downloaded again from the repo, and executed composer update, and it keeps giving the same error. What can I do?

Same thing for me and I have a large site down as a result. This is a significant problem now.

Downgrading twig to 3.8.0 worked for me!

composer req twig/twig:3.8.0

4 Likes

Thank you, that solved it straightaway, much appreciated @marco.grueter

I had to do this too, I have the same error, and only the downgrade resolved it.

@marco.grueter i had this same issue, the downgrade solve it for now. Thank You!
@daft for when a update on this ? Thank you!

Oh no, @ngyzsolt, you tried to warn us!

It looks like a breaking change coming from Twig - this has been patched in v3.6.14.

Twig v3.9 appears to be a significant departure from Twig v3.8. There are some issues with placeholder usage in October CMS v3.6.14.

It looks like Symfony attempted to avoid including breaking changes, but since October is heavily coupled with Twig’s internals, this is unavoidable.

As a result, we’ve released another patch, v3.6.17, which effectively drops support for Twig v3.8. The suggested workaround fix (above) will break the installation moving forward, so please remove it from your composer file when updating to v3.6.17.

composer rem twig/twig

We apologise for this circumstance. Unfortunately, it is outside our control and trying to include backward compatibility support for Twig v3.8 is too complex beyond reason.

In Summary:

  • For October CMS v3.5 and below, use Twig v3.8

  • For October CMS v3.6 or above, use Twig v3.9 onwards

@kallef @azvm @axomat @marco.grueter @Maria_UtopigStudio @renick @ngyzsolt

6 Likes

Great, thank you! Updated my project, removed twig which upgraded it to 3.9.0 and everything works fine on v3.6.16.

1 Like

is this supposed to be fixed in v3.6.16? i get the error “Undefined variable $context” in several cases.
btw. I’m using v3.6.16

Try updating to v3.6.17

1 Like

that looks good. You can then ignore the email :slight_smile:

1 Like

Thank you for the ultrafast reaction! :zap:

1 Like

Hi, If I symple press Update to 3.6.17 in Backend, the error is dissapearing.

Is it necessary to run composer rem twig/twig?

After running the command above, I got the following error: Removal failed, twig/twig is still present, it may be required by another package. See composer why twig/twig.
october/rain 3.x-dev requires twig/twig (~3.0)
symfony/http-kernel 6.0.x-dev conflicts twig/twig (<2.13)

Thank you,
Zs