#40579 [Bgs]: $_SERVER['SERVER_PORT'] is invalid during apache redirect

2009-05-25 Thread ruslan dot kyrychuk at gmail dot com
 ID:   40579
 User updated by:  ruslan dot kyrychuk at gmail dot com
 Reported By:  ruslan dot kyrychuk at gmail dot com
 Status:   Bogus
 Bug Type: *Web Server problem
 Operating System: Windows 2003
 PHP Version:  5.2.1
 New Comment:

Yes, mono on windows produce same results - so it not PHP.

Workaround was alredy written

RewriteRule ^(.+)$ index.php [E=PORT:%{SERVER_PORT},QSA,L]

then read

$_SERVER['REDIRECT_PORT']


Previous Comments:


[2009-05-25 17:15:47] ras...@php.net

This is not a PHP issue.  The Web server sets these variables.  If they
are set incorrectly, file a bug with the web server folks.  PHP doesn't
touch these at all, we just give you access to whatever information the
web server provides.



[2009-05-25 17:08:06] phpbugs at olliholliday dot co dot uk

I have the same problem.

This bug is reproducible and over a year old, if it's not going to be 
fixed is there at least a workaround?



[2009-05-09 21:24:44] vsamwarcraft3 at hotmail dot com

I have the same problem with the same symptoms. I am running a server
on Ubuntu and an server on Debian.



[2009-03-18 13:39:51] peter at lvp-media dot com

This isn't a PHP-specific bug, it seems to be a problem within
mod_rewrite or Apache itself. I ran into this problem as well, but was
able to reproduce it with Perl and C scripts. For completeness, I'm
running PHP 5.3-dev on Linux with Apache 2.2.



[2009-01-26 15:06:38] tim at timloram dot me dot uk

I am experiencing this issue with exact same symptoms. Having used
mod_rewrite to redirect incoming requests to central gateway script,
$_SERVER['SERVER_PORT'] is always reading '80' even if my inital URL was
http://abc.com:86

Any ideas?



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
http://bugs.php.net/40579

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



#40579 [NoF->Opn]: $_SERVER['SERVER_PORT'] is invalid during apache redirect

2007-03-23 Thread ruslan dot kyrychuk at gmail dot com
 ID:   40579
 User updated by:  ruslan dot kyrychuk at gmail dot com
 Reported By:  ruslan dot kyrychuk at gmail dot com
-Status:   No Feedback
+Status:   Open
 Bug Type: *Web Server problem
 Operating System: Windows 2003
 PHP Version:  5.2.1
 New Comment:

Reproduce code:
---
1. Configure Apache to use port 8080
2. Create .htaccess file:
Options +FollowSymLinks -Indexes
RewriteEngine on 

RewriteCond %{REQUEST_FILENAME}  (.+)\.html
RewriteRule ^(.+)$ test.php [QSA,L]
3. Create test.php file

Run http://localhost:8080/test.html
Output: 80
Run http://localhost:8080/test.php
Output: 8080


Previous Comments:


[2007-03-01 01:00:01] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".



[2007-02-21 14:47:25] [EMAIL PROTECTED]

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with ,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.





[2007-02-21 14:37:51] ruslan dot kyrychuk at gmail dot com

Description:

With apache redirects (mode_rewrite) then in $_SERVER['SERVER_PORT'] is
always 80, even if Apache server is working on another port.

Reproduce code:
---
While apache redirect with following rewrite rule
RewriteRule ^(.+)$ index.php [QSA,L]
Then $_SERVER['SERVER_PORT'] is "80"
---
P.S. While 

RewriteRule ^(.+)$ index.php [E=PORT:%{SERVER_PORT},QSA,L]

then $_SERVER['REDIRECT_PORT'] is "8080"
So it looks like redirected value is sending correctly but doesn't save
correctly into $_SERVER array.

Expected result:

RewriteRule ^(.+)$ index.php [QSA,L]
During redirecting 
$_SERVER['SERVER_PORT'] must be correct port.

Actual result:
--
$_SERVER['SERVER_PORT'] is always "80" during apache redirect.





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


