php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #61352
Patch 61352.1.patch revision 2012-03-13 17:54 UTC by ab@php.net
Patch 61352.0.patch revision 2012-03-12 11:11 UTC by ab@php.net

Patch 61352.1.patch for APC Bug #61352

Patch version 2012-03-13 17:54 UTC

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

Developer: ab@php.net

Index: apc_main.c
===================================================================
--- apc_main.c	(revision 324184)
+++ apc_main.c	(working copy)
@@ -391,7 +391,7 @@
 /* }}} */
 
 /* {{{ apc_compile_cache_entry  */
-zend_bool apc_compile_cache_entry(apc_cache_key_t key, zend_file_handle* h, int type, time_t t, zend_op_array** op_array, apc_cache_entry_t** cache_entry TSRMLS_DC) {
+zend_bool apc_compile_cache_entry(apc_cache_key_t *key, zend_file_handle* h, int type, time_t t, zend_op_array** op_array, apc_cache_entry_t** cache_entry TSRMLS_DC) {
     int num_functions, num_classes;
     apc_function_t* alloc_functions;
     zend_op_array* alloc_op_array;
@@ -437,7 +437,7 @@
             while((n = php_stream_read(stream, (char*)buf, sizeof(buf))) > 0) {
                 PHP_MD5Update(&context, buf, n);
             }
-            PHP_MD5Final(key.md5, &context);
+            PHP_MD5Final(key->md5, &context);
             php_stream_close(stream);
             if(n<0) {
                 apc_warning("Error while reading '%s' for md5 generation." TSRMLS_CC, filename);
@@ -459,7 +459,7 @@
     }
 
     path = h->opened_path;
-    if(!path && key.type == APC_CACHE_KEY_FPFILE) path = (char*)key.data.fpfile.fullpath;
+    if(!path && key->type == APC_CACHE_KEY_FPFILE) path = (char*)key->data.fpfile.fullpath;
     if(!path) path=h->filename;
 
     apc_debug("2. h->opened_path=[%s]  h->filename=[%s]\n" TSRMLS_CC, h->opened_path?h->opened_path:"null",h->filename);
@@ -607,7 +607,7 @@
 #endif
 
     zend_try {
-        if (apc_compile_cache_entry(key, h, type, t, &op_array, &cache_entry TSRMLS_CC) == SUCCESS) {
+        if (apc_compile_cache_entry(&key, h, type, t, &op_array, &cache_entry TSRMLS_CC) == SUCCESS) {
             ctxt.pool = cache_entry->pool;
             ctxt.copy = APC_COPY_IN_OPCODE;
             if (apc_cache_insert(apc_cache, key, cache_entry, &ctxt, t TSRMLS_CC) != 1) {
Index: apc_iterator.c
===================================================================
--- apc_iterator.c	(revision 324184)
+++ apc_iterator.c	(working copy)
@@ -118,7 +118,7 @@
     }
     if (APC_ITER_MD5 & iterator->format) {
         if(slot->value->type == APC_CACHE_ENTRY_FILE) {
-            if(slot->key.md5) {
+            if(APCG(file_md5) && slot->key.md5) {
                 make_digest(md5str, slot->key.md5);
                 add_assoc_string(item->value, "md5", md5str, 1);
             }
Index: php_apc.c
===================================================================
--- php_apc.c	(revision 324184)
+++ php_apc.c	(working copy)
@@ -1260,7 +1260,7 @@
 
             orig_current_execute_data = EG(current_execute_data);
             zend_try {
-                if (apc_compile_cache_entry(keys[i], &file_handle, ZEND_INCLUDE, t, &op_arrays[i], &cache_entries[i] TSRMLS_CC) != SUCCESS) {
+                if (apc_compile_cache_entry(&keys[i], &file_handle, ZEND_INCLUDE, t, &op_arrays[i], &cache_entries[i] TSRMLS_CC) != SUCCESS) {
                     op_arrays[i] = NULL;
                     cache_entries[i] = NULL;
                     add_assoc_long(return_value, Z_STRVAL_PP(hentry), -2);  /* -2: input or cache insertion error */
Index: tests/apc_012.phpt
===================================================================
--- tests/apc_012.phpt	(revision 0)
+++ tests/apc_012.phpt	(revision 0)
@@ -0,0 +1,98 @@
+--TEST--
+APC: apc_delete_file test with file_md5=on (see #61352)
+--SKIPIF--
+<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
+--INI--
+apc.enabled=1
+apc.enable_cli=1
+apc.file_update_protection=0
+apc.stat=On
+apc.file_md5=1
+report_memleaks=0
+--FILE--
+<?php
+
+$files = array( 'apc_012.php',
+                'apc_009-1.php',
+                'apc_009-2.php',
+                'nofile.php',
+              );
+
+file_put_contents(dirname(__FILE__).'/apc_009-1.php', '<?php echo "test file";');
+file_put_contents(dirname(__FILE__).'/apc_009-2.php', '<?php syntaxerrorhere!');
+
+apc_compile_file($files[0]);
+check_file($files[0]);
+apc_delete_file($files[0]);
+check_file($files[0]);
+
+apc_compile_file($files[0]);
+apc_delete_file(array($files[0]));
+check_file($files[0]);
+
+apc_compile_file($files[0]);
+$it = new APCIterator('file');
+apc_delete_file($it);
+check_file($files[0]);
+
+var_dump(apc_compile_file(array($files[0], $files[1])));
+check_file(array($files[0], $files[1]));
+
+var_dump(apc_compile_file($files));
+check_file($files);
+
+function check_file($files) {
+
+  if (!is_array($files)) {
+    $files = array($files);
+  }
+
+  $info = apc_cache_info('file');
+
+  foreach ($files as $file) {
+    $match = 0;
+    foreach($info['cache_list'] as $cached_file) {
+      if (stristr($cached_file['filename'], $file)) $match = 1;
+    }
+    if ($match) {
+      echo "$file Found File\n";
+    } else {
+      echo "$file Not Found\n";
+    }
+  }
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--CLEAN--
+<?php
+unlink('apc_009-1.php');
+unlink('apc_009-2.php');
+?>
+--EXPECTF--
+apc_012.php Found File
+apc_012.php Not Found
+apc_012.php Not Found
+apc_012.php Not Found
+array(0) {
+}
+apc_012.php Found File
+apc_009-1.php Found File
+
+Parse error: syntax error, unexpected '!' in %s/apc_009-2.php on line 1
+
+Warning: apc_compile_file(): Error compiling apc_009-2.php in apc_compile_file. in %s/apc_012.php on line 29
+
+Warning: apc_compile_file(): Error compiling nofile.php in apc_compile_file. in %s/apc_012.php on line 29
+array(2) {
+  ["apc_009-2.php"]=>
+  int(-1)
+  ["nofile.php"]=>
+  int(-1)
+}
+apc_012.php Found File
+apc_009-1.php Found File
+apc_009-2.php Not Found
+nofile.php Not Found
+===DONE===
Index: apc_cache.h
===================================================================
--- apc_cache.h	(revision 324184)
+++ apc_cache.h	(working copy)
@@ -287,7 +287,7 @@
                                                     TSRMLS_DC);
 
 
-zend_bool apc_compile_cache_entry(apc_cache_key_t key, zend_file_handle* h, int type, time_t t, zend_op_array** op_array_pp, apc_cache_entry_t** cache_entry_pp TSRMLS_DC);
+zend_bool apc_compile_cache_entry(apc_cache_key_t *key, zend_file_handle* h, int type, time_t t, zend_op_array** op_array_pp, apc_cache_entry_t** cache_entry_pp TSRMLS_DC);
 
 /*
  * apc_cache_make_user_entry creates an apc_cache_entry_t object given an info string
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 23:01:26 2024 UTC