1

I'm migrating my WebAPP from Smarty2 to Smarty3. Every step is easy except one. When i display a Smarty Template ( tpl ) an Exception is thrown.

This line

Source: /path_to_file/smarty/libs/sysplugins/smarty_resource.php (773)

(this is the source coude $compiled->timestamp = @filemtime($compiled->filepath); )

raise this Exception when the file doesn't exists

filemtime() [function.filemtime]: stat failed for /path_to_templates/smarty/templates_c/219dfe732aae7bd7c0edab091e3c53f3ce86b058.file.index.tpl.php

Folder permissions:

Smarty template folder Permission : 775

Smarty Cache folder permission: 775

Folder Owners:

both ftp_user:webserver_user

I'm trying to implement different solutions but it seems not possibile to solve this issue whitout changhing Php Error Reporting or disabling my Error Handler .

How can i solve this problem without hacks ?

alesdario
  • 1,873
  • 6
  • 25
  • 38

2 Answers2

1

What you should do is not to downgrade to 3.1.1 but rather try to upgrade to 3.1.19 version. Many bugs are removed all the time so maybe in this version you won't have it.

The other thing is that you can use muteExpectedErrors method to hide file system warnings from Smarty (documentation for this function is not very clear but it affects file system warnings what is explained in error_reporting documentation). You can read at error_reporting documentation page:

Smarty 3.1.2 introduced the muteExpectedErrors() function. Calling Smarty::muteExpectedErrors(); after setting up custom error handling will ensure that warnings and notices (deliberately) produced by Smarty will not be passed to other custom error handlers. If your error logs are filling up with warnings regarding filemtime() or unlink() calls, please enable Smarty's error muting.

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
  • I've upgraded my working Copy with the 3.1.19 (**Download of Smarty-3-1-19.zip**) and the bug still raising. So, i've downloaded the **Smarty-stable.zip** , [_marked as 3.1.19_](http://www.smarty.net/download) , and i noticed that inside the zip there is the Smarty **3.1.18** version, not the 3.1.19. I will test this version ASAP !!!! – alesdario Jul 17 '14 at 13:50
  • 1
    Accoring to Smarty administrators, you should simple mute those error as I said and don't worry about them at all. – Marcin Nabiałek Jul 17 '14 at 13:58
  • @alesdario And one more thing. You may get this notice because file simple doesn't exists. It's quite possible that some optimization were made and simple `if file_exists` was removed. You can look at http://stackoverflow.com/a/7120844/3593996 – Marcin Nabiałek Jul 17 '14 at 14:04
  • muteExpectedErrors() seems working fine but it mute also warning errors like _wrong parameters count_ errors (Ex `var_dump()` without parameters should thrown a warning) . Can i modify mute error level? – alesdario Jul 21 '14 at 12:32
  • As far as I know it doesn't affect it at all. Assume I have in my tpl `{$x|var_dump}` and variable 'x' hasn't been set in Smarty. When I use `$smarty->muteExpectedErrors();` I get 2 notices. When I want to hide them, I need to use also `$smarty->error_reporting = 0;` so for me `muteExpectedErrors` doesn't affect other warnings – Marcin Nabiałek Jul 21 '14 at 12:41
0

Check the filesystem permission on /path_to_templates/smarty/templates_c/219dfe732aae7bd7c0edab091e3c53f3ce86b058.file.index.tpl.php

PHP does not seam to have read/write permission on that file.

Also check the permission in the /path_to_templates/smarty/templates_c/ folder. Is the PHP allowed to read list and write in there as well?

JochenJung
  • 7,183
  • 12
  • 64
  • 113