From: csaba at alum dot mit dot edu Operating system: Win XP Pro PHP version: 5.1.0b1 PHP Bug Type: COM related Bug description: ScriptControl only sees last function of class
Description: ------------ When I use a PHP class with the MSScriptControl.ScriptControl object and want to invoke a function in the class from within the ScriptControl, I always get the last function from the class regardless of which one I try to invoke (provided I've used the name of ANY function in the class - see note on actual result). If I implement the same thing in VB5 (VBScript with VB5CCE, actually), this problem does not happen. The code for it is also short and I am happy to provide it, if it would be useful Csaba Gabor from Vienna Reproduce code: --------------- <?php // Demonstrates that you will get the last function when // calling to a PHP class via MSScriptControl class twoFuncs { public function func1() { echo " func one\n"; } public function func2() { echo " func two\n"; } } $ciTF = new twoFuncs; $oScript = new COM("MSScriptControl.ScriptControl"); $oScript->Language = "VBScript"; // the object, within the script control, is referred to as tFA // that final true means that the tFA. may be omitted within the script control $oScript->AddObject ("tfA", $ciTF, true); foreach (array(1,2) as $i) { $oScript->ExecuteStatement ("tfA.func$i"); $oScript->ExecuteStatement ("func$i"); } $oScript->AddObject ("tfB", $ciTF); foreach (array(1,2) as $i) $oScript->ExecuteStatement ("tfB.func$i"); ?> Expected result: ---------------- I expect to see: func one func two func one func two func one func two Actual result: -------------- I see func two repeated 6 times. In other words, regardless of what function I name, only the last defined function in the PHP class is executed, which is incorrect. However, if I attempt to call a function that isn't there, such as $oScript->ExecuteStatement ("tfA.func3"); then PHP will (correctly) throw an error This to me says that PHP gets as far as determining whether the function is there or not, but then it messes up on the indirection. -- Edit bug report at http://bugs.php.net/?id=33386&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33386&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33386&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33386&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33386&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33386&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33386&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33386&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33386&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33386&r=support Expected behavior: http://bugs.php.net/fix.php?id=33386&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33386&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33386&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33386&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33386&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33386&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33386&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33386&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33386&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33386&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33386&r=mysqlcfg