ZF-5918: connect errors are supressed when dbname is provided
Description
It seems a bit inconsistent that oci_connect() errors are suppressed in _connect() when dbname is provided in config.ini, but are not supressed when dbname isn't present.
It caused me a bit of head scratching during a recent connection issue.
Comments
Posted by Mickael Perraud (mikaelkael) on 2009-03-03T13:40:40.000+0000
In this case, Zend_Db_Adapter_Abstract will throw an exception with _checkRequiredOptions():
Since SVN5014, this part of code is unused.
Posted by Steve Jordan (stevejordan) on 2009-03-04T06:18:27.000+0000
sorry, I wasn't very clear in the description.
inside the _connect() function there is the following code:
at the moment a check is made to see if dbname has been declared somewhere, and if it has oci_connect has it's errors suppressed (@). There is no error suppression when dbname has not been set.
This is an inconsistency, and caused me some issues while trying to diagnose a connection issue (The exception thrown contained no useful information)
I hope this is clearer.
Posted by Mickael Perraud (mikaelkael) on 2009-03-04T11:14:28.000+0000
You were clear, no problem ;).
Based on actual trunk, I think this code is unreachable. So we could replace:
by:
Because $this->_config['dbname'] is mandatory, if it misses, then you have an exception thrown by Zend_Db_Adapter_Abstract::_checkRequiredOptions() before entering in Zend_Db_Adapter_Oracle::_connect()
Posted by Steve Jordan (stevejordan) on 2009-03-05T08:44:18.000+0000
I see what your saying. It sounds like a good idea to remove code which will never be run.
But the problem which I was having (with the empty Exception messages) will still occur in your replacement code, because you still have the @ suppressing error messages.
If you look at the next code block in the file:
Posted by Steve Jordan (stevejordan) on 2009-03-05T08:45:57.000+0000
sorry, I hit "Add" too soon.
the call to oci_error() will never return anything while the oci_connect() errors are suppressed.
So my suggestion is to remove the @ before oci_connect.
Posted by Mickael Perraud (mikaelkael) on 2009-03-06T12:58:13.000+0000
{quote} the call to oci_error() will never return anything while the oci_connect() errors are suppressed. {quote}
For me, it's false, see these examples:
=> return nothing
=>
=>
The goal of @ is simply to suppress the warning but oci_error() is always populated.
No?
Posted by Steve Jordan (stevejordan) on 2009-03-10T04:19:02.000+0000
It looks like I have misunderstood the purpose of @
In which case the exception thrown needs to contain at least the code and message, something like:
?
Posted by Mickael Perraud (mikaelkael) on 2009-03-11T01:57:25.000+0000
Open Zend/Db/Adapter/Oracle/Exception.php, you will see how this is managed
Posted by Steve Jordan (stevejordan) on 2009-03-11T02:29:59.000+0000
I see. That makes sense now.
So in my case the lack of an error message is down to oci_error not returning one, rather than the framework's processing.
Thanks for pointing me in the right direction.
Posted by Mickael Perraud (mikaelkael) on 2009-03-15T07:21:45.000+0000
The unreachable code was removed with SVN 14324 to close this issue.