| 148 |
lars |
1 |
Troubleshooting
|
|
|
2 |
===============
|
|
|
3 |
|
|
|
4 |
Smarty/PHP errors {#smarty.php.errors}
|
|
|
5 |
=================
|
|
|
6 |
|
|
|
7 |
Smarty can catch many errors such as missing tag attributes or malformed
|
|
|
8 |
variable names. If this happens, you will see an error similar to the
|
|
|
9 |
following:
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
Warning: Smarty: [in index.tpl line 4]: syntax error: unknown tag - '%blah'
|
|
|
13 |
in /path/to/smarty/Smarty.class.php on line 1041
|
|
|
14 |
|
|
|
15 |
Fatal error: Smarty: [in index.tpl line 28]: syntax error: missing section name
|
|
|
16 |
in /path/to/smarty/Smarty.class.php on line 1041
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
Smarty shows you the template name, the line number and the error. After
|
|
|
21 |
that, the error consists of the actual line number in the Smarty class
|
|
|
22 |
that the error occurred.
|
|
|
23 |
|
|
|
24 |
There are certain errors that Smarty cannot catch, such as missing close
|
|
|
25 |
tags. These types of errors usually end up in PHP compile-time parsing
|
|
|
26 |
errors.
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
Parse error: parse error in /path/to/smarty/templates_c/index.tpl.php on line 75
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
When you encounter a PHP parsing error, the error line number will
|
|
|
34 |
correspond to the compiled PHP script, NOT the template itself. Usually
|
|
|
35 |
you can look at the template and spot the syntax error. Here are some
|
|
|
36 |
common things to look for: missing close tags for
|
|
|
37 |
[`{if}{/if}`](#language.function.if) or
|
|
|
38 |
[`{section}{/section}`](#language.function.if), or syntax of logic
|
|
|
39 |
within an `{if}` tag. If you can\'t find the error, you might have to
|
|
|
40 |
open the compiled PHP file and go to the line number to figure out where
|
|
|
41 |
the corresponding error is in the template.
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
Warning: Smarty error: unable to read resource: "index.tpl" in...
|
|
|
45 |
or
|
|
|
46 |
Warning: Smarty error: unable to read resource: "site.conf" in...
|
|
|
47 |
|
|
|
48 |
- The [`$template_dir`](#variable.template.dir) is incorrect, doesn\'t
|
|
|
49 |
exist or the file `index.tpl` is not in the `templates/` directory
|
|
|
50 |
|
|
|
51 |
- A [`{config_load}`](#language.function.config.load) function is
|
|
|
52 |
within a template (or [`configLoad()`](#api.config.load) has been
|
|
|
53 |
called) and either [`$config_dir`](#variable.config.dir) is
|
|
|
54 |
incorrect, does not exist or `site.conf` is not in the directory.
|
|
|
55 |
|
|
|
56 |
<!-- -->
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
Fatal error: Smarty error: the $compile_dir 'templates_c' does not exist,
|
|
|
60 |
or is not a directory...
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
- Either the [`$compile_dir`](#variable.compile.dir)is incorrectly
|
|
|
65 |
set, the directory does not exist, or `templates_c` is a file and
|
|
|
66 |
not a directory.
|
|
|
67 |
|
|
|
68 |
<!-- -->
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
Fatal error: Smarty error: unable to write to $compile_dir '....
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
- The [`$compile_dir`](#variable.compile.dir) is not writable by the
|
|
|
76 |
web server. See the bottom of the [installing
|
|
|
77 |
smarty](#installing.smarty.basic) page for more about permissions.
|
|
|
78 |
|
|
|
79 |
<!-- -->
|
|
|
80 |
|
|
|
81 |
|
|
|
82 |
Fatal error: Smarty error: the $cache_dir 'cache' does not exist,
|
|
|
83 |
or is not a directory. in /..
|
|
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
- This means that [`$caching`](#variable.caching) is enabled and
|
|
|
88 |
either; the [`$cache_dir`](#variable.cache.dir) is incorrectly set,
|
|
|
89 |
the directory does not exist, or `cache/` is a file and not a
|
|
|
90 |
directory.
|
|
|
91 |
|
|
|
92 |
<!-- -->
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
Fatal error: Smarty error: unable to write to $cache_dir '/...
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
|
99 |
- This means that [`$caching`](#variable.caching) is enabled and the
|
|
|
100 |
[`$cache_dir`](#variable.cache.dir) is not writable by the web
|
|
|
101 |
server. See the bottom of the [installing
|
|
|
102 |
smarty](#installing.smarty.basic) page for permissions.
|
|
|
103 |
|
|
|
104 |
<!-- -->
|
|
|
105 |
|
|
|
106 |
|
|
|
107 |
Warning: filemtime(): stat failed for /path/to/smarty/cache/3ab50a623e65185c49bf17c63c90cc56070ea85c.one.tpl.php
|
|
|
108 |
in /path/to/smarty/libs/sysplugins/smarty_resource.php
|
|
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
|
112 |
- This means that your application registered a custom error handler
|
|
|
113 |
(using [set\_error\_handler()](&url.php-manual;set_error_handler))
|
|
|
114 |
which is not respecting the given `$errno` as it should. If, for
|
|
|
115 |
whatever reason, this is the desired behaviour of your custom error
|
|
|
116 |
handler, please call
|
|
|
117 |
[`muteExpectedErrors()`](#api.mute.expected.errors) after you\'ve
|
|
|
118 |
registered your custom error handler.
|
|
|
119 |
|
|
|
120 |
See also [debugging](#chapter.debugging.console).
|