Bug #79811 [Opn->Nab]: Script stops and delivers incomplete web page

From: Date: Thu, 09 Jul 2020 13:28:01 +0000
Subject: Bug #79811 [Opn->Nab]: Script stops and delivers incomplete web page
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227918@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79811&edit=1

 ID:                 79811
 Updated by:         nikic@php.net
 Reported by:        buschmann at nidsa dot net
 Summary:            Script stops and delivers incomplete web page
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            PostgreSQL related
 Operating System:   Windows Server 2019 64bit
 PHP Version:        8.0.0alpha2
 Block user comment: N
 Private report:     N

 New Comment:

Your script produces:

Warning: Undefined variable $rSOrder in /home/nikic/php/php-src/t036.php on line 34

Fatal error: Uncaught TypeError: pg_fetch_assoc(): Argument #1 ($result) must be of type resource,
null given in /home/nikic/php/php-src/t036.php:34
Stack trace:
#0 /home/nikic/php/php-src/t036.php(34): pg_fetch_assoc(NULL)
#1 {main}
  thrown in /home/nikic/php/php-src/t036.php on line 34

Exactly as expected and explained before. If you do not see the error message, you need to look at
your error handlers and your error related ini settings (do you have error_reporting=E_ALL? Do you
have at least one of display_errors=1 or enabled logging? If you are logging, did you check your
log?)

In any case, this is not a bug in PHP.


Previous Comments:
------------------------------------------------------------------------
[2020-07-09 13:24:29] buschmann at nidsa dot net

I have condensed the original script to a short version (even missing the connection to the
database).

This reproduces the same error (abrupt script termination):

<?php

session_start ();


function searchOrder(){
	global $fSOrder,$rSOrder,$book,$iden,$style,$season,$file,$only;
	echo 'inside searchOrder';
}

?>
<!DOCTYPE html>
<html>
<table border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td><h2 style="margin-left:4px;">BOX</h2></td>
		<td><input type="text" name="Txt_SizeA1AP"
class="CuadroTextoOtro" style="width:25px;" disabled readonly="yes"
value=""/></td>
		<td><input type="text" name="Txt_SizeA2AP"
class="CuadroTextoOtro" style="width:25px;" disabled readonly="yes"
value=""/></td>
		<td><input type="text" name="Txt_SizeA3AP"
class="CuadroTextoOtro" style="width:25px;" disabled readonly="yes"
value=""/></td>
		<td><input type="text" name="Txt_SizeA4AP"
class="CuadroTextoOtro" style="width:25px;" disabled readonly="yes"
value=""/></td>
		<td><input type="text" name="Txt_SizeA5AP"
class="CuadroTextoOtro" style="width:25px;" disabled readonly="yes"
value=""/></td>
		<td><input type="text" name="Txt_SizeA6AP"
class="CuadroTextoOtro" style="width:25px;" disabled readonly="yes"
value=""/></td>
		<td><input type="text" name="Txt_SizeA7AP"
class="CuadroTextoOtro" style="width:25px;" disabled readonly="yes"
value=""/></td>
		<td><input type="text" name="Txt_SizeA8AP"
class="CuadroTextoOtro" style="width:25px;" disabled readonly="yes"
value=""/></td>
		<td><input type="text" name="Txt_SizeA9AP"
class="CuadroTextoOtro" style="width:25px;" disabled readonly="yes"
value=""/></td>
		<td><input type="text" name="Txt_SizeA10AP"
class="CuadroTextoOtro" style="width:25px;" disabled readonly="yes"
value=""/></td>
		<td><input type="text" name="Txt_SizeA11AP"
class="CuadroTextoOtro" style="width:25px;" disabled readonly="yes"
value=""/></td>
		<td><input type="text" name="Txt_SizeA12AP"
class="CuadroTextoOtro" style="width:25px;" disabled readonly="yes"
value=""/></td>
		<td><h2 style="margin-left:2px;">TOTAL</h2></td>
	</tr>
