开发者

PHP random COM object problems on WAMP

开发者 https://www.devze.com 2023-03-20 00:33 出处:网络
I am using an old COM object / ActiveX-control in a PHP application. It runs under Windows/Apache. Normally everything is fine but sometimes I get

I am using an old COM object / ActiveX-control in a PHP application. It runs under Windows/Apache. Normally everything is fine but sometimes I get

Failed to create COM object 'TTF161.TTF1': Objektserver wird beendet, wenn der OLE-Dienst ihn aufruft.

The german part of the message means something like Objectserver terminates when the OLE-service calls it.

I tried enclosing the creation of the object with try-catch but it does not work.

The problem occurs randomly with the very same request. So it is not related to anything of the programming logic and I assume this old component is just a bit buggy and fails from time to time. But I would like to handle that situation like try again or give the user a better error messa开发者_JS百科ge. I could also imagine that it is related to the number of apache threads or processes. The event log does not state anyhting and also Apache error log is empty.

I would appreciate any hint how I can handle/catch the problem or where I might find more information.


The following code works for me (Win XP SP3, PHP 5.2.17 (cli) (built: Jan 6 2011 17:37:45)):

<?php
  try
  {
    echo "Trying to create object"."\r\n";
    $obj = new COM("FailingObject");
    echo "Object created";
  }
  catch(com_exception $e)
  {
    echo "Caught exception"."\r\n";
    $c = $e->getCode();
    $m = $e->getMessage();
    echo "Error Code: ".dechex($c)."\r\n";
    echo $m;
  }
?>

Executing this script using PHP on the command line yields the expected result:

Trying to create object
Caught exception
Error Code: 80080008
Failed to create COM object `FailingObject': Object server is stopping when
OLE service contacts it

The tested object "FailingObject" is a simple ATL COM object which uses

HRESULT FinalConstruct()
{
    return CO_E_SERVER_STOPPING;
}

to simulate an error during object creation.

My best guess is (and I could be completely wrong with this) that in your case the error is not thrown by the object creation but by a different COM call somewhere within PHP which then is not handled correctly.

You might consider filing a bug report for this behavior because normally you should be able to catch the error.

0

精彩评论

暂无评论...
验证码 换一张
取 消