#40579 [NEW]: $_SERVER['SERVER_PORT'] is invalid during apache redirect

2007-02-21 Thread ruslan dot kyrychuk at gmail dot com
From: ruslan dot kyrychuk at gmail dot com
Operating system: Windows 2003
PHP version:  5.2.1
PHP Bug Type: *Web Server problem
Bug description:  $_SERVER['SERVER_PORT'] is invalid during apache redirect

Description:

With apache redirects (mode_rewrite) then in $_SERVER['SERVER_PORT'] is
always 80, even if Apache server is working on another port.

Reproduce code:
---
While apache redirect with following rewrite rule
RewriteRule ^(.+)$ index.php [QSA,L]
Then $_SERVER['SERVER_PORT'] is "80"
---
P.S. While 

RewriteRule ^(.+)$ index.php [E=PORT:%{SERVER_PORT},QSA,L]

then $_SERVER['REDIRECT_PORT'] is "8080"
So it looks like redirected value is sending correctly but doesn't save
correctly into $_SERVER array.

Expected result:

RewriteRule ^(.+)$ index.php [QSA,L]
During redirecting 
$_SERVER['SERVER_PORT'] must be correct port.

Actual result:
--
$_SERVER['SERVER_PORT'] is always "80" during apache redirect.

-- 
Edit bug report at http://bugs.php.net/?id=40579&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=40579&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=40579&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=40579&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40579&r=fixedcvs
Fixed in release: 
http://bugs.php.net/fix.php?id=40579&r=alreadyfixed
Need backtrace:   http://bugs.php.net/fix.php?id=40579&r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=40579&r=needscript
Try newer version:http://bugs.php.net/fix.php?id=40579&r=oldversion
Not developer issue:  http://bugs.php.net/fix.php?id=40579&r=support
Expected behavior:http://bugs.php.net/fix.php?id=40579&r=notwrong
Not enough info:  
http://bugs.php.net/fix.php?id=40579&r=notenoughinfo
Submitted twice:  
http://bugs.php.net/fix.php?id=40579&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40579&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=40579&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40579&r=dst
IIS Stability:http://bugs.php.net/fix.php?id=40579&r=isapi
Install GNU Sed:  http://bugs.php.net/fix.php?id=40579&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=40579&r=float
No Zend Extensions:   http://bugs.php.net/fix.php?id=40579&r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=40579&r=mysqlcfg


#38640 [NEW]: Fatal error while get unsetted property.

2006-08-29 Thread ruslan dot kyrychuk at gmail dot com
From: ruslan dot kyrychuk at gmail dot com
Operating system: Windows 2003, XP
PHP version:  5.1.5
PHP Bug Type: Scripting Engine problem
Bug description:  Fatal error while get unsetted property.

Description:

When unsetting object property it unsetted from object then __get method
of object is called while accessing it.

Besides property exists in all reflection objects (ReflectionObject and
ReflectionProperty) but cause Fatal error while getting it.

Reproduce code:
---
Var= new B();
}
public function __get($name)
{
echo "get {$name}\n";
if(isset($this->Var))
{
return $this->Var;
}
else
{
echo "Undefined variable\n";
return null;
}
}
public function __unset($nm)
{
echo "unset";
}
}

$a = new A();
unset($a->Var);
$o = new ReflectionObject($a);
$p = $o->getProperty('Var');
Reflection::export($o);//Variable Exists
Reflection::export($p);//Variable Exists
var_dump($a->Var);//__get called 
var_dump($p->getValue($a)); //Fatal error
?>

Expected result:

$o = new ReflectionObject($a); 
has correct current instance properties or
$p->getValue($a) - will call __get method too and not cause fatal error.

Actual result:
--
Object of class [  class A ] {
  @@ D:\WWW\www.usoftinc.com\test2.php 3-27

  - Constants [0] {
  }

  - Static properties [0] {
  }

  - Static methods [0] {
  }

  - Properties [1] {
Property [  public $Var ]
  }

  - Dynamic properties [0] {
  }

  - Methods [3] {
Method [  public method __construct ] {
  @@ D:\WWW\www.usoftinc.com\test2.php 6 - 9
}

Method [  public method __get ] {
  @@ D:\WWW\www.usoftinc.com\test2.php 10 - 22

  - Parameters [1] {
Parameter #0 [  $name ]
  }
}

Method [  public method __unset ] {
  @@ D:\WWW\www.usoftinc.com\test2.php 23 - 26

  - Parameters [1] {
Parameter #0 [  $nm ]
  }
}
  }
}

