php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63838 class not found after reinstall pkg with yum
Submitted: 2012-12-23 07:10 UTC Modified: 2016-11-18 21:22 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: gxd305 at gmail dot com Assigned:
Status: Wont fix Package: APC (PECL)
PHP Version: 5.4.10 OS: CentOS 6.x
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gxd305 at gmail dot com
New email:
PHP Version: OS:

 

 [2012-12-23 07:10 UTC] gxd305 at gmail dot com
Description:
------------
We encountered a problem, after reinstalling a pkg with yum, there will be a lot 
of errors:
[Thu Dec 20 16:37:31 2012] [error] [client xxxxx] PHP Fatal error:  Class 
'YCL_Pay' not found in /xxx.php on line 141 

i found that there are two files have same mtime, and in the same directory.

after reinstalling the pkg, the inode changed while mtime not.

apc use devid + inode as the file cache key in system cache, then check mtime to 
see if the file is changed.

Coincidentally,another file 's inode after reinstall is same as the YCL_Pay.php 
's inode before, so the apc fetch the wrong cache entry.

so i add the filesize check in apc_cache_find_slot function to avoid this 
problem.

Test script:
---------------
<?php

/*
* file: test.php
* first run: php -S 127.0.0.1:10090
* then double wget the file.
*  wget 'http://127.0.0.1:10090/test.php' && wget 'http://127.0.0.1:10090/test.php'
*/

$A = '<' . '?php class A{}';
$B = '<' . '?php class B{}';

$t = strtotime("2012-12-21 00:00:00");

file_put_contents('A.php', $A);
file_put_contents('B.php', $B);

// make sure the same mtime
touch ('A.php', $t);
touch ('B.php', $t);

include 'B.php';
include 'A.php';

// use a.php 's inode instead of B.php's
copy('A.php', 'A.php.bak');
copy('B.php', 'A.php');
rename('A.php', 'B.php');
rename("A.php.bak", 'A.php');

// make sure the same mtime
touch ('A.php', $t);
touch ('B.php', $t);



Patches

apc-3.1.13-st_size (last revision 2012-12-23 07:12 UTC by gxd305 at gmail dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-12-27 19:01 UTC] ab@php.net
I'm not sure we should make that logic more complicated. The patch covers a very rare situation. But further more - if the file which replaces the inode has the same file size, here is the issue back. I'd say resetting cache is the best solution.
 [2012-12-27 19:01 UTC] ab@php.net
-Status: Open +Status: Analyzed
 [2012-12-27 20:22 UTC] gopalv@php.net
apc.stat_ctime was put in place to prevent the mtime update problems.

I suggest you try that instead.
 [2013-01-04 08:24 UTC] gxd305 at gmail dot com
to gopalv, unfortunately, both of the ctime are same in our situation.
to ab, yes, but the probability will be lower.
 [2016-11-18 21:22 UTC] kalle@php.net
-Status: Analyzed +Status: Wont fix
 [2016-11-18 21:22 UTC] kalle@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 18:01:30 2024 UTC