View previous topic :: View next topic |
Author |
Message |
markowe Smarty Rookie
Joined: 16 Nov 2010 Posts: 16
|
Posted: Sat Nov 10, 2012 2:50 pm Post subject: Compile path is too long for Windows/IIS environment? |
|
|
Hi, I have an issue with a customer setup running Smarty on PHP/Windows/IIS. This is pretty rare, but I have to try to fix the problem. Smarty is throwing this error:
Code: | Fatal error: Uncaught exception 'SmartyException' with message 'unable to write file |
...where the path name given is what you would expect: path_to_templates_c_dir/really_long_filename_comprised_of_the_path_name.tpl.php.
Only, this pathname comes out pretty long, 268 chars in the specific example. Somewhere I read that the maximum length of path names in IIS is 260 chars, so I believe this might be the cause of the error. I don't know much about IIS really, but is there a way to shorten this in Smarty? I would like to maybe SHA1 or MD5 the pathname, that ought to make the possibility of collisions practically negligible and shorten the pathname to 32 characters - but is there any way I can do this via the API, without hacking the core code, which I really don't want to do of course...? |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sat Nov 10, 2012 3:42 pm Post subject: |
|
|
What does make the filename so long? Do you use a compile_id?
Please provide an example of the filename. |
|
Back to top |
|
markowe Smarty Rookie
Joined: 16 Nov 2010 Posts: 16
|
Posted: Sat Nov 10, 2012 9:56 pm Post subject: |
|
|
U.Tews wrote: | What does make the filename so long? Do you use a compile_id?
Please provide an example of the filename. |
The filename is created by Smarty AFAIK, i.e the path is supplied by me via $smarty->setCompileDir, and the filename is evidently generated by Smarty from the path in its entirety, for reasons I remember reading about in an old thread (to avoid collisions I guess). I don't use a compile ID, I thought that was for use by Smarty when caching template output, not when caching compiled templates (compiled PHP files) which is the case here?
Here is an example (slightly altered to hide personal details):
Quote: | Fatal error: Uncaught exception 'SmartyException' with message 'unable to write file C:\HostingSpaces\username\website.com\wwwroot\wp-content\plugins\pluginname\templates_c\C_HostingSpaces_username_website_com_wwwroot_wp_content_plugins_pluginname_templates_Default_black_^4b7627f8b5010175aa0ee5444d9ada15f8f83b34.file.main.tpl.php |
Yes, this is running under a Wordpress plugin, but that doesn't matter, it has worked fine on Linux boxes up till now.
Any hints appreciated.
Mark |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sat Nov 10, 2012 11:00 pm Post subject: |
|
|
"C_HostingSpaces_username_website_com_wwwroot_wp_content_plugins_pluginname_templates_Default_black_" of the filename must have been generated by a compile_id.
With Smarty2 a compile_id was often used to distinguish template files in compiled_dir with same name from different templae folders.
In Smarty3 a compile_id is no longer required for this purpose.
A compile_id could be defined by $smarty->compile_id = ..... or as a paramter at the $smarty->display(...) call.
For caching a cache_id is used, not a compile_id. |
|
Back to top |
|
markowe Smarty Rookie
Joined: 16 Nov 2010 Posts: 16
|
Posted: Sun Nov 11, 2012 8:22 pm Post subject: |
|
|
U.Tews wrote: | "C_HostingSpaces_username_website_com_wwwroot_wp_content_plugins_pluginname_templates_Default_black_" of the filename must have been generated by a compile_id.
With Smarty2 a compile_id was often used to distinguish template files in compiled_dir with same name from different templae folders.
In Smarty3 a compile_id is no longer required for this purpose.
A compile_id could be defined by $smarty->compile_id = ..... or as a paramter at the $smarty->display(...) call.
For caching a cache_id is used, not a compile_id. |
OK, I am feeling very stupid now because not only did I evidently forget about compile_id, but in fact I just found it implemented in my own code (from a year or two ago, my memory, ), and guess what, it was me passing the full pathname. I guess it was Smarty changing the slashes to underscores. So, sorry for the steeopid question, now I am just trying to figure out why I did it that way, when Smarty 2 was set up to provide the exact same filename, i.e. the full path, by default anyway... Thanks for the help though, it put me back on the right track.
BTW, the comment before mine is SPAM - there doesn't seem to be a "report" button on PHPBB, but I hope an admin cam take care of it. |
|
Back to top |
|
Juliabrin Smarty n00b
Joined: 26 Jan 2013 Posts: 1
|
Posted: Sat Jan 26, 2013 10:08 am Post subject: Long Path Tool |
|
|
I suggest that you try the Long Path Tool. This would be very helpful in this type of situation. You should check it out. |
|
Back to top |
|
leslysab Smarty n00b
Joined: 05 Nov 2013 Posts: 1
|
Posted: Tue Nov 05, 2013 7:41 pm Post subject: Long Path Tool |
|
|
Use Long Path Tool for unlocking deleting copying long fie paths. |
|
Back to top |
|
|