Req #64885 [Sus]: getlastmod() should (optionally) check modification times of include files also
| From: | dean at omnivisiontechnology dot com | Date: | Mon, 06 Jan 2020 00:56:33 +0000 |
| Subject: | Req #64885 [Sus]: getlastmod() should (optionally) check modification times of include files also | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-224718@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64885&edit=1
ID: 64885
User updated by: dean at omnivisiontechnology dot com
Reported by: dean at omnivisiontechnology dot com
Summary: getlastmod() should (optionally) check modification
times of include files also
Status: Suspended
Type: Feature/Change Request
Package: Filesystem function related
PHP Version: 5.5.0RC1
Block user comment: N
Private report: N
New Comment:
Sure it can be done in user code.
But my point was that if you're going to have a built-in getlastmod() function at all, it
should probably fulfill the primary use-case users would want to use it for. I'd note that the
*existing* getlastmod() can also be recreated using user code, so if the argument is "we
won't implement core functions if they can be recreated in user code", there's no
reason for getlastmod() to exist at all!
I posted this nearly 7 years ago, I don't have the time to pursue an RFC for it now, sorry.
Previous Comments:
------------------------------------------------------------------------
[2020-01-05 13:12:54] cmb@php.net
The given test script shows that this functionality can easily be
implemented in userland, so adding it as built-in feature appears
to be doubtful. If you still like to see it, please pursue the
RFC process[1].
[1] <https://wiki.php.net/rfc/howto>
------------------------------------------------------------------------
[2013-05-21 01:57:28] dean at omnivisiontechnology dot com
Description:
------------
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);
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64885&edit=1