require('table.inc');
-if (!$res = mysql_list_dbs($link))
+if (!$res = @mysql_list_dbs($link))
printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
if (!$num = mysql_num_rows($res))
print "done!\n";
?>
--EXPECTF--
-Deprecated: Function mysql_list_dbs() is deprecated in %s on line %d
-
-Deprecated: mysql_list_dbs(): This function is deprecated; use mysql_query() with SHOW DATABASES instead in %s on line %d
-
Warning: mysql_db_name(): Unable to jump to row -1 on MySQL result index %d in %s on line %d
Warning: mysql_db_name(): Unable to jump to row %d on MySQL result index %d in %s on line %d
--- /dev/null
+--TEST--
+Check if deprecated API calls bail out
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--INI--
+mysql.trace_mode=1
+error_reporting=E_ALL | E_NOTICE | E_STRICT
+--FILE--
+<?php
+/*
+ We use an extra test to cover deprecation warning.
+ Due to this extra test we can silence deprecation warnings
+ in have other test using @ operator without loosing the information
+ which function is deprecated and, without reducing test portability.
+*/
+include "table.inc";
+
+if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
+ $error = NULL;
+ ob_start();
+ if (!$res = mysql_db_query($db, "SELECT * FROM test", $link))
+ $error .= sprintf("[001] [%d] %s\n", mysql_errno($link), mysql_error($link));
+ else
+ mysql_free_result($res);
+ $output = ob_get_contents();
+ ob_end_clean();
+
+ if (!stristr($output, 'deprecated')) {
+ printf("[002] mysql_db_query has been deprecated in 5.3.0\n");
+ }
+
+ /*
+ Deprecated since 2002 or the like but documented to be deprecated since 5.3.
+ In 5.3 and before the deprecation message was bound to mysql.trace_mode=1.
+ In 5.3.99 the warning will always be thrown, independent of the mysql.trace_mode
+ setting.
+ */
+ $error = NULL;
+ ob_start();
+ if (!$query = mysql_escape_string("charsets will be ignored"))
+ $error .= sprintf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link));
+ $output = ob_get_contents();
+ ob_end_clean();
+
+ if (!stristr($output, 'deprecated')) {
+ printf("[006] mysql_escape_string has been deprecated in 5.3.0\n");
+ }
+
+}
+
+if (version_compare(PHP_VERSION, '5.3.99') >= 0) {
+ $error = NULL;
+ ob_start();
+ if (!$res = mysql_list_dbs($link))
+ $error .= sprintf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
+ else
+ mysql_free_result($res);
+ $output = ob_get_contents();
+ ob_end_clean();
+
+ if (!stristr($output, 'deprecated')) {
+ printf("[004] mysql_db_query has been deprecated in 5.3.0\n");
+ }
+}
+
+
+
+print "done!";
+?>
+--CLEAN--
+<?php
+require_once("clean_table.inc");
+?>
+--EXPECTF--
+done!
\ No newline at end of file
if (NULL !== ($tmp = @mysql_escape_string()))
printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
-var_dump(mysql_escape_string("Am I a unicode string in PHP 6?"));
-var_dump(mysql_escape_string('\\'));
-var_dump(mysql_escape_string('"'));
-var_dump(mysql_escape_string("'"));
-var_dump(mysql_escape_string("\n"));
-var_dump(mysql_escape_string("\r"));
-var_dump(mysql_escape_string("foo" . chr(0) . "bar"));
+var_dump(@mysql_escape_string("Am I a unicode string in PHP 6?"));
+var_dump(@mysql_escape_string('\\'));
+var_dump(@mysql_escape_string('"'));
+var_dump(@mysql_escape_string("'"));
+var_dump(@mysql_escape_string("\n"));
+var_dump(@mysql_escape_string("\r"));
+var_dump(@mysql_escape_string("foo" . chr(0) . "bar"));
print "done!";
?>
require('table.inc');
-if (!$res = mysql_list_dbs($link))
+if (!$res = @mysql_list_dbs($link))
printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
if (!$num = mysql_num_rows($res))
mysql_free_result($res);
-if (!$res2 = mysql_list_dbs())
+if (!$res2 = @mysql_list_dbs())
printf("[006] [%d] %s\n", mysql_errno(), mysql_error());
$row2 = mysql_fetch_array($res2, MYSQL_NUM);
require_once("clean_table.inc");
?>
--EXPECTF--
-Deprecated: Function mysql_list_dbs() is deprecated in %s on line 15
-
-Deprecated: mysql_list_dbs(): This function is deprecated; use mysql_query() with SHOW DATABASES instead in %s on line %d
-
-Deprecated: mysql_list_dbs(): This function is deprecated; use mysql_query() with SHOW DATABASES instead in %s on line %d
-done!
+done!
\ No newline at end of file
$res1 = mysql_query('SELECT id FROM test', $link);
-if (!$res2 = mysql_db_query($db, 'SELECT id FROM test', $link))
+if (!$res2 = @mysql_db_query($db, 'SELECT id FROM test', $link))
printf("[001] [%d] %s\n", mysql_errno($link), mysql_error($link));
mysql_free_result($res2);
-print mysql_escape_string("I don't mind character sets, do I?\n");
+print @mysql_escape_string("I don't mind character sets, do I?\n");
$res3 = mysql_query('BOGUS_SQL', $link);
mysql_close($link);
require_once("clean_table.inc");
?>
--EXPECTF--
-Deprecated: mysql_db_query(): %s
-
-Deprecated: mysql_escape_string(): %s
I don\'t mind character sets, do I?\n
Warning: mysql_query(): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BOGUS_SQL' at line 1 in %s on line %d
done!