Opened 9 years ago
Closed 9 years ago
#989 closed Bug/Fehler (fixed)
Sprachkonstanten werden bei Benutzung von Smarty 2 aufgrund von Changeset r10166 nicht mehr geladen
| Reported by: | Torsten Riemer | Owned by: | somebody |
|---|---|---|---|
| Priority: | hoch | Milestone: | modified-shop-2.0.1.0 |
| Component: | Shop | Version: | trunk |
| Keywords: | Cc: | ||
| Blocked By: | Blocking: |
Description
Die Änderungen aus r10166 haben zur Folge, dass bei Benutzung von Smarty 2 keine Sprachkonstanten mehr geladen werden. Nachvollziehbar im Trunk Demoshop unter Verwendung des Templates xtc5.
Attachments (3)
Change History (30)
comment:1 by , 9 years ago
comment:3 by , 9 years ago
Ok, dann kann die Änderung aus der Smarty2 Datei raus, dann funktioniert das auch wieder, das xtc5 war von den Änderungen nicht betroffen.
comment:5 by , 9 years ago
bestimmt, müsste mir dafür dann genau anschauen wie Smarty2 intern arbeitet, habe aber gerade nicht die Zeit dafür.
comment:6 by , 9 years ago
Die neuen Template kann man auch unter Smarty 2 betreiben. Das ist dann sinnvoll, wenn von alten Modulen noch PHP Code inkludiert wird, und der Aufwand zu groß ist das ganze umzuschreiben.
Was auch wichtig ist wenn an externen Modulen Änderungen vorgenommen werden:
Die Modul Original Datei mit _org.php Kennzeichnung in das gleiche Verzeichnis laden.
Bei einem Modul Update weiss in einem Jahr keiner mehr das etwas entscheidend geändert wurde.
comment:7 by , 9 years ago
Von der Idee alte original-Dateien als *_org.php mit zu schleppen halte ich gar nichts. Wir setzen hier definierte Versionen ein - im Falle von Smarty 3 ist es Version 3.1.21 und mit der kann zu jedem Zeitpunkt vergleichen, welche nachträglich Änderungen gemacht wurden.
comment:8 by , 9 years ago
Mit Smarty 2 funktioniert es, wenn man:
if (isset($params['resource_base_path']))
$_params['resource_base_path'] = $params['resource_base_path'];
else
$_params['resource_base_path'] = $this->template_dir;
#mod
$_params['resource_base_path'] = array(
$this->template_dir,
$this->template_dir . DIRECTORY_SEPARATOR . CURRENT_TEMPLATE
);
#mod
ersetzt mit:
if (isset($params['resource_base_path'])) {
$_params['resource_base_path'] = $params['resource_base_path'];
} else {
//$_params['resource_base_path'] = $this->template_dir;
#mod
$_params['resource_base_path'] = array(
$this->template_dir,
$this->template_dir . DIRECTORY_SEPARATOR . CURRENT_TEMPLATE
);
#mod
}
Kann das mal bitte jemand verifizieren?
Das führt dann aber zu folgender Warnung:
[04-08-2016 14:40:40] E_WARNING : LoggingManager: is_readable(): open_basedir restriction in effect. File(/usr/share/pear/templates/module/includes/product_listing_include.html) is not within the allowed path(s): (/.../.../.../.../.../web:/.../.../.../.../.../private:/.../.../.../.../.../tmp:/.../.../.../web:/.../.../.../web:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin:/usr/share/php) in File: /.../.../.../.../.../.../.../includes/external/smarty/smarty_2/internals/core.get_include_path.php on Line: 34 [04-08-2016 14:40:40] E_WARNING : LoggingManager: Backtrace #0 - /.../.../.../.../.../.../.../includes/external/smarty/smarty_2/Smarty.class.php called at Line 1664 [04-08-2016 14:40:40] E_WARNING : LoggingManager: Backtrace #1 - /.../.../.../.../.../.../.../includes/external/smarty/smarty_2/Smarty.class.php called at Line 1558 [04-08-2016 14:40:40] E_WARNING : LoggingManager: Backtrace #2 - /.../.../.../.../.../.../.../includes/external/smarty/smarty_2/Smarty.class.php called at Line 1394 [04-08-2016 14:40:40] E_WARNING : LoggingManager: Backtrace #3 - /.../.../.../.../.../.../.../includes/external/smarty/smarty_2/Smarty.class.php called at Line 1884 [04-08-2016 14:40:40] E_WARNING : LoggingManager: Backtrace #4 - /.../.../.../.../.../.../.../templates_c/%%28^289^2894A3E0%%new_products_default.html.php called at Line 18 [04-08-2016 14:40:40] E_WARNING : LoggingManager: Backtrace #5 - /.../.../.../.../.../.../.../includes/external/smarty/smarty_2/Smarty.class.php called at Line 1270 [04-08-2016 14:40:40] E_WARNING : LoggingManager: Backtrace #6 - /.../.../.../.../.../.../.../includes/extra/default/center_modules/new_products_default.php called at Line 110 [04-08-2016 14:40:40] E_WARNING : LoggingManager: Backtrace #7 - /.../.../.../.../.../.../.../includes/modules/default.php called at Line 320 [04-08-2016 14:40:40] E_WARNING : LoggingManager: Backtrace #8 - /.../.../.../.../.../.../.../index.php called at Line 32
comment:9 by , 9 years ago
Hallo,
vielleicht kann mein Fix euch weiter helfen:
Neue Konstante in der nähe von MY_TEMPLATE_PLUGINS definieren:
define('MY_TEMPLATE_LANG', DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/lang');
folgende Zeile bei Smarty 2 ersetzen:
var $config_dir = 'lang';
durch
var $config_dir = array('lang', MY_TEMPLATE_LANG);
Dann werden die Dateien aus einer der folgenden Verzeichnissen gelesen:
- lang/
- templates/{CURRENT_TEMPLATE}/lang/
Wenn die Datei in lang/ nicht gefunden wird, wird sie in Template gesucht.
Der Fix ist fehlerhaft:
if (isset($params['resource_base_path']))
$_params['resource_base_path'] = $params['resource_base_path'];
else
$_params['resource_base_path'] = $this->template_dir;
#mod
$_params['resource_base_path'] = array(
$this->template_dir,
$this->template_dir . DIRECTORY_SEPARATOR . CURRENT_TEMPLATE
);
#mod
weil der nur ins "templates" schaut und $params[resource_base_path] vollständig ignoriert wird
Gruß
Jürgen H.
comment:10 by , 9 years ago
Das Problem ist ja nicht der Ordner DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/lang' sondern es werden die Sprachkonstanten aus der lang_german.conf nicht mehr gezogen, wenn man im Trunk Demoshop auf das Template xtc5 umstellt, welches noch Smarty 2 einsetzt.
comment:11 by , 9 years ago
es geht um das fehlende addTemplateDir() in Smarty2 und ->template_dir akzeptiert kein Array.
comment:12 by , 9 years ago
Verstehe, für die Ladung der Sprachkonstanten ist der Bereich verantwortlich:
if (isset($params['resource_base_path']))
$_params['resource_base_path'] = $params['resource_base_path'];
else
(Weil smarty_function_config_load ruft die Smarty::_fetch_resource_info auf und übergibt als Parameter: resource_base_path)
Der Fix in der erste Variante
#mod
$_params['resource_base_path'] = array(
$this->template_dir,
$this->template_dir . DIRECTORY_SEPARATOR . CURRENT_TEMPLATE
);
#mod
hat "lang" Verzeichnis durch "templates" ersetzt. Deswegen hat es nicht funktioniert. Aber Fix von Tomcraft (mit geschweiften Klammern) sollte doch funktionieren.
Mein Vorschlag wäre aber genau so zu machen, wie ich für die Sprachkonstanten empfohlen habe.
define('MY_TEMPLATE', DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE);
...
var $template_dir = array('templates', MY_TEMPLATE);
Schon probiert?
Gruß
Jürgen H.
comment:13 by , 9 years ago
Die Frage von Tomcraft wegen Warnungen, ich habe bei mir im Smarty ein Fix reingebracht, was den Pfad vervollständigt hat. Z.B. alle Pfade wie
- 'templates',
- 'templates_c',
- 'lang',
- 'plugins',
- 'cache',
durch absolute Pfade erweitert.
Dafür habe ich erstmal function Smarty() ins function __construct() umbenannt. Dann alle benötigte Variablen mit DIR_FS_CATALOG vervollständigt und open_base_dir Warnung wurde somit bei mir entfernt.
Beispiel:
function __construct()
{
$this->compile_dir = DIR_FS_CATALOG . $this->compile_dir;
$this->config_dir[0] = DIR_FS_CATALOG . $this->config_dir[0];
$this->template_dir[0] = DIR_FS_CATALOG . $this->template_dir[0];
$this->cache_dir = DIR_FS_CATALOG . $this->cache_dir;
$this->plugins_dir[0] = dirname(__FILE__) . '/' . $this->plugins_dir[0];
$this->assign('SCRIPT_NAME', isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME']
: @$GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']);
}
In dem Fall habe ich aber schon config_dir und template_dir ins Array umgewandelt, bitte aufpassen.
Gruß
Jürgen H.
by , 9 years ago
| Attachment: | Smarty.class.php added |
|---|
Für mich bräuchte ich eine Kind-Template (MY_MASTER_*), das kann man ignorieren.
by , 9 years ago
| Attachment: | Smarty.class.diff added |
|---|
by , 9 years ago
| Attachment: | Smarty_Compiler.class.diff added |
|---|
follow-up: 16 comment:15 by , 9 years ago
var $template_dir = array('templates', 'templates' . DIRECTORY_SEPARATOR . CURRENT_TEMPLATE);
habe ich jetzt nicht getestet, so wie ich einige Stellen im Code und im Netz verstanden habe, wird array nicht unterstützt.
comment:16 by , 9 years ago
Replying to h-h-h:
var $template_dir = array('templates', 'templates' . DIRECTORY_SEPARATOR . CURRENT_TEMPLATE);
Achtung, je nach PHP Version, könnte so ein Syntax "Fatal Error" produzieren. Man darf die Punkte bei Variablen nicht benutzen, aus dem Grund müsste ich dies ins Konstante verschieben. (Ich glaube sogar, erst ab PHP 5.6 funktioniert so ein Syntax)
Gruß
Jürgen H.
comment:18 by , 9 years ago
| Resolution: | fixed |
|---|---|
| Status: | closed → reopened |
Der Fix funktioniert soweit gut bis auf folgende Warnungen, die ich wieder erhalte:
[05-08-2016 14:48:59] E_WARNING : LoggingManager: is_readable(): open_basedir restriction in effect. File(/usr/share/pear/templates/module/includes/product_listing_include.html) is not within the allowed path(s): (/.../.../.../.../.../web:/.../.../.../.../.../private:/.../.../.../.../.../tmp:/.../.../.../web:/.../.../.../web:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin:/usr/share/php) in File: /.../.../.../.../.../.../.../includes/external/smarty/smarty_2/internals/core.get_include_path.php on Line: 34 [05-08-2016 14:48:59] E_WARNING : LoggingManager: Backtrace #0 - /.../.../.../.../.../.../.../includes/external/smarty/smarty_2/Smarty.class.php called at Line 1664 [05-08-2016 14:48:59] E_WARNING : LoggingManager: Backtrace #1 - /.../.../.../.../.../.../.../includes/external/smarty/smarty_2/Smarty.class.php called at Line 1558 [05-08-2016 14:48:59] E_WARNING : LoggingManager: Backtrace #2 - /.../.../.../.../.../.../.../includes/external/smarty/smarty_2/Smarty.class.php called at Line 1394 [05-08-2016 14:48:59] E_WARNING : LoggingManager: Backtrace #3 - /.../.../.../.../.../.../.../includes/external/smarty/smarty_2/Smarty.class.php called at Line 1884 [05-08-2016 14:48:59] E_WARNING : LoggingManager: Backtrace #4 - /.../.../.../.../.../.../.../templates_c/%%28^289^2894A3E0%%new_products_default.html.php called at Line 18 [05-08-2016 14:48:59] E_WARNING : LoggingManager: Backtrace #5 - /.../.../.../.../.../.../.../includes/external/smarty/smarty_2/Smarty.class.php called at Line 1270 [05-08-2016 14:48:59] E_WARNING : LoggingManager: Backtrace #6 - /.../.../.../.../.../.../.../includes/extra/default/center_modules/new_products_default.php called at Line 110 [05-08-2016 14:48:59] E_WARNING : LoggingManager: Backtrace #7 - /.../.../.../.../.../.../.../includes/modules/default.php called at Line 320 [05-08-2016 14:48:59] E_WARNING : LoggingManager: Backtrace #8 - /.../.../.../.../.../.../.../index.php called at Line 32
comment:19 by , 9 years ago
Gerade nochmals getestet: xtc5 Template
Windows xammpp php 5.4
Linux Apache/2.4.20 php 5.6
Bei beiden keine Fehler in den logs.
comment:20 by , 9 years ago
Achso sorry... hätte ich dazu sagen sollen. Es geht um die neuen Templates, die ja auch überhaupt erst includes verwenden. Wenn man die auf Smarty 2 stellt, dann erhält man diese Warnungen.
comment:22 by , 9 years ago
Ich habe im Trunk Demoshop mal das Template "tpl_modified_responsive" auf Smarty 2 umgestellt. Hier kannst du dir das Log runterladen um es nachzuvollziehen: http://demo.modified-shop.org/trunk/admin/logs.php
comment:23 by , 9 years ago
Ursache im trunk Shop ist die Servereinstellung bei
open_basedir
siehe Server Info.
Das ist eingentlich immer auf "no value"
Dehalb kann ich das auch nicht nachstellen
comment:24 by , 9 years ago
Wenn ich in Smarty-Code schaue, kommt die Ausführung in diese Abfrage rein:
// relative pathname to $params['resource_base_path']
// use the first directory where the file is found
foreach ((array)$params['resource_base_path'] as $_curr_path) {
$_fullpath = $_curr_path . DIRECTORY_SEPARATOR . $params['resource_name'];
if (file_exists($_fullpath) && is_file($_fullpath)) {
$params['resource_name'] = $_fullpath;
return true;
}
// didn't find the file, try include_path
$_params = array('file_path' => $_fullpath);
require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
if(smarty_core_get_include_path($_params, $this)) {
$params['resource_name'] = $_params['new_file_path'];
return true;
}
}
Scheinbar findet der die Datei nicht und versucht mit include_path zu arbeiten. Kann man versuchen diese Schleife in zwei Bereichen zu teilen:
// relative pathname to $params['resource_base_path']
// use the first directory where the file is found
foreach ((array)$params['resource_base_path'] as $_curr_path) {
$_fullpath = $_curr_path . DIRECTORY_SEPARATOR . $params['resource_name'];
if (file_exists($_fullpath) && is_file($_fullpath)) {
$params['resource_name'] = $_fullpath;
return true;
}
}
foreach ((array)$params['resource_base_path'] as $_curr_path) {
$_fullpath = $_curr_path . DIRECTORY_SEPARATOR . $params['resource_name'];
// didn't find the file, try include_path
$_params = array('file_path' => $_fullpath);
require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
if(smarty_core_get_include_path($_params, $this)) {
$params['resource_name'] = $_params['new_file_path'];
return true;
}
}
Das könnte ein Fix für open_basedir sein, könnt Ihr mal das testen?
Gruß
Jürgen H.
comment:25 by , 9 years ago
das ist ein guter fix, bitte in jedem Fall übernehmen, ungetestet, finde die Umsetzung besser als die von Smarty2.
comment:26 by , 9 years ago
Ich habe den Fix soeben getestet.
Der Fix ist super und behebt alle open_basedir Probleme bei Benutzung von Smarty 2 in den neuen Templates, die includes verwenden!

nutzt nur noch xtc5 smarty2 und funktionieren die anderen Templates auch noch mit Smarty2?