[Xapian-discuss] PHP Fatal error while indexing Wikipedia

Olly Betts olly at survex.com
Fri Jan 4 01:41:05 GMT 2008

On Fri, Jan 04, 2008 at 01:07:11AM +0000, James Aylett wrote:
> On Fri, Jan 04, 2008 at 12:21:53AM +0000, Robert Young wrote:
> > $mset = $enquire->get_mset(0, 10);
> > foreach ($mset as $match) {
> >   echo $match->get_document()->get_data() . "\n";
> > }
> > 
> > It's only one line less but I think it's a lot more intuitive.
> We do something akin to the latter in the python bindings, for exactly
> what reason. You should be able to use something like #pragma(php4)
> code="..." to inject PHP code into the final wrapper. If you put it in
> (I think) extra.i inside the php directory, it should do the right
> thing.

Originally, extra.i was for stuff which had to be included after SWIG
had seen all the classes (since util.i needs to be seen first).  I'm
not sure if that's still the case or not though - it's only used by
the python bindings, and they've evolved a lot over time.  It might
be that it now just exists so that the pythoncode gets better syntax
colouring in vim!

> The question then is whether you can augment things
> appropriately in PHP5.

We don't want Enquire::get_mset() to return a "PHPXapianMSetIterator"
as the user might want to have access to the XapianMSet object.

What's really wanted is to replace the "unPHPy" XapianMSetIterator
with a more "PHPy" version, and XapianMSet::begin() and end() with
"foreach ($mset as $item) { ... }".  I'm not very familiar with this
area of PHP5, but it looks like we need to make XapianMSet inherit from
IteratorAggregate and implement a getIterator() method.

Currently there's no way to drop your own PHP code *inside* a generated
class, but perhaps there should be - some of the other SWIG backends
allow similar things.


More information about the Xapian-discuss mailing list