|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64885 getlastmod() should (optionally) check modification times of include files also
Submitted: 2013-05-21 01:57 UTC Modified: -
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: dean at omnivisiontechnology dot com Assigned:
Status: Open Package: Filesystem function related
PHP Version: 5.5.0RC1 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: dean at omnivisiontechnology dot com
New email:
PHP Version: OS:


 [2013-05-21 01:57 UTC] dean at omnivisiontechnology dot com
Currently the getlastmod() function is essentially an alias for filemtime($_SERVER["SCRIPT_FILENAME"]).

Considering that a primary use case for this function is to supply the time for a HTTP Last-Modified header, and that the output of the page may change if any of its include or require files change, it would be nice to have the option for getlastmod() to return the latest modification time of (any of) the main script AND its includes (recursively, checking includes of includes and so on).  (At least the ones included up to the time the function was called, if they can't be checked in advance during some parsing phase?)

To preserve backward compatibility, this feature might be activated by passing the parameter "true", i.e. getlastmod(true) to check include files also.

A php-coded version of what I mean is included below just for clarification, although it can't (I think) check multiply-nested include files.

Test script:

function new_getlastmod($checkAll = false)
  if (!$checkAll) return getlastmod();
  $t = 0;
  foreach(get_included_files() as $f)
    if ((($mt = filemtime($f))!==false)&&($mt>$t)) $t = $mt;
  return ($t ? $t : false);


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Dec 10 10:01:24 2019 UTC