@@ -1516,42 +1516,9 @@ function _get_compile_path($resource_name)
1516
1516
$ this ->_compile_id );
1517
1517
$ compilePath .= '.php ' ;
1518
1518
1519
- //for 'string:' resource smarty might going to fail to create
1520
- //compile file, so make sure we should have valid path, CRM-5890
1521
- $ matches = array ( );
1522
- if ( preg_match ( '/^(\s+)?string:/ ' , $ resource_name , $ matches ) ) {
1523
- if ( !$ this ->validateCompilePath ( $ compilePath ) ) {
1524
- $ compilePath = $ this ->_get_auto_filename ( $ this ->compile_dir ,
1525
- time ().rand (),
1526
- $ this ->_compile_id );
1527
- $ compilePath .= '.php ' ;
1528
- }
1529
- }
1530
-
1531
1519
return $ compilePath ;
1532
1520
}
1533
1521
1534
- /**
1535
- * do check can smarty create a file w/ given path.
1536
- */
1537
- function validateCompilePath ( $ compilePath ) {
1538
- //first check for directory.
1539
- $ dirname = dirname ( $ compilePath );
1540
- if ( !is_dir ( $ dirname ) ) {
1541
- require_once (SMARTY_CORE_DIR . 'core.create_dir_structure.php ' );
1542
- smarty_core_create_dir_structure ( array ('dir ' => $ dirname ), $ this );
1543
- }
1544
-
1545
- $ isValid = false ;
1546
- if ( $ fd = @fopen ( $ compilePath , 'wb ' ) ) {
1547
- $ isValid = true ;
1548
- @fclose ( $ fd );
1549
- @unlink ($ compilePath );
1550
- }
1551
-
1552
- return $ isValid ;
1553
- }
1554
-
1555
1522
/**
1556
1523
* fetch the template info. Gets timestamp, and source
1557
1524
* if get_source is true
@@ -1786,13 +1753,11 @@ function _get_auto_filename($auto_base, $auto_source = null, $auto_id = null)
1786
1753
1787
1754
if (isset ($ auto_source )) {
1788
1755
// make source name safe for filename
1789
- $ _filename = urlencode (basename ($ auto_source ));
1790
- $ _crc32 = sprintf ('%08X ' , crc32 ($ auto_source ));
1756
+ $ _sha256 = hash ('sha256 ' , $ auto_source );
1791
1757
// prepend %% to avoid name conflicts with
1792
1758
// with $params['auto_id'] names
1793
- $ _crc32 = substr ($ _crc32 , 0 , 2 ) . $ _compile_dir_sep .
1794
- substr ($ _crc32 , 0 , 3 ) . $ _compile_dir_sep . $ _crc32 ;
1795
- $ _return .= '%% ' . $ _crc32 . '%% ' . $ _filename ;
1759
+ $ _return .= '%% ' . substr ($ _sha256 , 0 , 2 ) . $ _compile_dir_sep .
1760
+ substr ($ _sha256 , 0 , 3 ) . $ _compile_dir_sep . $ _sha256 ;
1796
1761
}
1797
1762
1798
1763
return $ _return ;
0 commit comments