|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59735 The filename field of the opcode array should be updated when cache hits
Submitted: 2011-04-27 23:07 UTC Modified: 2016-11-18 21:43 UTC
From: simpcl2008 at gmail dot com Assigned:
Status: Wont fix Package: APC (PECL)
PHP Version: 5.3.5 OS: CentOS5
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: simpcl2008 at gmail dot com
New email:
PHP Version: OS:


 [2011-04-27 23:07 UTC] simpcl2008 at gmail dot com
In my_compile_file of apc_main.c, the filename of opcode 
array should be updated when opcode array is found in apc 

There are two php script files a.php & b.php, and one is the 
hard link of the other. They have the same inode value, the 
same file content, and the different file names.

When APC is working with (apc.stat = 1) mode, the inode is 
as the hash key.  Assume there is nothing in APC cache, and 
the script a.php need to be compiled for the first time. The 
filename field of opcode array generated is "a.php".

When b.php need to be executed, opcode array cache hit 
because of b.php has the same inode with a.php. If the 
filename field of the found opcode array is not updated, 
zend_get_executed_filename will return "a.php" but not 
"b.php" during the execute time of b.php. 

zend_get_executed_filename can only get the compiled php 
script file name, but not the executed php script file name.

Reproduce code:
apply the following patch file to php 5.3.5:

  apc.stat = 1

test php scripts:
    echo executed_filename . PHP_EOL;

cp -l 1.php 2.php
php 1.php
php 2.php

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-04-27 23:13 UTC] simpcl2008 at gmail dot com
Attach the patch for APC 3.1.6:

--- APC-3.1.6/apc_main.c	2010-11-30 
18:18:31.000000000 +0800
+++ APC-3.1.6-sae/apc_main.c	2011-04-27 
15:56:34.000000000 +0800
@@ -559,6 +559,7 @@ static zend_op_array* my_compile_file(ze
             if (h->type != ZEND_HANDLE_FILENAME) {
                 zend_llist_add_element(&CG(open_files), h); 
+            op_array->filename = 
             return op_array;
         if(APCG(report_autofilter)) {
 [2011-04-27 23:50 UTC] paulgao at yeah dot net
echo __FILE__ . PHP_EOL;

ln -s 1.php 2.php

[root@xxx ~]# php 1.php 
[root@xxx ~]# php 2.php 
 [2011-04-28 00:23 UTC] simpcl2008 at gmail dot com
Sorry for some incorrent reproduce code!!!

access a.php/b.php by apache/browser:

not cli: 

php a.php
php b.php
 [2011-04-28 02:36 UTC]
This doesn't fix the __FILE__ issue from what I can tell.

It only works for the first file hit in the requests?
 [2011-04-28 02:53 UTC] simpcl2008 at gmail dot com
If you use the keyword 'executed_filename' instead of 
'__FILE__', in all the scripts files you can get the current 
executed file name by 'executed_filename'. Not the first php 
script file in a request.

If you want use the keyword '__FILE__', you must convince 
Zend Dev Team to replace the implement way of '__FILE__' 
with 'executed_filename' .

Do I make myself clear?
 [2011-04-28 03:13 UTC] simpcl2008 at gmail dot com
Hi gopalv,

If you want to replace the __FILE__'s implement, mail to me. 
I'm glad to send you the patch.
 [2016-11-18 21:43 UTC]
-Status: Open +Status: Wont fix
 [2016-11-18 21:43 UTC]
APC is no longer supported in favor of opcache that comes bundled with PHP, if you wish to use the user cache, then look at PECL/APCu.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Mar 24 21:03:38 2023 UTC