php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #58454 always match apc.filters on the absolute filepath
Submitted: 2008-12-10 10:08 UTC Modified: 2008-12-12 01:15 UTC
From: michel at madcap dot nl Assigned:
Status: Closed Package: APC (PECL)
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: michel at madcap dot nl
New email:
PHP Version: OS:

 

 [2008-12-10 10:08 UTC] michel at madcap dot nl
Description:
------------
The attached patch changes the behaviour of apc.filters to always match on the absolute path of the file, instead of the one passed to include/require.

The patch first asserts that opened_path is set, possibly by calling expand_filepath in the same fashion that php_fopen_and_set_opened_path does. Subsequently, apc_regex_match_array uses h->opened_path instead of h->filename to match on the regex array.

The patch is against 3.0.19.

Kind regards,
Michel


Reproduce code:
---------------
--- a/apc_main.c	Wed Dec 10 11:48:59 2008 +0100
+++ b/apc_main.c	Wed Dec 10 15:57:47 2008 +0100
@@ -310,7 +310,10 @@
 
     /* check our regular expression filters */
     if (APCG(filters) && apc_compiled_filters) {
-        int ret = apc_regex_match_array(apc_compiled_filters, h->filename);
+        if(!h->opened_path){
+            h->opened_path = expand_filepath(h->filename, NULL TSRMLS_CC);
+        }
+        int ret = apc_regex_match_array(apc_compiled_filters, h->opened_path);
         if(ret == APC_NEGATIVE_MATCH || (ret != APC_POSITIVE_MATCH && !APCG(cache_by_default))) {
             return old_compile_file(h, type TSRMLS_CC);
         }


Expected result:
----------------
E.g., setting

  apc.filters="/foo/bar"

causes APC to never cache files anywhere in the /foo/bar tree, regardless of the incidental path and filename used to include/require those files.



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-12 01:15 UTC] gopalv82 at yahoo dot com
3.1.x (aka HEAD) has this fix for the issue.

http://cvs.php.net/viewvc.cgi/pecl/apc/apc_main.c?r1=3.120&r2=3.121
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 22:01:33 2025 UTC