summaryrefslogtreecommitdiffstats
path: root/php-wip.patch
blob: d6e513162dd0071d2337bd6b58cc30210ab3df97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
diff -up php-5.5.6RC1/ext/opcache/ZendAccelerator.c.wip php-5.5.6RC1/ext/opcache/ZendAccelerator.c
--- php-5.5.6RC1/ext/opcache/ZendAccelerator.c.wip	2013-10-29 12:09:06.000000000 +0100
+++ php-5.5.6RC1/ext/opcache/ZendAccelerator.c	2013-11-04 14:23:59.395722970 +0100
@@ -145,9 +145,33 @@ static inline int is_cacheable_stream_pa
 	       memcmp(filename, "phar://", sizeof("phar://") - 1) == 0;
 }
 
+#ifdef COMPILE_DL_PHAR
+static typeof(phar_resolve_alias) *opcache_phar_resolve_alias;
+#else
+# define opcache_phar_resolve_alias phar_resolve_alias
+#endif
+
 static inline int is_phar_relative_alias_path(const char *filename, char **alias, int *alias_len)
 {
-	if (memcmp(filename, "phar://", sizeof("phar://") - 1) == 0
+#ifdef COMPILE_DL_PHAR
+	static int pharloaded = -1;
+
+	/* Only once, retrieve phar_resolve_alias from phar module if loaded */
+	if (pharloaded < 0) {
+		zend_module_entry *phar;
+
+		if (zend_hash_find(&module_registry, "phar", 5, (void**)&phar) == SUCCESS) {
+			opcache_phar_resolve_alias = DL_FETCH_SYMBOL(phar->handle, "phar_resolve_alias");
+			pharloaded = (opcache_phar_resolve_alias ? 1 : 0);
+		} else {
+			pharloaded = 0;
+		}
+	}
+	if (pharloaded &&
+#else
+	if (
+#endif
+			memcmp(filename, "phar://", sizeof("phar://") - 1) == 0
 			&& filename[sizeof("phar://") - 1] != '\0' && filename[sizeof("phar://") - 1] != '/') {
 		char *slash;
 		*alias = (char*)filename + sizeof("phar://") - 1;
@@ -1056,7 +1080,7 @@ char *accel_make_persistent_key_ex(zend_
 			if (is_phar_relative_alias_path(file_handle->filename, &alias, &alias_len)) {
 				char *phar_path;
 				int phar_path_len;
-				if (phar_resolve_alias(alias, alias_len, &phar_path, &phar_path_len TSRMLS_CC) == SUCCESS) {
+				if (opcache_phar_resolve_alias(alias, alias_len, &phar_path, &phar_path_len TSRMLS_CC) == SUCCESS) {
 					int filename_len = strlen(file_handle->filename);
 					memcpy(ZCG(key), "phar://", sizeof("phar://") -1);
 					memcpy(ZCG(key) + sizeof("phar://") - 1, phar_path, phar_path_len);