Problem reading exception stack (using 5b3)

php.internals

Markus Fischer

22 years ago
From my current tests I get the following stack: [23-Dec-2003 01:55:10] PHP Fatal error: Uncaught exception 'exception' with message 'Unable to connect to database; mysql_error = Unknown MySQL Server Host 'bla' (4)' in /home/mfischer/php/System.php:12 Stack trace: #0 /home/mfischer/php/Database/MySQL.php(30): mysql->mysql_connect('bla', '', '') #1 /home/mfischer/htdocs/php5/test.php(5): mysql->connect('hostname=bla') #2 {main} thrown in /home/mfischer/php/System.php on line 12 However, the code flow is as the following: 1) /home/mfischer/htdocs/php5/test.php(5): $db->connect("hostname=bla"); 'connect' method of object '$db' is called; not of object '$mysql' (only the class is called mysql) 2) /home/mfischer/php/Database/MySQL.php(30): $this->resource = System::mysql_connect($this->hostname, $this->username, $this->password); The static method 'mysql_connect' of the 'System' class is called (and not mysql->mysql_connect); 3) /home/mfischer/php/System.php(12): throw new Exception("Unable to connect to database$mysql_error"); So, for me it seems that a) the order of the stack is not right (0->1->2 should be 1->0->2) b) the called function on the stack doesn't reassemble the real names. In #1 it should be $db->connect and in #0 it should be System::mysql_connect; Any ideas about this? - Markus

Markus Fischer

22 years ago
Maybe some more information about how my code files are layed out may be helpful. /home/mfischer/htdocs/php5/test.php This is my test script which is executed via apache. It includes the file 'Database/MySQL.php'. /home/mfischer/php/Database/MySQL.php Includes the files 'Database/DatabaseInterfaces.php' and 'System.php'. /home/mfischer/php/Database/DatabaseInterfaces.php Provides 'interface DatabaseInterface' and 'interface DatabaseResultInterface'. /home/mfischer/php/System.php Contains the class 'System' which only has static methods which wrap 1:1 with PHP (native) functions but providing Exceptions in case of errors. So, my code flow until the exception is thrown is: test.php(5) calls $db->connect() Database/MySQL.php(30) calls System::mysql_connect() System.php(12) throws the Exception However, the stacktrace reported from PHP reads: [23-Dec-2003 01:55:10] PHP Fatal error: Uncaught exception 'exception' with message 'Unable to connect to database; mysql_error = Unknown MySQL Server Host 'bla' (4)' in /home/mfischer/php/System.php:12 Stack trace: #0 /home/mfischer/php/Database/MySQL.php(30): mysql->mysql_connect('bla', '', '') #1 /home/mfischer/htdocs/php5/test.php(5): mysql->connect('hostname=bla') #2 {main} thrown in /home/mfischer/php/System.php on line 12 My problem is (in order of priority): 1) the order in the trace is not correct 2) the called methods do not match my code regards, - Markus