Property [  public $Var ]

get Var
Undefined variable
NULL


Fatal error:  Internal error: Could not find the property Var in
test2.php on line 36


-- 
Edit bug report at http://bugs.php.net/?id=38640&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=38640&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=38640&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=38640&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=38640&r=fixedcvs
Fixed in release: 
http://bugs.php.net/fix.php?id=38640&r=alreadyfixed
Need backtrace:   http://bugs.php.net/fix.php?id=38640&r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=38640&r=needscript
Try newer version:http://bugs.php.net/fix.php?id=38640&r=oldversion
Not developer issue:  http://bugs.php.net/fix.php?id=38640&r=support
Expected behavior:http://bugs.php.net/fix.php?id=38640&r=notwrong
Not enough info:  
http://bugs.php.net/fix.php?id=38640&r=notenoughinfo
Submitted twice:  
http://bugs.php.net/fix.php?id=38640&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=38640&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=38640&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=38640&r=dst
IIS Stability:http://bugs.php.net/fix.php?id=38640&r=isapi
Install GNU Sed:  http://bugs.php.net/fix.php?id=38640&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=38640&r=float
No Zend Extensions:   http://bugs.php.net/fix.php?id=38640&r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=38640&r=mysqlcfg


#37964 [Com]: Reflection shows private methods of parent class

2006-08-20 Thread ruslan dot kyrychuk at gmail dot com
 ID:   37964
 Comment by:   ruslan dot kyrychuk at gmail dot com
 Reported By:  lavin dot peter at gmail dot com
 Status:   Assigned
 Bug Type: Scripting Engine problem
 Operating System: Windows XP
 PHP Version:  5.1.4
 Assigned To:  tony2001
 New Comment:

Maybe it is not valid to have private variables of parent class in
Reflection. Then it is only my own custom serialization problem.


Previous Comments:


[2006-08-20 12:39:18] ruslan dot kyrychuk at gmail dot com

With this serializing interface (if you mean __sleep and __wakeup
method) and with reflection can not work with private variables, I can
not write serialization method that can be used in all child classes
.In every child class Reflection will have child instance and will not
have access for private variables of parent. 

Reproduce code:
---
class A
{
public function __sleep() 
{
$refl = new ReflectionObject($this);
$props = $refl->getProperties();
$result = array();
foreach($props as $prop)
$result[] = $prop->getName();
return $result ;
}
private $privateVar = 'Test Private';
public $publicVar = 'Test Public';

public function setPublic($value)
{
$this->publicVar = $value;
}
public function setPrivate($value)
{
$this->privateVar = $value;
}
}

class B extends A{}

$instance = new B();
$instance->setPrivate('Set Test Private');
$instance->setPublic('Set Test Private');

var_dump($instance);
var_dump(unserialize(serialize($instance)));

Expected result:

Object before serializing and after is same.

Actual result:
--
object(B)#1 (2) {
  ["privateVar:private"]=>
  string(16) "Set Test Private"
  ["publicVar"]=>
  string(16) "Set Test Private"
}
object(B)#3 (2) {
  ["privateVar:private"]=>
  string(12) "Test Private"
  ["publicVar"]=>
  string(16) "Set Test Private"
}


--
When writing 
public function __sleep(){return array('privateVar', 'publicVar');} In
B class
Than you'll get 

Notice: serialize() [function.serialize]: "privateVar" returned as
member variable from __sleep() but does not exist.

So you can't write custom serializing for child object when private
properties exists in parent class.



[2006-08-20 11:07:59] [EMAIL PROTECTED]

That is why we have a new serializing interface which allows you to
call a serializing function in the base class which then can deal with
the private properties in that base class.



