php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59025 Creating two SolrQuery objects leads to wrong query value
Submitted: 2010-01-08 11:43 UTC Modified: 2010-01-10 21:33 UTC
From: xavier dot schepler at sciences-po dot fr Assigned: iekpo (profile)
Status: Closed Package: solr (PECL)
PHP Version: 5.2.4 OS: ubuntu5.9
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: xavier dot schepler at sciences-po dot fr
New email:
PHP Version: OS:

 

 [2010-01-08 11:43 UTC] xavier dot schepler at sciences-po dot fr
Description:
------------
It seems that attributes from the first SolrQuery object are presents in the second SolrQuery object attributes.

Reproduce code:
---------------
<?php
	$solrClient = new SolrClient(parse_ini_file('bdq/bdq/application/configs/solr.ini'));
	$solrQuery = new SolrQuery;
	$solrQuery->setQuery('l?gislative');
	$response = $solrClient->query($solrQuery);
	$solrQuery->setShowDebugInfo(true);
	$solrQuery->setHighlight(true);
	$solrQuery->addHighlightField('questionsLabelsFr');
	$solrQuery->addHighlightField('variableLabelsFr');
	$solrQuery->setHighlightFragsize(0);
	var_dump($response);
	$solrQuery = new SolrQuery;
	$solrQuery->setQuery('l?gislative');
	$solrQuery->setShowDebugInfo(true);
	$solrQuery->setHighlight(true);
	$solrQuery->addHighlightField('questionsLabelsFr');
	$solrQuery->addHighlightField('variableLabelsFr');
	$solrQuery->setHighlightFragsize(0);
	$response = $solrClient->query($solrQuery);
	var_dump($response);

Expected result:
----------------
I expected the same results from both queries.

Actual result:
--------------
Here are extracts from the SolrQueryResponse objects dumps :

- First response :
protected 'http_raw_request' => string 'q=l%E9gislative'

- Second response :
protected 'http_raw_request' => string 'q=l%E9gislativeq=l%E9gislative&debugQuery=true&hl=true&hl.fl=questionsLabelsFr%2CvariableLabelsFr&hl.fragsize=0' (length=111)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-01-08 19:35 UTC] iekpo@php.net
The difference in results is as a result of a logic error in the php code.

The first call sends only 1 parameter.
The second call sends 6 parameters.
<?php

    $solrClient = new SolrClient(parse_ini_file('bdq/bdq/application/configs/solr.ini'));
    $solrQuery = new SolrQuery;
    $solrQuery->setQuery('l?gislative');
    // At this point only the 1 parameter has been set
    $response = $solrClient->query($solrQuery);
    
    $solrQuery->setShowDebugInfo(true);
    $solrQuery->setHighlight(true);
    $solrQuery->addHighlightField('questionsLabelsFr');
    $solrQuery->addHighlightField('variableLabelsFr');
    $solrQuery->setHighlightFragsize(0);
    var_dump($response);
    
    $solrQuery = new SolrQuery;
    $solrQuery->setQuery('l?gislative');
    $solrQuery->setShowDebugInfo(true);
    $solrQuery->setHighlight(true);
    $solrQuery->addHighlightField('questionsLabelsFr');
    $solrQuery->addHighlightField('variableLabelsFr');
    $solrQuery->setHighlightFragsize(0);
    
    // At this point 6 parameters have been set.
    $response = $solrClient->query($solrQuery);
    var_dump($response);
 [2010-01-08 22:48 UTC] xavier dot schepler at yahoo dot fr
You're right about the logic error.
It was late in the day and I couldn't concentrate to give you a proper example.
I'm at home and I have not solr installed ATM.
Does it work this way ?

<?php
	$solrClient = new
SolrClient(parse_ini_file('bdq/bdq/application/configs/solr.ini'));
	$solrQuery = new SolrQuery;
	$solrQuery->setQuery('l?gislative');
	$solrQuery->setShowDebugInfo(true);
	$solrQuery->setHighlight(true);
	$solrQuery->addHighlightField('questionsLabelsFr');
	$solrQuery->addHighlightField('variableLabelsFr');
	$solrQuery->setHighlightFragsize(0);
	$response = $solrClient->query($solrQuery);
	var_dump($response);

	$solrQuery = new SolrQuery;
	$solrQuery->setQuery('l?gislative');
	$solrQuery->setShowDebugInfo(true);
	$solrQuery->setHighlight(true);
	$solrQuery->addHighlightField('questionsLabelsFr');
	$solrQuery->addHighlightField('variableLabelsFr');
	$solrQuery->setHighlightFragsize(0);
	$response = $solrClient->query($solrQuery);
	var_dump($response);
 [2010-01-08 22:50 UTC] xavier dot schepler at yahoo dot fr
by the way, you can see in the object dump that the q=l?gislative appears twice, so there is a bug man
 [2010-01-10 04:23 UTC] xavier dot schepler at yahoo dot fr
- First response :
protected 'http_raw_request' => string 'q=l%E9gislative'

- Second response :
protected 'http_raw_request' => string
'q=l%E9gislativeq=l%E9gislative&debugQuery=true&hl=true&hl.fl=questionsL
abelsFr%2CvariableLabelsFr&hl.fragsize=0' (length=111)

Can't you see in the second response q=l%E9gislativeq=l%E9gislative ???? Is it the way it is supposed to work ?

I'm gonna write my own client in PHP and come back to yours latter.
 [2010-01-10 17:53 UTC] iekpo@php.net
Xavier,

I found the problem.

The request data from the previous request was carried over in the buffer and was not reset.

So that is why the requests got concatenated.

I will fix it today and release it sometime tomorrow.
 [2010-01-10 21:33 UTC] iekpo@php.net
This bug has been fixed in SVN.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.

This issue has been resolved in SVN revision number 293379.

The SolrClient request buffer was carrying over that from the previous requests without discarding it prior to building the new request data.

This fix will be available in the next release of the PECL extension.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 12:01:27 2024 UTC