Post by Rainforest » Sat Sep 21, 2024 8:36 pm

I'm running tests on a dev server to upgrade a site from 3.0.3.8 to 3.0.4.0.
I've already done a successful upgrade of another live site by doing the following:
1. Installed a fresh copy of OC 3.0.4.0.
2. Merge, but not overwrite, the 3.0.3.8 live files
3. Connect database and debug any extensions etc.

This worked fine for the previous site I successfully upgraded. However, this second site I am upgrading is being a little bit of a pain.
When I refresh the modifications, I get this error and am unable to get back into admin (unless I delete the modifications folder)


Fatal error: Uncaught Error: Class "Twig_Loader_Array" not found in /home/customer/www/xxxx/storage/modification/system/library/template/twig.php:36 Stack trace: #0 /home/customer/www/xxxx/storage/modification/system/library/template.php(59): Template\Twig->render('common/header', '<!DOCTYPE html>...') #1 /home/customer/www/xxxx/storage/modification/system/engine/loader.php(133): Template->render('common/header', '') #2 /home/customer/www/xxxx/storage/modification/admin/controller/common/header.php(218): Loader->view('common/header', Array) #3 /home/customer/www/xxxx/storage/modification/system/engine/action.php(79): ControllerCommonHeader->index(Array) #4 /home/customer/www/xxxx/storage/modification/system/engine/loader.php(54): Action->execute(Object(Registry), Array) #5 /home/customer/www/xxxx/public_html/admin/controller/marketplace/modification.php(768): Loader->controller('common/header') #6 /home/customer/www/xxxx/public_html/admin/controller/marketplace/modification.php(17): ControllerMarketplaceModification->getList() #7 /home/customer/www/xxxx/storage/modification/system/engine/action.php(79): ControllerMarketplaceModification->index() #8 /home/customer/www/xxxx/public_html/admin/controller/startup/router.php(26): Action->execute(Object(Registry), Array) #9 /home/customer/www/xxxx/storage/modification/system/engine/action.php(79): ControllerStartupRouter->index() #10 /home/customer/www/xxxx/storage/modification/system/engine/router.php(143): Action->execute(Object(Registry)) #11 /home/customer/www/xxxx/storage/modification/system/engine/router.php(132): Router->execute(Object(Action)) #12 /home/customer/www/xxxx/public_html/system/framework.php(179): Router->dispatch(Object(Action), Object(Action)) #13 /home/customer/www/xxxx/public_html/system/startup.php(104): require_once('/home/customer/...') #14 /home/customer/www/xxxx/public_html/admin/index.php(24): start('admin') #15 {main} thrown in /home/customer/www/xxxx/storage/modification/system/library/template/twig.php on line 36


Any Ideas?
Last edited by Rainforest on Sun Sep 22, 2024 1:03 am, edited 1 time in total.

Self Taught Opencart User & Developer Since 2010.


User avatar
Active Member

Posts

Joined
Fri Jan 28, 2011 3:50 am

Post by by mona » Sat Sep 21, 2024 8:42 pm

viewtopic.php?t=234476#p873239
Rainforest wrote:
Sat Sep 21, 2024 8:36 pm
When I refresh the modifications, I get this error and am unable to get back into admin (unless I delete the modifications folder)
Any Ideas?
So the error is caused by a modification.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by Rainforest » Sat Sep 21, 2024 9:28 pm

Haha. Yes.

Would this work? Going into the database and disabling mods from the table?

Self Taught Opencart User & Developer Since 2010.


User avatar
Active Member

Posts

Joined
Fri Jan 28, 2011 3:50 am

Post by by mona » Sat Sep 21, 2024 9:46 pm

I can not advise to do that, but theoretically it is an option and if you are competent you can do it that way.

The responsible advise is to delete the modification folder and disable them in the correct place in admin.
I also don’t know if you use events or the built in editor but there can be issues can be there also.

viewtopic.php?t=234476#p873239
** For any users thinking they can save time by this type of upgrade method are advised to follow the link above and spend 10 mins more and have a clean install without rubbish to slow the site or copy anything that should not be there.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by Rainforest » Sun Sep 22, 2024 12:36 am

Oh but it's so much more fun doing it the naughty way. ;)

So, I did disable all my mods and with the help of GPT I zeroed in on lines 36-38 in twig.php

Something is modifying the lines to:
$loader1 = new \Twig_Loader_Array(array($filename . '.twig' => $code));
$loader2 = new \Twig_Loader_Filesystem(array(DIR_TEMPLATE));
$loader = new \Twig_Loader_Chain(array($loader1, $loader2));

When I change that to (thanks GPT):
$loader1 = new \Twig\Loader\ArrayLoader(array($filename . '.twig' => $code));
$loader2 = new \Twig\Loader\FilesystemLoader(array(DIR_TEMPLATE));
$loader = new \Twig\Loader\ChainLoader(array($loader1, $loader2));

the site works. That said, with all my mods disabled...what could be editing that code in the storage?

I'm learning and enjoy doing this on the development server. It may not be the right way but I do learn things from this. Any ideas are always greatly appreciated

Self Taught Opencart User & Developer Since 2010.


User avatar
Active Member

Posts

Joined
Fri Jan 28, 2011 3:50 am

Post by Rainforest » Sun Sep 22, 2024 12:50 am

.....and solved ;)

So, what I did was.

1. First identified that line 36-38 was being altered.
2. asked chatgpt what the correct code could be. Tried that and worked.
3. refreshed mod and the bad code came back.
4. downloaded my public html to my local
5. Used astrogrep to find the altered code
6.That led me to a rewards xml that was sitting in my system folder. _Disabled the file and all fixed.

<hair toss> ;D

Self Taught Opencart User & Developer Since 2010.


User avatar
Active Member

Posts

Joined
Fri Jan 28, 2011 3:50 am

Post by JNeuhoff » Sun Sep 22, 2024 6:04 pm

The reason for this modification was because of your web theme which apparently uses Twig's include tags. This is usually a sign that the web theme needs some improvements because it shouldn't rely on the include tags in a proper MVC design.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Rainforest » Sun Sep 22, 2024 7:39 pm

Thank you for input J.
It was actually a rewards module (mega rewards) which was inserting the lines into the twig, not the theme.

Self Taught Opencart User & Developer Since 2010.


User avatar
Active Member

Posts

Joined
Fri Jan 28, 2011 3:50 am

Post by JNeuhoff » Sun Sep 22, 2024 11:16 pm

Rainforest wrote:
Sun Sep 22, 2024 7:39 pm
Thank you for input J.
It was actually a rewards module (mega rewards) which was inserting the lines into the twig, not the theme.
Sorry, yes. Still, there should be no reason for the rewards module to do this modification unless its twig files use include-tags.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by faizanyasn » Mon Sep 23, 2024 8:57 pm

Previous code is twig 1 loader format and newer code is basically twig 2 /3 loader. secondly filesystem is used in case template engine fails to find file system assists.

For further assistance with Opencart Development you can reach me at
asktofaizan@gmail.com | https://asktofaizan.com |


Newbie

Posts

Joined
Tue Jan 12, 2021 2:28 pm
Who is online

Users browsing this forum: No registered users and 6 guests