[2006-08-20 09:31:05] ruslan dot kyrychuk at gmail dot com

I'd say it is not correct. Properties and methods defined as private
are inherited but you have no access to this properties in child
class.
If for example during serializing if you ommit private properties of
base class - you'll get wrong object.

class Base{
  private $basevar;
  public function baseFunction(){return $this->basevar;}
}
class Derived extends Base{}

if private properties are not inherited - than calling baseFunction
will cause null result and this is not correct in class inheritance.



[2006-07-04 14:13:08] lavin dot peter at gmail dot com

The "getMethods" method of ReflectionClass also returns the private
methods of the parent class.



[2006-06-29 20:06:15] lavin dot peter at gmail dot com

Description:

When using the export method of ReflectionClass the private methods of
of a parent class are displayed.

Reproduce code:
---
class Base{
  private $basevar;
  private function baseFunction(){}
}
class Derived extends Base{}
$d = new Derived;
Reflection::export(new ReflectionClass($d));



Expected result:

Since properties and methods defined as private are not inherited, the
exported Base class should have no properties or methods but in fact
the private method of the Parent class shows up.

Actual result:
--
Class [ class Derived extends Base ] { @@ C:\Program Files\Apache
Group\Apache2\htdocs\newstuff\captcha\refbug.php 6-6 - Constants [0] {
} - Static properties [0] { } - Static methods [0] { } - Properties [0]
{ } - Methods [1] { Method [ private method baseFunction ] { @@
C:\Program Files\Apache
Group\Apache2\htdocs\newstuff\captcha\refbug.php 4 - 4 } } } 





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


#37964 [Com]: Reflection shows private methods of parent class

2006-08-20 Thread ruslan dot kyrychuk at gmail dot com
 ID:   37964
 Comment by:   ruslan dot kyrychuk at gmail dot com
 Reported By:  lavin dot peter at gmail dot com
 Status:   Assigned
 Bug Type: Scripting Engine problem
 Operating System: Windows XP
 PHP Version:  5.1.4
 Assigned To:  tony2001
 New Comment:

With this serializing interface (if you mean __sleep and __wakeup
method) and with reflection can not work with private variables, I can
not write serialization method that can be used in all child classes
.In every child class Reflection will have child instance and will not
have access for private variables of parent. 

Reproduce code:
---
class A
{
public function __sleep() 
{
$refl = new ReflectionObject($this);
$props = $refl->getProperties();
$result = array();
foreach($props as $prop)
$result[] = $prop->getName();
return $result ;
}
private $privateVar = 'Test Private';
public $publicVar = 'Test Public';

public function setPublic($value)
{
$this->publicVar = $value;
}
public function setPrivate($value)
{
$this->privateVar = $value;
}
}

class B extends A{}

$instance = new B();
$instance->setPrivate('Set Test Private');
$instance->setPublic('Set Test Private');

var_dump($instance);
var_dump(unserialize(serialize($instance)));

Expected result:

Object before serializing and after is same.

Actual result:
--
object(B)#1 (2) {
  ["privateVar:private"]=>
  string(16) "Set Test Private"
  ["publicVar"]=>
  string(16) "Set Test Private"
}
object(B)#3 (2) {
  ["privateVar:private"]=>
  string(12) "Test Private"
  ["publicVar"]=>
  string(16) "Set Test Private"
}


--
When writing 
public function __sleep(){return array('privateVar', 'publicVar');} In
B class
Than you'll get 

Notice: serialize() [function.serialize]: "privateVar" returned as
member variable from __sleep() but does not exist.

So you can't write custom serializing for child object when private
properties exists in parent class.


Previous Comments:


[2006-08-20 11:07:59] [EMAIL PROTECTED]

That is why we have a new serializing interface which allows you to
call a serializing function in the base class which then can deal with
the private properties in that base class.



[2006-08-20 09:31:05] ruslan dot kyrychuk at gmail dot com

I'd say it is not correct. Properties and methods defined as private
are inherited but you have no access to this properties in child
class.
If for example during serializing if you ommit private properties of
base class - you'll get wrong object.

class Base{
  private $basevar;
  public function baseFunction(){return $this->basevar;}
}
class Derived extends Base{}

