php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #66639
Patch opcache_ctime revision 2014-02-04 01:41 UTC by nimzo at nimzo dot info

Patch opcache_ctime for opcache Bug #66639

Patch version 2014-02-04 01:41 UTC

Return to Bug #66639 | Download this patch
Patch Revisions:

Developer: nimzo@nimzo.info

diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index 9662c99..9fa7bd5 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -652,7 +652,7 @@ static int zend_get_stream_timestamp(const char *filename, struct stat *statbuf
 		return FAILURE;
 	}
 	if (!wrapper->wops || !wrapper->wops->url_stat) {
-		statbuf->st_mtime = 1;
+		statbuf->st_mtime = statbuf->st_ctime = 1;
 		return SUCCESS; /* anything other than 0 is considered to be a valid timestamp */
 	}
 
@@ -735,7 +735,12 @@ static accel_time_t zend_get_file_handle_timestamp(zend_file_handle *file_handle
 			if (size) {
 				*size = tmpbuf->st_size;
 			}
-			return tmpbuf->st_mtime;
+			if(!ZCG(accel_directives).use_ctime) {
+				return tmpbuf->st_mtime;
+            }
+			else {
+				return tmpbuf->st_ctime;
+			}
 		}
 	}
 
@@ -817,7 +822,13 @@ static accel_time_t zend_get_file_handle_timestamp(zend_file_handle *file_handle
 	if (size) {
 		*size = statbuf.st_size;
 	}
-	return statbuf.st_mtime;
+
+	if(!ZCG(accel_directives).use_ctime) {
+		return statbuf.st_mtime;
+    }
+	else {
+		return statbuf.st_ctime;
+	}
 }
 
 static inline int do_validate_timestamps(zend_persistent_script *persistent_script, zend_file_handle *file_handle TSRMLS_DC)
diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h
index dbda3b3..a9ede3c 100644
--- a/ext/opcache/ZendAccelerator.h
+++ b/ext/opcache/ZendAccelerator.h
@@ -220,6 +220,7 @@ typedef struct _zend_accel_directives {
 	zend_bool      use_cwd;
 	zend_bool      ignore_dups;
 	zend_bool      validate_timestamps;
+	zend_bool      use_ctime;
 	zend_bool      revalidate_path;
 	zend_bool      save_comments;
 	zend_bool      load_comments;
diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c
index 36d02cc..40d042e 100644
--- a/ext/opcache/zend_accelerator_module.c
+++ b/ext/opcache/zend_accelerator_module.c
@@ -245,6 +245,7 @@ ZEND_INI_BEGIN()
     STD_PHP_INI_BOOLEAN("opcache.enable"             , "1", PHP_INI_ALL,    OnEnable,     enabled                             , zend_accel_globals, accel_globals)
 	STD_PHP_INI_BOOLEAN("opcache.use_cwd"            , "1", PHP_INI_SYSTEM, OnUpdateBool, accel_directives.use_cwd            , zend_accel_globals, accel_globals)
 	STD_PHP_INI_BOOLEAN("opcache.validate_timestamps", "1", PHP_INI_ALL   , OnUpdateBool, accel_directives.validate_timestamps, zend_accel_globals, accel_globals)
+	STD_PHP_INI_BOOLEAN("opcache.use_ctime"          , "0", PHP_INI_ALL   , OnUpdateBool, accel_directives.use_ctime          , zend_accel_globals, accel_globals)
 	STD_PHP_INI_BOOLEAN("opcache.inherited_hack"     , "1", PHP_INI_SYSTEM, OnUpdateBool, accel_directives.inherited_hack     , zend_accel_globals, accel_globals)
 	STD_PHP_INI_BOOLEAN("opcache.dups_fix"           , "0", PHP_INI_ALL   , OnUpdateBool, accel_directives.ignore_dups        , zend_accel_globals, accel_globals)
 	STD_PHP_INI_BOOLEAN("opcache.revalidate_path"    , "0", PHP_INI_ALL   , OnUpdateBool, accel_directives.revalidate_path    , zend_accel_globals, accel_globals)
@@ -629,6 +630,7 @@ static ZEND_FUNCTION(opcache_get_configuration)
 	add_assoc_bool(directives, "opcache.enable_cli",          ZCG(accel_directives).enable_cli);
 	add_assoc_bool(directives, "opcache.use_cwd",             ZCG(accel_directives).use_cwd);
 	add_assoc_bool(directives, "opcache.validate_timestamps", ZCG(accel_directives).validate_timestamps);
+	add_assoc_bool(directives, "opcache.use_ctime",           ZCG(accel_directives).use_ctime);
 	add_assoc_bool(directives, "opcache.inherited_hack",      ZCG(accel_directives).inherited_hack);
 	add_assoc_bool(directives, "opcache.dups_fix",            ZCG(accel_directives).ignore_dups);
 	add_assoc_bool(directives, "opcache.revalidate_path",     ZCG(accel_directives).revalidate_path);
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 02:01:30 2024 UTC