MYSQL_FIELD *fields;
MYSQL_ROW row;
unsigned long *field_len;
+ zend_bool magic_quotes_warning_sent = FALSE;
#endif
if (into_object) {
/* check if we need magic quotes */
if (PG(magic_quotes_runtime)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "magic_quotes_runtime are deprecated since PHP 5.3");
+ if (magic_quotes_warning_sent == FALSE) {
+ magic_quotes_warning_sent = TRUE;
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "magic_quotes_runtime are deprecated since PHP 5.3");
+ }
Z_TYPE_P(res) = IS_STRING;
Z_STRVAL_P(res) = php_addslashes(row[i], field_len[i], &Z_STRLEN_P(res), 0 TSRMLS_CC);
} else {
char * string_key;
uint string_key_len;
ulong num_key;
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "magic_quotes_runtime are deprecated since PHP 5.3");
-
- array_init(return_value);
mysqlnd_fetch_into(result, ((fetchtype & MYSQLI_NUM)? MYSQLND_FETCH_NUM:0) | ((fetchtype & MYSQLI_ASSOC)? MYSQLND_FETCH_ASSOC:0), &new_return_value, MYSQLND_MYSQLI);
-
- zend_hash_internal_pointer_reset_ex(Z_ARRVAL(new_return_value), &pos_values);
- while (zend_hash_get_current_data_ex(Z_ARRVAL(new_return_value), (void **)&entry_values, &pos_values) == SUCCESS) {
- if (Z_TYPE_PP(entry_values) == IS_STRING) {
- int new_str_len;
- char * new_str = php_addslashes(Z_STRVAL_PP(entry_values), Z_STRLEN_PP(entry_values), &new_str_len, 0 TSRMLS_CC);
- switch (zend_hash_get_current_key_ex(Z_ARRVAL(new_return_value), &string_key, &string_key_len, &num_key, 0, &pos_values)) {
- case HASH_KEY_IS_LONG:
- add_index_stringl(return_value, num_key, new_str, new_str_len, 0);
- break;
- case HASH_KEY_IS_STRING:
- add_assoc_stringl_ex(return_value, string_key, string_key_len, new_str, new_str_len, 0);
- break;
- }
- } else {
- zval_add_ref(entry_values);
- switch (zend_hash_get_current_key_ex(Z_ARRVAL(new_return_value), &string_key, &string_key_len, &num_key, 0, &pos_values)) {
- case HASH_KEY_IS_LONG:
- add_index_zval(return_value, num_key, *entry_values);
- break;
- case HASH_KEY_IS_STRING:
- add_assoc_zval_ex(return_value, string_key, string_key_len, *entry_values);
- break;
+ if (Z_TYPE(new_return_value) == IS_ARRAY) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "magic_quotes_runtime are deprecated since PHP 5.3");
+ array_init(return_value);
+ zend_hash_internal_pointer_reset_ex(Z_ARRVAL(new_return_value), &pos_values);
+ while (zend_hash_get_current_data_ex(Z_ARRVAL(new_return_value), (void **)&entry_values, &pos_values) == SUCCESS) {
+ if (Z_TYPE_PP(entry_values) == IS_STRING) {
+ int new_str_len;
+ char * new_str = php_addslashes(Z_STRVAL_PP(entry_values), Z_STRLEN_PP(entry_values), &new_str_len, 0 TSRMLS_CC);
+ switch (zend_hash_get_current_key_ex(Z_ARRVAL(new_return_value), &string_key, &string_key_len, &num_key, 0, &pos_values)) {
+ case HASH_KEY_IS_LONG:
+ add_index_stringl(return_value, num_key, new_str, new_str_len, 0);
+ break;
+ case HASH_KEY_IS_STRING:
+ add_assoc_stringl_ex(return_value, string_key, string_key_len, new_str, new_str_len, 0);
+ break;
+ }
+ } else {
+ zval_add_ref(entry_values);
+ switch (zend_hash_get_current_key_ex(Z_ARRVAL(new_return_value), &string_key, &string_key_len, &num_key, 0, &pos_values)) {
+ case HASH_KEY_IS_LONG:
+ add_index_zval(return_value, num_key, *entry_values);
+ break;
+ case HASH_KEY_IS_STRING:
+ add_assoc_zval_ex(return_value, string_key, string_key_len, *entry_values);
+ break;
+ }
}
+ zend_hash_move_forward_ex(Z_ARRVAL(new_return_value), &pos_values);
}
- zend_hash_move_forward_ex(Z_ARRVAL(new_return_value), &pos_values);
+ } else {
+ RETVAL_NULL();
}
zval_dtor(&new_return_value);
} else {
"\\0" => "\\\\0",
"\\" => "\\\\",
);
+ $expectedBoth = array(
+ 0 => "\\'",
+ "'" => "\\'",
+ 1 => "\\\"",
+ '"' => "\\\"",
+ 2 => "\\\\0",
+ "\\0" => "\\\\0",
+ 3 => "\\\\",
+ "\\" => "\\\\",
+ );
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);
+ echo "Equal:";var_dump($row === array_values($expected));
+ if ($row !== array_values($expected)) {
+ var_dump($row, array_values($expected));
}
$res->free();
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);
+ echo "Equal:";var_dump($row === $expectedBoth);
+ if ($row !== $expectedBoth) {
+ var_dump($row, $expectedBoth);
}
$res->free();
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
+Deprecated: Directive 'magic_quotes_runtime' is deprecated in PHP 5.3 and greater in Unknown on line %d
Warning: mysqli_result::fetch_assoc(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d
array(4) {
}
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
+Equal:bool(true)
Warning: mysqli_fetch_array(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d
+Equal:bool(true)
-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
+Warning: mysqli_fetch_object(): magic_quotes_runtime are deprecated since PHP 5.3 in /work/vanilla/php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_magic_quotes.php on line 69
>'< => >\'<
>"< => >\"<
>\0< => >\\0<