if private properties are not inherited - than calling baseFunction
will cause null result and this is not correct in class inheritance.



[2006-07-04 14:13:08] lavin dot peter at gmail dot com

The "getMethods" method of ReflectionClass also returns the private
methods of the parent class.



[2006-06-29 20:06:15] lavin dot peter at gmail dot com

Description:

When using the export method of ReflectionClass the private methods of
of a parent class are displayed.

Reproduce code:
---
class Base{
  private $basevar;
  private function baseFunction(){}
}
class Derived extends Base{}
$d = new Derived;
Reflection::export(new ReflectionClass($d));



Expected result:

Since properties and methods defined as private are not inherited, the
exported Base class should have no properties or methods but in fact
the private method of the Parent class shows up.

Actual result:
--
Class [ class Derived extends Base ] { @@ C:\Program Files\Apache
Group\Apache2\htdocs\newstuff\captcha\refbug.php 6-6 - Constants [0] {
} - Static properties [0] { } - Static methods [0] { } - Properties [0]
{ } - Methods [1] { Method [ private method baseFunction ] { @@
C:\Program Files\Apache
Group\Apache2\htdocs\newstuff\captcha\refbug.php 4 - 4 } } } 





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


#37964 [Com]: Reflection shows private methods of parent class

2006-08-20 Thread ruslan dot kyrychuk at gmail dot com
 ID:   37964
 Comment by:   ruslan dot kyrychuk at gmail dot com
 Reported By:  lavin dot peter at gmail dot com
 Status:   Assigned
 Bug Type: Scripting Engine problem
 Operating System: Windows XP
 PHP Version:  5.1.4
 Assigned To:  tony2001
 New Comment:

I'd say it is not correct. Properties and methods defined as private
are inherited but you have no access to this properties in child
class.
If for example during serializing if you ommit private properties of
base class - you'll get wrong object.

class Base{
  private $basevar;
  public function baseFunction(){return $this->basevar;}
}
class Derived extends Base{}

if private properties are not inherited - than calling baseFunction
will cause null result and this is not correct in class inheritance.


Previous Comments:


[2006-07-04 14:13:08] lavin dot peter at gmail dot com

The "getMethods" method of ReflectionClass also returns the private
methods of the parent class.



[2006-06-29 20:06:15] lavin dot peter at gmail dot com

Description:

When using the export method of ReflectionClass the private methods of
of a parent class are displayed.

Reproduce code:
---
class Base{
  private $basevar;
  private function baseFunction(){}
}
class Derived extends Base{}
$d = new Derived;
Reflection::export(new ReflectionClass($d));



Expected result:

Since properties and methods defined as private are not inherited, the
exported Base class should have no properties or methods but in fact
the private method of the Parent class shows up.

Actual result:
--
Class [ class Derived extends Base ] { @@ C:\Program Files\Apache
Group\Apache2\htdocs\newstuff\captcha\refbug.php 6-6 - Constants [0] {
} - Static properties [0] { } - Static methods [0] { } - Properties [0]
{ } - Methods [1] { Method [ private method baseFunction ] { @@
C:\Program Files\Apache
Group\Apache2\htdocs\newstuff\captcha\refbug.php 4 - 4 } } } 





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


#38507 [Com]: __set "overloading" and language incongruency with arrays

2006-08-20 Thread ruslan dot kyrychuk at gmail dot com
 ID:   38507
 Comment by:   ruslan dot kyrychuk at gmail dot com
 Reported By:  phpa dot 20 dot crgtk at spamgourmet dot com
 Status:   Open
 Bug Type: Scripting Engine problem
 Operating System: Windows XP/2003 but not relevant
 PHP Version:  5CVS-2006-08-18 (snap)
 New Comment:

$instance->dynmember['language'] = $piece;
will get array by __get overload and than set array value in memory.
This is simple and clear logic.
With your expected result you must override __set property additionaly
for arrays and simple objects.


Previous Comments:


[2006-08-19 00:26:12] phpa dot 20 dot crgtk at spamgourmet dot com

Description:

