Skip to content

Commit 1db720c

Browse files
committed
Merge branch 'PHP-5.5' into PHP-5.6
Conflicts: ext/pgsql/pgsql.c
2 parents d0be36c + 7667f8e commit 1db720c

File tree

3 files changed

+63
-4
lines changed

3 files changed

+63
-4
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
. Fix bug #61285, #68329, #68046, #41631: encrypted streams don't observe
1313
socket timeouts (Brad Broerman)
1414

15+
- pgsql:
16+
. Fixed bug #68638 (pg_update() fails to store infinite values).
17+
(william dot welter at 4linux dot com dot br, Laruence)
18+
1519
?? Feb 2015, PHP 5.6.6
1620

1721
- Core:

ext/pgsql/pgsql.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5722,9 +5722,6 @@ static int php_pgsql_convert_match(const char *str, size_t str_len, const char *
57225722

57235723
regerr = regexec(&re, str, re.re_nsub+1, subs, 0);
57245724
if (regerr == REG_NOMATCH) {
5725-
#ifdef PHP_DEBUG
5726-
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "'%s' does not match with '%s'", str, regex);
5727-
#endif
57285725
ret = FAILURE;
57295726
}
57305727
else if (regerr) {
@@ -5971,7 +5968,12 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
59715968
else {
59725969
/* better regex? */
59735970
if (php_pgsql_convert_match(Z_STRVAL_PP(val), Z_STRLEN_PP(val), "^[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$", 0 TSRMLS_CC) == FAILURE) {
5974-
err = 1;
5971+
if (php_pgsql_convert_match(Z_STRVAL_PP(val), Z_STRLEN_PP(val), "^[+-]{0,1}(inf)(inity){0,1}$", 1 TSRMLS_CC) == FAILURE) {
5972+
err = 1;
5973+
} else {
5974+
ZVAL_STRING(new_val, Z_STRVAL_PP(val), 1);
5975+
php_pgsql_add_quotes(new_val, 1 TSRMLS_CC);
5976+
}
59755977
}
59765978
else {
59775979
ZVAL_STRING(new_val, Z_STRVAL_PP(val), 1);

ext/pgsql/tests/bug68638.phpt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
--TEST--
2+
Bug #68638 pg_update() fails to store infinite values
3+
--SKIPIF--
4+
<?php include("skipif.inc"); ?>
5+
--FILE--
6+
<?php
7+
8+
include('config.inc');
9+
10+
$conn = pg_connect($conn_str);
11+
12+
$table='test_68638';
13+
14+
pg_query("CREATE TABLE $table (id INT, value FLOAT)");
15+
16+
pg_insert($conn,$table, array('id' => 1, 'value' => 1.2));
17+
pg_insert($conn,$table, array('id' => 2, 'value' => 10));
18+
pg_insert($conn,$table, array('id' => 3, 'value' => 15));
19+
20+
var_dump(pg_update($conn,$table, array('value' => 'inf'), array('id' => 1), PGSQL_DML_STRING));
21+
22+
pg_update($conn,$table, array('value' => 'inf'), array('id' => 1));
23+
pg_update($conn,$table, array('value' => '-inf'), array('id' => 2));
24+
pg_update($conn,$table, array('value' => '+inf'), array('id' => 3));
25+
26+
$rs = pg_query("SELECT * FROM $table");
27+
while ($row = pg_fetch_assoc($rs)) {
28+
var_dump($row);
29+
}
30+
31+
pg_query("DROP TABLE $table");
32+
33+
?>
34+
--EXPECT--
35+
string(52) "UPDATE "test_68638" SET "value"=E'inf' WHERE "id"=1;"
36+
array(2) {
37+
["id"]=>
38+
string(1) "1"
39+
["value"]=>
40+
string(8) "Infinity"
41+
}
42+
array(2) {
43+
["id"]=>
44+
string(1) "2"
45+
["value"]=>
46+
string(9) "-Infinity"
47+
}
48+
array(2) {
49+
["id"]=>
50+
string(1) "3"
51+
["value"]=>
52+
string(8) "Infinity"
53+
}

0 commit comments

Comments
 (0)