Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6330835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:56:34+00:00 2026-05-24T17:56:34+00:00

I have a problem with PHP filemtime function. In my webapp I use Smarty

  • 0

I have a problem with PHP filemtime function. In my webapp I use Smarty template engine with caching option. In my webapp I can do some actions which generate error, but lets focus on only one action. When I click link on page some content is updated – I can click few times and everything is OK but about one request on 10 fails. Following error occurs:

filemtime() [<a href='function.filemtime'>function.filemtime</a>]: stat failed for

and the line that causes the problem:

 return ($_template->getCachedFilepath() && file_exists($_template->getCachedFilepath())) ? filemtime($_template->getCachedFilepath()) : false ;

As you can see, file exists because it is checked.

Problematic line of code is included in smarty_internal_cacheresource_file.php (part of Smarty lib v3.0.6)

App is run on UNIX system, external hosting.

Any ideas? Should I post more details?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:56:34+00:00Added an answer on May 24, 2026 at 5:56 pm

    file_exists internally uses the access system call which checks permissions as the real user, whereas filemtime uses stat, which performs the check as the effective user. Therefore, the problem may be rooted in the assumption of effective user == real user, which does not hold. Another explanation would be that the file gets deleted between the two calls.

    Since both the result of $_template->getCachedFilepath() and the existance of the file can change in between system calls, why do you call file_exists at all? Instead, I’d suggest just

    return @filemtime($_template->getCachedFilepath());
    

    If $_template->getCachedFilepath() can be set to a dummy value such as false, use the following:

    $path = $_template->getCachedFilepath();
    if (!$path) return false;
    return @filemtime($path);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem using php rename function. If I use the following syntax
I have a problem in php code inserting values into database (I use PHPMyAdmin).
I have a bizzare problem with php date function. code: $numDays = 8; $date
I have problem with date function in php. If I supply string in format
I have a problem with php file upload, so..when I try to uploads some
I use the PHP function filemtime to get the last modification time with PHP
I have a problem with php header redirect. I already spent hours trying to
I have a problem in integrating PHP and JQuery: My main file is MyFile.html
I have problem with session in cakephp.I have one file chat.php that is in
I have a problem with maintenance of my php based website. My website is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.