ENHANCEMENT Added ManifestBuilder::$cache_expiry_mins

API CHANGE Deprecated URL parameter ?buildmanifest=1 (please use ?flush=1)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63182 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-09-28 19:52:06 +00:00
parent 97263cd09c
commit d7a4ae6a8f

View File

@ -56,26 +56,38 @@ class ManifestBuilder {
); );
/** /**
* Returns true if the manifest file should be regenerated * @var int $cache_expiry_mins Specifies the time (in minutes) until a rebuild
* of the manifest cache is forced.
* @usedby self::staleManifest()
*/
public static $cache_expiry_mins = 60;
/**
* Returns true if the manifest file should be regenerated,
* by asserting one of the following conditions:
* - Manifest cache file doesn't exist
* - The modification time of the webroot folder is newer than the cache file
* - The cache file is older than {@link self::$cache_expiry_mins}
* - A cache rebuild is forced by the "?flush=1" URL parameter
*
* Checked on every request handled by SilverStripe in main.php or cli-script.php.
* *
* @return bool Returns TRUE if the manifest file should be regenerated, * @return bool Returns TRUE if the manifest file should be regenerated, otherwise FALSE.
* otherwise FALSE.
*/ */
static function staleManifest() { static function staleManifest() {
/*if(Director::isDev() || Director::isTest()) $lastEdited = filemtime(BASE_PATH);
$lastEdited = Filesystem::folderModTime(".", array('ss','php'));
else*/
$lastEdited = filemtime("../");
return !file_exists(MANIFEST_FILE) return (
!file_exists(MANIFEST_FILE)
|| (filemtime(MANIFEST_FILE) < $lastEdited) || (filemtime(MANIFEST_FILE) < $lastEdited)
|| (filemtime(MANIFEST_FILE) < time() - 3600) || (filemtime(MANIFEST_FILE) < time() - 60 * self::$cache_expiry_mins)
|| isset($_GET['buildmanifest']) || isset($_GET['flush']); || isset($_GET['flush'])
);
} }
/** /**
* Generates a new manifest file and saves it to {@link MANIFEST_FILE} * Generates a new manifest file and saves it to {@link MANIFEST_FILE}.
*/ */
static function compileManifest() { static function compileManifest() {
// Config manifest // Config manifest