From: Thomas J. <tho...@in...> - 2005-06-13 08:39:49
|
Christophe, On Monday 13 June 2005 10:25, Christophe de VIENNE wrote: > > Document::Init Document::init_; > > > > We use PHP as apache module and have another module linking libxml++. > > The above piece of code totally breaks PHP's XML parser > > just by loading the second module. > > Can you be more precise ? What is broken exactly ? > It the php xml parser is base on libxml2 and use it's callback (as we do > with libxml++), then I don't think a cohexistence is possible. PHP uses libxml2 without those callbacks. As soon as I create a node using PHP function calls, I end up in libxml++'s callback :o) > > Changing the code is not easy as it would break existing applications. > > One possible solution would be to add a check to every constructor if the > > library was already initialized. On the destruction of the last libxml++ > > class if would have to be uninitialized. > > It's unclear to me if the problem comes from a double-initialisation of > libxml++ or a conflit between php and libxml++ which are not able to > 'share' their use of libxml2. > Moreover such a test ( checking to every constructor if the library was > already initialized) is basically what's being done by the static Init > instance. We could maybe add some checks in the Init constructor but I > don't see a case where it's needed : static should do it for us. The problem with the "static" class is that it gets executed during library load time. This is why it breaks PHP. > > A more clean way would be to have an init()/deinit() function. > > Perhaps the use of this mode could be a compile time option? > > > > Please let me know what you think about this. > > I'm unsure about this. I don't think having a different behavior (ie the > user being obliged to call the init/deinit functions) based on a > compile-time option is a good idea. Anyway if the problem really comes from > here you can try and patch libxml++ to see if it's fixing you problems. I already did and it fixed the problem. Took me hours to debug it until I realized what's really happening (PHP just started to segfault). The question is now if there's a more elegant solution than having a compile-time option? Cheers, Thomas |