Annotation of embedaddon/php/ext/mysqli/tests/mysqli_magic_quotes.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: magic_quotes_runtime (DEPRECATED)
3: --SKIPIF--
4: <?php
5: require_once('skipif.inc');
6: require_once('skipifemb.inc');
7: require_once('skipifconnectfailure.inc');
8:
9: if (version_compare(PHP_VERSION, '5.3.98') >= 0) {
10: die("skip: PHP 5.3 test");
11: }
12: ?>
13: --INI--
14: magic_quotes_runtime=1
15: --FILE--
16: <?php
17: require('connect.inc');
18:
19: if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
20: printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
21:
22: $query = sprintf("SELECT '%s', '%s', '%s', '%s' FROM DUAL",
23: mysqli_real_escape_string($link, "'"),
24: mysqli_real_escape_string($link, '"'),
25: mysqli_real_escape_string($link, '\0'),
26: mysqli_real_escape_string($link, '\\'));
27:
28: if (!$res = mysqli_query($link, $query)) {
29: printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
30: }
31:
32: while ($row = $res->fetch_assoc()) {
33: var_dump($row);
34: }
35:
36: $res->free();
37:
38: $expected = array(
39: "'" => "\\'",
40: '"' => "\\\"",
41: "\\0" => "\\\\0",
42: "\\" => "\\\\",
43: );
44: $expectedBoth = array(
45: 0 => "\\'",
46: "'" => "\\'",
47: 1 => "\\\"",
48: '"' => "\\\"",
49: 2 => "\\\\0",
50: "\\0" => "\\\\0",
51: 3 => "\\\\",
52: "\\" => "\\\\",
53: );
54:
55: if (!$res = mysqli_query($link, $query)) {
56: printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
57: }
58: $row = mysqli_fetch_row($res);
59: echo "Equal:";var_dump($row === array_values($expected));
60: if ($row !== array_values($expected)) {
61: var_dump($row, array_values($expected));
62: }
63: $res->free();
64:
65: if (!$res = mysqli_query($link, $query)) {
66: printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
67: }
68: $row = mysqli_fetch_array($res, MYSQLI_BOTH);
69: echo "Equal:";var_dump($row === $expectedBoth);
70: if ($row !== $expectedBoth) {
71: var_dump($row, $expectedBoth);
72: }
73: $res->free();
74:
75: class fetch_object {
76: public function __set($key, $value) {
77: printf(">%s< => >%s<\n", $key, $value);
78: }
79: }
80:
81: if (!$res = mysqli_query($link, $query)) {
82: printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
83: }
84: $obj = mysqli_fetch_object($res, "fetch_object");
85: $res->free();
86:
87: if (false && $IS_MYSQLND) {
88: if (!$res = mysqli_query($link, $query)) {
89: printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
90: }
91: $row = @mysqli_fetch_all($res, MYSQLI_ASSOC);
92: if ($row[0] !== $expected) {
93: printf("[015] Wrong data, dumping\n");
94: var_dump($row);
95: }
96: }
97:
98: $link->close();
99:
100: print "done!";
101: ?>
102: --EXPECTF--
103: Deprecated: Directive 'magic_quotes_runtime' is deprecated in PHP 5.3 and greater in Unknown on line %d
104:
105: Warning: mysqli_result::fetch_assoc(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d
106: array(4) {
107: ["'"]=>
108: string(2) "\'"
109: ["""]=>
110: string(2) "\""
111: ["\0"]=>
112: string(3) "\\0"
113: ["\"]=>
114: string(2) "\\"
115: }
116:
117: Warning: mysqli_fetch_row(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d
118: Equal:bool(true)
119:
120: Warning: mysqli_fetch_array(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d
121: Equal:bool(true)
122:
123: Warning: mysqli_fetch_object(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d
124: >'< => >\'<
125: >"< => >\"<
126: >\0< => >\\0<
127: >\< => >\\<
128: done!
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>