Bug #47878 [Opn->Nab]: ScriptControl function capitalization discrepancy

From: Date: Fri, 07 Feb 2020 13:55:31 +0000
Subject: Bug #47878 [Opn->Nab]: ScriptControl function capitalization discrepancy
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225426@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=47878&edit=1 ID: 47878 Updated by: cmb@php.net Reported by: csaba at alum dot mit dot edu Summary: ScriptControl function capitalization discrepancy -Status: Open +Status: Not a bug Type: Bug Package: COM related Operating System: Win XP Pro PHP Version: 5.3.0RC1 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: While PHP method names are case-insensitive, what is accomplished by storing lower-cased versions of the names in the method table (and using lower-cased versions at the call site), COM method names are case-sensitive. Furthermore, there is no special treatment from PHP of the string parameter of ExecuteStatement() (or other string parameters of COM methods); these are passed verbatim; however, the class name passed to AddObject() is treated by COM according to the declared scripting language (VBScript or JScript). So, for VBScript, the string passed to ExecuteStatement() can have the class name in either spelling, while the method name has to be lower-cased. For JScript, however, also the class name has to match case-sensitively. Previous Comments: ------------------------------------------------------------------------ [2009-04-02 13:51:48] csaba at alum dot mit dot edu Description: ------------ It is possible to call a PHP function in a class that has been stuffed into a ScriptControl using the code below. However, the name of the function must be given as lower case, which is probably not the intent. This is especially odd when the original function's name contains capital letters. Reproduce code: --------------- <?php // Demonstrates that caps in the function name // leads to an error when calling a function within // a class within a VBScript ScriptControl // Related to http://bugs.php.net/bug.php?id=33386 class twoFuncs { public function Func1() { echo " func one\n"; } public function func2() { echo " func two\n"; } } $clsInstTF = new twoFuncs; // class instance $oScript = new COM("MSScriptControl.ScriptControl"); $oScript->Language = "VBScript"; $oScript->AddObject ("tF", $clsInstTF, true); $clsInstTF->func1(); // OK $clsInstTF->Func1(); // OK $oScript->ExecuteStatement ("tF.func1"); // OK $oScript->ExecuteStatement ("tf.func1"); // OK $oScript->ExecuteStatement ("tF.Func1"); // Error ?> Expected result: ---------------- I expect so see " func one" repeated on five consecutive lines Actual result: -------------- " func one" is repeated four times, and on the 5th attempt an error results: Object doesn't support this property or method: 'tF.Func1' My guess is that what is happening is that when the function name is being matched, the actual function name is being lower cased while the function name being sought is not being lower cased. Note that class instance in the VBScript script control is matched regardless of capitalization. In contrast, if the language line is changed to: $oScript->Language = "VBScript"; then 4th test line (tf.func1) should be commented out because JScript is case sensitive there. But after that commenting out, the last line still errors. This bug is similar to, but distinct from, bug 33386 Csaba Gabor from Vienna ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=47878&edit=1

« previous php.bugs (#225426) next »