Jeff-Lewis / smarty-php

Automatically exported from code.google.com/p/smarty-php
0 stars 0 forks source link

clearCompiledTemplate fails with UnexpectedValueException for PHP 5.3+ #172

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Try clearing compiled templates on PHP 5.3+

What is the expected output? What do you see instead?
The templates should get cleared, nothing happens and no explanation as the 
code returns silently after catching the exception.

What version of the product are you using? On what operating system?
3.1.16dev Ubuntu

Please provide any additional information below.
Simple problem, which should have been fixed back when the exception catching 
was added. It happens because 5.3 fixed the previously buggy behaviour of the 
RecursiveDirectoryIterator.
Easy fix, just give it a proper path not a relative one ;-)

example fix:
if (strtolower(substr(PHP_OS, 0, 3)) != 'win') {
  $tmpDir = substr($_dir, 0, 1) == '/' ? $_dir : realpath(SMARTY_DIR . $_dir);
} else {
  $tmpDir = $_dir;
}
$_compileDirs = new RecursiveDirectoryIterator($tmpDir);

I've assumed the SMARTY_DIR as the base for relative paths, you should probably 
generating a full path from the info available to smarty.

Original issue reported on code.google.com by niel.arc...@gmail.com on 23 Jan 2014 at 10:33

GoogleCodeExporter commented 9 years ago
clearCompiledTemplate(), clearAll() and clear() has been modified to use 
internally realpath to avoid the possible exception.

The fix is now in the SVN trunk and will later be included in 3.1.17

Original comment by Uwe.Tews@googlemail.com on 27 Jan 2014 at 4:40