Post by siteadvice » Thu Jan 14, 2021 11:46 pm

I have been trying to solve a problem with my development server and I'm completely stuck, so I hope someone in the community has some advice for me.

My live, public site works fine. However, when using my duplicate development site and trying to open a product edit page in the Opencart dashboard I get a blank white screen.

The error from the error_log file is pasted below (path names removed for privacy and to make it easier to read).

The development server is a very similar spec to the live server and both sites are using the same version of PHP. The version of Opencart is the same as the live site (3.0.3.2) and the development database is a recent backup from the live server.

I have tried restoring the whole system/library/template folder from the original Opencart 3.0.3.2 repository, just in case, but that didn't help. I didn't really think it would, but it was worth a try!

The obvious culprit would be one of the extensions, but I have tried disabling every extension that is not built in to Opencart and it doesn't make any difference.

Any ideas anybody!?

PHP Fatal error: Uncaught Error: Call to a member function needsEnvironment() on bool in /home/{{path}}/system/library/template/Twig/Node/Expression/Function.php:26
Stack trace:
#0 /home/{{path}}/system/library/template/Twig/Compiler.php(97): Twig_Node_Expression_Function->compile(Object(Twig_Compiler))
#1 /home/{{path}}/system/library/template/Twig/Node/Print.php(30): Twig_Compiler->subcompile(Object(Twig_Node_Expression_Function))
#2 /home/{{path}}/system/library/template/Twig/Node.php(110): Twig_Node_Print->compile(Object(Twig_Compiler))
#3 /home/{{path}}/system/library/template/Twig/Node.php(110): Twig_Node->compile(Object(Twig_Compiler))
#4 /home/{{path}}/system/library/template/Twig/Compiler.php(97): Twig_Node->compile(Object(Twig_Compiler))
#5 /home/{{path}}/system/library/template/Twig/Node/Module.php(277): Twig_Compiler->subcompile(Object(Twig_N in /home/{{path}}/system/library/template/Twig/Node/Expression/Function.php on line 26
Last edited by siteadvice on Thu Jan 21, 2021 11:59 pm, edited 1 time in total.

inframes.com Website Design with Opencart, Wordpress, Lucee and bespoke application design and development


User avatar
New member

Posts

Joined
Mon Oct 24, 2011 8:12 pm

Post by JNeuhoff » Fri Jan 15, 2021 12:18 am

Make sure you use the same PHP version on your local server that is used on the live site.

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 mikeinterserv » Fri Jan 15, 2021 12:47 am

siteadvice wrote:
Thu Jan 14, 2021 11:46 pm
both sites are using the same version of PHP.
They ARE

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by siteadvice » Fri Jan 15, 2021 12:54 am

Thanks @JNeuhoff - that is good thinking, but as @mikeinterserv says, I already confirmed that both installations are running the same version of PHP. For the record it is ea-php72. Out of interest, I tried upgrading to 7.4, just to see if I got a different/more helpful error, but it doesn't make any difference.

inframes.com Website Design with Opencart, Wordpress, Lucee and bespoke application design and development


User avatar
New member

Posts

Joined
Mon Oct 24, 2011 8:12 pm

Post by JNeuhoff » Fri Jan 15, 2021 1:00 am

You may also want to clear and then refresh your OCmod and VQmod modification caches. And then check the OCmod log for any errors.

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 mikeinterserv » Fri Jan 15, 2021 1:05 am

Whats on line 26 of your Function.php

Maybe you call a local variable that is global

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by siteadvice » Fri Jan 15, 2021 1:15 am

@JNeuhoff Thanks, but I have tried that. I don't have VQMOD installed anyway.

inframes.com Website Design with Opencart, Wordpress, Lucee and bespoke application design and development


User avatar
New member

Posts

Joined
Mon Oct 24, 2011 8:12 pm

Post by siteadvice » Fri Jan 15, 2021 1:17 am

@mikeinterserv It is just the regular line from the core Opencart/Twig code, which happens to be:
$this->setAttribute('needs_environment', $function->needsEnvironment());
I don't know what that does, to be honest.

