[prev in list] [next in list] [prev in thread] [next in thread]
List: smarty-dev
Subject: Re[2]: [SMARTY-DEV] More accurate compiled file names
From: 213.248.61.33
Date: 2004-05-31 14:58:16
Message-ID: 513939605.20040531190140 () koteroff ! ru
[Download RAW message or body]
Ho-ho. (-;
So, why not to revert?
--
Best regards,
Dmitry Koteroff.
MM> On Mon, May 31, 2004 at 12:28:31AM +0400, Dmitry Koteroff wrote:
>> 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.
MM> yes. FWIW: Smarty-2.5.0 behaves differently than 2.6.2 does: with
MM> use_sub_dirs=true it behaves like 2.6.2, but with use_sub_dirs=false
MM> it behaves as you propose: no crc32-numbers in the
MM> compiled-template-name, but something like
MM> ^full^path^to^template.tpl .
MM> I like the behaviour of 2.5.0 more than it is now and would like to
MM> see it reverted.
>> --
>> 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
>>
>> --
>> Smarty Development Mailing List (http://smarty.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
--
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic