PHP Notice: Undefined variable: expire in C:\inetpub\wwwroot\oc\system\library\template.php
Hi guys, how are you?
First at all, Sorry for my English , but im gonna try to write the best of me.
Well.
im new in PHP, but, with some tutorials im turn on the MySql Server and PHP extensión in my IIS 7.5
Well, the problema is this
When im trying to open the OpenCart Installation, this throw me an exception: "PHP Notice: Undefined variable: expire in C:\inetpub\wwwroot\oc\system\library\template.php on line 9 ".
when i put this into a GoDaddy, this Works fine!!, but in my local machin this fail..
Can you help me please
im using:
PHP 7
Windows 7 profesional
MySql 5.7
Best regards.
Hi guys, how are you?
First at all, Sorry for my English , but im gonna try to write the best of me.
Well.
im new in PHP, but, with some tutorials im turn on the MySql Server and PHP extensión in my IIS 7.5
Well, the problema is this
When im trying to open the OpenCart Installation, this throw me an exception: "PHP Notice: Undefined variable: expire in C:\inetpub\wwwroot\oc\system\library\template.php on line 9 ".
when i put this into a GoDaddy, this Works fine!!, but in my local machin this fail..
Can you help me please
im using:
PHP 7
Windows 7 profesional
MySql 5.7
Best regards.
I had that error no matter what I did. Even when installing a new version from scratch. Downgrade your php version. I had it at 7.1 when I had the error. Now I set in the cpanel to version 7.0 and it is gone.
So whenever you get this error - downgrade PHP version
So whenever you get this error - downgrade PHP version
I had the same issue, downgrading to PHP 7.0 fixed it as welldoktorek wrote: ↑Wed Oct 19, 2016 7:41 amI had that error no matter what I did. Even when installing a new version from scratch. Downgrade your php version. I had it at 7.1 when I had the error. Now I set in the cpanel to version 7.0 and it is gone.
So whenever you get this error - downgrade PHP version
Came across it a few days ago as well after updating to php7.1
I did a quick fix:
if(!isset($expire)){$expire=86400;}
$this->adaptor = new $class($expire);
Didn't check what expire means in context or what called it, just added a default value of 1 day as it sounded like a cache expiration time.
I did a quick fix:
if(!isset($expire)){$expire=86400;}
$this->adaptor = new $class($expire);
Didn't check what expire means in context or what called it, just added a default value of 1 day as it sounded like a cache expiration time.
Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+
Thanks!
Regarding this error I found almost same code in "system\library\cache.php" on line 5
So it looks like constructor is missing one parameter, if I am right You need to add second parameter "$expire = 3600" in "system\library\template.php" file on line 5
Code: Select all
public function __construct($adaptor, $expire = 3600) {
$class = 'Cache\\' . $adaptor;
Code: Select all
public function __construct($adaptor, $expire = 3600) {
$class = 'Template\\' . $adaptor;
for some reason $expire is undefined therefore it will throw this error.
My fix is
<?php
class Template {
private $adaptor;
public function __construct($adaptor) {
$class = 'Template\\' . $adaptor;
if (class_exists($class)) {
// add $expire="" to clear "undefined variable warning" -reason
$expire="";
$this->adaptor = new $class($expire);
} else {
throw new \Exception('Error: Could not load template adaptor ' . $adaptor . '!');
}
}
public function set($key, $value) {
$this->adaptor->set($key, $value);
}
public function render($template) {
return $this->adaptor->render($template);
}
}
My fix is
<?php
class Template {
private $adaptor;
public function __construct($adaptor) {
$class = 'Template\\' . $adaptor;
if (class_exists($class)) {
// add $expire="" to clear "undefined variable warning" -reason
$expire="";
$this->adaptor = new $class($expire);
} else {
throw new \Exception('Error: Could not load template adaptor ' . $adaptor . '!');
}
}
public function set($key, $value) {
$this->adaptor->set($key, $value);
}
public function render($template) {
return $this->adaptor->render($template);
}
}
I have created an ocmod plugin for this fix. You can download it for free from https://www.huntbee.com/fix-for-undefin ... e-opencart
HuntBee OpenCart Services
https://www.huntbee.com
vytasm wrote: ↑Tue Nov 07, 2017 4:23 pmRegarding this error I found almost same code in "system\library\cache.php" on line 5
So it looks like constructor is missing one parameter, if I am right You need to add second parameter "$expire = 3600" in "system\library\template.php" file on line 5Code: Select all
public function __construct($adaptor, $expire = 3600) { $class = 'Cache\\' . $adaptor;
Code: Select all
public function __construct($adaptor, $expire = 3600) { $class = 'Template\\' . $adaptor;
thanks!
my extension:https://www.opencart.com/index.php?rout ... estshop24h
email :support@bestshop24h.com
site:http://www.bestshop24h.com
Who is online
Users browsing this forum: No registered users and 161 guests