Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Compile path is too long for Windows/IIS environment?

 
Post new topic   Reply to topic    Smarty Forum Index -> Installation and Setup
View previous topic :: View next topic  
Author Message
markowe
Smarty Rookie


Joined: 16 Nov 2010
Posts: 8

PostPosted: Sat Nov 10, 2012 2:50 pm    Post subject: Compile path is too long for Windows/IIS environment? Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 4671
Location: Hamburg / Germany

PostPosted: Sat Nov 10, 2012 3:42 pm    Post subject: Reply with quote

What does make the filename so long? Do you use a compile_id?
Please provide an example of the filename.
Back to top
View user's profile Send private message
markowe
Smarty Rookie


Joined: 16 Nov 2010
Posts: 8

PostPosted: Sat Nov 10, 2012 9:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 4671
Location: Hamburg / Germany

PostPosted: Sat Nov 10, 2012 11:00 pm    Post subject: Reply with quote

"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
View user's profile Send private message
markowe
Smarty Rookie


Joined: 16 Nov 2010
Posts: 8

PostPosted: Sun Nov 11, 2012 8:22 pm    Post subject: Reply with quote

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, Embarassed), 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
View user's profile Send private message
Juliabrin
Smarty n00b


Joined: 26 Jan 2013
Posts: 1

PostPosted: Sat Jan 26, 2013 10:08 am    Post subject: Long Path Tool Reply with quote

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
View user's profile Send private message
leslysab
Smarty n00b


Joined: 05 Nov 2013
Posts: 1

PostPosted: Tue Nov 05, 2013 7:41 pm    Post subject: Long Path Tool Reply with quote

Use Long Path Tool for unlocking deleting copying long fie paths.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Installation and Setup All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP