helly           Mon Mar 15 14:47:23 2004 EDT

  Added files:                 
    /php-src/ext/pgsql/tests    80_bug27597.phpt 

  Modified files:              
    /php-src    NEWS 
    /php-src/ext/pgsql  pgsql.c 
  Log:
  Bugfix #27597 pg_fetch_array not returning false .
  
  
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1636&r2=1.1637&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1636 php-src/NEWS:1.1637
--- php-src/NEWS:1.1636 Mon Mar 15 13:22:01 2004
+++ php-src/NEWS        Mon Mar 15 14:47:11 2004
@@ -46,6 +46,7 @@
 - Fixed problem preventing startup errors from being displayed. (Marcus)
 - Fixed start-up problem if both SPL and SimpleXML were enabled. The double
   initialization of apache 1.3 was causing problems here. (Marcus, Derick)
+- Fixed bug #27597 (pg_fetch_array not returning false). (Marcus)
 - Fixed bug #27586 (ArrayObject::getIterator crashes with [] assignment). 
   (Marcus)
 - Fixed bug #27537 (Objects pointing to each other segfaults). (Dmitry)
http://cvs.php.net/diff.php/php-src/ext/pgsql/pgsql.c?r1=1.306&r2=1.307&ty=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.306 php-src/ext/pgsql/pgsql.c:1.307
--- php-src/ext/pgsql/pgsql.c:1.306     Wed Feb 25 15:16:27 2004
+++ php-src/ext/pgsql/pgsql.c   Mon Mar 15 14:47:15 2004
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
  
-/* $Id: pgsql.c,v 1.306 2004/02/25 20:16:27 abies Exp $ */
+/* $Id: pgsql.c,v 1.307 2004/03/15 19:47:15 helly Exp $ */
 
 #include <stdlib.h>
 
@@ -1403,7 +1403,7 @@
 /* {{{ void php_pgsql_fetch_hash */
 static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type, int 
into_object)
 {
-       zval                *result;
+       zval                *result, *zrow;
        PGresult            *pgsql_result;
        pgsql_result_handle *pg_result;
        int             i, num_fields, pgsql_row, use_row;
@@ -1432,10 +1432,14 @@
                result_type = PGSQL_ASSOC;
                use_row = 0;
        } else {
-               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|ll", &result, 
&row, &result_type) == FAILURE) {
+               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|zl", &result, 
&zrow, &result_type) == FAILURE) {
                        return;
                }
-               use_row = ZEND_NUM_ARGS() > 1;
+               use_row = ZEND_NUM_ARGS() > 1 && Z_TYPE_P(zrow) != IS_NULL;
+               if (use_row) {
+                       convert_to_long_ex(&zrow);
+                       row = Z_LVAL_P(zrow);
+               }
        }
 
        if (!(result_type & PGSQL_BOTH)) {

http://cvs.php.net/co.php/php-src/ext/pgsql/tests/80_bug27597.phpt?r=1.1&p=1
Index: php-src/ext/pgsql/tests/80_bug27597.phpt
+++ php-src/ext/pgsql/tests/80_bug27597.phpt
--TEST--
Bug #27597 pg_fetch_array not returning false 
--SKIPIF--
<?php 
require_once('skipif.inc');
?>
--FILE--
<?php

require_once('config.inc');
        
$dbh = @pg_connect($conn_str);
if (!$dbh) {
        die ("Could not connect to the server");
}

@pg_query("DROP TABLE id");
pg_query("CREATE TABLE id (id INT)");

for ($i=0; $i<4; $i++) {
        pg_query("INSERT INTO id (id) VALUES ($i)");
}

function xi_fetch_array($res, $type = PGSQL_ASSOC) {
        $a = pg_fetch_array($res, NULL, $type) ;
        return $a ;     
}

$res = pg_query("SELECT * FROM id");
$i = 0; // endless-loop protection
while($row = xi_fetch_array($res)) {
        print_r($row);
        if ($i++ > 4) {
                echo "ENDLESS-LOOP";
                exit(1);
        }
}

pg_close($dbh);

?>
===DONE===
--EXPECTF--
Array
(
    [id] => 0
)
Array
(
    [id] => 1
)
Array
(
    [id] => 2
)
Array
(
    [id] => 3
)
===DONE===

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to