Skip to content
This repository
Browse code

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
  • Loading branch information...
commit d7a4ae6a8f434efcbbbc4f72105b3cf2866655ae 1 parent 97263cd
Ingo Schommer authored September 28, 2008

Showing 1 changed file with 23 additions and 11 deletions. Show diff stats Hide diff stats

  1. 34  core/ManifestBuilder.php
34  core/ManifestBuilder.php
@@ -56,26 +56,38 @@ class ManifestBuilder {
56 56
 	);
57 57
 	
58 58
 	/**
59  
-	 * Returns true if the manifest file should be regenerated
  59
+	 * @var int $cache_expiry_mins Specifies the time (in minutes) until a rebuild
  60
+	 *   of the manifest cache is forced.
  61
+	 * @usedby self::staleManifest()
  62
+	 */
  63
+	public static $cache_expiry_mins = 60;
  64
+	
  65
+	/**
  66
+	 * Returns true if the manifest file should be regenerated,
  67
+	 * by asserting one of the following conditions:
  68
+	 * - Manifest cache file doesn't exist
  69
+	 * - The modification time of the webroot folder is newer than the cache file
  70
+	 * - The cache file is older than {@link self::$cache_expiry_mins}
  71
+	 * - A cache rebuild is forced by the "?flush=1" URL parameter
  72
+	 * 
  73
+	 * Checked on every request handled by SilverStripe in main.php or cli-script.php.
60 74
 	 *
61  
-	 * @return bool Returns TRUE if the manifest file should be regenerated,
62  
-	 *              otherwise FALSE.
  75
+	 * @return bool Returns TRUE if the manifest file should be regenerated, otherwise FALSE.
63 76
 	 */
64 77
 	static function staleManifest() {
65  
-		/*if(Director::isDev() || Director::isTest())
66  
-			$lastEdited = Filesystem::folderModTime(".", array('ss','php'));
67  
-		else*/
68  
-			$lastEdited = filemtime("../");
  78
+		$lastEdited = filemtime(BASE_PATH);
69 79
 
70  
-		return !file_exists(MANIFEST_FILE)
  80
+		return (
  81
+			!file_exists(MANIFEST_FILE)
71 82
 			|| (filemtime(MANIFEST_FILE) < $lastEdited)
72  
-			|| (filemtime(MANIFEST_FILE) < time() - 3600)
73  
-			|| isset($_GET['buildmanifest']) || isset($_GET['flush']);
  83
+			|| (filemtime(MANIFEST_FILE) < time() - 60 * self::$cache_expiry_mins)
  84
+			|| isset($_GET['flush'])
  85
+		);
74 86
 	}
75 87
 
76 88
 
77 89
 	/**
78  
-	 * Generates a new manifest file and saves it to {@link MANIFEST_FILE}
  90
+	 * Generates a new manifest file and saves it to {@link MANIFEST_FILE}.
79 91
 	 */
80 92
 	static function compileManifest() {
81 93
 		// Config manifest

0 notes on commit d7a4ae6

Please sign in to comment.
Something went wrong with that request. Please try again.