|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2012-11-18 13:22 UTC] andras dot galli at gmail dot com
 Description: ------------ I’ve been using your php_apc.dll version for php 5.4.8 on a Windows 7 x64 environment, on Apache 2.4 webserver. I use log4php to log the script execution, and what i examined, that after a succesfull run of my script, the log entries appear in my log file as they should. When I enable APC, my script log’s every entry twice (I call it phantom run), just like if I’ve run the whole script twice, but I didn’t. Also I’ve examined, that my user cached variables shows 0 hits. If the script still runs, the hit count goes up to 1, and on the second fantom run of the script, every hit counts go back to 0. In my log, it appears that on the first script run (which was initiated by me) all values are fetched from the cache, here changes the user cache value hits to 1, and on the phantom run (which initiated by apc I think) my log tels me, that these values are not fetched from but they are stored again. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 23:00:01 2025 UTC | 
The error was related to the following class. The session handling for some reason didn't worked correctly. It reads and writes the data to the session, and for some reason it generated an exception. I couldn't found the exact code part, so i've copyed the full class to here: <?php /** * SessionDBHandler * * @package framework * @author Andras andras@iwshungary.com * @copyright 2012 IWSHungary.com * @version 1.0 * @access public */ class SessionDBHandler extends BaseClass { public $sessionDB; public $configuration; /** * SessionHandlerObject::__construct() * Creates the SessionHandlerObject and sets the required variables in the php.ini * @return */ function __construct($parent, $configuration){ parent::__construct($parent); $this->configuration = $configuration; ini_set("session.gc_maxlifetime", "7200"); ini_set("session.cache_expire", "360"); ini_set("session.cookie_lifetime", "0"); session_module_name('user'); session_set_save_handler(array($this, 'SessionOpen'), array($this, 'SessionClose'), array($this, 'SessionRead'), array($this, 'SessionWrite'), array($this, 'SessionRemove'), array($this, 'SessionGC')); session_start(); } public static function RemoveItem($itemName) { unset($_SESSION[$itemName]); } public static function ResetSession() { session_start(); session_unset(); session_destroy(); session_write_close(); setcookie(session_name(),'',0,'/'); session_regenerate_id(true); } /** * SessionHandlerObject::GetItem() * Gets a session item * @param mixed $itemName * @return */ public static function GetItem($itemName) { if(isset($_SESSION[$itemName])){ return $_SESSION[$itemName]; } else { return null; } } /** * SessionHandlerObject::GetSession() * Get's the whole session array * @return */ public static function GetSession() { return $_SESSION; } /** * SessionHandlerObject::IsSetAlready() * Checks whether the variable is set or not in the session array * @param mixed $itemName * @return */ public static function IsSetAlready($itemName) { return isset($_SESSION[$itemName]); } /** * SessionHandlerObject::SetItem() * Sets a new or updates an old session value * @param mixed $itemName * @param mixed $newValue * @return */ public static function SetItem($itemName, $newValue){ $_SESSION[$itemName] = $newValue; } /** * SessionHandlerObject::GetSessionID() * Get's the session ID * @return */ public static function GetSessionID() { return session_id(); } /** * SessionFunctions::SessionOpen() * * @return */ public function SessionOpen() { $this->sessionDB = new DBConnectionBase(null, $this->configuration->DatabaseType, $this->configuration->ApplicationWorkingMode, $this->configuration->FrameworkDatabaseDBName, $this->configuration->FrameworkDatabaseUserName, $this->configuration->FrameworkDatabasePassword, $this->configuration->FrameworkDatabaseHost, $this->configuration->FrameworkDatabasePort); return true; } /** * SessionFunctions::SessionClose() * * @return */ public function SessionClose() { return true; } /** * SessionFunctions::SessionRead() * * @param mixed $sessionID * @return */ public function SessionRead($sessionID) { $sql = 'SELECT * FROM fw_Session WHERE ID="' . $sessionID . '" AND IsDeleted=0 AND IsElapsed=0'; if( ! $result = $this->sessionDB->ExecuteQuery($sql)) { return(""); } else { if ( $result->num_rows > 0 ) { $row = $this->sessionDB->FetchAssoc($result); return($row["Data"]); } else { return(""); } } } /** * SessionFunctions::SessionWrite() * * @param mixed $sessionID * @param mixed $data * @return */ public function SessionWrite($sessionID, $data) { $sql = 'SELECT Data FROM fw_Session WHERE ID="' . $sessionID . '" AND IsDeleted=0 AND IsElapsed=0'; $current = $this->sessionDB->ExecuteQuery($sql); //Updating the session record if ( $current->num_rows > 0 ) { $current_data = $this->sessionDB->FetchAssoc($current); if ( $current_data['Data'] <> $data ) { $updateSQL = "UPDATE fw_Session SET Data='" . $data . "' WHERE ID='" . $sessionID . "' AND IsDeleted=0 AND IsElapsed=0"; if ( ! $this->sessionDB->ExecuteQuery($updateSQL) ) { return(false); } else { return(true); } } } else { //Inserting a new session record $insertSQL = "INSERT INTO fw_Session ( ID, Time, Data, IsDeleted, IsElapsed ) VALUES ( '" . $sessionID . "', " . time() . ", '" . $data . "', 0, 0 )"; //echo $insertSQL; if ( ! $this->sessionDB->ExecuteQuery($insertSQL) ) { return(false); } else { return(true); } } $this->sessionDB->FlushData(); } /** * SessionFunctions::SessionRemove() * * @param mixed $sessionID * @return */ public function SessionRemove($sessionID) { $removeSQL = 'UPDATE fw_Session SET IsDeleted=1 WHERE ID="' . $sessionID . '" AND IsDeleted=0'; if ( ! $this->sessionDB->ExecuteQuery($removeSQL) ) { return(false); } else { return(true); } $this->sessionDB->FlushData(); } /** * SessionFunctions::SessionGC() * * @param mixed $lifeTime * @return */ public function SessionGC($lifeTime) { $GCSQL = 'UPDATE fw_Session SET IsElapsed=1, IsDeleted=1 WHERE Time < "' . date("YmdHis", time() - $lifeTime) . '" AND IsElapsed=0 AND IsDeleted=0'; if ( ! $this->sessionDB->ExecuteQuery($GCSQL) ) { return(false); } else { return(true); } $this->sessionDB->FlushData(); } } ?>