#34344 [Opn]: register_shutdown_function() in classes  
Author Message
php-bugs





PostPosted: 2005-9-2 18:55:20 Top

php-dev, #34344 [Opn]: register_shutdown_function() in classes ID: 34344
User updated by: thomas at ecommerce dot com
Reported By: thomas at ecommerce dot com
Status: Open
Bug Type: SPL related
Operating System: SuSE Linux
PHP Version: 5.0.4
New Comment:

Updated Expected result part


Previous Comments:
------------------------------------------------------------------------

[2005-09-02 12:48:51] thomas at ecommerce dot com

Description:
------------
When trying to call the register_shutdown_function() inside class like
this:

register_shutdown_function(array(&$this, "_log"));

and the method _log() is a private method it don't work. We assign
$this here to the function so
register_shutdown_function() should be allowed to call a private
function inside of the class or at least throw allready here an error
message when this function is called and _log() is a private function.
Its also not documented that this wouldn't work....

Reproduce code:
---------------
<?php
final class TestClass
{
public function TestClass()
{
echo "Class init call!\n";
$this->_init();
}

private function _init()
{
echo "Registrering shutdown function..\n";

//-- register log function
register_shutdown_function(array(&$this, "_log"));

echo "done\n";
}

private function _log()
{
//-- send mail
mail("email***@***.com", "subject", "content");
}
}

echo "Script start! Init Class.\n";
$TestClass = new TestClass();
echo "Class inited!\n";

Expected result:
----------------
email will be send to email***@***.com when script is done.

Actual result:
--------------
Script will not call the shutdown function


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


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





PostPosted: 2005-9-2 18:55:00 Top

php-dev >> #34344 [Opn]: register_shutdown_function() in classes ID: 34344
User updated by: thomas at ecommerce dot com
Reported By: thomas at ecommerce dot com
Status: Open
Bug Type: SPL related
Operating System: SuSE Linux
PHP Version: 5.0.4
New Comment:

Script start! Init Class.
Class init call!
Registrering shutdown function..
done
Class inited!

Fatal error: Call to private method TestClass::_log() from context ''
in Unknown on line 0
----------
is the current result


Previous Comments:
------------------------------------------------------------------------

[2005-09-02 12:53:19] thomas at ecommerce dot com

Updated Expected result part

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

[2005-09-02 12:48:51] thomas at ecommerce dot com

Description:
------------
When trying to call the register_shutdown_function() inside class like
this:

register_shutdown_function(array(&$this, "_log"));

and the method _log() is a private method it don't work. We assign
$this here to the function so
register_shutdown_function() should be allowed to call a private
function inside of the class or at least throw allready here an error
message when this function is called and _log() is a private function.
Its also not documented that this wouldn't work....

Reproduce code:
---------------
<?php
final class TestClass
{
public function TestClass()
{
echo "Class init call!\n";
$this->_init();
}

private function _init()
{
echo "Registrering shutdown function..\n";

//-- register log function
register_shutdown_function(array(&$this, "_log"));

echo "done\n";
}

private function _log()
{
//-- send mail
mail("email***@***.com", "subject", "content");
}
}

echo "Script start! Init Class.\n";
$TestClass = new TestClass();
echo "Class inited!\n";

Expected result:
----------------
email will be send to email***@***.com when script is done.

Actual result:
--------------
Script will not call the shutdown function


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


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