Re: php5 COM strange behaviour

From: Date: Tue, 23 Aug 2005 14:11:32 +0000
Subject: Re: php5 COM strange behaviour
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-221169@lists.php.net to get a copy of this message
Martin Staiger wrote:
Hello NG, we have a script to create a word-document via COM which, so far, run pretty stable under php 4.3.7
are you using apache2 with php4? are you using the prefork version of apache2? (you should be!!)
Since we upgraded to php 5.0.3.3 the same script works only on the first
maybe try 5.0.2, 5.0.4 or 5.0.5beta ??
run!
blooming odd - sounds like a thread[ing] related issue (which is why I say you should be using the orefork version of apache2)
On the following runs the same script causes a fatal error on the code below: Fatal error: Uncaught exception 'com_exception' with message 'Source: Microsoft Word Description: Wrong Parameter.' in [Scriptname]:65 Stack trace: #0 [Scriptname](65): variant->GoTo('wdGoToField', 'wdGoToFirst', 1) #1 [SourceScript] include('[Scriptname]') #2 {main} thrown in [Scriptname] on line 65
apparently the COM extension is designed to throw exceptions in php5 (sometimes). which, regardless of the fact that this exception is being thrown seems to be a complete error, would seem to mean that you are going to have to change your code slightly to incorporate at least one try/catch block around all your code in order to avoid uncaught exceptions.
Code : ================================================ $NumberFields = $word->ActiveDocument->MailMerge->fields->Count; for ($CounterFields = 1; $CounterFields <= $NumberFields; $CounterFields++) {
    $word->Selection->Range->GoTo(wdGoToField, wdGoToFirst, $CounterFields); 
are wdGoToField and wdGoToFirst actually constants?
<-- Creates Fatal Error ... } ================================================ When we reset the Apache-Service, the script runs again once! Subsequent calls create the same fatal error again ... we changed access-rights in dcomcnfg which didn't show any influence ... Environment: win 2003 server, Apache 2.0.53 I'm greatful for any hint !


« previous php.general (#221169) next »