From: Ulf Wendel Date: Fri, 3 Sep 2010 14:20:32 +0000 (+0000) Subject: Test for http://bugs.php.net/52221. Test will fail with mysqlnd but should pass with... X-Git-Tag: php-5.3.4RC1~275 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4789901728e295c58afa7a252cb81caa09eeb16f;p=php Test for http://bugs.php.net/52221. Test will fail with mysqlnd but should pass with libmysql. --- diff --git a/ext/mysqli/tests/mysqli_magic_quotes.phpt b/ext/mysqli/tests/mysqli_magic_quotes.phpt new file mode 100644 index 0000000000..76bbda9d1f --- /dev/null +++ b/ext/mysqli/tests/mysqli_magic_quotes.phpt @@ -0,0 +1,170 @@ +--TEST-- +magic_quotes_runtime (DEPRECATED) +--SKIPIF-- += 0) { + die("skip: PHP 5.3 test"); +} +?> +--INI-- +magic_quotes_runtime=1 +--FILE-- +fetch_assoc()) { + var_dump($row); + } + + $res->free(); + + $expected = array( + "'" => "\\'", + '"' => "\\\"", + "\\0" => "\\\\0", + "\\" => "\\\\", + ); + + if (!$res = mysqli_query($link, $query)) { + printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + $row = mysqli_fetch_row($res); + $idx = 0; + foreach ($expected as $key => $value) { + if (!isset($row[$idx])) + printf("[004] Index %d missing\n", $idx); + + if ($row[$idx] !== $value) + printf("[005] Expecting %d => %s got %d => %s\n", $idx, $value, $idx, $row[$idx]); + + unset($row[$idx]); + $idx++; + } + if (count($row) != 0) { + printf("[006] Unexpected results, dumping\n"); + var_dump($row); + } + $res->free(); + + if (!$res = mysqli_query($link, $query)) { + printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + $row = mysqli_fetch_array($res, MYSQLI_BOTH); + $idx = 0; + foreach ($expected as $key => $value) { + if (!isset($row[$idx])) + printf("[008] Index %d missing\n", $idx); + + if ($row[$idx] !== $value) + printf("[009] Expecting %d => %s got %d => %s\n", $idx, $value, $idx, $row[$idx]); + + unset($row[$idx]); + $idx++; + + if (!isset($row[$key])) + printf("[010] Index %s missing\n", $key); + + if ($row[$key] !== $value) + printf("[011] Expecting %s => %s got %s => %s\n", $key, $value, $key, $row[$key]); + + unset($row[$key]); + } + if (count($row) != 0) { + printf("[012] Unexpected results, dumping\n"); + var_dump($row); + } + $res->free(); + + class fetch_object { + public function __set($key, $value) { + printf(">%s< => >%s<\n", $key, $value); + } + } + + if (!$res = mysqli_query($link, $query)) { + printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + $obj = mysqli_fetch_object($res, "fetch_object"); + $res->free(); + + if (false && $IS_MYSQLND) { + if (!$res = mysqli_query($link, $query)) { + printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } + $row = @mysqli_fetch_all($res, MYSQLI_ASSOC); + if ($row[0] !== $expected) { + printf("[015] Wrong data, dumping\n"); + var_dump($row); + } + } + + $link->close(); + + print "done!"; +?> +--EXPECTF-- +Deprecated: Directive 'magic_quotes_runtime' is deprecated in PHP 5.3 and greater in %s on line %d + +Warning: mysqli_result::fetch_assoc(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d + +Warning: mysqli_result::fetch_assoc(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d + +Warning: mysqli_result::fetch_assoc(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d + +Warning: mysqli_result::fetch_assoc(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d +array(4) { + ["'"]=> + string(2) "\'" + ["""]=> + string(2) "\"" + ["\0"]=> + string(3) "\\0" + ["\"]=> + string(2) "\\" +} + +Warning: mysqli_fetch_row(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d + +Warning: mysqli_fetch_row(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d + +Warning: mysqli_fetch_row(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d + +Warning: mysqli_fetch_row(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d + +Warning: mysqli_fetch_array(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d + +Warning: mysqli_fetch_array(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d + +Warning: mysqli_fetch_array(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d + +Warning: mysqli_fetch_array(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d + +Warning: mysqli_fetch_object(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d + +Warning: mysqli_fetch_object(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d + +Warning: mysqli_fetch_object(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d + +Warning: mysqli_fetch_object(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d +>'< => >\'< +>"< => >\"< +>\0< => >\\0< +>\< => >\\< +done! \ No newline at end of file