<?php class App { private $_objAuth = null; private function __construct() { $XMLConfigParser = XMLConfigParser::GetInstance(); $_objAuth = new ADODBAuthDriver( $XMLConfigParser->GetMainConfig( 'auth_config' ), $XMLConfigParser->GetMainConfig( 'session_config' ) ); } { { self::$_objInstance = new App; } return self::$_objInstance; } function SetVariable( $strVariableName, $strVariableValue ) { $this->arrVariables[$strVariableName] = $strVariableValue; } } ?>
Jak widac w onstruktorze tworzony jest nowy egzemplarz klasy ADODBAuthDriver, jednak gdy w srodku tej klasy probuje pobrac instancje obiektu App skrypt nie wykonuje sie (jest tmeout z serwera) przyklad:
<?php class ADODBAuthDriver { private $_objDB = null; private $_objSession = null; private $_strDBUser = 'root'; private $_strDBPassword = 'pass'; private $_strDBHost = 'localhost'; private $_strDBName = 'db'; function __construct( $arrAuthConfig, $arrSessionConfig ) { $this->_objDB = NewADOConnection( 'mysql' ); $this->_objDB->Connect($this->_strDBHost, $this->_strDBUser, $this->_strDBPassword, $this->_strDBName); $this->_objSession = new ADODBSession( $this->_objDB, $arrSessionConfig ); // wywolanie App:GetInstance() powoduje timeout App::GetInstance()->SetVariable( 'objDB', $this->_objDB ); App::GetInstance()->SetVariable( 'objSession', $this->_objSession ); } } ?>
problem pojawia sie gdy wywoluje metoge ::GetInstance() w obiekcie, ktory zostal stworzony wewnatrz obiektu App, gdy wywoluje App::GetInstance() gdzies na zewnatrz wszystko dziala ok.
Jak myslicie, jaka jest tego przyczyna, czy to jakis bug w php5 rc3 ?
[edit] - poprawione dwukropki