Prestashop: Can't access to some BO pages because of 'Variable "ps" does not exist.' with debug mode

Created on 11 Oct 2019  路  17Comments  路  Source: PrestaShop/PrestaShop

I upgrade my shop from PS 1.7.5.2 to PS 1.7.6.1 with 1-Click upgrade module and now I can't no more access to some admin pages with debug mode to ON. This pages are:

  • Theme and logo
  • Translations
  • Design mail theme
  • Advanced email

With related screenshots:

Design theme and logo page error
Translations page error
Design mail theme page error
Advanced email page error

With debug mode to OFF all this pages are available.

Additional information
PrestaShop version: 1.7.6.1
PHP version: 7.2
Nginx version: 1.15

1.7.6.1 Autoupgrade BO Bug No change required

Most helpful comment

Conclusion: never do an update with Composer or will crash your PrestaShop!

Indeed I would not suggest using a composer update in production. Composer update will basically ignore your composer.lock and attempts to use all possible latest versions of the libraries in composer.json, no matter whether they are compatible with PrestaShop or not.

If you want to use composer to manage your dependencies on your shop, you must carefully select the exact libraries you want to use. I recommand using composer require command or use composer update [my-dependency], but never the global composer update.

Composer is a very powerful tool, and just like all powerful tools can destroy your project if you let him run wild 馃槃

All 17 comments

Hi @Klemart3D,

Could you please try to clear the cache manually by deleting all the folder into var/cache (prod & dev).
Thanks to check and feedback.

Same by cleaning cache manually (rm -rf var/cache/dev/ var/cache/prod/) or with "Clear Cache" button in BO. Error remains if debug mode is enable and cache enabled or disabled.

@Klemart3D, have you some errors during the upgrade?
What is the exact version of the module 1-click upgrade did you use?
Can you please provide us the log of your upgrade? It can be found in the log.txt file, available in <admin folder>/autoupgrade/tmp/log.txt

Thanks!

@khouloudbelguith
I don't remember any error during upgrade.
Module 1-click upgrade v.4.9.0
Here upgrade logs: log.zip

@Klemart3D, thanks!

  • Database upgrade OK
  • All files upgraded.
  • Addons modules files have been upgraded

=> Upgrade process done, but some warnings have been found.

I think your issue is similar to this ticket: https://github.com/PrestaShop/PrestaShop/issues/14327

Thanks to check & feedback.

@khouloudbelguith,

=> Upgrade process done, but some warnings have been found.

Which type of warnings ?
Yes error seems similar to #14327 but process to get it is different. I never used Travis or unit tests in my case.

I have the same issue without using autoupgrade, we started with 1.7.6.1, was working well but since about 2-3 weeks we encounter this problem.

We are working on our client's website, so i'll try to track the change that occured.

If you have any leads, i'll gladly take them !

Hi @Klemart3D, @thesupad,

PrestaShop is not compatible with Twig v2, in fact, PrestaShop uses Twig v1.
Could you please check the exact version of the twig did you use?

Thanks!

Hi @khouloudbelguith,

Like defined in PS v1.7.6.1 _composer.json_, I have:

   "twig/twig": "^1.38||^2.6.2"

And as I can see in my _composer.lock_, it's Twig v2.12.0 installed:

{
    "name": "twig/twig",
    "version": "v2.12.0",
    "source": {
        "type": "git",
        "url": "https://github.com/twigphp/Twig.git",
        "reference": "c7a85fd08348ca04b4d8f234f49583d9910906aa"

If PrestaShop is not compatible with Twig v2, why is it added by Composer?

@Klemart3D, no, In fact, as you can see here: https://github.com/PrestaShop/PrestaShop/blob/1.7.6.1/composer.lock#L6560
The version of the twig is 1.38.4 & not v2
Thanks!

Congrats @khouloudbelguith !!!

We needed to add some php module and so got this composer.json :
https://raw.githubusercontent.com/PrestaShop/PrestaShop/develop/composer.json

In it, you'll see that the required version are :
"twig/twig": "^1.38||^2.6.2"

For anyone who is facing the same :

  • replace this line with "twig/twig": "^1.38"
  • remove twig folder
  • remove composer.lock file
  • do a composer install

@thesupad, Great!
@Klemart3D, any news?
Thanks!

@khouloudbelguith,

I still reproducing errors below today, so that what I tested:

  1. I removed my composer.lock (with _Twig v2.12.0_ inside)
  2. I downloaded official PS 1.7.6.1 composer.lock (with _Twig v1.38.4_ inside)
  3. I launched composer install
  4. I saw the following line in stdout:
    - Downgrading twig/twig (v2.12.0 => v1.38.4): Downloading (100%)
  5. I removed my cache folders (rm -rf var/cache/dev/ var/cache/prod/)
  6. I check my BO, all previous pages in error are now available! :)

Next test:

  1. I launched composer update
  2. I saw nothing about Twig in stdout
  3. I checked my composer.lock (it's now _Twig v2.12.1_ inside!)
  4. I removed my cache folders (rm -rf var/cache/dev/ var/cache/prod/)
  5. I check my BO, error is back on BO pages :(

Next test:

  1. I removed the ||^2.6.2" part from the line "twig/twig": "^1.38||^2.6.2" of composer.json
  2. I launched a new composer update
  3. I saw the following line in stdout:
    - Downgrading twig/twig (v2.12.1 => v1.42.3): Loading from cache
  4. I checked my composer.lock (it's now _Twig v1.42.3_ inside!)
  5. I check my BO, all previous pages in error are now available! :)

Conclusion: never do an update with Composer or will crash your PrestaShop!

EDIT: After my tests I can't anymore access to a product page in BO with DEBUG mode disabled: blank page with no error (code 200) and no log :(

Conclusion: never do an update with Composer or will crash your PrestaShop!

Indeed I would not suggest using a composer update in production. Composer update will basically ignore your composer.lock and attempts to use all possible latest versions of the libraries in composer.json, no matter whether they are compatible with PrestaShop or not.

If you want to use composer to manage your dependencies on your shop, you must carefully select the exact libraries you want to use. I recommand using composer require command or use composer update [my-dependency], but never the global composer update.

Composer is a very powerful tool, and just like all powerful tools can destroy your project if you let him run wild 馃槃

@Klemart3D, also, there is a difference

composer update will update your dependencies as they are specified in composer.json
composer install will not update anything; it will just install all the dependencies as specified in the composer.lock file

Thanks!

Thanks for your answers, it's clear for me and issue can be closed. Only question I have is why is there a ||^2.6.2 in the composer.json if PS in not compatible with Twig v2 :thinking:

@Klemart3D, The require key: The first (and often only) thing you specify in composer.json is the require key. You are simply telling Composer which packages your project depends on.
I close the issue, feel free to open a new one when needed.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings