PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/test/zend/bad/ext/mysql/tests/mysql_deprecated_api.php

http://github.com/facebook/hiphop-php
PHP | 65 lines | 43 code | 10 blank | 12 comment | 8 complexity | 707df9b13c50c791f6568909efa18a2a MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?php
  2. /*
  3. We use an extra test to cover deprecation warning.
  4. Due to this extra test we can silence deprecation warnings
  5. in have other test using @ operator without loosing the information
  6. which function is deprecated and, without reducing test portability.
  7. */
  8. include "table.inc";
  9. if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
  10. $error = NULL;
  11. ob_start();
  12. if (!$res = mysql_db_query($db, "SELECT * FROM test", $link))
  13. $error .= sprintf("[001] [%d] %s\n", mysql_errno($link), mysql_error($link));
  14. else
  15. mysql_free_result($res);
  16. $output = ob_get_contents();
  17. ob_end_clean();
  18. if (!stristr($output, 'deprecated')) {
  19. printf("[002] mysql_db_query has been deprecated in 5.3.0\n");
  20. }
  21. /*
  22. Deprecated since 2002 or the like but documented to be deprecated since 5.3.
  23. In 5.3 and before the deprecation message was bound to mysql.trace_mode=1.
  24. In 5.3.99 the warning will always be thrown, independent of the mysql.trace_mode
  25. setting.
  26. */
  27. $error = NULL;
  28. ob_start();
  29. if (!$query = mysql_escape_string("charsets will be ignored"))
  30. $error .= sprintf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link));
  31. $output = ob_get_contents();
  32. ob_end_clean();
  33. if (!stristr($output, 'deprecated')) {
  34. printf("[006] mysql_escape_string has been deprecated in 5.3.0\n");
  35. }
  36. }
  37. if (version_compare(PHP_VERSION, '5.3.99') >= 0) {
  38. $error = NULL;
  39. ob_start();
  40. if (!$res = mysql_list_dbs($link))
  41. $error .= sprintf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
  42. else
  43. mysql_free_result($res);
  44. $output = ob_get_contents();
  45. ob_end_clean();
  46. if (!stristr($output, 'deprecated')) {
  47. printf("[004] mysql_db_query has been deprecated in 5.3.0\n");
  48. }
  49. }
  50. print "done!";
  51. ?>
  52. <?php error_reporting(0); ?>
  53. <?php
  54. require_once("clean_table.inc");
  55. ?>