Recursive PHP method crashes Apache

Recursive PHP method crashes Apache

am 04.01.2008 05:07:00 von Aaron Schiff

I call my method Assembler::PrefetchComponents with an array of valid
components and it crashes only when I include the line
"self::PrefetchComponents($dependencies);" Please help me solve the
error in this code.

Here's Assembler::PrefetchComponents:

public static function PrefetchComponents($names)
{
$failed = array();

if(sizeof($m_arrComponents) > 0)
{
$names = array_filter($names,create_function('$var',
'return(Assembler::GetComponentByName
($var))==NULL;'));
}

$dependencies = array();

foreach($names as $name)
{
if(self::TryIncludingComponent($name))
{
$dependencies = array_merge($dependencies,
call_user_func(array("Component_$name",
"Dependencies")));
}
else
{
$failed[] = $name;
}
}

if(sizeof($failed)!=0)
{
sort($failed);
Error::ThrowError(CBD_NO_COMPONENT, $failed);
}

self::PrefetchComponents($dependencies);
}

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

Re: Recursive PHP method crashes Apache

am 04.01.2008 06:15:33 von Stanislav Malyshev

> I call my method Assembler::PrefetchComponents with an array of valid
> components and it crashes only when I include the line
> "self::PrefetchComponents($dependencies);" Please help me solve the
> error in this code.

Most probably you are getting infinite (or very very very deep)
recursion loop in this code, which in PHP would lead to a crash.

--
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com

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

Re: Recursive PHP method crashes Apache

am 04.01.2008 10:46:26 von Stut

Aaron Schiff wrote:
> I call my method Assembler::PrefetchComponents with an array of valid
> components and it crashes only when I include the line
> "self::PrefetchComponents($dependencies);" Please help me solve the
> error in this code.

The code below is an infinite loop. Unless there is an error (assuming
Error::ThrowError halts execution), at no point does it return and at
the end of the function it calls itself. This will never end. Apache
crashes because it fills up the stack.

> Here's Assembler::PrefetchComponents:
>
> public static function PrefetchComponents($names)
> {
> $failed = array();
>
> if(sizeof($m_arrComponents) > 0)
> {
> $names = array_filter($names,create_function('$var',
> 'return(Assembler::GetComponentByName
> ($var))==NULL;'));
> }
>
> $dependencies = array();
>
> foreach($names as $name)
> {
> if(self::TryIncludingComponent($name))
> {
> $dependencies = array_merge($dependencies,
> call_user_func(array("Component_$name",
> "Dependencies")));
> }
> else
> {
> $failed[] = $name;
> }
> }
>
> if(sizeof($failed)!=0)
> {
> sort($failed);
> Error::ThrowError(CBD_NO_COMPONENT, $failed);
> }
>
> self::PrefetchComponents($dependencies);
> }

I'm thinking that last line should be...

if (count($dependencies) > 0)
{
self::PrefetchComponents($dependencies);
}

-Stut

--
http://stut.net/

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

Issues trying to connect to DB2 via PHP

am 04.01.2008 16:46:08 von Jason.McCallister

I'm using IIS on a windows server. I'm having issues trying to connect
to DB2 via PHP.



I can connect to DB2 on the command line on the server.

> db2cmd db2 "connect to emr1u1 user etldbu using xxxx"

Database Connection Information

Database server =3D DB2/AIX64 9.1.3
SQL authorization ID =3D ETLDBU
Local database alias =3D EMR1U1



When I connect to the same DB in PHP as cataloged or uncataloged, I get
this:

Connection to database failed.
SQLSTATE:=20
Message:=20




Below are my PHPINFO settings and the cataloged and uncataloged PHP
scripts.



***************
*** PHPINFO ***
***************

*** ibm_db2***

IBM DB2, Cloudscape and Apache Derby support =3D enabled
Module release =3D 1.6.3
Module revision =3D 1.71
Binary data mode (ibm_db2.binmode) =3D DB2_BINARY =20


*** Environment ***

CLASSPATH =3D .;
C:\PROGRA~1\IBM\SQLLIB\java\db2java.zip;
C:\PROGRA~1\IBM\SQLLIB\java\db2jcc.jar;
C:\PROGRA~1\IBM\SQLLIB\java\db2jcc_license_cu.jar;
C:\PROGRA~1\IBM\SQLLIB\bin;
C:\PROGRA~1\IBM\SQLLIB\java\common.jar =20

DB2INSTANCE =3D DB2
DB2TEMPDIR =3D C:\PROGRA~1\IBM\SQLLIB\ =20

Path =3D F:\PHP\;F:\cygwin\bin;C:\Program Files\EMC\PowerPath\;
C:\Program Files\Windows Resource Kits\Tools\;C:\Program Files\Support
Tools\;
C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\PROGRA~ 1\IBM\SQLLIB
\BIN;
C:\PROGRA~1\IBM\SQLLIB\FUNCTION;C:\PROGRA~1\IBM\SQLLIB\SAMPL ES\REPL;
C:\Program Files\PGP Corporation\PGP Command Line\;F:\AbInitio\bin =20


*****************
*** CATALOGED ***
*****************

<=3Fphp

$database =3D 'emr1u1';
$user =3D 'etldbu';
$password =3D 'xxxx';

print 'Timestamp: '. date('H:i:s, F j, Y') ."

";

$conn =3D db2_connect($database, $user, $password);

if ($conn) {
echo "Connection succeeded.";
db2_close($conn);
}
else {
echo "Connection failed.

";
echo 'SQLSTATE: ' . db2_conn_error() . '
';
echo 'Message: ' . db2_conn_errormsg(). '
';
}
=3F>


*******************
*** UNCATALOGED ***
*******************

<=3Fphp

$database =3D 'emr1u1';
$user =3D 'etldbu';
$password =3D 'xxxx';
$hostname =3D 'imdsdev01';
$port =3D 42016;

print 'Timestamp: '. date('H:i:s, F j, Y') ."

";

$conn_string =3D "DRIVER=3D{IBM DB2 ODBC DRIVER};DATABASE=3D$database;" .
=20
"HOSTNAME=3D$hostname;PORT=3D$port;PROTOCOL=3DTCPIP;UID=3D$u ser;PWD=3D$pass=
word;";
$conn =3D db2_connect($conn_string, '', '');

if ($conn) {
echo "Connection succeeded.";
db2_close($conn);
}
else {
echo "Connection failed.

";
echo 'SQLSTATE: ' . db2_conn_error() . '
';
echo 'Message: ' . db2_conn_errormsg(). '
';
}
=3F>


Blue Cross Blue Shield of Florida, Inc., and its subsidiary and affiliate =
companies are not responsible for errors or omissions in this e-mail =
message. Any personal comments made in this e-mail do not reflect the views=
=
of Blue Cross Blue Shield of Florida, Inc. The information contained in =
this document may be confidential and intended solely for the use of the =
individual or entity to whom it is addressed. This document may contain =
material that is privileged or protected from disclosure under applicable =
law. If you are not the intended recipient or the individual responsible =
=66or delivering to the intended recipient, please (1) be advised that any =
use, dissemination, forwarding, or copying of this document IS STRICTLY =
PROHIBITED; and (2) notify sender immediately by telephone and destroy the =
document. THANK YOU.

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