From: david at sickmiller dot com Operating system: CentOS 5.8 PHP version: 5.3.18 Package: MSSQL related Bug Type: Feature/Change Request Bug description:I don't think the mssql_min_error_severity() function works as it should.
Description: ------------ Hi, I don't think the mssql_min_error_severity() function works as it should. At a minimum, the one example in the manual does not make sense (http://www.php.net/function.mssql-min-error-severity#refsect1-function.mssql-min-error-severity-examples). The example uses a SQL statement with a syntax error. Regardless of what you set mssql_min_error_severity to, a syntax error is always going to trigger both (a) a PHP Warning and (b) a false return value from mssql_query(). This behavior contradicts the comment above mssql_min_error_severity(1);. Also, since the code checks the return value from mssql_query(), it's most likely the user will want to use @ to suppress the PHP Warning but that is not shown in the example. Here's an example that at least shows the mssql_min_error_severity() function doing something: <?php mssql_connect($host, $user, $pass); mssql_select_db($dbname); mssql_min_error_severity(16); mssql_min_message_severity(16); // This SQL has a severity 16 error -- subquery returns multiple rows $query = mssql_query('SELECT *, (select error from master.dbo.sysmessages) as bad_subquery from master.dbo.sysmessages'); // Prints: // PHP Warning: mssql_query(): message: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. (severity 16) // PHP Warning: mssql_query(): General SQL Server error: Check messages from the SQL Server (severity 16) mssql_min_error_severity(17); mssql_min_message_severity(17); $query = mssql_query('SELECT *, (select error from master.dbo.sysmessages) as bad_subquery from master.dbo.sysmessages'); // Prints nothing Now, the behavior I disagree with relates to the return value from mssql_query(). Unlike the PHP Warnings, it seems to be unaffected by the min severity settings. Please see the test script section. Test script: --------------- <?php mssql_connect($host, $user, $pass); mssql_select_db($dbname); mssql_min_error_severity(16); mssql_min_message_severity(16); // This SQL has a severity 16 error -- subquery returns multiple rows $query = @mssql_query('SELECT *, (select error from master.dbo.sysmessages) as bad_subquery from master.dbo.sysmessages'); if (!$query) { echo "With min severity set to 16, inside custom error handler\n"; } else { echo "With min severity set to 16, return code indicates no error from mssql_query()\n"; } mssql_min_error_severity(17); mssql_min_message_severity(17); $query = @mssql_query('SELECT *, (select error from master.dbo.sysmessages) as bad_subquery from master.dbo.sysmessages'); if (!$query) { echo "With min severity set to 17, inside custom error handler\n"; } else { echo "With min severity set to 17, return code indicates no error from mssql_query()\n"; } Expected result: ---------------- Expected output: With min severity set to 16, inside custom error handler With min severity set to 17, return code indicates no error from mssql_query() Actual result: -------------- Actual output: With min severity set to 16, return code indicates no error from mssql_query() With min severity set to 17, return code indicates no error from mssql_query() -- Edit bug report at https://bugs.php.net/bug.php?id=63485&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63485&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63485&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63485&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=63485&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=63485&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=63485&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=63485&r=needscript Try newer version: https://bugs.php.net/fix.php?id=63485&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=63485&r=support Expected behavior: https://bugs.php.net/fix.php?id=63485&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=63485&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=63485&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=63485&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63485&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=63485&r=dst IIS Stability: https://bugs.php.net/fix.php?id=63485&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=63485&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=63485&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=63485&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=63485&r=mysqlcfg