ID: 48686 Comment by: aaron at xavisys dot com Reported By: codextasy at gmail dot com Status: Open Bug Type: Scripting Engine problem Operating System: * PHP Version: 5.2.10 New Comment:
I'm having the same issue. My problem is that I upgraded from PHP 5.2.9 to 5.2.11 and set up APC at the same time. The problem actually affected my custom session handler. After finding this ticket I disabled APC and restarted apache, but the problem persists. My code to recreate: session.class.php ------------------ <?php /** * These are our session handler functions */ class Session { /** * Open a session * * @return bool true */ public static function ses_open() { return true; } /** * Closes the session, after cleaning up. * * @return bool true */ public static function ses_close() { self::ses_clean(ini_get('session.gc_maxlifetime')); return true; } /** * Reads the data from the session. * * @param string $session_id * @return unknown */ public static function ses_read($session_id) { $db = db::get_instance(); $q = "SELECT `data` FROM `sessions` WHERE `id`=".quote_smart($session_id); if (($r = $db->query($q)) && $r->num_rows > 0) { $i = $r->fetch_object(); return $i->data; } return false; } /** * Writes the session * * @param string $session_id * @param string $data - serialized version of $_SESSION * @return unknown */ public static function ses_write($session_id, $data) { /** * I guess that our database connection is closed before this runs, but the * static variable is not reset. We run the destroy instance first, so that * the singleton knows to create a new instance */ db::destroy_instance(); $db = db::get_instance(); $uid = (isset($_SESSION['uid']))? $_SESSION['uid']:''; $q = "REPLACE INTO `sessions` (`id`, `uid`, `ip`, `data`) VALUES (".quote_smart($session_id, $uid, $_SERVER['REMOTE_ADDR'], $data).')'; return $db->query($q); } /** * Destroys the session, and clears our 'remember me' cookie, so we can use this * to log a user out * * * @param string $session_id * @return bool */ public static function ses_destroy($session_id) { $db = db::get_instance(); $q = "DELETE FROM `sessions` WHERE `id`=".quote_smart($session_id); if(isset($_COOKIE['user'])){ setcookie("ezd_user", '', time()-(60*60*24*7), '/', ''); //60*60*24*7=secs*mins*hrs*days=7days } return $db->query($q); } /** * Cleans up (removes) old sessions * * @param int $max - How old "old" data is (in seconds) * @return bool */ public static function ses_clean($max) { $db = db::get_instance(); $q = "DELETE FROM `sessions` WHERE `access` < NOW() - INTERVAL {$max} SECOND"; return $db->query($q); } } test.php ----------- /** * Starts a session. Since we need to do this in more than one place, this * function sets the session name and handler, then starts it. */ function start_session() { require_once('session.class.php'); session_name('EZD_ID'); /* session_set_save_handler( array('Session','ses_open'), array('Session','ses_close'), array('Session','ses_read'), array('Session','ses_write'), array('Session','ses_destroy'), array('Session','ses_clean')); */ session_start(); } start_session(); Previous Comments: ------------------------------------------------------------------------ [2009-07-06 08:26:31] pietro dot baldassarri at unibo dot it Same problem here (Gentoo Linux PHP 5.2.10). This bug seems some way related to this http://bugs.php.net/bug.php?id=48787 ------------------------------------------------------------------------ [2009-06-25 10:31:38] codextasy at gmail dot com I can reproduce the bug with or without APC installed/enabled. ------------------------------------------------------------------------ [2009-06-25 10:06:08] davide dot ferrari at atrapalo dot com Same grave bug here! But here it happens only when APC (3.0.19) is enabled. Can the OP confirm it happens only with APC as well? ------------------------------------------------------------------------ [2009-06-25 09:01:25] codextasy at gmail dot com Description: ------------ There is a bug with cyclic inclusion of files with class definition. There are three classes - A, B, C - each placed in a separate file - A.php, B.php, C.php - all in the same directory. B is a derived class of A, C is a derived of B. So, B.php includes A.php (using require_once), C.php includes B.php. A.php contains both class A and function f(), which is subsequently called. f() includes 'C.php'. When trying to request B.php (or include it from another file) I get Fatal error: Class 'B' not found C.php on line 4. Reproduce code: --------------- Three files here: --------[ A.php ]-------- <? class A {} function f() { include 'C.php'; } f(); ?> --------[ B.php ]-------- <? require_once 'A.php'; class B extends A {} ?> --------[ C.php ]-------- <? require_once 'B.php'; class C extends B {} ?> Expected result: ---------------- No error when requesting or including B.php. Actual result: -------------- Fatal error: Class 'B' not found in /srv/www/test/C.php on line 4 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48686&edit=1