Fact: By utilizing the __get() overload functionality in a class, PHP
allows one to return a dynamic member of an object as an array that can
be used as if the array were an actual static member of the object.
[Example (1) below].

Issue: However, a glaring incongruency in the PHP language arrises when
one attempts to utilze the __set() overload functionality to modify the
given dynamic member array. One can get, but cannot set the dynamic
member as if it were an array. [Example (2) below].

Consequence: This situation prevents one from making a drop-in
replacement object -- that utilizes dynamic member arrays -- for an
object that originally contained static member arrays.

Reproduce code:
---
class MyClass
{
function __get($name){
return array("hooray"=>"for", "language"=>"incongruencies");
}
function __set($name, $value){
echo "set was passed:\n";
echo print_r($name, true)."\n";
echo print_r($value, true)."\n";
}
}

$instance = new MyClass();

// (1) proof of dynamic member "being" an array
print_r($instance->dynmember); 

// (1) proof of dynamic member array "being accessed"
$piece = $instance->dynmember["language"]; 
echo "piece is: $piece\n\n";

// (2) issue: since one can do the above, one expects to be able to do
the following
$piece = "being congruent";
$instance->dynmember['language'] = $piece; // as of php 5.2, literally
does nothing

Expected result:

Since the language does not seem to have any current capability of
detecting this condition, the following is a _proposed_ result of the
above code:

Array
(
[hooray] => for
[language] => incongruencies
)
piece is: incongruencies

set was passed:
dynmember
Array
(
[language] => being congruent
)





Actual result:
--
Please observe that there are no errors in the output below. That is
because there are literally no errors raised by PHP; the code fails
silently.

Array
(
[hooray] => for
[language] => incongruencies
)
piece is: incongruencies






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


#33595 [Com]: recursive references leak memory

2006-08-15 Thread ruslan dot kyrychuk at gmail dot com
 ID:   33595
 Comment by:   ruslan dot kyrychuk at gmail dot com
 Reported By:  rodricg at sellingsource dot com
 Status:   Assigned
 Bug Type: Class/Object related
 Operating System: *
 PHP Version:  6CVS-2005-08-02
 Assigned To:  dmitry
 New Comment:

Maybe solutution can be to call destructor every time when new object
is assigned to old reference?
Example:
b = new B($this);
}
function __destruct () {
$this->b->__destruct();
}
}

class B {
function __construct ($parent = NULL) {
$this->parent = $parent;
}
function __destruct () {
unset($this->parent);
}
}

for ($i = 0 ; $i < 100 ; $i++) {
$a = new A();
$a->__destruct();
}

echo number_format(memory_get_usage());
?>

$a->__destruct(); can be called automatically because new reference is
created. Then writing correct destructors will solve this issue.

Or maybe I missing something?


Previous Comments:


[2006-05-04 14:08:22] frode at coretrek dot com

I worked around this exact problem by using a proxy class with a
destructor that explicitly breaks the cycle; I got the idea from a
perl.com[1] article describing how perl suffers from the same problem.
It's also interesting to note that perl has chosen a different (less
elegant) solution to the problem than python, by introducing weak
references.

[1] http://www.perl.com/pub/a/2002/08/07/proxyobject.html



[2006-04-13 06:24:02] seufert at gmail dot com

I have been experiencing this problem. Unfortunately i have an
application which relies heavily on a class->driver arrangement where
both the class and the driver class need a reference to each other. I
was wondering if we could have a way of getting an uncounted reference
to the object to pass to the child? So the child would have a reference
to the parent, but it would not be counted, and therefore when all
external references to the parent are removed/unset, the parent will
GC, and then the child will be freed as usual.

Is this a workable solution? Even just a reference count decrement
would work. Not a perfect solution, but it would solve calling
descructors all the time.



[2006-02-22 15:12:21] K dot Londenberg at librics dot de

The problem with circular references is a known weakness of reference
counting schemes. Python uses a workaround (cycle detector). 

Excerpt from
http://wingware.com/psupport/python-manual/2.4/ext/refcounts.html:

