Bug #37546
tx_solr_query::__toString not called when sending request - results in HTTP 400 Bad Request
| Status: | Rejected | Start date: | 2012-05-28 | |
|---|---|---|---|---|
| Priority: | Should have | Due date: | ||
| Assignee: | - | % Done: | 0% |
|
| Category: | Queries | |||
| Target version: | - | |||
| TYPO3 Version: | Has patch: | |||
| PHP Version: | Tags: | |||
| Votes: | 0 |
Description
This is tx_solr 2.1.0 on php 5.3.13:
The following fails:
$query = t3lib_div::makeInstance('tx_solr_Query', '*:*');
$parameters['fl'] = 'uid,type';
$parameters['fq'] = 'appKey:EXT\:myextkey AND type:' . $table;
$response = $solr->search($query, 0, 10000, $parameters);
devlog message:
12-05-28 14:51:20 INFO myextkey Updating Solr Index Queue for myextkey.
12-05-28 14:51:20 FATAL solr Querying Solr using GET
query url => http://usr:pwd@mysolrhost:80/mycore/select?fl=uid%2Ctype&fq=appKey%3AEXT%5C%3Amyextkey+AND+type%3Atx_myextkey_domain_model_xyz&wt=json&json.nl=map&start=0&rows=10000
response => array (
_response => object: Apache_Solr_HttpTransport_Response
_isParsed =>
_parsedData =>
_createDocuments => 1
_collapseSingleValueArrays => 1
)
exception => exception 'Apache_Solr_HttpTransportException' with message ''400' Status: Bad Request' in /home/srv/domains/mysite.nl/public_html/typo3conf/ext/solr/lib/SolrPhpClient/Apache/Solr/Service.php:338
Stack trace:
#0 /home/srv/domains/mysite.nl/public_html/typo3conf/ext/solr/classes/class.tx_solr_solrservice.php(222): Apache_Solr_Service->_sendRawGet('http://solr5043...', false)
#1 /home/srv/domains/mysite.nl/public_html/typo3conf/ext/solr/lib/SolrPhpClient/Apache/Solr/Service.php(1170): tx_solr_SolrService->_sendRawGet('http://solr5043...')
#2 /home/srv/domains/mysite.nl/public_html/typo3conf/ext/solr/classes/class.tx_solr_solrservice.php(194): Apache_Solr_Service->search(Object(tx_solr_Query), 0, 10000, Array)
#3 /home/srv/domains/mysite.nl/public_html/typo3conf/ext/myextkey/Classes/Scheduler/UpdateIndexQueue.php(213): tx_solr_SolrService->search(Object(tx_solr_Query), 0, 10000, Array)
#4 /home/srv/domains/mysite.nl/public_html/typo3conf/ext/myextkey/Classes/Scheduler/UpdateIndexQueue.php(56): tx_MyExtkey_Scheduler_UpdateIndexQueue->updateIndexQueue()
#5 /home/srv/domains/mysite.nl/typo3_src-4.6.8/typo3/sysext/scheduler/class.tx_scheduler.php(173): tx_MyExtkey_Scheduler_UpdateIndexQueue->execute()
#6 /home/srv/domains/mysite.nl/typo3_src-4.6.8/typo3/sysext/scheduler/class.tx_scheduler_module.php(914): tx_scheduler->executeTask(Object(tx_MyExtkey_Scheduler_UpdateIndexQueue))
#7 /home/srv/domains/mysite.nl/typo3_src-4.6.8/typo3/sysext/scheduler/class.tx_scheduler_module.php(204): tx_scheduler_Module->executeTasks()
#8 /home/srv/domains/mysite.nl/typo3_src-4.6.8/typo3/sysext/scheduler/class.tx_scheduler_module.php(147): tx_scheduler_Module->getModuleContent()
#9 /home/srv/domains/mysite.nl/typo3_src-4.6.8/typo3/sysext/scheduler/mod1/index.php(40): tx_scheduler_Module->main()
#10 /home/srv/domains/mysite.nl/typo3_src-4.6.8/typo3/mod.php(45): require('/home/srv/d...')
#11 {main}
what makes the url work is to add a &q=*:* - the q parameter goes missing on the way.
Fix by typecast:
class tx_solr_SolrService extends Apache_Solr_Service {
...
public function search($query, $offset = 0, $limit = 10, $params = array()) {
$response = parent::search((string)$query, $offset, $limit, $params);
...
}
...
}
Apparently the builtin
http_build_querycalled in
Apache_Solr_Service::_generateQueryStringcalled in
Apache_Solr_Service::searchdrops
$params['q'] => $query<tx_solr_Query>instead of invoking
__toString().
History
Updated by Ingo Renner 12 months ago
- Category changed from Solr TYPO3 Plugin to Queries
- Status changed from New to Needs Feedback
- Assignee set to Klaus B
- Priority changed from Must have to Should have
Klaus B wrote:
The following fails:
$response = $solr->search($query, 0, 10000, $parameters);
of what type is $solr ?
Updated by Ingo Renner 11 months ago
- Target version set to 2.2
Updated by Ingo Renner 11 months ago
- Status changed from Needs Feedback to Rejected
- Assignee deleted (
Klaus B) - Target version deleted (
2.2)
It's not a bug, but from your stack trace I can see that you're using the API incorrectly. You need to use tx_solr_Search->search(tx_solr_Query) to search this will internally use tx_solr_SolrService. You should not need to use tx_solr_SolrService yourself.
See http://forge.typo3.org/projects/extension-solr/wiki/Extension_API