[Xapian-discuss] PHP5 - Query Parsing Bug

Yannick Warnier ywarnier at beeznest.org
Sun Mar 27 00:21:23 GMT 2016


I'm replying to a very old thread (9 years ago) here 
http://grokbase.com/t/xapian/xapian-discuss/072tprmr6h/php5-query-parsing-bug

So not sure if that's going to end up being more or less readable...

I have this error :

Fatal error: No matching function for overloaded 'new_Query' in 
/usr/share/php/xapian.php on line 2607

Line 2607 (and surrounding) looks like this and are in the __construct() 
of XapianQuery (with better indentation):

"""
         switch (func_num_args()) {
         case 0: $this->_cPtr=new_Query(); break;
         case 1: 
$this->_cPtr=new_Query($copyme_or_tname__or_op__or_external_source_or_op); 
break;
         case 2: 
$this->_cPtr=new_Query($copyme_or_tname__or_op__or_external_source_or_op,$wqf__or_left_or_q_or_slot_or_subqs); 
break;
         case 3: 
$this->_cPtr=new_Query($copyme_or_tname__or_op__or_external_source_or_op,$wqf__or_left_or_q_or_slot_or_subqs,$pos__or_right_or_parameter_or_begin_or_value_or_param); 
break;
         default: 
$this->_cPtr=new_Query($copyme_or_tname__or_op__or_external_source_or_op,$wqf__or_left_or_q_or_slot_or_subqs,$pos__or_right_or_parameter_or_begin_or_value_or_param,$end);
"""


The patch suggested in the initial post is here: 
http://www.oligarchy.co.uk/xapian/patches/xapian-php5-query-ctor-overload-fix.patch

But clearly, that's not going to do it now (it was adding a "case 1" to 
a single-standing "case 0", but now we've got 0, 1, 2, 3 and default).

The error appear when trying to instanciate a new XapianQuery object 
with a query element:

   new XapianQuery($subquery);

(from 
https://github.com/chamilo/chamilo-lms/blob/1.10.x/main/inc/lib/search/xapian/XapianQuery.php#L44 
)

Honestly, I feel comfortable with PHP but this is one of these 
super-explicit messages that tend to send you in another direction than 
the one you should go.

Assuming the message is correct, we overload an existing PHP function 
"new_Query()" by passing it a different number of parameters than what 
it expects.
So
1) I can't find any php-defined new_Query(): 
http://php.net/manual-lookup.php?pattern=new_Query&lang=en&scope=404quickref
2) the new_Query() function in Xapian might have suddendly removed 
support for a case with one single parameter and not updated the binding 
accordingly? (that seems the most likely)

That's where I start to be bad (looking at C++ code)

Yannick



More information about the Xapian-discuss mailing list