"
While Python uses the traditional reference counting implementation, it
also offers a cycle detector that works to detect reference cycles. This
allows applications to not worry about creating direct or indirect
circular references; these are the weakness of garbage collection
implemented using only reference counting. Reference cycles consist of
objects which contain (possibly indirect) references to themselves, so
that each object in the cycle has a reference count which is non-zero.
Typical reference counting implementations are not able to reclaim the
memory belonging to any objects in a reference cycle, or referenced
from the objects in the cycle, even though there are no further
references to the cycle itself. "

Maybe this would also be a viable Strategy for PHP..



[2006-01-19 10:31:05] letssurf at gmail dot com

Thank you for your solution. It's the same path we had taken here. We
had created a kill() method to do the same job. Shame it hasn't been
fixed.

Thank you again :)



[2006-01-17 19:08:55] rodricg at sellingsource dot com

You can avoid the memory leak by manually calling the destructors and
unsetting the recursive ref:

b = new B($this);
}
function __destruct () {
$this->b->__destruct();
}
}

class B {
function __construct ($parent = NULL) {
$this->parent = $parent;
}
function __destruct () {
unset($this->parent);
}
}

for ($i = 0 ; $i < 100 ; $i++) {
$a = new A();
$a->__destruct();
}

echo number_format(memory_get_usage());
?>



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
http://bugs.php.net/33595

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


#15333 [Com]: strndup access violation

2002-11-18 Thread ruslan
 ID:   15333
 Comment by:   [EMAIL PROTECTED]
 Reported By:  [EMAIL PROTECTED]
 Status:   Open
 Bug Type: IIS related
 Operating System: Windows 2000 Pro
 PHP Version:  4.3.0-dev
 New Comment:

Hi..

i have been working on this a couple of days for now, and here are some
facts i noticed after a couple of work-arounds...

- the error occurs only on systems with Win2K (SP >= 2)
- the error WILL NOT occur if logged in as system administrator, and
the IIS security is turned to LOW !!
- the error will occur on EACH request if you fronpage extensions
installed, and a global.asa file exists on the root .
- please keep us informed of a solution

thanks...
http://www.snip.com.ua


Previous Comments:


[2002-11-07 10:01:14] [EMAIL PROTECTED]

attachment to previous message:

>> There is a curious connection:
>> Under applications-configuration...

also not the best.., dit crash aniway.



[2002-11-06 12:52:54] [EMAIL PROTECTED]

I get same error but also with different function:

php4ts!zend_strndup + 0x2B
 + 0xA05D8578

php4ts!zend_hash_copy + 0x1B
 + 0xA05D8578

There is a curious connection:

Under applications-configuration (i do not now the english correct
name)
(where to install php4isapi.dll)
Dlg-page: applications-options (seems concerning ASP)

After deselecting "Buffer", IIS run very stable with no more
interruption.

Mayby tray also..



[2002-11-05 03:52:31] [EMAIL PROTECTED]

I think this may be caused by some memory used for each page
loading,these memory are allocated but not being released properly.
May be the environment variables used.
The memory leap accumulated until crash the IIS.

Any thing done when a page loaded need to be noticed.



[2002-10-29 08:28:56] [EMAIL PROTECTED]

regarding the asp not loading with php as ISAPI...

Try commenting out all the extra loaded extensions in php.ini. (execpt
ones that are in use and necessary)

I had to do this to fix a form submit problem running in .cgi mode that
stripped off characters on submit from normal form posts in PostNuke.

This also made the access violations much much less frequent for ISAPI.



[2002-10-28 13:52:30] [EMAIL PROTECTED]

We are locked in to using IIS with Crystal Reports ASP for web
reporting.  When I run PHP in CGI mode I experience some problems with
pages rendering with errors (if anyone has suggestions in that area I
would love to hear them) - pages will occasionally render with slightly
scrambles source code ... javascript visible in the browser, html
visible in the browser, form fields in the wrong place or the wrong
size.

When PHP is run as an ISAPI mod all of the page scrambling problems go
away.  However, my ASP apps start failing.

Here are the server stats:


PHP Version 4.2.3
Windows NT 5.0 build 2195
SP3



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
http://bugs.php.net/15333

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