inframes.com Website Design with Opencart, Wordpress, Lucee and bespoke application design and development


User avatar
New member

Posts

Joined
Mon Oct 24, 2011 8:12 pm

Post by mikeinterserv » Fri Jan 15, 2021 1:34 am

Well its NOT in my opencart twig code
You have a very different path in your system folder

appears something like the environment loader is not working for the function
I will struggle to help from here as I do not have the same files etc as you

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by JNeuhoff » Fri Jan 15, 2021 1:44 am

The error indicates that the Twig environment is missing. Make sure the system/library/template/twig.php is not corrupted nor modified.

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 siteadvice » Fri Jan 15, 2021 1:52 am

@mikeinterserv You do not have this folder...?
/system/library/template/Twig/Node/Expression
I assure you it is part of the Opencart distributable.

inframes.com Website Design with Opencart, Wordpress, Lucee and bespoke application design and development


User avatar
New member

Posts

Joined
Mon Oct 24, 2011 8:12 pm

Post by mikeinterserv » Fri Jan 15, 2021 1:56 am

No not at all -
I have
/htdocs/Shop/system/library/template

and inside just 2 files
template.php
twig.php

You have EXTENDED Twig
Either deliberately because you need that or NOT I don't know
I do know that is NOT the CORE STANDARD install.

Your function is failing because the environment is not loaded

Maybe see if you can find this code SOMEWHERE :-)

Code: Select all

$twig = new \Twig\Environment($loader);
$function = new \Twig\TwigFunction('function_name', function () {
    // ...
});
$twig->addFunction($function);

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by straightlight » Fri Jan 15, 2021 2:44 am

siteadvice wrote:
Fri Jan 15, 2021 1:52 am
@mikeinterserv You do not have this folder...?
/system/library/template/Twig/Node/Expression
I assure you it is part of the Opencart distributable.
However, it is not what is being delivered from Opencart.com which are the distributions that this site officially supports. It is confirmed that the TWIG sub-folder is not included in the system/library/template folder. Only two files are officially distributed. Which means, you are using a development version of Opencart which also leads to why you may encounter additional errors from those distributions.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by sw!tch » Fri Jan 15, 2021 2:47 am

You cant compare 3.0.3.6 version to 3.0.3.2, there were significant updates to twig in 3.0.3.6.

If on a version below 3.0.3.6 ensure you are on PHP 7.3.

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by straightlight » Fri Jan 15, 2021 2:48 am

In addition to the above, the master branch also contains an updated bootstrap and TWIG Engine as part of the recent development core.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by mikeinterserv » Fri Jan 15, 2021 2:51 am

Yep start with this ^
as straighlight suggets

OR

Do a new install :-)

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by by mona » Fri Jan 15, 2021 3:31 am

Whilst what straightlight says is true, you should stick to the official downloads.
However to clear something up ... see attached the official download - because I do have that folder

Attachments

Screen-Shot-2021-01-14-at-19.23.31.png

Screen-Shot-2021-01-14-at-19.23.31.png (195.27 KiB) Viewed 3020 times


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 mikeinterserv » Fri Jan 15, 2021 3:38 am

I'm trying to see what's in another 3.0.3.2 I have
But vm instances will NOT start on europe-west2 on google cloud
If I have that file structure there I can help you more.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by sw!tch » Fri Jan 15, 2021 3:49 am

As mentioned before there are significant updates to twig in 3.0.3.6. Twig was updated and pulled in via composer, along with other updates.

You shouldn't be comparing 3.0.3.6 to 3.0.3.2.
https://github.com/opencart/opencart/tr ... y/template

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by paulfeakins » Fri Jan 15, 2021 5:55 pm

siteadvice wrote:
Thu Jan 14, 2021 11:46 pm
My live, public site works fine. However, when using my duplicate development site and trying to open a product edit page in the Opencart dashboard I get a blank white screen.
Take a fresh copy of it on to dev and see if the issue still occurs.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom
Who is online

Users browsing this forum: No registered users and 259 guests