Re[2]: [SMARTY-DEV] More accurate compiled file names

From: Date: Sun, 30 May 2004 20:28:31 +0000
Subject: Re[2]: [SMARTY-DEV] More accurate compiled file names
References: 1 2  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-2332@lists.php.net to get a copy of this message
I know about crc32(). Let's see code: - // make source name safe for filename - $_filename = urlencode(basename($auto_source)); - $_crc32 = crc32($auto_source) . $_compile_dir_sep; - // prepend %% to avoid name conflicts with - // with $params['auto_id'] names - $_crc32 = '%%' . substr($_crc32,0,3) . $_compile_dir_sep . '%%' . $_crc32; - $_return .= $_crc32 . $_filename; Please consider using of basename() function! Pathname is NOT included in the cache filename. I am talking about that, ant attached patch solves this - uses full path instead of crc32() (or in addition to it). Use_sub_dirs does not makes Smarty to consider full path. It does other thing - it improves (theoretically) performance. -- Best regards, Dmitry Koteroff. RA> Hi, RA> The compiled templates are saved in filenames that reflect their filename RA> and content. RA> The numbers you see there are the result of a crc32() on the contents of RA> the file (see http://www.php.net/crc32). This is taken to ensure that each RA> filename is unique, so that two templates called "header.tpl" in different RA> locations do not overwrite each others compiled template file. RA> so a file like %%-13/%%-135052920/header.tpl.php should be perfectly RA> understandable as the compiled template for "header.tpl" RA> The filenames are split into directories so that on larger smarty RA> installations, there is no filesystem delay trying to access the files. If RA> you do not wish to use directories, simply ensure that RA> $smarty->use_sub_dirs = false and Smarty will automatically substitute / RA> for ^ in your compiled template files. RA> Hope this helps. RA> Regards, RA> -bok RA> At 08:31 AM 30/05/2004, you wrote: >>Hello. >> >>Smarty saves its compiled code to files with unreadable names >>(like %%23t2763%%sjhdjsdhjshgd.php). It makes too difficult to >>find fatal error in the template (for example, {$obj->spoon()}, >>where spoon is non-existent method). >> >>Attached patch corrects this problem - it replaces "/" by "^" and >>saves the file to temporary location. >> >>Replacement code: >> >>$_filename = preg_replace("{[/\\\\]}s", "^", $_filename); >>$_filename = preg_replace("{[^a-z0-9~!_=.^-]}si", "_", $_filename); >> >>Don't you plan to insert this patch to production version? >> >>-- >>Best regards, >> Dmitry Koteroff. >>-- >>Smarty Development Mailing List (http://smarty.php.net/) >>To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.smarty.dev (#2332) next »