<?php
	for($i=0;$i<=7;$i++){
		//HB @$fSOrder=pg_fetch_assoc($rSOrder);
		$fSOrder=pg_fetch_assoc($rSOrder);
			echo "<tr>";
			echo "<td><input type='text' name=Txt_BoxAAP$i
class='TextoSubFicha' style='width:30px; background-color:#FFFFFF;
font-weight:bold;' onBlur=\"calPairs('box',this.name,$i);\"/><input
type='hidden' name='Txt_id_a$i' value='0'/></td>";
			echo "<td><input type='text' name=Txt_CantSizeA1AP$i
class='CuadroTallas' onChange=\"calPairs('assorted',this.name,$i)\"
disabled/></td>";
			echo "<td><input type='text' name=Txt_CantSizeA2AP$i
class='CuadroTallas' onChange=\"calPairs('assorted',this.name,$i)\"
disabled/></td>";
			echo "<td><input type='text' name=Txt_CantSizeA3AP$i
class='CuadroTallas' onChange=\"calPairs('assorted',this.name,$i)\"
disabled/></td>";
			echo "<td><input type='text' name=Txt_CantSizeA4AP$i
class='CuadroTallas' onChange=\"calPairs('assorted',this.name,$i)\"
disabled/></td>";
			echo "<td><input type='text' name=Txt_CantSizeA5AP$i
class='CuadroTallas' onChange=\"calPairs('assorted',this.name,$i)\"
disabled/></td>";
			echo "<td><input type='text' name=Txt_CantSizeA6AP$i
class='CuadroTallas' onChange=\"calPairs('assorted',this.name,$i)\"
disabled/></td>";
			echo "<td><input type='text' name=Txt_CantSizeA7AP$i
class='CuadroTallas' onChange=\"calPairs('assorted',this.name,$i)\"
disabled/></td>";
			echo "<td><input type='text' name=Txt_CantSizeA8AP$i
class='CuadroTallas' onChange=\"calPairs('assorted',this.name,$i)\"
disabled/></td>";
			echo "<td><input type='text' name=Txt_CantSizeA9AP$i
class='CuadroTallas' onChange=\"calPairs('assorted',this.name,$i)\"
disabled/></td>";
			echo "<td><input type='text' name=Txt_CantSizeA10AP$i
class='CuadroTallas' onChange=\"calPairs('assorted',this.name,$i)\"
disabled/></td>";
			echo "<td><input type='text' name=Txt_CantSizeA11AP$i
class='CuadroTallas' onChange=\"calPairs('assorted',this.name,$i)\"
disabled/></td>";
			echo "<td><input type='text' name=Txt_CantSizeA12AP$i
class='CuadroTallas' onChange=\"calPairs('assorted',this.name,$i)\"
disabled/></td>";
			echo "<td><input type='text' name=Txt_TotalAAP$i
class='TextoSubFicha' style='width:35px; background-color:#FFFFFF;
font-weight:bold;' readonly='yes'/></td>";
			echo "</tr>";
	}
	echo 'past for loop';
?>
</table>
</html>

------------------------------------------------------------------------
[2020-07-09 08:24:55] cmb@php.net

The point is that pg_fetch_assoc($rSOrder) is called while
$rSOrder is undefined.  This is supposed to throw a TypeError in
PHP 8.  This TypeError is apparently caught by your script (maybe
by set_error_handler() or set_exception_handler()).  At least for
debugging purposes, you could rewrite

    @$fSOrder=pg_fetch_assoc($rSOrder);

to

    $fsOrder = isset($rSOrder) ? pg_fetch_assoc($rSOrder) : [];

or so.

------------------------------------------------------------------------
[2020-07-09 07:09:30] buschmann at nidsa dot net

I have tried it with opcache disabled, same error:

The Zend OPcache extension is installed but not active

The code comes from the php 4 era and has no explicit exception handling.

The variable $rSOrder is only declared inside of this function as global and not set before.

It should be easyly reproducable by declaring the function, calling the loop with dummy echos and
some dummy echos after the loop.


The core problem is that the script stops processing (different from 7.x.y).

------------------------------------------------------------------------
[2020-07-08 16:46:56] cmb@php.net

> The call is probably throwing a TypeError, but something in your
> error/exception handling setting eats it.

That's quite likely.  However, to exclude any potential OPcache
issues, please run the script with OPcache disabled.

------------------------------------------------------------------------
[2020-07-08 16:27:10] nikic@php.net

The call is probably throwing a TypeError, but something in your error/exception handling setting
eats it.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=79811


--
Edit this bug report at https://bugs.php.net/bug.php?id=79811&edit=1


Thread (9 messages)

« previous php.bugs (#227918) next »