- Saved searches
- Use saved searches to filter your results more quickly
- Class autoloading in templates not working anyomre since 3.1.28 #124
- Class autoloading in templates not working anyomre since 3.1.28 #124
- Comments
- Smarty Icon
- Sites Using Smarty
- Advertisement
- Chapter 17. Troubleshooting
- Smarty/PHP errors
- Smarty Icon
- Sites Using Smarty
- Advertisement
- Chapter 20. Troubleshooting
- Smarty/PHP errors
- Smarty Icon
- Sites Using Smarty
- Advertisement
- Chapter 17. Решение проблем
- Ошибки Smarty/PHP
- Saved searches
- Use saved searches to filter your results more quickly
- Smarty is not compatible with PHP 8.1 #671
- Smarty is not compatible with PHP 8.1 #671
- Comments
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Class autoloading in templates not working anyomre since 3.1.28 #124
Class autoloading in templates not working anyomre since 3.1.28 #124
Comments
Since I upgraded from 3.1.27 to 3.1.28, I get a PHP fatal error like
Fatal error: Uncaught exception ‘LogicException’ with message ‘Class Smarty_Internal_Data could not be loaded’
My example project looks like this
index.php
folder1\class1.php
templates\start.tpl
// autoloader from http://php.net/manual/de/function.spl-autoload-register.php#92514 spl_autoload_extensions('.php'); spl_autoload_register(); require 'path/to/smarty.class'; $smarty = new Smarty; /* some settings here */ $smarty->display('start.tpl');
namespace folder1; class class1< public static function x()< return 1; > >
assign 'test' folder1\class1::x()>
When I use a custom Autoloader like
spl_autoload_register(function($classname)< $filename = __DIR__.DIRECTORY_SEPARATOR.$classname.'.php'; if(file_exists($filename)) include $filename; >);
. it works. Am I forced to rewrite my code here or is this actually a bug?
The text was updated successfully, but these errors were encountered:
Smarty Icon
You may use the Smarty logo according to the trademark notice. For sponsorship, advertising, news or other inquiries, contact us at:
Sites Using Smarty
Advertisement
Chapter 17. Troubleshooting
Smarty/PHP errors
Smarty can catch many errors such as missing tag attributes or malformed variable names. If this happens, you will see an error similar to the following:
Warning: Smarty: [in index.tpl line 4]: syntax error: unknown tag - '%blah' in /path/to/smarty/Smarty.class.php on line 1041 Fatal error: Smarty: [in index.tpl line 28]: syntax error: missing section name in /path/to/smarty/Smarty.class.php on line 1041
Smarty shows you the template name, the line number and the error. After that, the error consists of the actual line number in the Smarty class that the error occured. There are certain errors that Smarty cannot catch, such as missing close tags. These types of errors usually end up in PHP compile-time parsing errors.
Parse error: parse error in /path/to/smarty/templates_c/index.tpl.php on line 75
When you encounter a PHP parsing error, the error line number will correspond to the compiled PHP script, NOT the template itself. Usually you can look at the template and spot the syntax error. Here are some common things to look for: missing close tags for or , or syntax of logic within an tag. If you can’t find the error, you might have to open the compiled PHP file and go to the line number to figure out where the corresponding error is in the template.
Warning: Smarty error: unable to read resource: "index.tpl" in. or Warning: Smarty error: unable to read resource: "site.conf" in.
- The $template_dir is incorrect, doesn’t exist or the file index.tpl is not in the templates/ directory
- A function is within a template (or config_load() has been called) and either $config_dir is incorrect, does not exist or site.conf is not in the directory.
Fatal error: Smarty error: the $compile_dir 'templates_c' does not exist, or is not a directory.
- Either the $compile_diris incorrectly set, the directory does not exist, or templates_c is a file and not a directory.
Fatal error: Smarty error: unable to write to $compile_dir '.
Fatal error: Smarty error: the $cache_dir 'cache' does not exist, or is not a directory. in /..
- This means that $caching is enabled and either; the $cache_dir is incorrectly set, the directory does not exist, or cache/ is a file and not a directory.
Fatal error: Smarty error: unable to write to $cache_dir '/.
- This means that $caching is enabled and the $cache_dir is not writable by the web server. See the bottom of the installing smarty page for permissions.
Smarty Icon
You may use the Smarty logo according to the trademark notice. For sponsorship, advertising, news or other inquiries, contact us at:
Sites Using Smarty
Advertisement
Chapter 20. Troubleshooting
Smarty/PHP errors
Smarty can catch many errors such as missing tag attributes or malformed variable names. If this happens, you will see an error similar to the following:
Warning: Smarty: [in index.tpl line 4]: syntax error: unknown tag - '%blah' in /path/to/smarty/Smarty.class.php on line 1041 Fatal error: Smarty: [in index.tpl line 28]: syntax error: missing section name in /path/to/smarty/Smarty.class.php on line 1041
Smarty shows you the template name, the line number and the error. After that, the error consists of the actual line number in the Smarty class that the error occurred. There are certain errors that Smarty cannot catch, such as missing close tags. These types of errors usually end up in PHP compile-time parsing errors.
Parse error: parse error in /path/to/smarty/templates_c/index.tpl.php on line 75
When you encounter a PHP parsing error, the error line number will correspond to the compiled PHP script, NOT the template itself. Usually you can look at the template and spot the syntax error. Here are some common things to look for: missing close tags for or , or syntax of logic within an tag. If you can’t find the error, you might have to open the compiled PHP file and go to the line number to figure out where the corresponding error is in the template.
Warning: Smarty error: unable to read resource: "index.tpl" in. or Warning: Smarty error: unable to read resource: "site.conf" in.
- The $template_dir is incorrect, doesn’t exist or the file index.tpl is not in the templates/ directory
- A function is within a template (or configLoad() has been called) and either $config_dir is incorrect, does not exist or site.conf is not in the directory.
Fatal error: Smarty error: the $compile_dir 'templates_c' does not exist, or is not a directory.
- Either the $compile_diris incorrectly set, the directory does not exist, or templates_c is a file and not a directory.
Fatal error: Smarty error: unable to write to $compile_dir '.
Fatal error: Smarty error: the $cache_dir 'cache' does not exist, or is not a directory. in /..
- This means that $caching is enabled and either; the $cache_dir is incorrectly set, the directory does not exist, or cache/ is a file and not a directory.
Fatal error: Smarty error: unable to write to $cache_dir '/.
- This means that $caching is enabled and the $cache_dir is not writable by the web server. See the bottom of the installing smarty page for permissions.
Warning: filemtime(): stat failed for /path/to/smarty/cache/3ab50a623e65185c49bf17c63c90cc56070ea85c.one.tpl.php in /path/to/smarty/libs/sysplugins/smarty_resource.php
- This means that your application registered a custom error hander (using set_error_handler()) which is not respecting the given $errno as it should. If, for whatever reason, this is the desired behaviour of your custom error handler, please call muteExpectedErrors() after you’ve registered your custom error handler.
Smarty Icon
You may use the Smarty logo according to the trademark notice. For sponsorship, advertising, news or other inquiries, contact us at:
Sites Using Smarty
Advertisement
Chapter 17. Решение проблем
Ошибки Smarty/PHP
Smarty может ловить многие ошибки, например отсутствующие атрибуты тэгов или недопустимые имена переменных. Если это произойдет, вы увидите ошибку наподобие следующей:
Warning: Smarty: [in index.tpl line 4]: syntax error: unknown tag - '%blah' in /path/to/smarty/Smarty.class.php on line 1041 Fatal error: Smarty: [in index.tpl line 28]: syntax error: missing section name in /path/to/smarty/Smarty.class.php on line 1041
Smarty покажет вам имя шаблона, номер строки и ошибку. Далее сообщение об ошибке состоит из фактического номера строки в классе Smarty, где возникла ошибка. Есть определенные ошибки, которые не может поймать Smarty, например отсутствующие закрывающие тэги. Такие ошибки обычно приводят к ошибкам разбора PHP на этапе компиляции.
Parse error: parse error in /path/to/smarty/templates_c/index.tpl.php on line 75
Когда вы встречаетесь с ошибкой разбора PHP, номер строки, в которой допущена ошибка, будет соответствовать скомпилированному PHP-скрипту, а НЕ самому шаблону. Обычно вы можете посмотреть на шаблон и увидить синтаксическую ошибку. Типичные ошибки: отсутствующие закрывающие тэги для или , или синтаксис логики внутри тэга . Если вы не можете найти ошибку, вам может понадобиться открыть скомпилированный PHP-файл и перейти к номеру строки чтобы выяснить, в чём заключается ошибка в шаблоне.
Warning: Smarty error: unable to read resource: "index.tpl" in. or Warning: Smarty error: unable to read resource: "site.conf" in.
- Значение $template_dir неверно, эта директория не существует или файл index.tpl не найден в директории templates/ .
- В шаблоне присутствует функция (либо была вызвана функция config_load() ) и значение $config_dir неверно, эта директория не существует или файл site.conf находится за пределами этой директории.
Fatal error: Smarty error: the $compile_dir 'templates_c' does not exist, or is not a directory.
- Переменная $compile_dir установлена неверно, эта директория не существует или templates_c является файлом, а не директорией.
Fatal error: Smarty error: unable to write to $compile_dir '.
- У веб сервера нет прав на запись в директорию $compile_dir. Смотрите конец страницы Базовая установка для получения информации о правах доступа.
Fatal error: Smarty error: the $cache_dir 'cache' does not exist, or is not a directory. in /..
- Это означает, что параметр $caching включен, но параметр $cache_dir установлен неправильно, эта директория не существует или cache/ является файлом, а не директорией.
Fatal error: Smarty error: unable to write to $cache_dir '/.
- Это означает, что параметр $caching включен, но у веб сервера нет прав на запись в директорию $cache_dir. Смотрите конец страницы Базовая установка для получения информации о правах доступа.
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Smarty is not compatible with PHP 8.1 #671
Smarty is not compatible with PHP 8.1 #671
Comments
For example, this patch causes a fatal error
aim-server[~/www/smarty/demo]$ gitdiff . diff —git a/demo/templates/index.tpl b/demo/templates/index.tpl index 1fbb6d37..1e125e15 100644 — a/demo/templates/index.tpl +++ b/demo/templates/index.tpl @@ -1,6 +1,6 @@ — +
Fatal error: Type of SmartyCompilerException::$line must be int (as in class Exception) in public_html/smarty/libs/sysplugins/smartycompilerexception.php on line 8
Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "file:public_html/smarty/demo/templates/index.tpl" on line 3 " " tags not allowed. Use SmartyBC to enable them
The text was updated successfully, but these errors were encountered: