php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33386 ScriptControl only sees last function of class
Submitted: 2005-06-17 16:38 UTC Modified: 2006-12-24 10:04 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: csaba at alum dot mit dot edu Assigned: wez (profile)
Status: Closed Package: COM related
PHP Version: 5CVS-2005-06-20 OS: Win XP Pro
Private report: No CVE-ID: None
 [2005-06-17 16:38 UTC] csaba at alum dot mit dot edu
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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-17 16:47 UTC] csaba at alum dot mit dot edu
Sigh...the expected results are actually:
 func one
 func one
 func two
 func two
 func one
 func two
 [2006-12-24 10:04 UTC] rrichards@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 06 03:01:27 2024 UTC