ID:               34344
 Updated by:       [EMAIL PROTECTED]
 Reported By:      thomas at ecommerce dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         SPL related
 Operating System: SuSE Linux
 PHP Version:      5.0.4
 New Comment:

Ah yes, you can't really call any object methods inside a shutdown
function since the objects are destructed before that.


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

[2005-09-02 16:27:45] thomas at ecommerce dot com

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

Warning: (Registered shutdown functions) Unable to call
TestClass::_log() - function does not exist in Unknown on line 0
------------------------------
This is the output with the latest CVS Snap. The problem still exists
and the Error Message is wrong ( function does not exist, but exists )

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

[2005-09-02 16:15:12] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip



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

[2005-09-02 12:54:14] thomas at ecommerce dot com

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

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

[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 PROTECTED]", "subject", "content");
        }
}

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

Expected result:
----------------
email will be send to [EMAIL PROTECTED] 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

Reply via email to