PHP bindings (was Re: [Xapian-discuss] Q prefix / Unique ID not being found)

James Aylett james-xapian at
Mon Mar 21 10:01:28 GMT 2005

On Mon, Mar 21, 2005 at 07:12:21AM +0000, Olly Betts wrote:

> > I'm on 1.3.23 at the moment. There seems to be something up with the
> > bindings - merely loading them into PHP causes lots of "eek, function
> > redefined" kind of errors.
> Yes, that's the symptom.

This isn't 1.3.23's fault. If you have installed the PHP bindings, and
have put it in the extension autoload list, then it will be loaded
before the script is executed. Running dl() on the .so will then cause
function redefined errors. Removing the .so from the PHP extensions
directory will cause a minor "couldn't load extension" warning, and
the tests pass - this was using 1.3.23 before your last commit, but
with the changes from mine.

We should probably run PHP with a blank config file when testing, so
it doesn't load any of its configured modules.

I also think I've discovered the problem with the Weight director. You
added private clone() which is pure virtual - it seems that SWIG is
generating the director (which is a subclass) without implementing
clone() (presumably because it's private), for the director is still
abstract. Other code requires it to be instantiatable as is.

SWIG probably needs fixing to implement private methods. A short-term
fix on our part might be to make clone() protected, which is slightly
icky, but should do the trick. Haven't had a chance to test this,

> > There is one "Overloaded constructor ignored" (for Document), and we
> > have an unprotected operator() lying around that PHP doesn't know what
> > to do with.
> We should probably run swig with -Werror now that we're running it when
> we build the release tarball rather than on the end user's machine.

Probably. I've #ifndef SWIGPHP4 for the moment on the second
constructor (it's for Database, not Document, so it's not terribly
important as you can use auto() instead).

> > I'm using PHP 4.2.1 built myself; I don't build any of the bindings
> > against Debian.
> The issue is they enabled some threading stuff in zend, which changes
> the zend API slightly.  You're meant to use magic macros which expand to
> nothing in the non-threaded case, but SWIG generates PHP without the
> required macro in one place.

Lovely :-(


  James Aylett                                        
  james at                     

More information about the Xapian-discuss mailing list