Lots of cakephp warnings in the log
i 开发者_如何学Pythonget a lot of warnings in my logs like: 2010-08-24 09:34:01 Warning: Warning (2): mssql_num_rows(): supplied argument is not a valid MS SQL-result resource in [C:\xampp\htdocs\cake\libs\model\datasources\dbo\dbo_mssql.php, line 468] 2010-08-24 09:34:01 Warning: Warning (2): mssql_free_result(): supplied argument is not a valid MS SQL-result resource in [C:\xampp\htdocs\cake\libs\model\datasources\dbo\dbo_mssql.php, line 180] 2010-08-24 09:34:01 Warning: Warning (2): mssql_free_result(): supplied argument is not a valid MS SQL-result resource in [C:\xampp\htdocs\cake\libs\model\datasources\dbo\dbo_mssql.php, line 180]
these warnings just overun my log files and make them almost useless. i looked up the lines and they used the @ sign to suppress these errors like: @mssql_free_result($this->results);
and still the show up in my log is there anyway to really suppress them without changing the cake code?
UPDATE:
ok i looked in to this a bit more this only happens when I'm not in debug mode
and this is becous in the error handling function fron debugger there is this:
if (error_reporting() == 0 || $code === 2048 || $code === 8192) {
return;
}
and in the normal production error handling:
if ($code === 2048 || $code === 8192) {
return;
}
so in production it doesn't check if error_reporting() is suppressed
Errors like that are usually the result of poor database error handling. Assuming a query will succeed and blindly using the returned values from ..._query() functions will cause warnings like that. mssql_query()
returns a statement handle only if there were results. It will also return TRUE
if the query succeeded but there were no results, and FALSE
on error.
Passing true/false in to the later functions (such as mssql_num_rows()
) will spit out the "not a valid ... resource" errors/warnings, because, well... they aren't handles.
In other words, the error isn't really at the lines indicated in the warnings, it's earlier in the script, wherever the query actually was executed.
精彩评论