package.xml0000664000175000017500000013675712676753707011722 0ustar omaromar solr pecl.php.net The Apache Solr PHP extension is an extremely fast, light-weight, feature-rich library that allows PHP applications to communicate easily and efficiently with Apache Solr server instances using an object-oriented API. It effectively simplifies the process of interacting with Apache Solr using PHP5 and it already comes with built-in readiness for the latest features. The extension has features such as built-in, serializable query string builder objects which effectively simplifies the manipulation of name-value pair request parameters across repeated requests. The response from the Solr server is also automatically parsed into native php objects whose properties can be accessed as array keys or object properties without any additional configuration on the client-side. Its advanced HTTP client reuses the same connection across multiple requests and provides built-in support for connecting to Solr servers secured behind HTTP Authentication or HTTP proxy servers. It is also able to connect to SSL-enabled containers. Please consult the documentation for more details on features. Included in the source code are phpdoc stubs that enable autocomplete of Solr classes and methods in IDE during development in userland. PECL Solr 2+ is only compatible with Apache Solr Server 4.0+ Omar Shaban omars omars@php.net yes 2016-03-30 2.4.0 2.4.0 stable stable PHP License - PHP 7 Support [Request #70696] - Performance Optimizations - Enabled SolrUtils::getSolrStats() - Fix SolrException*::getInternalInfo - Fix SolrQueryResponse::getRequestUrl returns wrong url with terms [Bug #71591] - Fix SolrClient::deleteByIds Segfaults with invalid ids [Bug #71853] - Fix SolrObject::offsetExists SegFault [Bug #71852] - Fix float formatting with decimal comma [Bug #71568] 5.3 1.4.0 libxml solr Omar Shaban omars omars@php.net yes 2.4.0 2.4.0 stable stable 2016-03-30 PHP License - PHP 7 Support [Request #70696] - Performance Optimizations - Enabled SolrUtils::getSolrStats() - Fix SolrException*::getInternalInfo - Fix SolrQueryResponse::getRequestUrl returns wrong url with terms [Bug #71591] - Fix SolrClient::deleteByIds Segfaults with invalid ids [Bug #71853] - Fix SolrObject::offsetExists SegFault [Bug #71852] - Fix float formatting with decimal comma [Bug #71568] Omar Shaban omars omars@php.net yes 2.3.0 2.3.0 stable stable 2015-11-29 PHP License - Support indexing child/nested documents [Request #70739] - Support nested documents parsing SolrObject [Request #70953] - Support nested documents parsing SolrDocument [Request #70974] - Added maxScore to SolrResponse [Request #68610] - Fixed issues on big endean processors (Remi Collet) - Enhancements on method parameter naming (reflections) Omar Shaban omars omars@php.net yes 2.2.1 2.2.1 stable stable 2015-09-27 PHP License - Fix windows build Omar Shaban omars omars@php.net yes 2.2.0 2.2.0 stable stable 2015-09-26 PHP License - Support Real Time Get (Request #68647) - Support Result Grouping (Request #68793) - Support Field Collapsing (Request #70175) - Support Expand Component (Request #70176) - SolrMissingMandatoryParameterException (Request #70301) - Fix SegFault on Solr Server 500 Response with no msg [xml RW] (Bug #69156) - Fix SegFault on non-phpserialized 500 responses from Solr Server with PHPS RW (Bug #69156) - Fix Failed to parse 500 error response when it lacks msg JSON/PHPS RW (Bug #70495, #70496) - Fix compatibility tests with Solr Server 5 (Bug #70333) - Fix Error unserializing raw response on statistics response having NaN as value (Bug #67394) Omar Shaban omars omars@php.net yes 2.1.0 2.1.0 stable stable 2014-01-15 PHP License - New Feature: SolrDisMaxQuery Builder (dismax/edismax) [Feature #67101] - Support PHPS (PHP Serialized) Response Writer [Request #61329] - SolrResponse::getArrayResponse [Feature #67660] - SolrResponse::getResponse() returns SolrObject instead of array (with json response writer) [Bug #67579] - Argument list parameter: Argument to value separator disappears [Bug #68179] - Conflict Occurs When using SolrDisMax::addBoostQuery and setBoostQuery [Bug #68181] - Doc Fix [Doc #67542] - Internals: simple_list parameter type allow custom delimiter - Internals: Allowed zero-length argument value - Internals: Allowed zero-length argument-to-argument-value separator - Security Fix Omar Shaban omars omars@php.net yes 2.0.0 2.0.0 stable stable 2014-06-24 PHP License - Introduced SolrServerException which handles exception responses produced by Solr Server [Feature #67063] - SolrClient::commit $maxSegments removed - Removed php curl extension dependency for static builds [Bug #59028] - SolrParams/SolrModifiableParams/SolrQuery throws SolrIllegalArguments Exception instead of E_ERROR [Feature #66858] - SolrQuery::__construct throws SolrIllegalArgumentException instead of E_ERROR - Dropped Support for phpnative Response Writer - Fix config that always enables solr debug [Bug #60361] Omar Shaban omars omars@php.net yes 1.1.1 1.1.1 stable stable 2014-06-20 PHP License - Fix Windows Build Omar Shaban omars omars@php.net yes 1.1.0 1.1.0 stable stable 2014-06-19 PHP License 1.1.0 Stable - Introduced SolrServerException which handles exception responses produced by Solr Server [Feature #67063] - SolrClient::commit $maxSegments removed - SolrQuery::__construct throws SolrIllegalArgumentException instead of E_ERROR - Removed php curl extension dependency for static builds [Bug #59028] From 1.1.0b - SolrClient::system Access system servlet which fetch Solr Server System Information - SolrClient::commit argument $maxSegments is now DEPRECATED - SolrClient::commit Added support for expungeDeletes on - All SolrClient methods throws SolrClientExceptions instead of E_WARNING + SolrClientException - SolrClientExceptions' messages are more informative in case of connection errors - Added json extension validation - All SolrResponse, SolrQueryResponse, SolrUpdateResponse, SolrPingResponse, SolrGenericResponse, SolrDocument, and SolrInputDocument classes are now final - All parameters functions throws SolrIllegalArgumentException instead of E_RROR - SolrParams/SolrModifiableParams/SolrQuery throws SolrIllegalArguments Exception instead of E_ERROR [Feature #66858] - Various Bug Fixes Omar Shaban omars omars@php.net yes 1.1.0b 1.1.0b beta beta 2014-03-17 PHP License - SolrClient::system Access system servlet which fetch Solr Server System Information - SolrClient::commit argument $maxSegments is now DEPRECATED - SolrClient::commit Added support for expungeDeletes on - All SolrClient methods throws SolrClientExceptions instead of E_WARNING + SolrClientException - SolrClientExceptions' messages are more informative in case of connection errors - Added json extension validation - All SolrResponse, SolrQueryResponse, SolrUpdateResponse, SolrPingResponse, SolrGenericResponse, SolrDocument, and SolrInputDocument classes are now final - All parameters functions throws SolrIllegalArgumentException instead of E_RROR - SolrParams/SolrModifiableParams/SolrQuery throws SolrIllegalArguments Exception instead of E_ERROR (Feature #66858) - Various Bug Fixes Omar Shaban omars omars@php.net yes 2.0.0b 2.0.0b beta beta 2014-02-28 PHP License - Support Solr version 4.0+ - Added support for retreiving Solr Server system information through SolrClient SolrClient::system() - Support for softCommit - Suppport for expungeDeletes - maxSegments for commit is deprecated - Added escape character / as per Solr 4 it is reserved for REGEX - Disabled warnings for connection errors, SolrClientException is thrown - SolrClientException messages for connection errors are more meaningful indicating error messages and codes - API changes for: SolrClient::commit($maxSegments = 0, $softCommit = false, $waitSearcher = true, $expungeDeletes = false) SolrClient::optimize($maxSegments = 1, $softCommit = false, $waitSearcher = true) SolrClient::addDocument(SolrInputDocument &$doc, $overwrite = true, $commitWithin = 0) SolrClient::addDocuments(array &$docs, $overwrite = true, $commitWithin = 0) - Several Bug Fixes Warning: PECL Solr >= 2 is not compatible with Solr Server < 4.0 Israel Ekpo iekpo iekpo@php.net yes 1.0.2 1.0.2 stable stable 2011-11-29 PHP License - Several Bug Fixes by Pierrick, Felipe and Tony - Changes to make the code compile on 5.2.3 and greater - Changes to Tests by Pierrick Israel Ekpo iekpo iekpo@php.net yes 1.0.1 1.0.1 stable stable 2011-06-04 PHP License - Added support for json response writer in SolrClient - Removed final bit from classes so that they can be mocked in unit tests - Changed from beta to stable - Included phpdoc stubs in source to enable autocomplete of Solr classes and methods in IDE during development - Lowered libxml2 version requirement to 2.6.16 Israel Ekpo iekpo iekpo@php.net yes 0.9.11 0.9.11 beta beta 2010-06-22 PHP License - Added ability to specify response writer in constructor option - Added new method to set response writer SolrClient::setResponseWriter() - Currently, the only supported response writers are 'xml' and 'phpnative' - Added support for new native Solr response writer - New response writer is available at https://issues.apache.org/jira/browse/SOLR-1967 Israel Ekpo iekpo iekpo@php.net yes 0.9.10 0.9.10 beta beta 2010-05-04 PHP License - Increased compatibility with older systems running CentOS 4 or 5 and RHEL4 or 5 - Added ability to compile directly without having to build libcurl and libxml2 from source on older systems - Lowered minimum supported version for libcurl to 7.15.0 (Alex Samorukov) - Lowered minimum supported version for libxml2 to 2.6.26 (Alex Samorukov) - Fixed PECL Bug# 17172 MoreLikeThis only parses one doc (trevor at blubolt dot com, max at blubolt dot com) - Declared workaround macros for SSL private key constants due to support for earlier versions of libcurl (Alex Samorukov) - Changed extension version numbers to start using hexadecimal numbers (Israel Ekpo) - Added instructions on how to attempt to compile on windows (Israel Ekpo) - Fixed PECL Bug# 17292 sending UTF-8 encoding in header (giguet at info dot unicaen dot fr) Israel Ekpo iekpo iekpo@php.net yes 0.9.9 0.9.9 beta beta 2010-01-10 PHP License - Fixed Bug #17009 Creating two SolrQuery objects leads to wrong query value - Reset the buffer for the request data from the previous request in SolrClient - Added new internal static function solr_set_initial_curl_handle_options() - Moved the intialization of CURL handle options to solr_set_initial_curl_handle_options() function - Resetting the CURL options on the (CURL *) handle after each request is completed - Added more explicit error message to indicate that cloning SolrParams objects and its descendants is currently not yet supported Israel Ekpo iekpo iekpo@php.net yes 0.9.8 0.9.8 beta beta 2009-12-04 PHP License - Fixed config.w32 for Windows build support (Pierre, Pierrick) - Fixed Bug #16943 Segmentation Fault from solr_encode_string() during attempt to retrieve solrXmlNode->children->content when solrXmlNode->children is NULL (Israel) - Disabled Expect header in libcurl (Israel) - Disabled Memory Debugging when normal debug is enabled (Israel) - Added list of contributors to the project Israel Ekpo iekpo iekpo@php.net yes 0.9.7 0.9.7 beta beta 2009-11-17 PHP License - Fixed bug 16924 AC_MSG_NOTICE() is undefined in autoconf 2.13 - Added new method SolrClient::getDebug() - Modified SolrClient::__construct() so that port numbers and other integer values for the options can be passed as strings. - Changed internal string handling mechanism to allow for tracking of memory allocation in debug mode. - Lowered minimum php version to 5.2.3. Unfortunately, this is the lowest PHP version that will be supported. PHP versions lower than 5.2.3 are not compatible or are causing tests to FAIL. - Added php stubs for code-completion assists in IDEs and editors. - Added more examples Israel Ekpo iekpo iekpo@php.net yes 0.9.6 0.9.6 beta beta 2009-11-01 PHP License Reduced minimum php version to 5.2.4 Israel Ekpo iekpo iekpo@php.net yes 0.9.5 0.9.5 beta beta 2009-10-27 PHP License Added support for secure connections to SSL-enabled Solr servers (SSL/HTTPS). Made connection errors more verbose. The following options where added to the SolrClient constructor : - secure (Boolean value indicating whether or not to connect in secure mode) - timeout (This is maximum time in seconds allowed for the http data transfer operation. Default is 30 seconds) - ssl_cert (File name to a PEM-formatted file containing the private key + private certificate (concatenated in that order) ) - ssl_key (File name to a PEM-formatted private key file only) - ssl_keypassword (Password for private key) - ssl_cainfo (Name of file holding one or more CA certificates to verify peer with) - ssl_capath (Name of directory holding multiple CA certificates to verify peer with ) Israel Ekpo iekpo iekpo@php.net yes 0.9.4 0.9.4 beta beta 2009-10-23 PHP License Fixed bug 16897 - ap_php_vasprintf not available in 5.2.11 Israel Ekpo iekpo iekpo@php.net yes 0.9.3 0.9.3 beta beta 2009-10-19 PHP License - Corrected configuration options for automated installation via PECL. Removed extra hyphens. Israel Ekpo iekpo iekpo@php.net yes 0.9.2 0.9.2 beta beta 2009-10-19 PHP License - Fixed bug #16874 Added explanation in documentation - Updated SolrParams::__toString() - modified to return name-value pair list instead of serialized object string - Added the following methods to SolrParams : SolrParams::toString() SolrParams::getParam() - Created the following aliases in SolrParams : SolrParams::set() SolrParams::add() SolrParams::get() - Added the following methods to SolrQuery : SolrQuery::getQuery() SolrQuery::getStart() SolrQuery::getRows() SolrQuery::getFields() SolrQuery::getSortFields() SolrQuery::getFilterQueries() SolrQuery::getTimeAllowed() SolrQuery::getFacet() SolrQuery::getFacetFields() SolrQuery::getFacetQueries() SolrQuery::getFacetPrefix() SolrQuery::getFacetSort() SolrQuery::getFacetLimit() SolrQuery::getFacetOffset() SolrQuery::getFacetMinCount() SolrQuery::getFacetMissing() SolrQuery::getFacetMethod() SolrQuery::getFacetDateFields() SolrQuery::getFacetDateStart() SolrQuery::getFacetDateEnd() SolrQuery::getFacetDateGap() SolrQuery::getFacetDateHardEnd() SolrQuery::getFacetDateOther() SolrQuery::getHighlight() SolrQuery::getHighlightFields() SolrQuery::getHighlightSnippets() SolrQuery::getHighlightFragsize() SolrQuery::getHighlightMergeContiguous() SolrQuery::getHighlightRequireFieldMatch() SolrQuery::getHighlightMaxAnalyzedChars() SolrQuery::getHighlightAlternateField() SolrQuery::getHighlightMaxAlternateFieldLength() SolrQuery::getHighlightFormatter() SolrQuery::getHighlightSimplePre() SolrQuery::getHighlightSimplePost() SolrQuery::getHighlightFragmenter() SolrQuery::getHighlightUsePhraseHighlighter() SolrQuery::getHighlightHighlightMultiTerm() SolrQuery::getHighlightRegexSlop() SolrQuery::getHighlightRegexPattern() SolrQuery::getHighlightRegexMaxAnalyzedChars() SolrQuery::getStats() SolrQuery::getStatsFields() SolrQuery::getStatsFacets() SolrQuery::getMlt() SolrQuery::getMltCount() SolrQuery::getMltFields() SolrQuery::getMltQueryFields() SolrQuery::getMltMinTermFrequency() SolrQuery::getMltMinDocFrequency() SolrQuery::getMltMinWordLength() SolrQuery::getMltMaxWordLength() SolrQuery::getMltMaxNumTokens() SolrQuery::getMltMaxNumQueryTerms() SolrQuery::getMltBoost() SolrQuery::getTerms() SolrQuery::getTermsField() SolrQuery::getTermsLowerBound() SolrQuery::getTermsUpperBound() SolrQuery::getTermsIncludeLowerBound() SolrQuery::getTermsIncludeUpperBound() SolrQuery::getTermsMinCount() SolrQuery::getTermsMaxCount() SolrQuery::getTermsPrefix() SolrQuery::getTermsLimit() SolrQuery::getTermsReturnRaw() SolrQuery::getTermsSort() Israel Ekpo iekpo iekpo@php.net yes 0.9.1 0.9.1 beta beta 2009-10-07 PHP License - Fixed bug #16864 (Build failure in Non-ZTS builds) Israel Ekpo iekpo iekpo@php.net yes 0.9.0 0.9.0 beta beta 2009-10-05 PHP License - Initial release after approximately 10 months of development and 3 weeks of testing. This is the beta version. Some of the features may be modified in future releases. solr-2.4.0/examples/bootstrap.php0000644000175000017500000000004212676753706015535 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient($options); $query = new SolrQuery('*:*'); $query->setFacet(true); $query->addFacetField('cat')->addFacetField('name')->setFacetMinCount(2); $updateResponse = $client->query($query); $response_array = $updateResponse->getResponse(); $facet_data = $response_array->facet_counts->facet_fields; print_r($facet_data); solr-2.4.0/examples/facet_002.php0000644000175000017500000000116712676753706015174 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient($options); $query = new SolrQuery('*:*'); $query->setFacet(true); $query->addFacetField('cat')->addFacetField('name')->setFacetMinCount(2); $query->setFacetMinCount(4, 'name'); $updateResponse = $client->query($query); $response_array = $updateResponse->getResponse(); $facet_data = $response_array->facet_counts->facet_fields; print_r($facet_data); solr-2.4.0/examples/solrclient_001_adddocument_01.php0000644000175000017500000000114112676753706021126 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient($options); $doc = new SolrInputDocument(); $doc->addField('id', 334455); $doc->addField('cat', 'Software'); $doc->addField('cat', 'Lucene'); $updateResponse = $client->addDocument($doc); print_r($updateResponse->getResponse()); /* you will have to commit changes to be written if you didn't use $commitWithin */ $client->commit(); solr-2.4.0/examples/solrclient_002_adddocument_02.php0000644000175000017500000000116612676753706021137 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient($options); $doc = new SolrInputDocument(); $doc->addField('id', 334455); $doc->addField('cat', 'Software'); $doc->addField('cat', 'Lucene'); // No need to call commit() because $commitWithin is passed, so Solr Server will auto commit within 10 seconds $updateResponse = $client->addDocument($doc, false, 10000); print_r($updateResponse->getResponse()); solr-2.4.0/examples/solrclient_002_adddocument_03_child_docs.php0000644000175000017500000000312212676753706023305 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_STORE_PATH, ); $client = new SolrClient($options); $product = new SolrInputDocument(); $product->addField('id', 'black'); $product->addField('cat', 'tshirt'); $product->addField('cat', 'polo'); $product->addField('content_type', 'product'); $small = new SolrInputDocument(); $small->addField('id', 'TS-BLK-S'); $small->addField('content_type', 'sku'); $small->addField('size', 'S'); $small->addField('inventory', 100); $medium = new SolrInputDocument(); $medium->addField('id', 'TS-BLK-M'); $medium->addField('content_type', 'sku'); $medium->addField('size', 'M'); $medium->addField('inventory', 200); $large = new SolrInputDocument(); $large->addField('id', 'TS-BLK-L'); $large->addField('content_type', 'sku'); $large->addField('size', 'L'); $large->addField('inventory', 300); // add child documents $product->addChildDocument($small); $product->addChildDocument($medium); $product->addChildDocument($large); // or // $skus = [$small, $medium, $large]; // $product->addChildDocuments($skus); // add product document to the index $updateResponse = $client->addDocument( $product, true, // overwrite if the document exists 10000 // commit within 10 seconds ); print_r($updateResponse->getResponse()); /* OUTPUT SIMILAR TO: SolrObject Object ( [responseHeader] => SolrObject Object ( [status] => 0 [QTime] => 5 ) ) */ solr-2.4.0/examples/solrclient_003_adddocuments_01.php0000644000175000017500000000131712676753706021320 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient($options); $doc = new SolrInputDocument(); $doc->addField('id', 334455); $doc->addField('cat', 'Software'); $doc->addField('cat', 'Lucene'); $doc2 = clone $doc; $doc2->deleteField('id'); $doc2->addField('id', 334456); $docs = array($doc, $doc2); $updateResponse = $client->addDocuments($docs); /* you will have to commit changes to be written if you didn't use $commitWithin */ $client->commit(); print_r($updateResponse->getResponse()); solr-2.4.0/examples/solrclient_004_adddocuments_02.php0000644000175000017500000000116212676753706021320 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient($options); $doc = new SolrInputDocument(); $doc->addField('id', 334455); $doc->addField('cat', 'Software'); $doc->addField('cat', 'Lucene'); $doc2 = clone $doc; $doc2->deleteField('id'); $doc2->addField('id', 334456); $docs = array($doc, $doc2); $updateResponse = $client->addDocuments($docs, true, 1024); print $updateResponse->getRawRequest(); solr-2.4.0/examples/solrclient_005_optimize.php0000644000175000017500000000063112676753706020206 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient($options); $update_response = $client->optimize(4, false, false); $response = $update_response->getRawRequest(); print_r($response); solr-2.4.0/examples/solrclient_006_commit.php0000644000175000017500000000063212676753706017640 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient($options); $update_response = $client->commit(true, false, false); $response = $update_response->getRawRequest(); print_r($response); solr-2.4.0/examples/solrclient_007_query.php0000644000175000017500000000110412676753706017511 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient($options); $query = new SolrQuery(); $query->setQuery('lucene'); $query->setStart(0); $query->setRows(50); $query->addField('cat')->addField('features')->addField('id')->addField('timestamp'); $query_response = $client->query($query); $response = $query_response->getResponse(); print_r($response); solr-2.4.0/examples/solrclient_008_query_lucene.php0000644000175000017500000000114612676753706021053 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient($options); $query = new SolrQuery(); $query->setQuery('manu:"Apple Computer Inc." OR text:apple'); $query->setStart(0); $query->setRows(50); $query->addField('cat')->addField('features')->addField('id')->addField('timestamp'); $query_response = $client->query($query); $response = $query_response->getResponse(); print_r($response); solr-2.4.0/examples/solrclient_009_query_parsemode.php0000644000175000017500000000120712676753706021556 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient($options); $query = new SolrQuery(); $query->setQuery('lucene'); $query->setStart(0); $query->setRows(50); $query->addField('cat')->addField('features')->addField('id')->addField('timestamp'); $query_response = $client->query($query); $query_response->setParseMode(SolrQueryResponse::PARSE_SOLR_DOC); $response = $query_response->getResponse(); print_r($response); solr-2.4.0/examples/solrdocument_001.php0000644000175000017500000000045212676753706016623 0ustar omaromaraddField('id', 1123); $doc->features = "PHP Client Side"; $doc->features = "Fast development cycles"; $doc['cat'] = 'Software'; $doc['cat'] = 'Custom Search'; $doc->cat = 'Information Technology'; print_r($doc->toArray()); ?>solr-2.4.0/examples/solrdocument_002.php0000644000175000017500000000056712676753706016633 0ustar omaromaraddField('id', 1123); $doc->features = "PHP Client Side"; $doc->features = "Fast development cycles"; $doc['cat'] = 'Software'; $doc['cat'] = 'Custom Search'; $doc->cat = 'Information Technology'; foreach ($doc as $fieldname => $fieldvalues) { print "$fieldname\n"; print_r($fieldvalues); } ?>solr-2.4.0/examples/solrdocument_003.php0000644000175000017500000000053212676753706016624 0ustar omaromaraddField('id', 1123); $doc->features = "PHP Client Side"; $doc->features = "Fast development cycles"; $doc['cat'] = 'Software'; $doc['cat'] = 'Custom Search'; $doc->cat = 'Information Technology'; $input_doc = $doc->getInputDocument(); var_dump(get_class($input_doc)); ?>solr-2.4.0/examples/solrdocument_004.php0000644000175000017500000000064612676753706016633 0ustar omaromaraddField('id', 1123); $doc->features = "PHP Client Side"; $doc->features = "Fast development cycles"; $doc['cat'] = 'Software'; $doc['cat'] = 'Custom Search'; $doc->cat = 'Information Technology'; $second_doc->addField('cat', 'Lucene Search'); $second_doc->merge($doc, true); print_r($second_doc->toArray()); ?>solr-2.4.0/examples/solrobject_001.php0000644000175000017500000000026012676753706016250 0ustar omaromarsolr-2.4.0/examples/solrobject_002.php0000644000175000017500000000034112676753706016251 0ustar omaromaremail = "iekpo@php.net"; } catch (Exception $e) { var_dump($e->getCode()); var_dump($e->getMessage()); } var_dump($solrObject->getPropertyNames()); ?>solr-2.4.0/examples/solrobject_003.php0000644000175000017500000000033012676753706016250 0ustar omaromarsystem->threadDump->thread->stackTrace); ?>solr-2.4.0/examples/solrobject_004.php0000644000175000017500000000041112676753706016251 0ustar omaromarresponseHeader); $system = $solrObject->system; print_r($header); print_r($system); ?>solr-2.4.0/examples/solrobject_005.php0000644000175000017500000000041612676753706016257 0ustar omaromar solr-2.4.0/examples/solrquery_001.php0000644000175000017500000000061212676753706016150 0ustar omaromarsetParam('a', 1); $query->setParam('b', 2); $query->setParam('c', 3); $query->setStart(4)->setQuery('solr')->setTimeAllowed(500)->setRows(17); $query->addField('israel')->addField('joshua')->addField('june'); $query->addSortField('cat', 0); $query->addFilterQuery('solr')->addFilterQuery('solr1')->addFilterQuery('solr2'); echo $query; echo "\n";solr-2.4.0/examples/solrquery_002_facet.php0000644000175000017500000000113512676753706017314 0ustar omaromarsetFacet(0); $query->addFacetField('israel')->addFacetField('israel2'); $query->addFacetQuery('silk')->addFacetQuery('name:june'); $query->setFacetPrefix('A')->setFacetPrefix('C', 'june'); $query->setFacetSort(1)->setFacetSort(0, 'june'); // $query->setFacetLimit(98)->setFacetLimit(44, 'june'); $query->setFacetOffset(110)->setFacetOffset(12, 'june'); $query->setFacetMinCount(4)->setFacetMinCount(30, 'june'); $query->setFacetMissing(1)->setFacetMissing(0, 'june'); $query->setFacetMethod('enum')->setFacetMethod('fc', 'june'); echo $query; echo "\n";solr-2.4.0/examples/solrquery_003_date_facet.php0000644000175000017500000000140712676753706020314 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient($options); $query = new SolrQuery('*:*'); $query->setFacet(true); $query->addFacetDateField('manufacturedate_dt'); $query->setFacetDateStart('2006-02-13T00:00:00Z'); $query->setFacetDateEnd('2012-02-13T00:00:00Z'); $query->setFacetDateGap('+1YEAR'); $query->setFacetDateHardEnd(1); $query->addFacetDateOther('before'); $updateResponse = $client->query($query); $response_array = $updateResponse->getResponse(); $facet_data = $response_array->facet_counts->facet_dates; print_r($facet_data); solr-2.4.0/examples/solrquery_004_highlight.php0000644000175000017500000000304412676753706020204 0ustar omaromarsetHighlight(0); $query->addHighlightField('a')->addHighlightField('a')->addHighlightField('a'); $query->removeHighlightField('a')->removeHighlightField('a')->removeHighlightField('a'); $query->setHighlightSnippets(4)->setHighlightSnippets(5, 'june'); $query->setHighlightFragsize(41)->setHighlightFragsize(52, 'june'); $query->setHighlightMergeContiguous(true)->setHighlightMergeContiguous(false, 'june'); $query->setHighlightRequireFieldMatch(true); $query->setHighlightMaxAnalyzedChars(44)->setHighlightMaxAnalyzedChars(53); $query->setHighlightAlternateField('pizza')->setHighlightAlternateField('bread', 'june'); $query->setHighlightAlternateField('blue')->setHighlightAlternateField('red','june'); $query->setHighlightAlternateField('a')->setHighlightAlternateField('b','june'); $query->setHighlightMaxAlternateFieldLength(300)->setHighlightMaxAlternateFieldLength(335, 'june'); $query->setHighlightFormatter('F')->setHighlightFormatter('G', 'june'); $query->setHighlightSimplePre('OO')->setHighlightSimplePre('PP', 'june'); $query->setHighlightSimplePost('ZZ')->setHighlightSimplePost('YY', 'june'); $query->setHighlightFragmenter('gap')->setHighlightFragmenter('space', 'june'); $query->setHighlightUsePhraseHighlighter(false); $query->setHighlightHighlightMultiTerm(1); $query->setHighlightRegexSlop(0.0025); $query->setHighlightRegexPattern("israel")->setHighlightRegexPattern("ekpo"); $query->setHighlightRegexMaxAnalyzedChars(444)->setHighlightRegexMaxAnalyzedChars(5.0); echo $query; echo "\n"; solr-2.4.0/examples/solrquery_005_stats.php0000644000175000017500000000036612676753706017400 0ustar omaromarsetStats(0); $query->addStatsField('hello')->addStatsField('june')->removeStatsField('hello'); $query->addStatsFacet('world')->addStatsFacet('pear')->removeStatsFacet('world'); echo $query; echo "\n"; solr-2.4.0/examples/solrquery_006_mlt.php0000644000175000017500000000102212676753706017025 0ustar omaromarsetMlt(1); $query->setMltCount(55)->setMltCount(90); $query->addMltField('june')->addMltField('joshua')->addMltField('mom')->removeMltField('joshua'); $query->addMltQueryField('june', 0.0)->addMltQueryField('israel', 9.558); $query->setMltMinTermFrequency(9); $query->setMltMinDocFrequency(5); $query->setMltMinWordLength(8); $query->setMltMaxWordLength(99); $query->setMltMaxNumTokens(6); $query->setMltMaxNumQueryTerms(2); $query->setMltBoost(true); echo $query; echo "\n"; solr-2.4.0/examples/solrquery_007_terms.php0000644000175000017500000000071112676753706017370 0ustar omaromarsetTerms(true); $query->setTermsField('israel'); $query->setTermsLowerBound('june'); $query->setTermsUpperBound('joshua'); $query->setTermsIncludeLowerBound(false); $query->setTermsIncludeUpperBound(0); $query->setTermsMinCount(50); $query->setTermsMaxCount(200); $query->setTermsPrefix('A'); $query->setTermsLimit(45); $query->setTermsReturnRaw(false); $query->setTermsSort(0); echo $query; echo "\n"; solr-2.4.0/examples/solrutils_001_digestxmlresponse.php0000644000175000017500000000033512676753706022004 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, ); $client = new SolrClient($options); $query = new SolrQuery(); $userInput = 'USB/2'; $escapedUserInput = SolrUtils::escapeQueryChars($userInput); $query->setQuery('text:'.$escapedUserInput); echo $query.PHP_EOL; solr-2.4.0/examples/terms_001.php0000644000175000017500000000070312676753706015236 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient($options); $query = new SolrQuery(); $query->setTerms(true); $query->setTermsField('cat'); $updateResponse = $client->query($query); print_r($updateResponse->getResponse()); solr-2.4.0/examples/terms_002.php0000644000175000017500000000103212676753706015233 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient($options); $query = new SolrQuery(); $query->setTerms(true); /* Return only terms starting with $prefix */ $prefix = 'c'; $query->setTermsField('cat')->setTermsPrefix($prefix); $updateResponse = $client->query($query); print_r($updateResponse->getResponse()); solr-2.4.0/examples/terms_003.php0000644000175000017500000000121212676753706015234 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient($options); $query = new SolrQuery(); $query->setTerms(true); /* Return only terms starting with $prefix */ $prefix = 'c'; /* Return only terms with a frequency of 2 or greater */ $min_frequency = 2; $query->setTermsField('cat')->setTermsPrefix($prefix)->setTermsMinCount($min_frequency); $updateResponse = $client->query($query); print_r($updateResponse->getResponse()); solr-2.4.0/examples/test.config.php0000644000175000017500000000332112676753706015746 0ustar omaromar solr-2.4.0/examples/solrdismaxquery_001.php0000644000175000017500000000174512676753706017366 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient($options); $disMaxQuery = new SolrDisMaxQuery(); $disMaxQuery->setStart(0)->setQuery('solr')->setTimeAllowed(500)->setRows(17); $disMaxQuery->addSortField('price', 0); $disMaxQuery ->setQueryAlt('*:*')->addQueryField('text', 1.5) ->addQueryField('title', 5) ->addBoostQuery('cat', 'electronics', 2) ->setQueryPhraseSlop(1) ->setBigramPhraseSlop(3) ->addBigramPhraseField('text', 2.5) ->addBigramPhraseField('type', 3, 4) ->setTrigramPhraseFields('content^0.5 anchor~4^1.5 title^1.2 site^1.5') ; $queryResponse = $client->query($disMaxQuery); $response = $queryResponse->getResponse(); if($response->response->numFound > 0) { $docs = $response->response->docs; print_r($docs); } else { echo "No Documents Found".PHP_EOL; } solr-2.4.0/examples/solrclient_010_getbyid.php0000644000175000017500000000054712676753706017777 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH ); $client = new SolrClient($options); $response = $client->getById('GB18030TEST'); print_r($response->getResponse()); solr-2.4.0/examples/solrclient_011_getbyids.php0000644000175000017500000000056612676753706020164 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH ); $client = new SolrClient($options); $response = $client->getByIds(['GB18030TEST', '6H500F0']); print_r($response->getResponse()); solr-2.4.0/examples/solrclient_012_system.php0000644000175000017500000000060412676753706017670 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient($options); $query_response = $client->system(); $response = $query_response->getResponse(); print_r($response); solr-2.4.0/examples/solrquery_008_facetquery.php0000644000175000017500000000105512676753706020411 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient($options); $query = new SolrQuery('*:*'); $query->setFacet(true); $query->addFacetQuery('price:[* TO 500]')->addFacetQuery('price:[500 TO *]'); $query_response = $client->query($query); $response = $query_response->getResponse(); print_r($response->facet_counts->facet_queries); solr-2.4.0/examples/solrquery_009_grouping.php0000644000175000017500000000115712676753706020077 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH ); $client = new SolrClient($options); $query = new SolrDismaxQuery('*:*'); $query->setRows(4); $query->setGroup(true); $query->addGroupField('manu_s_id'); $query->setGroupLimit(2); $query->addGroupSortField('price', SolrQuery::ORDER_ASC); $query->setGroupNGroups(true); $query_response = $client->query($query); $response = $query_response->getResponse(); print_r($response); solr-2.4.0/examples/solrquery_010_collapse.php0000644000175000017500000000123712676753706020036 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH ); $client = new SolrClient($options); $query = new SolrQuery('*:*'); $collapseFunction = new SolrCollapseFunction('manu_id_s'); $collapseFunction ->setSize(2) ->setNullPolicy(SolrCollapseFunction::NULLPOLICY_IGNORE); // $collapseFunction->setMax('sum(cscore(),field(A))'); $query ->collapse($collapseFunction) ->setRows(4); $queryResponse = $client->query($query); $response = $queryResponse->getResponse(); print_r($response); solr-2.4.0/examples/solrquery_011_expand.php0000644000175000017500000000126212676753706017512 0ustar omaromar SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH ); $client = new SolrClient($options); $query = new SolrQuery('*:*'); $func = new SolrCollapseFunction('manu_id_s'); $query->collapse($func); $query->setExpand(true); $query->setExpandRows(10); $query->setExpandQuery('manu_id_s:corsair'); $query->addExpandFilterQuery('inStock:true'); $query->addExpandSortField('score', SolrQuery::ORDER_DESC); $queryResponse = $client->query($query); $response = $queryResponse->getResponse(); print_r($response); solr-2.4.0/tests/files/bug67394.json0000644000175000017500000000143512676753706015531 0ustar omaromar{ "responseHeader": { "status": 0, "QTime": 5, "params": { "fl": "date", "indent": "true", "start": "0", "stats": "true", "stats.field": "date", "q": "bahruz", "_": "1402067668264", "wt": "json", "rows": "1" } }, "response": { "numFound": 1039, "start": 0, "docs": [ { "date": "2012-10-10T15:05:18Z" } ] }, "stats": { "stats_fields": { "date": { "min": "2011-10-20T11:16:34Z", "max": "2014-06-04T13:41:45Z", "count": 1039, "missing": 0, "sum": "47085-11-30T17:59:27.999Z", "mean": "2013-06-03T17:17:43.684Z", "sumOfSquares": -234260129500201700000, "stddev": "NaN", "facets": {} } } } } solr-2.4.0/tests/files/bug67394.xml0000644000175000017500000000120212676753706015350 0ustar omaromar 0 72 0 0 0.0 0.0 NaN 0.0 solr-2.4.0/tests/files/response_xml.1.xml0000644000175000017500000002504612676753706017047 0ustar omaromar 07215151321http-8983-3WAITINGorg.apache.tomcat.util.net.JIoEndpoint$Worker@1bf68a960.0000ms40.0000msjava.lang.Object.wait(Native Method)java.lang.Object.wait(Object.java:474)org.apache.tomcat.util.net.JIoEndpoint$Worker.await(JIoEndpoint.java:416)org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:442)java.lang.Thread.run(Thread.java:595)20http-8983-2WAITINGorg.apache.tomcat.util.net.JIoEndpoint$Worker@1706eb70.0000ms0.0000msjava.lang.Object.wait(Native Method)java.lang.Object.wait(Object.java:474)org.apache.tomcat.util.net.JIoEndpoint$Worker.await(JIoEndpoint.java:416)org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:442)java.lang.Thread.run(Thread.java:595)19http-8983-1RUNNABLE160.0000ms160.0000mssun.management.ThreadImpl.getThreadInfo0(Native Method)sun.management.ThreadImpl.getThreadInfo(ThreadImpl.java:142)org.apache.solr.handler.admin.ThreadDumpHandler.handleRequestBody(ThreadDumpHandler.java:73)org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:131)org.apache.solr.core.SolrCore.execute(SolrCore.java:1299)org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:338)org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:241)org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)java.lang.Thread.run(Thread.java:595)17TP-MonitorTIMED_WAITINGorg.apache.tomcat.util.threads.ThreadPool$MonitorRunnable@74db2c0.0000ms0.0000msjava.lang.Object.wait(Native Method)org.apache.tomcat.util.threads.ThreadPool$MonitorRunnable.run(ThreadPool.java:565)java.lang.Thread.run(Thread.java:595)16TP-Processor4RUNNABLEtrue0.0000ms0.0000msjava.net.PlainSocketImpl.socketAccept(Native Method)java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)java.net.ServerSocket.implAccept(ServerSocket.java:450)java.net.ServerSocket.accept(ServerSocket.java:421)org.apache.jk.common.ChannelSocket.accept(ChannelSocket.java:306)org.apache.jk.common.ChannelSocket.acceptConnections(ChannelSocket.java:660)org.apache.jk.common.ChannelSocket$SocketAcceptor.runIt(ChannelSocket.java:870)org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)java.lang.Thread.run(Thread.java:595)15TP-Processor3WAITINGorg.apache.tomcat.util.threads.ThreadPool$ControlRunnable@1e164830.0000ms0.0000msjava.lang.Object.wait(Native Method)java.lang.Object.wait(Object.java:474)org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:662)java.lang.Thread.run(Thread.java:595)14TP-Processor2WAITINGorg.apache.tomcat.util.threads.ThreadPool$ControlRunnable@8ddb930.0000ms0.0000msjava.lang.Object.wait(Native Method)java.lang.Object.wait(Object.java:474)org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:662)java.lang.Thread.run(Thread.java:595)13TP-Processor1WAITINGorg.apache.tomcat.util.threads.ThreadPool$ControlRunnable@14ab51b0.0000ms0.0000msjava.lang.Object.wait(Native Method)java.lang.Object.wait(Object.java:474)org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:662)java.lang.Thread.run(Thread.java:595)12http-8983-Acceptor-0RUNNABLEtrue0.0000ms0.0000msjava.net.PlainSocketImpl.socketAccept(Native Method)java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)java.net.ServerSocket.implAccept(ServerSocket.java:450)java.net.ServerSocket.accept(ServerSocket.java:421)org.apache.tomcat.util.net.DefaultServerSocketFactory.acceptSocket(DefaultServerSocketFactory.java:61)org.apache.tomcat.util.net.JIoEndpoint$Acceptor.run(JIoEndpoint.java:310)java.lang.Thread.run(Thread.java:595)11ContainerBackgroundProcessor[StandardEngine[Catalina]]TIMED_WAITING1400.0000ms920.0000msjava.lang.Thread.sleep(Native Method)org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1579)java.lang.Thread.run(Thread.java:595)10pool-1-thread-1WAITING100.0000ms100.0000mssun.misc.Unsafe.park(Native Method)java.util.concurrent.locks.LockSupport.park(LockSupport.java:118)java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1841)java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:359)java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:470)java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:674)java.lang.Thread.run(Thread.java:595)4Signal DispatcherRUNNABLE0.0000ms0.0000ms3FinalizerWAITINGjava.lang.ref.ReferenceQueue$Lock@1b82d690.0000ms0.0000msjava.lang.Object.wait(Native Method)java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:120)java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:136)java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)2Reference HandlerWAITINGjava.lang.ref.Reference$Lock@ad65130.0000ms0.0000msjava.lang.Object.wait(Native Method)java.lang.Object.wait(Object.java:474)java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)1mainRUNNABLEtrue3340.0000ms3180.0000msjava.net.PlainSocketImpl.socketAccept(Native Method)java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)java.net.ServerSocket.implAccept(ServerSocket.java:450)java.net.ServerSocket.accept(ServerSocket.java:421)org.apache.catalina.core.StandardServer.await(StandardServer.java:389)org.apache.catalina.startup.Catalina.await(Catalina.java:642)org.apache.catalina.startup.Catalina.start(Catalina.java:602)sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)java.lang.reflect.Method.invoke(Method.java:585)org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) solr-2.4.0/tests/files/response_xml.2.xml0000644000175000017500000000070612676753706017044 0ustar omaromar parent_1 CHILD_1_1 parent_2 CHILD_2_1 CHILD_2_2 not_a_parent_1 solr-2.4.0/tests/files/response_xml.3.xml0000644000175000017500000000164712676753706017052 0ustar omaromar parent_1 Solr adds block join support CHILD_1_1 SolrCloud supports it too! parent_2 CHILD_2_1 Cool features CHILD_2_2 Cool features parent_3 CHILD_3_1 Cool features solr-2.4.0/tests/files/response_xml.4.xml0000644000175000017500000000372112676753706017046 0ustar omaromar 0 0 *:* 0 2 xml GB18030TEST Test with some GB18030 encoded characters No accents here 这是一个功能 This is a feature (translated) 这份文件是很有光泽 This document is very shiny (translated) 0.0 true 1513324811722424320 SP2514N Samsung SpinPoint P120 SP2514N - hard drive - 250 GB - ATA-133 Samsung Electronics Co. Ltd. samsung electronics hard drive 7200RPM, 8MB cache, IDE Ultra ATA-133 NoiseGuard, SilentSeek technology, Fluid Dynamic Bearing (FDB) motor 92.0 6 true 2006-02-13T15:26:37Z 35.0752,-97.032 1513324812366249984 solr-2.4.0/tests/bootstrap.inc0000644000175000017500000000041312676753706015045 0ustar omaromargetCode(), $e->getMessage()). PHP_EOL; }solr-2.4.0/tests/skip.if.server_not_configured.inc0000644000175000017500000000016512676753706020771 0ustar omaromarsolr-2.4.0/tests/test.config.inc0000644000175000017500000000351312676753706015257 0ustar omaromar solr-2.4.0/tests/000.solrclient_ping.phpt0000644000175000017500000000110212676753706016717 0ustar omaromar--TEST-- SolrClient::ping() - Ping Solr Server --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH ); $client = new SolrClient($options); $pingResponse = $client->ping(); echo $pingResponse->getRawResponse(); ?> --EXPECT-- HTTP/1.1 200 OK Content-Type: application/xml; charset=UTF-8 Content-Length: 0solr-2.4.0/tests/000.solr_server_compat.phpt0000644000175000017500000000125012676753706017440 0ustar omaromar--TEST-- Solr Server 4+ Compatibility Test --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH ); $client = new SolrClient($options); $query_response = $client->system(); $solrVersion = $query_response->getResponse()->lucene['solr-spec-version']; $match = preg_match('#([0-9]+)\.[0-9]+\.[0-9]+#', $solrVersion, $matches); var_dump($matches[1] >=4 ); ?> --EXPECTF-- bool(true)solr-2.4.0/tests/001.solrclient_addDocument.phpt0000644000175000017500000000176512676753706020231 0ustar omaromar--TEST-- SolrClient::addDocument() - sending document to the Solr server --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient($options); $doc = new SolrInputDocument(); $doc->addField('id', 334455); $doc->addField('cat', 'Software'); $doc->addField('cat', 'Lucene'); $doc2 = new SolrInputDocument(); $doc2->addField('id', 12345); $doc->addField('cat', 'Category1'); $doc->addField('cat', 'Category2'); $updateResponse = $client->addDocument($doc, true, 500); $updateResponse = $client->addDocument($doc2, true, 500); print_r($updateResponse->getResponse()); ?> --EXPECTF-- SolrObject Object ( [responseHeader] => SolrObject Object ( [status] => 0 [QTime] => %d ) ) solr-2.4.0/tests/002.solrclient_addDocuments.phpt0000644000175000017500000000175412676753706020413 0ustar omaromar--TEST-- SolrClient::addDocuments() - sending multiple documents to the Solr server --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient($options); $doc = new SolrInputDocument(); $doc->addField('id', 334455); $doc->addField('cat', 'Software'); $doc->addField('cat', 'Lucene'); $doc2 = new SolrInputDocument(); $doc2->addField('id', 12345); $doc->addField('cat', 'Category1'); $doc->addField('cat', 'Category2'); $docs = array($doc, $doc2); $updateResponse = $client->addDocuments($docs); $client->commit(); print_r($updateResponse->getResponse()); ?> --EXPECTF-- SolrObject Object ( [responseHeader] => SolrObject Object ( [status] => 0 [QTime] => %d ) ) solr-2.4.0/tests/003.solrclient_addDocument_no_overwrite.phpt0000644000175000017500000000156112676753706023027 0ustar omaromar--TEST-- SolrClient::addDocument() - Overwrite an existing document --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH ); $client = new SolrClient($options); $doc = new SolrInputDocument(); $doc->addField('id', 334455); $doc->addField('cat', 'Software'); $doc->addField('cat', 'Solr'); $updateResponse = $client->addDocument($doc, false); $client->commit(); print $updateResponse->getRawRequest(); ?> --EXPECT-- 334455 Software Solr solr-2.4.0/tests/004.solrclient_query_response.phpt0000644000175000017500000000201612676753706021056 0ustar omaromar--TEST-- SolrClient::query() - Sending a chained query request --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient($options); $query = new SolrQuery(); $query->setQuery('lucene'); $query->setStart(0); $query->setRows(50); $query->addField('cat')->addField('features')->addField('id')->addField('timestamp'); $query_response = $client->query($query); $response = $query_response->getResponse(); var_dump(get_class($response->responseHeader->params) == 'SolrObject'); var_dump(property_exists($response->responseHeader->params, 'q')); var_dump(property_exists($response->responseHeader->params, 'wt')); var_dump(property_exists($response->responseHeader->params, 'version')); ?> --EXPECTF-- bool(true) bool(true) bool(true) bool(true)solr-2.4.0/tests/005.solrclient_query_error.phpt0000644000175000017500000000133412676753706020354 0ustar omaromar--TEST-- SolrClient::query() - throw SolrClientException on Solr Server exception --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH ); $client = new SolrClient($options); $query = new SolrQuery("lucene\\"); try { $query_response = $client->query($query); } catch (SolrServerException $e) { echo $e->getMessage(); } ?> --EXPECTF-- %s: Cannot parse 'lucene\': Lexical error at line 1, column 8. Encountered: after : ""solr-2.4.0/tests/006.solrclient_system.phpt0000644000175000017500000000120612676753706017321 0ustar omaromar--TEST-- SolrClient::system() - Retrieve Solr Server/System Info --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH ); $client = new SolrClient($options); $genericResponse = $client->system(); var_dump(get_class($genericResponse->getResponse())) . PHP_EOL; var_dump(get_class($genericResponse->getResponse()->system)); ?> --EXPECTF-- string(10) "SolrObject" string(10) "SolrObject" solr-2.4.0/tests/007.solrclient_deleteByIds.phpt0000644000175000017500000000216712676753706020202 0ustar omaromar--TEST-- SolrClient::deleteByIds() - Test deleting documents by an array of IDS --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH ); $client = new SolrClient($options); $response = $client->deleteByIds(array('334455','334456')); $client->commit(); print_r($response->getResponse()); try { $client->deleteByIds(array(0)); } catch (SolrIllegalArgumentException $e) { echo sprintf("Exception %d: %s", $e->getCode(), $e->getMessage()). PHP_EOL; } try { $client->deleteByIds(array('334455', '')); } catch (SolrIllegalArgumentException $e) { echo sprintf("Exception %d: %s", $e->getCode(), $e->getMessage()). PHP_EOL; } ?> --EXPECTF-- SolrObject Object ( [responseHeader] => SolrObject Object ( [status] => %d [QTime] => %d ) ) Exception 4000: Id number 1 is not a valid string Exception 4000: Id number 2 is not a valid stringsolr-2.4.0/tests/008.solrclient_commit.phpt0000644000175000017500000000153612676753706017275 0ustar omaromar--TEST-- SolrClient::commit() - Testing commit --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH ); $client = new SolrClient($options); $updateResponse = $client->commit(); print $updateResponse->getRawRequest(); $updateResponse = $client->commit(true,false,true); print $updateResponse->getRawRequest(); $updateResponse = $client->commit(true,false,true); ?> --EXPECTF-- solr-2.4.0/tests/009.solrclient_optimize.phpt0000644000175000017500000000144612676753706017646 0ustar omaromar--TEST-- SolrClient::optimize() - Testing optimize --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH ); $client = new SolrClient($options); $updateResponse = $client->optimize(); print $updateResponse->getRawRequest(); $updateResponse = $client->optimize(4,true,false); print $updateResponse->getRawRequest(); ?> --EXPECTF-- solr-2.4.0/tests/010.solrclient_getOptions.phpt0000644000175000017500000000140612676753706020125 0ustar omaromar--TEST-- SolrClient::getOptions - Returning all the default options --FILE-- false); $client = new SolrClient($options); var_dump($client->getOptions()); ?> --EXPECTF-- array(17) { ["timeout"]=> int(30) ["secure"]=> bool(false) ["hostname"]=> string(9) "localhost" ["wt"]=> string(3) "xml" ["port"]=> int(8983) ["proxy_host"]=> string(0) "" ["proxy_port"]=> int(0) ["path"]=> string(4) "solr" ["http_auth"]=> string(0) "" ["proxy_auth"]=> string(0) "" ["ssl_verify_peer"]=> bool(false) ["ssl_verify_host"]=> int(2) ["ssl_cert"]=> string(0) "" ["ssl_key"]=> string(0) "" ["ssl_keypassword"]=> string(0) "" ["ssl_cainfo"]=> string(0) "" ["ssl_capath"]=> string(0) "" } solr-2.4.0/tests/011.solrclient_phps_response.phpt0000644000175000017500000000074412676753706020667 0ustar omaromar--TEST-- SolrClient - PHPS response writer support --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient ( $options ); $client->setResponseWriter('phps'); $options = $client->getOptions(); var_dump($options['wt'] == 'phps'); ?> --EXPECTF-- bool(true)solr-2.4.0/tests/012.solrclient_getById.phpt0000644000175000017500000000117012676753706017321 0ustar omaromar--TEST-- SolrClient::getById() - Testing Real Time Get by id --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH ); $client = new SolrClient($options); $response = $client->getById('GB18030TEST'); var_dump(isset($response->getArrayResponse()['doc'])).PHP_EOL; var_dump($response->getResponse()->doc->id) . PHP_EOL; ?> --EXPECTF-- bool(true) string(11) "GB18030TEST"solr-2.4.0/tests/013.solrclient_getByIds.phpt0000644000175000017500000000313212676753706017505 0ustar omaromar--TEST-- SolrClient::getByIds() - Testing Real Time Get by ids --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH ); $client = new SolrClient($options); $response = $client->getByIds(['GB18030TEST', '6H500F0']); var_dump(isset($response->getArrayResponse()['response']['docs'])) . PHP_EOL; var_dump($response->getResponse()->response->start) . PHP_EOL; try { $response = $client->getByIds(['GB18030TEST', '']); } catch (Exception $e) { printf("Exception %d: %s", $e->getCode(), $e->getMessage()); } echo PHP_EOL.PHP_EOL; // make sure request was reset echo "- Headers start".PHP_EOL; $response = $client->getByIds(['GB18030TEST']); $headers = explode(PHP_EOL, trim($response->getRawRequestHeaders())); sort($headers); print_r(implode(PHP_EOL, $headers).PHP_EOL); echo "- Headers End".PHP_EOL;; echo PHP_EOL; try { $response = $client->getByIds([]); } catch (Exception $e) { printf("Exception %d: %s", $e->getCode(), $e->getMessage()); } ?> --EXPECTF-- bool(true) int(0) Exception 4000: Invalid id at position 1 - Headers start Accept-Charset: utf-8 Accept: */* Authorization: Basic YWRtaW46Y2hhbmdlaXQ= Connection: keep-alive GET /solr/collection1/get/?version=2.2&indent=on&wt=xml&ids=GB18030TEST HTTP/1.1 Host: %s:8983 Keep-Alive: 300 User-Agent: %s - Headers End Exception 4000: Invalid parameter: at least 1 ID is required. Passed an empty array. solr-2.4.0/tests/014.solrclient_addDocument_nested_document.phpt0000644000175000017500000000407612676753706023473 0ustar omaromar--TEST-- SolrClient::addDocument() - Sending a document with child documents --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH ); $client = new SolrClient($options); $doc = new SolrInputDocument(); $doc->addField('id', 'CTEST_1'); $doc->addField('title', 'Solr adds block join support'); $doc->addField('content_type', 'parentDocument'); $doc2 = new SolrInputDocument(); $doc2->addField('id', 'CTEST_2'); $doc2->addField('comment_t', 'SolrCloud supports it too!'); $doc3 = new SolrInputDocument(); $doc3->addField('id', 'CTEST_3'); $doc3->addField('comment_t', 'Lots of features'); $doc->addChildDocument($doc2); $doc->addChildDocument($doc3); $doc4 = new SolrInputDocument(); $doc4->addField('id', 'CTEST_4'); $doc4->addField('comment_t', 'Child Child'); $doc3->addChildDocument($doc4); $docs = $doc->getChildDocuments(); $docs[0]->addField('one_more_field_t', 'testing'); $updateResponse = $client->addDocument($doc); print_r($updateResponse->getRawRequest()); print_r($updateResponse->getResponse()); $client->commit(); ?> --EXPECTF-- CTEST_1 Solr adds block join support parentDocument CTEST_2 SolrCloud supports it too! testing CTEST_3 Lots of features CTEST_4 Child Child SolrObject Object ( [responseHeader] => SolrObject Object ( [status] => %d [QTime] => %d ) )solr-2.4.0/tests/015.solrclient_addDocuments_nested_document.phpt0000644000175000017500000000403412676753706023651 0ustar omaromar--TEST-- SolrClient::addDocuments() - Sending multiple documents with child documents --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH ); $client = new SolrClient($options); $doc = new SolrInputDocument(); $doc->addField('id', 'CTEST_1'); $doc->addField('title', 'Solr adds block join support'); $doc->addField('content_type', 'parentDocument'); $doc2 = new SolrInputDocument(); $doc2->addField('id', 'CTEST_2'); $doc2->addField('comment_t', 'SolrCloud supports it too!'); $doc3 = new SolrInputDocument(); $doc3->addField('id', 'CTEST_3'); $doc3->addField('content_type', 'parentDocument'); $doc3->addField('comment_t', 'Lots of features'); $doc4 = new SolrInputDocument(); $doc4->addField('id', 'CTEST_4'); $doc4->addField('comment_t', 'Cool features'); $doc->addChildDocument($doc2); $doc3->addChildDocument($doc4); $documents = [$doc, $doc3]; $updateResponse = $client->addDocuments($documents); print_r($updateResponse->getRawRequest()); print_r($updateResponse->getResponse()); $client->commit(); ?> --EXPECTF-- CTEST_1 Solr adds block join support parentDocument CTEST_2 SolrCloud supports it too! CTEST_3 parentDocument Lots of features CTEST_4 Cool features SolrObject Object ( [responseHeader] => SolrObject Object ( [status] => %d [QTime] => %d ) )solr-2.4.0/tests/020.solrdocument_adding_fields.phpt0000644000175000017500000000275412676753706021116 0ustar omaromar--TEST-- SolrDocument - checking dimension and magic property sets. --FILE-- addField('id', 1123); $doc->features = "PHP Client Side"; $doc->features = "Fast development cycles"; $doc['cat'] = 'Software'; $doc['cat'] = 'Custom Search'; $doc->cat = 'Information Technology'; print_r($doc->toArray()); ?> --EXPECT-- Array ( [document_boost] => 0 [field_count] => 3 [fields] => Array ( [0] => SolrDocumentField Object ( [name] => id [boost] => 0 [values] => Array ( [0] => 1123 ) ) [1] => SolrDocumentField Object ( [name] => features [boost] => 0 [values] => Array ( [0] => PHP Client Side [1] => Fast development cycles ) ) [2] => SolrDocumentField Object ( [name] => cat [boost] => 0 [values] => Array ( [0] => Software [1] => Custom Search [2] => Information Technology ) ) ) ) solr-2.4.0/tests/021.solrdocument_iterator.phpt0000644000175000017500000000176612676753706020176 0ustar omaromar--TEST-- SolrDocument - checking Iterator interface implementation --FILE-- addField('id', 1123); $doc->features = "PHP Client Side"; $doc->features = "Fast development cycles"; $doc['cat'] = 'Software'; $doc['cat'] = 'Custom Search'; $doc->cat = 'Information Technology'; foreach ($doc as $fieldname => $fieldvalues) { print "$fieldname\n"; print_r($fieldvalues); } ?> --EXPECT-- id SolrDocumentField Object ( [name] => id [boost] => 0 [values] => Array ( [0] => 1123 ) ) features SolrDocumentField Object ( [name] => features [boost] => 0 [values] => Array ( [0] => PHP Client Side [1] => Fast development cycles ) ) cat SolrDocumentField Object ( [name] => cat [boost] => 0 [values] => Array ( [0] => Software [1] => Custom Search [2] => Information Technology ) ) solr-2.4.0/tests/022.solrdocument_getInputDocument.phpt0000644000175000017500000000075412676753706021640 0ustar omaromar--TEST-- SolrDocument::getInputDocument() - creating SolrInputDocument from SolrDocument --FILE-- addField('id', 1123); $doc->features = "PHP Client Side"; $doc->features = "Fast development cycles"; $doc['cat'] = 'Software'; $doc['cat'] = 'Custom Search'; $doc->cat = 'Information Technology'; $input_doc = $doc->getInputDocument(); var_dump(get_class($input_doc)); ?> --EXPECT-- string(17) "SolrInputDocument" solr-2.4.0/tests/023.solrdocument_merge.phpt0000644000175000017500000000316312676753706017437 0ustar omaromar--TEST-- SolrDocument::merge() - merging source document into current document --FILE-- addField('id', 1123); $doc->features = "PHP Client Side"; $doc->features = "Fast development cycles"; $doc['cat'] = 'Software'; $doc['cat'] = 'Custom Search'; $doc->cat = 'Information Technology'; $second_doc->addField('cat', 'Lucene Search'); $second_doc->merge($doc, true); print_r($second_doc->toArray()); ?> --EXPECT-- Array ( [document_boost] => 0 [field_count] => 3 [fields] => Array ( [0] => SolrDocumentField Object ( [name] => cat [boost] => 0 [values] => Array ( [0] => Software [1] => Custom Search [2] => Information Technology ) ) [1] => SolrDocumentField Object ( [name] => id [boost] => 0 [values] => Array ( [0] => 1123 ) ) [2] => SolrDocumentField Object ( [name] => features [boost] => 0 [values] => Array ( [0] => PHP Client Side [1] => Fast development cycles ) ) ) ) solr-2.4.0/tests/023.solrdocument_merge_no_overwrite.phpt0000644000175000017500000000304012676753706022233 0ustar omaromar--TEST-- SolrDocument::merge() - merging source document into current document without overwrite --FILE-- addField('id', 1123); $doc->features = "PHP Client Side"; $doc->features = "Fast development cycles"; $doc['cat'] = 'Software'; $doc['cat'] = 'Custom Search'; $doc->cat = 'Information Technology'; $second_doc->addField('cat', 'Lucene Search'); $second_doc->merge($doc, false); print_r($second_doc->toArray()); ?> --EXPECT-- Array ( [document_boost] => 0 [field_count] => 3 [fields] => Array ( [0] => SolrDocumentField Object ( [name] => cat [boost] => 0 [values] => Array ( [0] => Lucene Search ) ) [1] => SolrDocumentField Object ( [name] => id [boost] => 0 [values] => Array ( [0] => 1123 ) ) [2] => SolrDocumentField Object ( [name] => features [boost] => 0 [values] => Array ( [0] => PHP Client Side [1] => Fast development cycles ) ) ) ) solr-2.4.0/tests/024.solrdocument_child_fetch.phpt0000644000175000017500000000242412676753706020574 0ustar omaromar--TEST-- SolrClient::query() - Query child documents SolrObject (Integ) --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_STORE_PATH, 'wt' => 'xml' ); $client = new SolrClient ( $options ); $query = new SolrQuery (); $query->setQuery ( 'id:1 AND {!parent which=$parentFilter}' ); $query->setParam ( 'parentFilter', 'content_type_s:product' ); $query->addFilterQuery('{!parent which=$parentFilter}'); $query->addField ( '*' ); $query->addField ( '[child parentFilter=$parentFilter]' ); $query->setStart ( 0 ); $query->setRows ( 50 ); $queryResponse = $client->query ( $query ); $response = $queryResponse->getResponse (); echo "----XML----" . PHP_EOL; var_dump($response->response->docs[0]->_childDocuments_[0]->id); echo "----JSON----" . PHP_EOL; $options['wt'] = 'json'; $client = new SolrClient ( $options ); $queryResponse = $client->query($query); $response = $queryResponse->getResponse (); var_dump($response->response->docs[0]->_childDocuments_[0]->id); ?> --EXPECT-- ----XML---- string(9) "IMM-HOW-S" ----JSON---- string(9) "IMM-HOW-S"solr-2.4.0/tests/025.solrdocument_haschilddocuments.phpt0000644000175000017500000000051412676753706022040 0ustar omaromar--TEST-- SolrDocument::hasChildDocuments() - Method test --FILE-- response->docs[0]->hasChildDocuments()); ?> --EXPECT-- bool(true)solr-2.4.0/tests/026.solrdocument_getchilddocscount.phpt0000644000175000017500000000052212676753706022044 0ustar omaromar--TEST-- SolrDocument::getChildDocumentsCount() - Method test --FILE-- response->docs[0]->getChildDocumentsCount()); ?> --EXPECT-- int(1)solr-2.4.0/tests/027.solrdocument_getinputdocument_children.phpt0000644000175000017500000000236112676753706023611 0ustar omaromar--TEST-- SolrDocument::getInputDocument() - Where document has child docs --FILE-- response->docs as $doc) { $childrenOfTheInput = $doc->getInputDocument()->getChildDocuments(); if ($childrenOfTheInput) { $firstChild = $childrenOfTheInput[0]; var_dump(get_class($firstChild)); var_dump(current($childrenOfTheInput)->toArray()); } } ?> --EXPECT-- string(17) "SolrInputDocument" array(3) { ["document_boost"]=> float(0) ["field_count"]=> int(1) ["fields"]=> array(1) { [0]=> object(SolrDocumentField)#9 (3) { ["name"]=> string(2) "id" ["boost"]=> float(0) ["values"]=> array(1) { [0]=> string(9) "CHILD_1_1" } } } } string(17) "SolrInputDocument" array(3) { ["document_boost"]=> float(0) ["field_count"]=> int(1) ["fields"]=> array(1) { [0]=> object(SolrDocumentField)#10 (3) { ["name"]=> string(2) "id" ["boost"]=> float(0) ["values"]=> array(1) { [0]=> string(9) "CHILD_2_1" } } } } solr-2.4.0/tests/040.solrobject_xmlresponse.phpt0000644000175000017500000000504012676753706020342 0ustar omaromar--TEST-- SolrObject - checking xml response digest --FILE-- --EXPECT-- SolrObject Object ( [responseHeader] => SolrObject Object ( [status] => 0 [QTime] => 72 ) [system] => SolrObject Object ( [threadCount] => SolrObject Object ( [current] => 15 [peak] => 15 [daemon] => 13 ) [threadDump] => SolrObject Object ( [thread] => SolrObject Object ( [id] => 1 [name] => main [state] => RUNNABLE [native] => 1 [cpuTime] => 3340.0000ms [userTime] => 3180.0000ms [stackTrace] => Array ( [0] => java.net.PlainSocketImpl.socketAccept(Native Method) [1] => java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384) [2] => java.net.ServerSocket.implAccept(ServerSocket.java:450) [3] => java.net.ServerSocket.accept(ServerSocket.java:421) [4] => org.apache.catalina.core.StandardServer.await(StandardServer.java:389) [5] => org.apache.catalina.startup.Catalina.await(Catalina.java:642) [6] => org.apache.catalina.startup.Catalina.start(Catalina.java:602) [7] => sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [8] => sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [9] => sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [10] => java.lang.reflect.Method.invoke(Method.java:585) [11] => org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) [12] => org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) ) ) ) ) ) solr-2.4.0/tests/041.solrobject_illegal_operation.phpt0000644000175000017500000000361112676753706021457 0ustar omaromar--TEST-- SolrObject - checking illegal operation of modifying object --FILE-- email = "iekpo@php.net"; } catch (Exception $e) { var_dump($e->getCode()); var_dump($e->getMessage()); } try { $solrObject['usingOffset'] = 'test'; } catch (SolrIllegalOperationException $e) { echo sprintf("Exception %d: %s", $e->getCode(), $e->getMessage()) . PHP_EOL; } try { $solrObject['newprop2_dimension_access'] = 'test'; } catch (SolrIllegalOperationException $e) { echo sprintf("Exception %d: %s", $e->getCode(), $e->getMessage()) . PHP_EOL; } // unset try { unset($solrObject->responseHeader); } catch (SolrIllegalOperationException $e) { echo sprintf("Exception %d: %s", $e->getCode(), $e->getMessage()) . PHP_EOL; } try { unset($solrObject['responseHeader']); } catch (SolrIllegalOperationException $e) { echo sprintf("Exception %d: %s", $e->getCode(), $e->getMessage()) . PHP_EOL; } ?> --EXPECTF-- int(1006) string(83) "SolrObject instances are read-only. Properties cannot be added, updated or removed." Warning: main(): Attempting to set value for [usingOffset] property in a SolrObject instance in %s on line %d Exception 1006: SolrObject instances are read-only. Properties cannot be added, updated or removed. Warning: main(): Attempting to set value for [newprop2_dimension_access] property in a SolrObject instance in %s on line %d Exception 1006: SolrObject instances are read-only. Properties cannot be added, updated or removed. Warning: main(): Attempting to remove [responseHeader] property in a SolrObject instance in %s on line %d Exception 1006: SolrObject instances are read-only. Properties cannot be added, updated or removed. Warning: main(): Attempting to remove [responseHeader] property in a SolrObject instance in %s on line %d Exception 1006: SolrObject instances are read-only. Properties cannot be added, updated or removed.solr-2.4.0/tests/042.solrobject_magic_property.phpt0000644000175000017500000000236412676753706021017 0ustar omaromar--TEST-- SolrObject - testing the magic property access --FILE-- system->threadDump->thread->stackTrace); ?> --EXPECT-- Array ( [0] => java.net.PlainSocketImpl.socketAccept(Native Method) [1] => java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384) [2] => java.net.ServerSocket.implAccept(ServerSocket.java:450) [3] => java.net.ServerSocket.accept(ServerSocket.java:421) [4] => org.apache.catalina.core.StandardServer.await(StandardServer.java:389) [5] => org.apache.catalina.startup.Catalina.await(Catalina.java:642) [6] => org.apache.catalina.startup.Catalina.start(Catalina.java:602) [7] => sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [8] => sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [9] => sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [10] => java.lang.reflect.Method.invoke(Method.java:585) [11] => org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) [12] => org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) ) solr-2.4.0/tests/043.solrobject_magic_properties.phpt0000644000175000017500000000062512676753706021326 0ustar omaromar--TEST-- SolrObject - test property access --FILE-- responseHeader; $system = $solrObject->system; var_dump(isset($solrObject['system'])); var_dump(property_exists($solrObject, 'system')); ?> --EXPECT-- bool(true) bool(true)solr-2.4.0/tests/044.solrobject_dimension_access_properties.phpt0000644000175000017500000000441112676753706023552 0ustar omaromar--TEST-- SolrObject - checking dimension access on properties. --FILE-- --EXPECT-- SolrObject Object ( [status] => 0 [QTime] => 72 ) SolrObject Object ( [threadCount] => SolrObject Object ( [current] => 15 [peak] => 15 [daemon] => 13 ) [threadDump] => SolrObject Object ( [thread] => SolrObject Object ( [id] => 1 [name] => main [state] => RUNNABLE [native] => 1 [cpuTime] => 3340.0000ms [userTime] => 3180.0000ms [stackTrace] => Array ( [0] => java.net.PlainSocketImpl.socketAccept(Native Method) [1] => java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384) [2] => java.net.ServerSocket.implAccept(ServerSocket.java:450) [3] => java.net.ServerSocket.accept(ServerSocket.java:421) [4] => org.apache.catalina.core.StandardServer.await(StandardServer.java:389) [5] => org.apache.catalina.startup.Catalina.await(Catalina.java:642) [6] => org.apache.catalina.startup.Catalina.start(Catalina.java:602) [7] => sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [8] => sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [9] => sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [10] => java.lang.reflect.Method.invoke(Method.java:585) [11] => org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) [12] => org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) ) ) ) ) solr-2.4.0/tests/045.solrobject_array_access.phpt0000644000175000017500000000440712676753706020435 0ustar omaromar--TEST-- SolrObject - checking dimension access on properties. --FILE-- --EXPECT-- SolrObject Object ( [status] => 0 [QTime] => 72 ) SolrObject Object ( [threadCount] => SolrObject Object ( [current] => 15 [peak] => 15 [daemon] => 13 ) [threadDump] => SolrObject Object ( [thread] => SolrObject Object ( [id] => 1 [name] => main [state] => RUNNABLE [native] => 1 [cpuTime] => 3340.0000ms [userTime] => 3180.0000ms [stackTrace] => Array ( [0] => java.net.PlainSocketImpl.socketAccept(Native Method) [1] => java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384) [2] => java.net.ServerSocket.implAccept(ServerSocket.java:450) [3] => java.net.ServerSocket.accept(ServerSocket.java:421) [4] => org.apache.catalina.core.StandardServer.await(StandardServer.java:389) [5] => org.apache.catalina.startup.Catalina.await(Catalina.java:642) [6] => org.apache.catalina.startup.Catalina.start(Catalina.java:602) [7] => sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [8] => sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [9] => sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [10] => java.lang.reflect.Method.invoke(Method.java:585) [11] => org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) [12] => org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) ) ) ) ) solr-2.4.0/tests/046.solrobject_getpropertynames.phpt0000644000175000017500000000067512676753706021412 0ustar omaromar--TEST-- SolrObject - SolrObject::getPropertyNames() --FILE-- getPropertyNames()); require_once "bootstrap.inc"; $xml_reponse = file_get_contents(EXAMPLE_RESPONSE_XML_1); $solrObject = SolrUtils::digestXMLResponse($xml_reponse); var_dump($solrObject->getPropertyNames()); ?> --EXPECT-- array(0) { } array(2) { [0]=> string(14) "responseHeader" [1]=> string(6) "system" } solr-2.4.0/tests/050.solrinputdocument_addchilddocument_01.phpt0000644000175000017500000000144112676753706023210 0ustar omaromar--TEST-- SolrInputDocument::addChildDocument() - add child document --FILE-- addField('id', 1123); $doc->addField('features', "PHP Client Side"); $doc->addField('features', "Fast development cycles"); $doc->cat = 'Information Technology'; $secondDoc->addField('cat', 'Lucene Search'); $secondDoc->cat = 'Custom Search'; $doc->addChildDocument($secondDoc); var_dump($doc->hasChildDocuments(), $secondDoc->hasChildDocuments()); $childs = $doc->getChildDocuments(); print_r($childs[0]->getField('cat')); ?> --EXPECT-- bool(true) bool(false) SolrDocumentField Object ( [name] => cat [boost] => 0 [values] => Array ( [0] => Lucene Search ) ) solr-2.4.0/tests/050.solrinputdocument_addchilddocument_02_error.phpt0000644000175000017500000000145112676753706024423 0ustar omaromar--TEST-- SolrInputDocument::addChildDocument()/SolrInputDocument::addChildDocuments() - Expected SolrIllegalArgumentException --FILE-- addField('id', 1123); $doc->addField('features', "PHP Client Side"); $doc->addField('features', "Fast development cycles"); $doc->cat = 'Information Technology'; try { $doc->addChildDocument($child1); } catch (SolrIllegalArgumentException $e) { echo $e->getMessage(). PHP_EOL; } $children = array($child1, $child2); try { $doc->addChildDocuments($children); } catch (SolrIllegalArgumentException $e) { echo $e->getMessage(). PHP_EOL; } ?> --EXPECT-- Child document has no fields SolrInputDocument number 1 has no fieldssolr-2.4.0/tests/051.solrinputdocument_getchilddocuments.phpt0000644000175000017500000000126512676753706023127 0ustar omaromar--TEST-- SolrInputDocument::getChildDocuments() - test --FILE-- addField('id', 1123); $doc->addField('features', "PHP Client Side"); $doc->addField('features', "Fast development cycles"); $doc->cat = 'Information Technology'; $secondDoc->addField('cat', 'Lucene Search'); $secondDoc->cat = 'Custom Search'; $doc->addChildDocument($secondDoc); $childs = $doc->getChildDocuments(); print_r($childs[0]->getField('cat')); ?> --EXPECT-- SolrDocumentField Object ( [name] => cat [boost] => 0 [values] => Array ( [0] => Lucene Search ) )solr-2.4.0/tests/052.solrinputdocument_haschilddocuments.phpt0000644000175000017500000000110412676753706023114 0ustar omaromar--TEST-- SolrInputDocument::hasChildDocuments() - test --FILE-- addField('id', 1123); $doc->addField('features', "PHP Client Side"); $doc->addField('features', "Fast development cycles"); $doc->cat = 'Information Technology'; $secondDoc->addField('cat', 'Lucene Search'); $secondDoc->cat = 'Custom Search'; $doc->addChildDocument($secondDoc); var_dump($doc->hasChildDocuments()); var_dump($secondDoc->hasChildDocuments()); ?> --EXPECT-- bool(true) bool(false)solr-2.4.0/tests/053.solrinputdocument_getchilddocumentscount.phpt0000644000175000017500000000111212676753706024171 0ustar omaromar--TEST-- SolrInputDocument::getChildDocumentsCount() - test --FILE-- addField('id', 1123); $doc->addField('features', "PHP Client Side"); $doc->addField('features', "Fast development cycles"); $doc->cat = 'Information Technology'; $secondDoc->addField('cat', 'Lucene Search'); $secondDoc->cat = 'Custom Search'; $doc->addChildDocument($secondDoc); var_dump($doc->getChildDocumentsCount()); var_dump($secondDoc->getChildDocumentsCount()); ?> --EXPECT-- int(1) int(0)solr-2.4.0/tests/054.solrinputdocument_addchilddocuments.phpt0000644000175000017500000000132712676753706023102 0ustar omaromar--TEST-- SolrInputDocument::addChildDocuments() - add child documents --FILE-- addField('id', 1123); $doc->addField('features', "PHP Client Side"); $doc->addField('features', "Fast development cycles"); $doc->cat = 'Information Technology'; $doc2->addField('cat', 'Lucene Search'); $doc2->cat = 'Custom Search'; $doc2->addField('cat', 'Lucene Search'); $doc2->cat = 'Custom Search'; $doc3->addField('cat', 'Lucene Search'); $doc3->cat = 'Custom Search'; $docs = array($doc2, $doc3); $doc->addChildDocuments($docs); var_dump($doc->getChildDocumentsCount()); ?> --EXPECT-- int(2)solr-2.4.0/tests/055.solrinputdocument_serialization.phpt0000644000175000017500000000045212676753706022300 0ustar omaromar--TEST-- SolrInputDocument - serialize/unserialize Exception --FILE-- getMessage().PHP_EOL; } ?> --EXPECT-- SolrInputDocument objects cannot be serialized or unserializedsolr-2.4.0/tests/060.solrquery_comon_query_params.phpt0000644000175000017500000000303312676753706021567 0ustar omaromar--TEST-- SolrQuery - testing CommonQueryParameters --FILE-- getQuery(), $query->getTimeAllowed(), $query->getStart(), $query->getRows(), $query->getFields(), $query->getFilterQueries(), $query->getSortFields() ); $nullOutput = ob_get_clean(); $query->setParam('a', 1); $query->setParam('b', 2); $query->setParam('c', 3); $query->setStart(4)->setQuery('solr')->setTimeAllowed(500)->setRows(17); $query->addField('israel')->addField('joshua')->addField('june'); $query->addSortField('cat', SolrQuery::ORDER_ASC); $query->addFilterQuery('solr')->addFilterQuery('solr1')->addFilterQuery('solr2'); $query ->setShowDebugInfo(true) ->setExplainOther('id:SOL*') ->setOmitHeader(false) ->setEchoHandler(true) ->setEchoParams('all') ; echo $query . PHP_EOL . PHP_EOL; var_dump( $query->getQuery(), $query->getTimeAllowed(), $query->getStart(), $query->getRows(), $query->getFields(), $query->getFilterQueries(), $query->getSortFields() ); echo $nullOutput; ?> --EXPECT-- a=1&b=2&c=3&start=4&q=solr&timeAllowed=500&rows=17&fl=israel,joshua,june&sort=cat asc&fq=solr&fq=solr1&fq=solr2&debugQuery=true&explainOther=id:SOL*&omitHeader=false&echoHandler=true&echoParams=all string(4) "solr" int(500) int(4) int(17) array(3) { [0]=> string(6) "israel" [1]=> string(6) "joshua" [2]=> string(4) "june" } array(3) { [0]=> string(4) "solr" [1]=> string(5) "solr1" [2]=> string(5) "solr2" } array(1) { [0]=> string(7) "cat asc" } NULL NULL NULL NULL NULL NULL NULLsolr-2.4.0/tests/061.solrquery_simpleFacetParameters.phpt0000644000175000017500000000363512676753706022155 0ustar omaromar--TEST-- SolrQuery - testing SimpleFacetParameters --FILE-- setFacet(0); $query->addFacetField('israel')->addFacetField('israel2'); $query->addFacetQuery('silk')->addFacetQuery('name:june'); $query->setFacetPrefix('A')->setFacetPrefix('C', 'june'); $query->setFacetSort(1)->setFacetSort(0, 'june'); $query->setFacetLimit(98)->setFacetLimit(44, 'june'); $query->setFacetOffset(110)->setFacetOffset(12, 'june'); $query->setFacetMinCount(4)->setFacetMinCount(30, 'june'); $query->setFacetMissing(1)->setFacetMissing(0, 'june'); $query->setFacetMethod('enum')->setFacetMethod('fc', 'june'); $query->setFacetEnumCacheMinDefaultFrequency(25); echo $query . PHP_EOL . PHP_EOL; var_dump( $query->getFacet(), $query->getFacetFields(), $query->getFacetQueries(), $query->getFacetPrefix(), $query->getFacetPrefix('june'), $query->getFacetSort(), $query->getFacetSort('june'), $query->getFacetLimit(), $query->getFacetLimit('june'), $query->getFacetOffset(), $query->getFacetOffset('june'), $query->getFacetMinCount(), $query->getFacetMinCount('june'), $query->getFacetMissing(), $query->getFacetMissing('june'), $query->getFacetMethod(), $query->getFacetMethod('june') ); ?> --EXPECTF-- facet=false&facet.field=israel&facet.field=israel2&facet.query=silk&facet.query=name:june&facet.prefix=A&f.june.facet.prefix=C&facet.sort=count&f.june.facet.sort=index&facet.limit=98&f.june.facet.limit=44&facet.offset=110&f.june.facet.offset=12&facet.mincount=4&f.june.facet.mincount=30&facet.missing=true&f.june.facet.missing=false&facet.method=enum&f.june.facet.method=fc&facet.enum.cache.minDf=25 bool(false) array(2) { [0]=> string(6) "israel" [1]=> string(7) "israel2" } array(2) { [0]=> string(4) "silk" [1]=> string(9) "name:june" } string(1) "A" string(1) "C" int(1) int(0) int(98) int(44) int(110) int(12) int(4) int(30) bool(true) bool(false) string(4) "enum" string(2) "fc" solr-2.4.0/tests/062.solrquery_date_facet_parameters.phpt0000644000175000017500000000370412676753706022175 0ustar omaromar--TEST-- SolrQuery - Testing Date facet parameters --FILE-- getFacetDateFields(), $query->getFacetDateStart(), $query->getFacetDateStart('june'), $query->getFacetDateEnd(), $query->getFacetDateEnd('israel'), $query->getFacetDateGap(), $query->getFacetDateGap('june'), $query->getFacetDateHardEnd(), $query->getFacetDateHardEnd('june'), $query->getFacetDateOther(), $query->getFacetDateOther('june') ); $nullOutput = ob_get_clean(); $query->addFacetDateField('israel') ->addFacetDateField('israel') ->removeFacetDateField('israel') ; $query->setFacetDateStart('January')->setFacetDateStart('Feb', 'june'); $query->setFacetDateEnd('Jan')->setFacetDateEnd('Febr', 'israel'); $query->setFacetDateGap('AOL')->setFacetDateGap('YAHOO', 'june'); $query->setFacetDateHardEnd(1)->setFacetDateHardEnd(0,'june'); $query->addFacetDateOther('Google') ->addFacetDateOther('Yahoos','june') ->addFacetDateOther('removeme') ->removeFacetDateOther('removeme'); echo $query. PHP_EOL . PHP_EOL; var_dump( $query->getFacetDateFields(), $query->getFacetDateStart(), $query->getFacetDateStart('june'), $query->getFacetDateEnd(), $query->getFacetDateEnd('israel'), $query->getFacetDateGap(), $query->getFacetDateGap('june'), $query->getFacetDateHardEnd(), $query->getFacetDateHardEnd('june'), $query->getFacetDateOther(), $query->getFacetDateOther('june') ); echo $nullOutput; ?> --EXPECTF-- facet.date=israel&facet.date.start=January&f.june.facet.date.start=Feb&facet.date.end=Jan&f.israel.facet.date.end=Febr&facet.date.gap=AOL&f.june.facet.date.gap=YAHOO&facet.date.hardend=true&f.june.facet.date.hardend=false&f.june.facet.date.other=Yahoos array(1) { [0]=> string(6) "israel" } string(7) "January" string(3) "Feb" string(3) "Jan" string(4) "Febr" string(3) "AOL" string(5) "YAHOO" bool(true) bool(false) NULL array(1) { [0]=> string(6) "Yahoos" } NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULLsolr-2.4.0/tests/063.solrquery_HighlightingParameters.phpt0000644000175000017500000001157312676753706022330 0ustar omaromar--TEST-- SolrQuery - testing HighlightingParameters --FILE-- getHighlight(), $query->getHighlightFields(), $query->getHighlightSnippets(), $query->getHighlightSnippets('june'), $query->getHighlightFragsize(), $query->getHighlightFragsize('june'), $query->getHighlightMergeContiguous(), $query->getHighlightMergeContiguous('june'), $query->getHighlightRequireFieldMatch(), $query->getHighlightMaxAnalyzedChars(), $query->getHighlightAlternateField(), $query->getHighlightAlternateField('june'), $query->getHighlightMaxAlternateFieldLength(), $query->getHighlightMaxAlternateFieldLength('june'), $query->getHighlightFormatter(), $query->getHighlightFormatter('june'), $query->getHighlightSimplePre(), $query->getHighlightSimplePre('june'), $query->getHighlightSimplePost(), $query->getHighlightSimplePost('june'), $query->getHighlightFragmenter(), $query->getHighlightFragmenter('june'), $query->getHighlightUsePhraseHighlighter(), $query->getHighlightHighlightMultiTerm(), $query->getHighlightRegexSlop(), $query->getHighlightRegexPattern(), $query->getHighlightRegexMaxAnalyzedChars() ); $nullOutput = ob_get_clean(); $query->setHighlight(0); $query->addHighlightField('a')->addHighlightField('a')->addHighlightField('a') ->addHighlightField('b'); $query->removeHighlightField('a')->removeHighlightField('a')->removeHighlightField('a'); $query->setHighlightSnippets(4)->setHighlightSnippets(5, 'june'); $query->setHighlightFragsize(41)->setHighlightFragsize(52, 'june'); $query->setHighlightMergeContiguous(true)->setHighlightMergeContiguous(false, 'june'); $query->setHighlightRequireFieldMatch(true); $query->setHighlightMaxAnalyzedChars(44)->setHighlightMaxAnalyzedChars(53); $query->setHighlightAlternateField('pizza')->setHighlightAlternateField('bread', 'june'); $query->setHighlightAlternateField('blue')->setHighlightAlternateField('red','june'); $query->setHighlightAlternateField('a')->setHighlightAlternateField('b','june'); $query->setHighlightMaxAlternateFieldLength(300)->setHighlightMaxAlternateFieldLength(335, 'june'); $query->setHighlightFormatter('F')->setHighlightFormatter('G', 'june'); $query->setHighlightSimplePre('OO')->setHighlightSimplePre('PP', 'june'); $query->setHighlightSimplePost('ZZ')->setHighlightSimplePost('YY', 'june'); $query->setHighlightFragmenter('gap')->setHighlightFragmenter('space', 'june'); $query->setHighlightUsePhraseHighlighter(false); $query->setHighlightHighlightMultiTerm(1); $query->setHighlightRegexSlop(0.0025); $query->setHighlightRegexPattern("israel")->setHighlightRegexPattern("ekpo"); $query->setHighlightRegexMaxAnalyzedChars(444)->setHighlightRegexMaxAnalyzedChars(5.0); echo $query . PHP_EOL . PHP_EOL; var_dump( $query->getHighlight(), $query->getHighlightFields(), $query->getHighlightSnippets(), $query->getHighlightSnippets('june'), $query->getHighlightFragsize(), $query->getHighlightFragsize('june'), $query->getHighlightMergeContiguous(), $query->getHighlightMergeContiguous('june'), $query->getHighlightRequireFieldMatch(), $query->getHighlightMaxAnalyzedChars(), $query->getHighlightAlternateField(), $query->getHighlightAlternateField('june'), $query->getHighlightMaxAlternateFieldLength(), $query->getHighlightMaxAlternateFieldLength('june'), $query->getHighlightFormatter(), $query->getHighlightFormatter('june'), $query->getHighlightSimplePre(), $query->getHighlightSimplePre('june'), $query->getHighlightSimplePost(), $query->getHighlightSimplePost('june'), $query->getHighlightFragmenter(), $query->getHighlightFragmenter('june'), $query->getHighlightUsePhraseHighlighter(), $query->getHighlightHighlightMultiTerm(), $query->getHighlightRegexSlop(), $query->getHighlightRegexPattern(), $query->getHighlightRegexMaxAnalyzedChars() ); echo PHP_EOL.$nullOutput; ?> --EXPECT-- hl=false&hl.fl=b&hl.snippets=4&f.june.hl.snippets=5&hl.fragsize=41&f.june.hl.fragsize=52&hl.mergeContiguous=true&f.june.hl.mergeContiguous=false&hl.requireFieldMatch=true&hl.maxAnalyzedChars=53&hl.alternateField=a&f.june.hl.alternateField=b&hl.maxAlternateFieldLength=300&f.june.hl.maxAlternateFieldLength=335&hl.formatter=F&f.june.hl.formatter=G&hl.simple.pre=OO&f.june.hl.simple.pre=PP&hl.simple.post=ZZ&f.june.hl.simple.post=YY&hl.fragmenter=gap&f.june.hl.fragmenter=space&hl.usePhraseHighlighter=false&hl.highlightMultiTerm=true&hl.regex.slop=0.0025&hl.regex.pattern=ekpo&hl.regex.maxAnalyzedChars=5 bool(false) array(1) { [0]=> string(1) "b" } int(4) int(5) int(41) int(52) bool(true) bool(false) bool(true) int(53) string(1) "a" string(1) "b" int(300) int(335) string(1) "F" string(1) "G" string(2) "OO" string(2) "PP" string(2) "ZZ" string(2) "YY" string(3) "gap" string(5) "space" bool(false) bool(true) float(0.0025) string(4) "ekpo" int(5) NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL solr-2.4.0/tests/064.solrquery_StatsComponent.phpt0000644000175000017500000000154012676753706020652 0ustar omaromar--TEST-- SolrQuery - testing StatsComponent --FILE-- getStats(), $query->getStatsFields(), $query->getStatsFacets() ); $nullOutput = ob_get_clean(); $query->setStats(0); $query ->addStatsField('hello') ->removeStatsField('hello') ->addStatsField('june') ->addStatsField('july') ; $query ->addStatsFacet('world') ->removeStatsFacet('world') ->addStatsFacet('pear') ->addStatsFacet('pecl') ; echo $query . PHP_EOL . PHP_EOL; var_dump( $query->getStats(), $query->getStatsFields(), $query->getStatsFacets() ); echo $nullOutput; ?> --EXPECTF-- stats=false&stats.field=june&stats.field=july&stats.facet=pear&stats.facet=pecl bool(false) array(2) { [0]=> string(4) "june" [1]=> string(4) "july" } array(2) { [0]=> string(4) "pear" [1]=> string(4) "pecl" } NULL NULL NULLsolr-2.4.0/tests/065.solrquery_MoreLikeThis.phpt0000644000175000017500000000346412676753706020240 0ustar omaromar--TEST-- SolrQuery - testing MoreLikeThis component --FILE-- getMlt(), $query->getMltCount(), $query->getMltFields(), $query->getMltQueryFields(), $query->getMltMinTermFrequency(), $query->getMltMinDocFrequency(), $query->getMltMinWordLength(), $query->getMltMaxWordLength(), $query->getMltMaxNumTokens(), $query->getMltMaxNumQueryTerms(), $query->getMltBoost() ); $nullOutput = ob_get_clean(); $query->setMlt(1); $query->setMltCount(55)->setMltCount(90); $query->addMltField('june')->addMltField('joshua')->addMltField('mom')->removeMltField('joshua'); $query->addMltQueryField('june', 0.0)->addMltQueryField('israel', 9.558) ->addMltQueryField('removeme', 0.0) ->removeMltQueryField('removeme') ; $query->setMltMinTermFrequency(9); $query->setMltMinDocFrequency(5); $query->setMltMinWordLength(8); $query->setMltMaxWordLength(99); $query->setMltMaxNumTokens(6); $query->setMltMaxNumQueryTerms(2); $query->setMltBoost(true); echo $query . PHP_EOL . PHP_EOL; var_dump( $query->getMlt(), $query->getMltCount(), $query->getMltFields(), $query->getMltQueryFields(), $query->getMltMinTermFrequency(), $query->getMltMinDocFrequency(), $query->getMltMinWordLength(), $query->getMltMaxWordLength(), $query->getMltMaxNumTokens(), $query->getMltMaxNumQueryTerms(), $query->getMltBoost() ); echo $nullOutput; ?> --EXPECTF-- mlt=true&mlt.count=90&mlt.fl=june,mom&mlt.qf=june^0 israel^9.558&mlt.mintf=9&mlt.mindf=5&mlt.minwl=8&mlt.maxwl=99&mlt.maxntp=6&mlt.maxqt=2&mlt.boost=true bool(true) int(90) array(2) { [0]=> string(4) "june" [1]=> string(3) "mom" } array(2) { [0]=> string(6) "june^0" [1]=> string(12) "israel^9.558" } int(9) int(5) int(8) int(99) int(6) int(2) bool(true) NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULLsolr-2.4.0/tests/066.solrquery_TermsComponent.phpt0000644000175000017500000000345712676753706020661 0ustar omaromar--TEST-- SolrQuery - testing TermsComponent --FILE-- getTerms(), $query->getTermsField(), $query->getTermsLowerBound(), $query->getTermsUpperBound(), $query->getTermsIncludeLowerBound(), $query->getTermsIncludeUpperBound(), $query->getTermsMinCount(), $query->getTermsMaxCount(), $query->getTermsPrefix(), $query->getTermsLimit(), $query->getTermsReturnRaw(), $query->getTermsSort() ); }; ob_start(); $dumpVars(); $nullOutput = ob_get_clean(); $query->setTerms(true); $query->setTermsField('israel'); $query->setTermsLowerBound('june'); $query->setTermsUpperBound('joshua'); $query->setTermsIncludeLowerBound(false); $query->setTermsIncludeUpperBound(0); $query->setTermsMinCount(50); $query->setTermsMaxCount(200); $query->setTermsPrefix('A'); $query->setTermsLimit(45); $query->setTermsReturnRaw(false); $query->setTermsSort(SolrQuery::TERMS_SORT_INDEX); echo $query . PHP_EOL . PHP_EOL; $dumpVars(); $query->setTermsSort(SolrQuery::TERMS_SORT_COUNT); echo PHP_EOL . $query . PHP_EOL . PHP_EOL; var_dump( $query->getTermsSort() ); echo $nullOutput; ?> --EXPECTF-- terms=true&terms.fl=israel&terms.lower=june&terms.upper=joshua&terms.lower.incl=false&terms.upper.incl=false&terms.mincount=50&terms.maxcount=200&terms.prefix=A&terms.limit=45&terms.raw=false&terms.sort=index bool(true) string(6) "israel" string(4) "june" string(6) "joshua" bool(false) bool(false) int(50) int(200) string(1) "A" int(45) bool(false) int(0) terms=true&terms.fl=israel&terms.lower=june&terms.upper=joshua&terms.lower.incl=false&terms.upper.incl=false&terms.mincount=50&terms.maxcount=200&terms.prefix=A&terms.limit=45&terms.raw=false&terms.sort=count int(1) NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL solr-2.4.0/tests/067.solrquery__construct.phpt0000644000175000017500000000044012676753706020055 0ustar omaromar--TEST-- SolrQuery::_construct - Throws exception on illegal Argument --FILE-- getMessage(); } ?> --EXPECT-- SolrQuery::__construct() expects parameter 1 to be string, object givensolr-2.4.0/tests/068.solrquery_parameters_error.phpt0000644000175000017500000000142312676753706021251 0ustar omaromar--TEST-- SolrQuery - Invalid Parameters thorws exception Throws exception on illegal Argument --FILE-- setQuery(''); }catch (SolrIllegalArgumentException $e) { echo $e->getMessage().PHP_EOL; try { // simple list $query->addField(''); } catch (SolrIllegalArgumentException $e) { echo $e->getMessage().PHP_EOL; try { // argument list $query->addSortField(''); } catch (SolrIllegalArgumentException $e) { echo $e->getMessage().PHP_EOL; try { $params->addParam('',1); } catch (Exception $e) { echo $e->getMessage().PHP_EOL; } } } } ?> --EXPECT-- Invalid parameter value Invalid parameter value Invalid parameter value Invalid parameter name solr-2.4.0/tests/069.solrquery_GroupParameters.phpt0000644000175000017500000000444012676753706021020 0ustar omaromar--TEST-- SolrQuery - Result Grouping (Group Parameters) --FILE-- setGroup(true); $query->addGroupField('category')->addGroupField('featured'); $query->addGroupFunction('ceil(internalScore)'); $query->addGroupQuery('silk')->addGroupQuery('name:june'); $query->setGroupLimit(98); $query->setGroupOffset(110); $query->addGroupSortField('count', SolrQuery::ORDER_ASC); $query->addGroupSortField('name', SolrQuery::ORDER_DESC); $query->setGroupFormat('simple'); $query->setGroupMain(false); $query->setGroupNGroups(false); $query->setGroupTruncate(true); $query->setGroupFacet(true); $query->setGroupCachePercent(100); echo PHP_EOL . "-- Query String --".PHP_EOL; echo $query.PHP_EOL; echo PHP_EOL . "-- Integer --".PHP_EOL; var_dump($query->getGroupOffset(), $query->getGroupLimit(), $query->getGroupCachePercent(0)); echo PHP_EOL . "-- String --".PHP_EOL; var_dump($query->getGroupFormat()); echo PHP_EOL . "-- Array --".PHP_EOL; var_dump($query->getGroupFields()); var_dump($query->getGroupFunctions()); var_dump($query->getGroupQueries()); var_dump($query->getGroupSortFields()); echo PHP_EOL . "-- BOOL --".PHP_EOL; var_dump($query->getGroup(), $query->getGroupMain(), $query->getGroupNGroups(), $query->getGroupTruncate(), $query->getGroupFacet()); echo PHP_EOL; try { $query->setGroupCachePercent(-1); } catch (SolrIllegalArgumentException $e) { echo sprintf("Exception Caught %d: %s", $e->getCode(), $e->getMessage()).PHP_EOL; } ?> --EXPECTF-- -- Query String -- group=true&group.field=category&group.field=featured&group.func=ceil(internalScore)&group.query=silk&group.query=name:june&group.limit=98&group.offset=110&group.sort=count asc,name desc&group.format=simple&group.main=false&group.ngroups=false&group.truncate=true&group.facet=true&group.cache.percent=100 -- Integer -- int(110) int(98) int(100) -- String -- string(6) "simple" -- Array -- array(2) { [0]=> string(8) "category" [1]=> string(8) "featured" } array(1) { [0]=> string(19) "ceil(internalScore)" } array(2) { [0]=> string(4) "silk" [1]=> string(9) "name:june" } array(2) { [0]=> string(9) "count asc" [1]=> string(9) "name desc" } -- BOOL -- bool(true) bool(false) bool(false) bool(true) bool(true) Exception Caught 4000: Group cache percent must be between 0 and 100solr-2.4.0/tests/070.solrquery_collapse.phpt0000644000175000017500000000046712676753706017477 0ustar omaromar--TEST-- SolrQuery::collapse - Collapse Using a SolrCollapseFunction --FILE-- setMax(5); $query->collapse($collapseFunction); echo $query; ?> --EXPECTF-- q=lucene&fq={!collapse field=ISBN max=5} solr-2.4.0/tests/071.solrquery_collapse_exception.phpt0000644000175000017500000000064412676753706021553 0ustar omaromar--TEST-- SolrQuery::collapse - throws SolrMissingMandatoryParameterException --FILE-- collapse($collapseFunction); } catch (SolrMissingMandatoryParameterException $e) { echo PHP_EOL.sprintf('Exception %d: %s', $e->getCode(), $e->getMessage()); } ?> --EXPECTF-- Exception 4100: Mandatory parameter Missing: field solr-2.4.0/tests/072.solrquery_expand.phpt0000644000175000017500000000217712676753706017156 0ustar omaromar--TEST-- SolrQuery - Expand Component --FILE-- setExpand(true); $query->setExpandRows(50); $query->setExpandQuery('text:product'); $query->addExpandFilterQuery('manu:apple')->addExpandFilterQuery('inStock:true'); $query->addExpandSortField('score', SolrQuery::ORDER_DESC)->addExpandSortField('title', SolrQuery::ORDER_ASC); // removal test $query->addExpandFilterQuery('extra')->removeExpandFilterQuery('extra'); $query->addExpandSortField('extra', SolrQuery::ORDER_ASC)->removeExpandSortField('extra'); echo $query.PHP_EOL; var_dump($query->getExpand()).PHP_EOL; var_dump($query->getExpandRows()).PHP_EOL; var_dump($query->getExpandQuery()).PHP_EOL; var_dump($query->getExpandFilterQueries()).PHP_EOL; var_dump($query->getExpandSortFields()).PHP_EOL; ?> --EXPECTF-- q=lucene&expand=true&expand.rows=50&expand.q=text:product&expand.fq=manu:apple&expand.fq=inStock:true&expand.sort=score desc,title asc bool(true) int(50) string(12) "text:product" array(2) { [0]=> string(10) "manu:apple" [1]=> string(12) "inStock:true" } array(2) { [0]=> string(5) "score" [1]=> string(5) "title" } solr-2.4.0/tests/080.solrutils_escapequerychars.phpt0000644000175000017500000000052312676753706021231 0ustar omaromar--TEST-- SolrUtils::escapeQueryChars() - Testing Lucene Reserved Characters --FILE-- --EXPECTF-- \+a \- q\{ \} \[\^test\] \|| \&& \(\) \^ \" \~ \* \? \: \\ \/solr-2.4.0/tests/081.solrutils_digest_json_response.phpt0000644000175000017500000000640612676753706022117 0ustar omaromar--TEST-- SolrUtils::digestJsonResponse() - Digest JSON Response --FILE-- response->docs[0]->_version_ == 1460602453694087168); ?> --EXPECTF-- bool(true) object(SolrObject)#%d (2) { ["responseHeader"]=> object(SolrObject)#4 (3) { ["status"]=> int(0) ["QTime"]=> int(1) ["params"]=> object(SolrObject)#5 (4) { ["indent"]=> string(2) "on" ["wt"]=> string(4) "json" ["q"]=> string(6) "lucene" ["version"]=> string(3) "2.2" } } ["response"]=> object(SolrObject)#%d (3) { ["numFound"]=> int(1) ["start"]=> int(0) ["docs"]=> array(1) { [0]=> object(SolrObject)#%d (11) { ["id"]=> string(8) "SOLR1000" ["name"]=> string(34) "Solr, the Enterprise Search Server" ["manu"]=> string(26) "Apache Software Foundation" ["cat"]=> array(2) { [0]=> string(8) "software" [1]=> string(6) "search" } ["features"]=> array(7) { [0]=> string(51) "Advanced Full-Text Search Capabilities using Lucene" [1]=> string(37) "Optimized for High Volume Web Traffic" [2]=> string(46) "Standards Based Open Interfaces - XML and HTTP" [3]=> string(44) "Comprehensive HTML Administration Interfaces" [4]=> string(64) "Scalability - Efficient Replication to other Solr Search Servers" [5]=> string(56) "Flexible and Adaptable with XML configuration and Schema" [6]=> string(61) "Good unicode support: hello (hello with an accent over the e)" } ["price"]=> float(0) ["price_c"]=> string(5) "0,USD" ["popularity"]=> int(10) ["inStock"]=> bool(true) ["incubationdate_dt"]=> string(20) "2006-01-17T00:00:00Z" ["_version_"]=> %s } } } } bool(true)solr-2.4.0/tests/090.solrserverexception_xml.phpt0000644000175000017500000000151512676753706020552 0ustar omaromar--TEST-- SolrServerException (xml) - Throw Exception on solr server exception using xml response writer --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, // 'wt' => 'xml' ); $client = new SolrClient ( $options ); $query = new SolrQuery ( "lucene\\" ); try { $response = $client->query ( $query ); } catch ( SolrServerException $e ) { echo sprintf("code: %d", $e->getCode()).PHP_EOL; echo sprintf("message: %s", $e->getMessage()).PHP_EOL; print_r($e->getInternalInfo()); } ?> --EXPECTF-- code: %d message: %s Array ( [sourceline] => %d [sourcefile] => %s [zif_name] => %s ) solr-2.4.0/tests/091.solrserverexception_json.phpt0000644000175000017500000000136612676753706020730 0ustar omaromar--TEST-- SolrServerException (json) - Throw Exception on solr server exception using json response writer --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, 'wt' => 'json' ); $client = new SolrClient ( $options ); $query = new SolrQuery ( "lucene\\" ); try { $response = $client->query ( $query ); print_r ( $response ); } catch ( SolrServerException $e ) { echo sprintf("code: %d", $e->getCode()).PHP_EOL; echo sprintf("message: %s", $e->getMessage()).PHP_EOL; } ?> --EXPECTF-- code: %d message: %ssolr-2.4.0/tests/092.solrserverexception_php.phpt0000644000175000017500000000136612676753706020547 0ustar omaromar--TEST-- SolrServerException (phps) - Throw Exception on solr server exception using phps response writer --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, 'wt' => 'phps' ); $client = new SolrClient ( $options ); $query = new SolrQuery ( "lucene\\" ); try { $response = $client->query ( $query ); print_r ( $response ); } catch ( SolrServerException $e ) { echo sprintf("code: %d", $e->getCode()).PHP_EOL; echo sprintf("message: %s", $e->getMessage()).PHP_EOL; } ?> --EXPECTF-- code: %d message: %ssolr-2.4.0/tests/100.solrresponse_json.phpt0000644000175000017500000000111612676753706017321 0ustar omaromar--TEST-- SolrResponse::getResponse - JSON response writer --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, 'wt' => 'json' ); $client = new SolrClient ( $options ); $query = new SolrQuery ( "lucene" ); $response = $client->query ( $query ); $x = $response->getResponse(); var_dump($x instanceof SolrObject); ?> --EXPECTF-- bool(true)solr-2.4.0/tests/101.solrresponse_parseMode.phpt0000644000175000017500000000120112676753706020263 0ustar omaromar--TEST-- SolrResponse - ParseMode --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, 'wt' => 'xml' ); $client = new SolrClient ( $options ); $query = new SolrQuery ( "lucene" ); $response = $client->query ( $query ); $response->setParseMode(SolrResponse::PARSE_SOLR_DOC); $x = $response->getResponse(); var_dump($x->response->docs[0] instanceof SolrDocument); ?> --EXPECTF-- bool(true)solr-2.4.0/tests/102.solrresponse_phps.phpt0000644000175000017500000000111612676753706017324 0ustar omaromar--TEST-- SolrResponse::getResponse - PHPS response writer --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, 'wt' => 'phps' ); $client = new SolrClient ( $options ); $query = new SolrQuery ( "lucene" ); $response = $client->query ( $query ); $x = $response->getResponse(); var_dump($x instanceof SolrObject); ?> --EXPECTF-- bool(true)solr-2.4.0/tests/103.solrresponse_get_array_response.phpt0000644000175000017500000000146412676753706022254 0ustar omaromar--TEST-- SolrResponse::getArrayResponse - For All response writers --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, ); $client = new SolrClient ( $options ); $testArrayResponse = function ($writer) use ($client){ $client->setResponseWriter($writer); $q = new SolrQuery("lucene"); $response = $client->query ( $q ); $arrayResponse = $response->getArrayResponse(); return is_array($arrayResponse); }; var_dump($testArrayResponse('phps')); var_dump($testArrayResponse('xml')); var_dump($testArrayResponse('json')); ?> --EXPECTF-- bool(true) bool(true) bool(true)solr-2.4.0/tests/104.solrresponse_get_response_maxscore.phpt0000644000175000017500000000242012676753706022751 0ustar omaromar--TEST-- SolrResponse::getResponse() - maxScore --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, 'wt'=> 'xml' ); $client = new SolrClient ( $options ); $q = new SolrQuery("lucene"); $q->addField('score'); $response = $client->query ( $q ); $arrayResponse = $response->getArrayResponse(); var_dump($arrayResponse['response']['maxScore']); var_dump($response->getResponse()->response->maxScore); var_dump($response->getResponse()->response->start); var_dump($response->getResponse()->response->numFound); var_dump(is_array($response->getResponse()->response->docs)); echo "------ W/O maxScore ------".PHP_EOL; $q->removeField('score'); $response = $client->query ( $q ); var_dump($response->getResponse()->response->start); var_dump($response->getResponse()->response->numFound); var_dump(is_array($response->getResponse()->response->docs)); var_dump(property_exists($response->getResponse()->response, 'maxScore')); ?> --EXPECTF-- float(%f) float(%f) int(%d) int(%d) bool(true) ------ W/O maxScore ------ int(0) int(1) bool(true) bool(false)solr-2.4.0/tests/105.solrresponse_child_doc_response.phpt0000644000175000017500000000332612676753706022210 0ustar omaromar--TEST-- Response - Response with child documents --FILE-- --EXPECT-- SolrObject Object ( [response] => SolrObject Object ( [numFound] => 3 [start] => 0 [docs] => Array ( [0] => SolrObject Object ( [id] => parent_1 [_childDocuments_] => Array ( [0] => SolrObject Object ( [id] => CHILD_1_1 ) ) ) [1] => SolrObject Object ( [id] => parent_2 [_childDocuments_] => Array ( [0] => SolrObject Object ( [id] => CHILD_2_1 ) [1] => SolrObject Object ( [id] => CHILD_2_2 ) ) ) [2] => SolrObject Object ( [id] => not_a_parent_1 ) ) ) ) solr-2.4.0/tests/106.solrresponse_child_doc_response_solrdoc.phpt0000644000175000017500000000562512676753706023742 0ustar omaromar--TEST-- SolrDocument - Response parsed as SolrDocument with child documents --FILE-- response->docs as $doc) { echo '--- doc start ---'.PHP_EOL; print_r($doc->toArray()); if ($doc->hasChildDocuments()) { foreach ($doc->getChildDocuments() as $child) { print_r($child->toArray()); } } echo '--- doc end ---'.PHP_EOL; } ?> --EXPECT-- --- doc start --- Array ( [document_boost] => 0 [field_count] => 1 [fields] => Array ( [0] => SolrDocumentField Object ( [name] => id [boost] => 0 [values] => Array ( [0] => parent_1 ) ) ) ) Array ( [document_boost] => 0 [field_count] => 1 [fields] => Array ( [0] => SolrDocumentField Object ( [name] => id [boost] => 0 [values] => Array ( [0] => CHILD_1_1 ) ) ) ) --- doc end --- --- doc start --- Array ( [document_boost] => 0 [field_count] => 1 [fields] => Array ( [0] => SolrDocumentField Object ( [name] => id [boost] => 0 [values] => Array ( [0] => parent_2 ) ) ) ) Array ( [document_boost] => 0 [field_count] => 1 [fields] => Array ( [0] => SolrDocumentField Object ( [name] => id [boost] => 0 [values] => Array ( [0] => CHILD_2_1 ) ) ) ) Array ( [document_boost] => 0 [field_count] => 1 [fields] => Array ( [0] => SolrDocumentField Object ( [name] => id [boost] => 0 [values] => Array ( [0] => CHILD_2_2 ) ) ) ) --- doc end --- --- doc start --- Array ( [document_boost] => 0 [field_count] => 1 [fields] => Array ( [0] => SolrDocumentField Object ( [name] => id [boost] => 0 [values] => Array ( [0] => not_a_parent_1 ) ) ) ) --- doc end --- solr-2.4.0/tests/110.solrdismaxquery.phpt0000644000175000017500000000400312676753706017004 0ustar omaromar--TEST-- SolrDisMaxQuery - Methods --FILE-- addPhraseField('source', 55) ->addPhraseField('cat', 3, 1) ->addPhraseField('third', 4, 1) ->removePhraseField('third') ->addPhraseField('fourth', 0.5) ->addPhraseField('fifth',5.2, 7.8) ->setQueryAlt('*:*') ->addQueryField("price") ->addQueryField("location", 4) ->setPhraseSlop(2) ->setQueryPhraseSlop(3) ->setTieBreaker(0.5) ->setMinimumMatch(2) ; // reverse echo $dismaxQuery.PHP_EOL; $dismaxQuery = new SolrDisMaxQuery("lucene"); $dismaxQuery ->addQueryField("location", 4) ->addQueryField("price") ->addQueryField("sku") ->addQueryField("title",3.4) ->addPhraseField('cat', 3, 1) ->addPhraseField('third', 4, 1) ->addPhraseField('source', 55) ; echo $dismaxQuery.PHP_EOL; $dismaxQuery->setPhraseFields('source^55 cat~1^3'); echo $dismaxQuery.PHP_EOL; $dismaxQuery = new SolrDisMaxQuery('lucene'); $dismaxQuery->addPhraseField('first', 3, 1) ->addPhraseField('second', 4, 1) ->addPhraseField('cat', 55); echo $dismaxQuery. PHP_EOL; echo $dismaxQuery->removePhraseField('second').PHP_EOL; $dismaxQuery = new SolrDisMaxQuery('lucene'); $dismaxQuery->addQueryField('first', 3) ->addQueryField('second', 0.2) ->addQueryField('cat'); echo $dismaxQuery. PHP_EOL; echo $dismaxQuery->removeQueryField('second').PHP_EOL; $dismaxQuery = new SolrDisMaxQuery('lucene'); $dismaxQuery->setPhraseSlop(4); echo $dismaxQuery.PHP_EOL; ?> --EXPECTF-- q=lucene&defType=%s&pf=source^55 cat~1^3 fourth^0.5 fifth~7.8^5.2&q.alt=*:*&qf=price location^4&ps=2&qs=3&tie=0.5&mm=2 q=lucene&defType=%s&qf=location^4 price sku title^3.4&pf=cat~1^3 third~1^4 source^55 Notice: SolrDisMaxQuery::setPhraseFields(): Parameter pf value(s) was overwritten by this call in %s on line %d q=lucene&defType=%s&qf=location^4 price sku title^3.4&pf=source^55 cat~1^3 q=lucene&defType=%s&pf=first~1^3 second~1^4 cat^55 q=lucene&defType=%s&pf=first~1^3 cat^55 q=lucene&defType=%s&qf=first^3 second^0.2 cat q=lucene&defType=%s&qf=first^3 cat q=lucene&defType=%s&ps=4solr-2.4.0/tests/111.solrdismaxquery_boostquery.phpt0000644000175000017500000000125112676753706021303 0ustar omaromar--TEST-- SolrDisMaxQuery - Boost Query --FILE-- addBoostQuery('cat', 'electronics', 5.1) ->addBoostQuery('cat', 'hard drive') ; // reverse echo $dismaxQuery.PHP_EOL; $dismaxQuery ->removeBoostQuery('cat'); echo $dismaxQuery.PHP_EOL; $dismaxQuery->setBoostQuery('cat:electronics manu:local^2'); echo $dismaxQuery.PHP_EOL; ?> --EXPECTF-- q=lucene&defType=edismax&bq=cat:electronics^5.1 cat:hard drive q=lucene&defType=edismax&bq=cat:hard drive Notice: SolrDisMaxQuery::setBoostQuery(): Parameter bq value(s) was overwritten by this call in %s on line %d q=lucene&defType=edismax&bq=cat:electronics manu:local^2 solr-2.4.0/tests/112.solrdismaxquery_query_parser.phpt0000644000175000017500000000056112676753706021614 0ustar omaromar--TEST-- SolrDisMaxQuery - QueryParser Switch --FILE-- useDisMaxQueryParser(); echo $dismaxQuery.PHP_EOL; $dismaxQuery->useEDisMaxQueryParser(); echo $dismaxQuery.PHP_EOL; ?> --EXPECTF-- q=hard drive&defType=edismax q=hard drive&defType=dismax q=hard drive&defType=edismaxsolr-2.4.0/tests/113.solrdismaxquery_bigramfields.phpt0000644000175000017500000000153112676753706021522 0ustar omaromar--TEST-- SolrDisMaxQuery - BigramFields and slop (addBigramPhraseField, removeBigramPhraseField, setBigramPhraseFields) --FILE-- addBigramPhraseField('cat', 2, 5.1) ->addBigramPhraseField('feature', 4.5) ; echo $dismaxQuery.PHP_EOL; // reverse $dismaxQuery ->removeBigramPhraseField('cat'); echo $dismaxQuery.PHP_EOL; $dismaxQuery->setBigramPhraseFields("cat~5.1^2 feature^4.5"); echo $dismaxQuery.PHP_EOL; $dismaxQuery->setBigramPhraseSlop(2); echo $dismaxQuery.PHP_EOL; ?> --EXPECTF-- q=lucene&defType=%s&pf2=cat~5.1^2 feature^4.5 q=lucene&defType=%s&pf2=feature^4.5 Notice: SolrDisMaxQuery::setBigramPhraseFields(): Parameter pf2 value(s) was overwritten by this call in %s on line %d q=lucene&defType=%s&pf2=cat~5.1^2 feature^4.5 q=lucene&defType=%s&pf2=cat~5.1^2 feature^4.5&ps2=2 solr-2.4.0/tests/114.solrdismaxquery_trigramfields.phpt0000644000175000017500000000154312676753706021732 0ustar omaromar--TEST-- SolrDisMaxQuery - TrigramFields and slop (addTrigramPhraseField, removeTrigramPhraseField, setTrigramPhraseFields) --FILE-- addTrigramPhraseField('cat', 2, 5.1) ->addTrigramPhraseField('feature', 4.5) ; echo $dismaxQuery.PHP_EOL; // reverse $dismaxQuery ->removeTrigramPhraseField('cat'); echo $dismaxQuery.PHP_EOL; $dismaxQuery->setTrigramPhraseFields('cat~5.1^2 feature^4.5'); echo $dismaxQuery.PHP_EOL; $dismaxQuery->setTrigramPhraseSlop(2); echo $dismaxQuery.PHP_EOL; ?> --EXPECTF-- q=lucene&defType=%s&pf3=cat~5.1^2 feature^4.5 q=lucene&defType=%s&pf3=feature^4.5 Notice: SolrDisMaxQuery::setTrigramPhraseFields(): Parameter pf3 value(s) was overwritten by this call in %s on line %d q=lucene&defType=%s&pf3=cat~5.1^2 feature^4.5 q=lucene&defType=%s&pf3=cat~5.1^2 feature^4.5&ps3=2 solr-2.4.0/tests/115.solrdismaxquery_userfields.phpt0000644000175000017500000000120312676753706021235 0ustar omaromar--TEST-- SolrDisMaxQuery - UserFields (uf parameter) (addUserField) --FILE-- addUserField('cat') ->addUserField('text') ->addUserField('*_dt') ; echo $dismaxQuery.PHP_EOL; // // reverse $dismaxQuery ->removeUserField('text'); echo $dismaxQuery.PHP_EOL; $dismaxQuery->setUserFields('field1 field2 *_txt'); echo $dismaxQuery.PHP_EOL; ?> --EXPECTF-- q=lucene&defType=%s&uf=cat text *_dt q=lucene&defType=%s&uf=cat *_dt Notice: SolrDisMaxQuery::setUserFields(): Parameter uf value(s) was overwritten by this call in %s on line %d q=lucene&defType=edismax&uf=field1 field2 *_txtsolr-2.4.0/tests/116.solrdismaxquery_boostfunction.phpt0000644000175000017500000000052512676753706021773 0ustar omaromar--TEST-- SolrDisMaxQuery - setBoostFunction --FILE-- setBoostFunction($boostRecentDocsFunction); echo $dismaxQuery.PHP_EOL; ?> --EXPECTF-- q=lucene&defType=%s&bf=recip(ms(NOW,mydatefield),3.16e-11,1,1)solr-2.4.0/tests/130.parameters_simple_list_separator.phpt0000644000175000017500000000062512676753706022370 0ustar omaromar--TEST-- simple_list_parameter type - Use of default, non-default separator --FILE-- addField("te")->addField("te2"); echo $query.PHP_EOL; $dismaxQuery = new SolrDisMaxQuery(); $dismaxQuery ->addUserField('cat') ->addUserField('text') ->addUserField('*_dt') ; echo $dismaxQuery.PHP_EOL; ?> --EXPECTF-- fl=te,te2 defType=edismax&uf=cat text *_dtsolr-2.4.0/tests/150.solrcollapsefunction.phpt0000644000175000017500000000153112676753706020010 0ustar omaromar--TEST-- SolrCollapseFunction - string conversion --FILE-- setField('field2'); $func->setMax('max'); $func->setMin('min'); $func->setSize(1000); $func->setHint('hint'); $func->setNullPolicy(SolrCollapseFunction::NULLPOLICY_EXPAND); var_dump($func->getField()); var_dump($func->getMax()); var_dump($func->getMin()); var_dump($func->getSize()); var_dump($func->getHint()); var_dump($func->getNullPolicy()); var_dump((string)$func); $func->setMax('with space'); var_dump((string)$func); ?> --EXPECTF-- string(6) "field2" string(3) "max" string(3) "min" string(4) "1000" string(4) "hint" string(6) "expand" string(78) "{!collapse field=field2 max=max min=min size=1000 hint=hint nullPolicy=expand}" string(87) "{!collapse field=field2 max='with space' min=min size=1000 hint=hint nullPolicy=expand}" solr-2.4.0/tests/151.solrcollapsefunction_illegal_operations.phpt0000644000175000017500000000137012676753706023746 0ustar omaromar--TEST-- SolrCollapseFunction - Illegal Operations --SKIPIF-- --FILE-- getCode(), $e->getMessage()).PHP_EOL; } $func->setMax('max'); try { // known issue, object corruption $tmp = serialize($func); } catch (SolrIllegalOperationException $e) { echo PHP_EOL . sprintf('Code %d: %s', $e->getCode(), $e->getMessage()).PHP_EOL; } ?> --EXPECTF-- Code 4001: Cloning of SolrCollapseFunction objects is currently not supported Code 1001: Serialization of SolrCollapseFunction objects is currently not supported solr-2.4.0/tests/160.solr_update_document_block.phpt0000644000175000017500000000424712676753706021141 0ustar omaromar--TEST-- Solr - Fetch and Update nested documents --SKIPIF-- --FILE-- getChildDocuments(); $child = $children[0]; $child->deleteField('inventory_i'); $child->addField('inventory_i', $inventory); $document->deleteField('_version_'); }; $getInventory = function ($response) { return (int) current($response->response->docs[0]->getChildDocuments()[0]['inventory_i']->values); }; $options = array ( 'hostname' => SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_STORE_PATH, 'wt' => 'xml' ); $client = new SolrClient ( $options ); $query = new SolrQuery ('id:1 AND {!parent which=$parentFilter}'); $query->setParam ( 'parentFilter', 'content_type_s:product' ); $query->addFilterQuery('{!parent which=$parentFilter}'); $query->addField ( '*' ); $query->addField ( '[child parentFilter=$parentFilter]' ); $query->setStart ( 0 ); $query->setRows ( 1 ); // query existing inventory $queryResponse = $client->query ( $query ); $queryResponse->setParseMode(SolrResponse::PARSE_SOLR_DOC); $response = $queryResponse->getResponse(); $existingInventory = $getInventory($response); // update inventory to 300 $document = $response->response->docs[0]->getInputDocument(); $updateInventory($document, 300); $client->addDocument($document); $client->commit(); // fetch the document again after the update $queryResponse = $client->query ( $query ); $queryResponse->setParseMode(SolrResponse::PARSE_SOLR_DOC); $response = $queryResponse->getResponse(); $newInventory = $getInventory($response); assert($newInventory == 300); echo "------EXISTING------" . PHP_EOL; var_dump($existingInventory); echo "----AFTER UPDATE----" . PHP_EOL; var_dump($newInventory); // cleanup: restore document's original state $document = $response->response->docs[0]->getInputDocument(); $updateInventory($document, $existingInventory); $client->addDocument($document); $client->commit(); ?> --EXPECT-- ------EXISTING------ int(200) ----AFTER UPDATE---- int(300)solr-2.4.0/tests/bug_59511_error.phpt0000644000175000017500000000131512676753706015766 0ustar omaromar--TEST-- Solr bug #59511 - SolrClient::query() Timeout shall throw a SolrClientException --SKIPIF-- --FILE-- 'anyhost', 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, 'timeout' => 2 ); $client = new SolrClient($options); $query = new SolrQuery("lucene"); try { $query_response = $client->query($query); } catch (SolrClientException $e) { echo $e->getMessage().PHP_EOL; echo $e->getCode().PHP_EOL; } ?> --EXPECTF-- Solr HTTP Error %d: '%s' 1004solr-2.4.0/tests/bug_61836_error.phpt0000644000175000017500000000106212676753706015770 0ustar omaromar--TEST-- Solr bug #61836 - Extending SolrDocument --SKIPIF-- --FILE-- addField('testname', true); ?> --EXPECTF-- Fatal error: Class Model_SolrDocument may not inherit from final class (SolrDocument) in %s on line %dsolr-2.4.0/tests/bug_67394.phpt0000644000175000017500000000125012676753706014563 0ustar omaromar--TEST-- Solr Bug #67394 - Unable to parse response with NaN --FILE-- stats->stats_fields->date->stddev); $xmlFixture = file_get_contents(ROOT_DIRECTORY . '/files/bug67394.xml'); if (!json_decode($fixture)) { echo "PHP JSON DECODE failed with: ". json_last_error_msg().PHP_EOL; } $response = SolrUtils::digestXmlResponse($xmlFixture); var_dump($response->response->stats->stats_fields->currentPrice->mean); ?> --EXPECTF-- string(3) "NaN" float(NAN)solr-2.4.0/tests/bug_68179.phpt0000644000175000017500000000052512676753706014571 0ustar omaromar--TEST-- Solr Bug #68179 - Solr Params (Argument list) separator disappears --FILE-- addSortField('price', SolrQuery::ORDER_ASC); $dismaxQuery->addSortField('score', SolrQuery::ORDER_DESC); echo $dismaxQuery.PHP_EOL; ?> --EXPECTF-- q=score&defType=%s&sort=price asc,score descsolr-2.4.0/tests/bug_68181.phpt0000644000175000017500000000110112676753706014551 0ustar omaromar--TEST-- Solr Bug #68181 - Conflict occurs when using SolrDisMax::addBoostQuery and setBoostQuery --FILE-- setBoostQuery("failing:val^3") ->addBoostQuery('category','software',2) ->setBoostQuery("end:result^4"); echo $dismaxQuery.PHP_EOL; ?> --EXPECTF-- Notice: SolrDisMaxQuery::addBoostQuery(): Parameter bq value(s) was overwritten by this call in %s on line %d Notice: SolrDisMaxQuery::setBoostQuery(): Parameter bq value(s) was overwritten by this call in %s on line %d q=lucene&defType=%s&bq=end:result^4solr-2.4.0/tests/bug_69156.phpt0000644000175000017500000000122312676753706014561 0ustar omaromar--TEST-- Solr Bug #69156 - segfault on 500 response from Solr --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => 'solr/collection44444', 'wt' => 'phps' ); $client = new SolrClient($options); $query = new SolrQuery("lucene"); try { $query_response = $client->query($query); } catch (Exception $e) { } ?> --EXPECTF-- Notice: SolrClient::query(): Unable to parse serialized php response in %s on line %d solr-2.4.0/tests/bug_70482.phpt0000644000175000017500000000170212676753706014555 0ustar omaromar--TEST-- Solr Bug #70482 - Segmentation fault on server 500 response with no msg field XML RW --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, 'wt' => 'xml' ); $client = new SolrClient($options); $query = new SolrQuery('*:*'); $func = new SolrCollapseFunction('manu_id_s'); $func->setMax('sum(cscore(),field(manu_id_s))'); $func->setSize(100); $func->setNullPolicy(SolrCollapseFunction::NULLPOLICY_EXPAND); $query->collapse($func); try { $queryResponse = $client->query($query); } catch (SolrServerException $e) { printf("Exception code %d", $e->getCode()); assert(strlen($e->getMessage()) > 0, 'Exception message is empty'); echo PHP_EOL; } ?> OK --EXPECTF-- Exception code %d OKsolr-2.4.0/tests/bug_70495.phpt0000644000175000017500000000174612676753706014571 0ustar omaromar--TEST-- Solr Bug #70495 - Failed to parse 500 error response when Solr it lacks msg JSON RW --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, 'wt' => 'json' ); $client = new SolrClient($options); $query = new SolrQuery('*:*'); $func = new SolrCollapseFunction('manu_id_s'); $func->setMax('sum(cscore(),field(manu_id_s))'); $func->setSize(100); $func->setNullPolicy(SolrCollapseFunction::NULLPOLICY_EXPAND); $query->collapse($func); try { $queryResponse = $client->query($query); } catch (SolrServerException $e) { printf("Exception code %d", $e->getCode()); assert(strlen($e->getMessage()) > 0, 'Exception message is empty'); } ?> OK --EXPECTF-- Exception code 500 OKsolr-2.4.0/tests/bug_70496.phpt0000644000175000017500000000164212676753706014565 0ustar omaromar--TEST-- Solr Bug #70496 - Failed to parse 500 error response when Solr it lacks msg PHPS RW --SKIPIF-- --FILE-- SOLR_SERVER_HOSTNAME, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD, 'port' => SOLR_SERVER_PORT, 'path' => SOLR_SERVER_PATH, 'wt' => 'phps' ); $client = new SolrClient($options); $query = new SolrQuery('*:*'); $func = new SolrCollapseFunction('manu_id_s'); $func->setMax('sum(cscore(),field(manu_id_s))'); $func->setNullPolicy(SolrCollapseFunction::NULLPOLICY_EXPAND); $query->collapse($func); try { $queryResponse = $client->query($query); } catch (SolrServerException $e) { printf("Exception code %d", $e->getCode()); assert(strlen($e->getMessage()) > 0, 'Exception message is empty'); } ?> OK --EXPECTF-- Exception code 500 OKsolr-2.4.0/pecl-compat/src/misc.h0000644000175000017500000001602512676753706015300 0ustar omaromar/* +----------------------------------------------------------------------+ | Compatibility between PHP versions | +----------------------------------------------------------------------+ | Copyright (c) 2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Francois Laupretre | +----------------------------------------------------------------------+ */ #ifndef __PECL_COMPAT_MISC_H #define __PECL_COMPAT_MISC_H 1 #ifdef PHP_7 /*============================================================================*/ typedef zend_string * OPENED_PATH_PTR; /* Type of stream opened_path argument */ typedef size_t COMPAT_ARG_SIZE_T; /* Size of string arguments */ typedef zend_long COMPAT_ARG_LONG_T; /* Type of long (integer) arguments */ #define compat_zval_ptr_dtor(zp) zval_ptr_dtor(zp) #include #else /*== PHP 5 ===================================================================*/ typedef char * OPENED_PATH_PTR; typedef off_t zend_off_t; typedef int COMPAT_ARG_SIZE_T; typedef long COMPAT_ARG_LONG_T; typedef long zend_long; #define compat_zval_ptr_dtor(zp) zval_dtor(zp) #endif /*============================================================================*/ #ifndef MIN # define MIN(a,b) (((a) < (b)) ? (a) : (b)) #endif #ifndef MAX # define MAX(a,b) (((a) > (b)) ? (a) : (b)) #endif /*---------------------------------------------------------------*/ /* (Taken from pcre/pcrelib/internal.h) */ /* To cope with SunOS4 and other systems that lack memmove() but have bcopy(), define a macro for memmove() if HAVE_MEMMOVE is false, provided that HAVE_BCOPY is set. Otherwise, include an emulating function for those systems that have neither (there are some non-Unix environments where this is the case). This assumes that all calls to memmove are moving strings upwards in store, which is the case in this extension. */ #if ! HAVE_MEMMOVE # ifdef memmove # undef memmove /* some systems may have a macro */ # endif # if HAVE_BCOPY # define memmove(a, b, c) bcopy(b, a, c) # else static void *my_memmove(unsigned char *dest, const unsigned char *src, size_t n) { int i; dest += n; src += n; for (i = 0; i < n; ++i) *(--dest) = *(--src); } # define memmove(a, b, c) my_memmove(a, b, c) # endif /* not HAVE_BCOPY */ #endif /* not HAVE_MEMMOVE */ #ifdef _AIX # undef PHP_SHLIB_SUFFIX # define PHP_SHLIB_SUFFIX "a" #endif #ifndef ZVAL_IS_ARRAY #define ZVAL_IS_ARRAY(zp) (Z_TYPE_P((zp))==IS_ARRAY) #endif #ifndef ZVAL_IS_STRING #define ZVAL_IS_STRING(zp) (Z_TYPE_P((zp))==IS_STRING) #endif #ifndef ZVAL_IS_LONG #define ZVAL_IS_LONG(zp) (Z_TYPE_P((zp))==IS_LONG) #endif #ifndef ZVAL_IS_BOOL #define ZVAL_IS_BOOL(zp) (Z_TYPE_P((zp))==IS_BOOL) #endif #ifndef INIT_ZVAL #define INIT_ZVAL(z) memset(&z, 0, sizeof(z)) #endif #ifndef ZVAL_UNDEF #define ZVAL_UNDEF(z) INIT_ZVAL(*(z)) #endif #ifndef MAKE_STD_ZVAL #define MAKE_STD_ZVAL(zp) { zp = emalloc(sizeof(zval)); INIT_ZVAL(*zp); } #endif #ifndef ALLOC_INIT_ZVAL #define ALLOC_INIT_ZVAL(zp) MAKE_STD_ZVAL(zp) #endif #ifndef ZEND_ASSUME #if defined(ZEND_WIN32) && !defined(__clang__) # define ZEND_ASSUME(c) __assume(c) #else # define ZEND_ASSUME(c) #endif #endif #ifndef ZEND_ASSERT #if ZEND_DEBUG # define ZEND_ASSERT(c) assert(c) #else # define ZEND_ASSERT(c) ZEND_ASSUME(c) #endif #endif #ifndef EMPTY_SWITCH_DEFAULT_CASE /* Only use this macro if you know for sure that all of the switches values are covered by its case statements */ #if ZEND_DEBUG # define EMPTY_SWITCH_DEFAULT_CASE() default: ZEND_ASSERT(0); break; #else # define EMPTY_SWITCH_DEFAULT_CASE() default: ZEND_ASSUME(0); break; #endif #endif #ifndef ZEND_IGNORE_VALUE #if defined(__GNUC__) && __GNUC__ >= 4 # define ZEND_IGNORE_VALUE(x) (({ __typeof__ (x) __x = (x); (void) __x; })) #else # define ZEND_IGNORE_VALUE(x) ((void) (x)) #endif #endif #if PHP_API_VERSION >= 20100412 typedef size_t PHP_ESCAPE_HTML_ENTITIES_SIZE; #else typedef int PHP_ESCAPE_HTML_ENTITIES_SIZE; #endif /* Avoid a warning when compiling stream wrapper declarations for openfile/opendir/url_stat */ #if ZEND_EXTENSION_API_NO >= PHP_5_6_X_API_NO # define COMPAT_STREAM_CONST_DECL const #else # define COMPAT_STREAM_CONST_DECL #endif #ifndef ZEND_MODULE_GLOBALS_ACCESSOR # ifdef ZTS # define ZEND_MODULE_GLOBALS_ACCESSOR(module_name, v) \ TSRMG(module_name##_globals_id, zend_##module_name##_globals *, v) # else # define ZEND_MODULE_GLOBALS_ACCESSOR(module_name, v) \ (module_name##_globals.v) # endif #endif #ifndef ZEND_MODULE_GLOBALS_BULK # ifdef ZTS # define ZEND_MODULE_GLOBALS_BULK(module_name) \ ((zend_##module_name##_globals *) \ (*((void ***) tsrm_ls))[module_name##_globals_id - 1]) # else # define ZEND_MODULE_GLOBALS_BULK(module_name) \ (&module_name##_globals) # endif #endif #ifndef ZEND_TSRMLS_CACHE_DEFINE # define ZEND_TSRMLS_CACHE_DEFINE() #endif #ifndef ZEND_TSRMLS_CACHE_UPDATE # define ZEND_TSRMLS_CACHE_UPDATE() #endif #ifndef PHP_FE_END # define PHP_FE_END { NULL, NULL, NULL } #endif #ifndef ZEND_MOD_END /* for php < 5.3.7 */ # define ZEND_MOD_END {NULL, NULL, NULL} #endif /*============================================================================*/ /* Duplicate a memory buffer */ /* Supports zero size (allocates 1 byte) */ static zend_always_inline void *_compat_dup(const void *ptr, size_t size, int persistent) { char *p; if (!ptr) return NULL; if (size) { p = pemalloc(size, persistent); memmove(p, ptr, size); } else { p = pemalloc(1,persistent); (*p) = '\0'; /* Ensures deterministic behavior */ } return p; } /*---------------------------------------------------------------*/ /* Duplicate a string and set terminating null. Input string does not have to be null-terminated */ static zend_always_inline void *_compat_dup_str(const void *ptr, size_t size, int persistent) { char *p; if (!ptr) return NULL; p = pemalloc(size + 1, persistent); if (size) memmove(p, ptr, size); p[size] = '\0'; return p; } /*-----------------------------------------------------*/ /* Fatal error - display message and abort process */ static zend_always_inline void compat_unsupported(char *msg) { php_error(E_CORE_ERROR, "This feature is not supported in this environment : %s", msg); exit(1); } /*============================================================================*/ #endif /* __PECL_COMPAT_MISC_H */ solr-2.4.0/pecl-compat/src/zend_hash.h0000644000175000017500000002566212676753706016317 0ustar omaromar/* +----------------------------------------------------------------------+ | zend_hash compatibility layer for PHP 5 & 7 | +----------------------------------------------------------------------+ | Copyright (c) 2005-2007 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Francois Laupretre | +----------------------------------------------------------------------+ */ #ifndef _COMPAT_ZEND_HASH_H #define _COMPAT_ZEND_HASH_H #include "zend_hash.h" #ifdef PHP_7 /*============================================================================*/ #define compat_zend_hash_exists(ht, key) zend_hash_exists(ht, key) #define compat_zend_hash_str_exists(ht, str, len) zend_hash_str_exists(ht, str, len) #define COMPAT_HASH_PTR(_zp) (&(Z_PTR_P(_zp))) /*---------*/ /* Changes from original version: - If numeric key, returned (zend_string *) is set to NULL. - If non null, returned zend_string must be released. */ static zend_always_inline int compat_zend_hash_get_current_key_ex(const HashTable *ht , zend_string **str_index, zend_ulong *num_index, HashPosition *pos) { int status; if (str_index) (*str_index) = NULL; status = zend_hash_get_current_key_ex(ht, str_index, num_index, pos); if (*str_index) zend_string_addref(*str_index); return status; } /*---------*/ /* Added - This function is equivalent to the PHP 5 version of zend_hash_get_current_key_ex() */ static zend_always_inline int compat_zend_hash_str_get_current_key_ex(const HashTable *ht , char **str_index, size_t *str_length, zend_ulong *num_index , zend_bool duplicate, HashPosition *pos) { int status; zend_string *zp; zp = NULL; status = zend_hash_get_current_key_ex(ht, &zp, num_index, pos); if (zp) { if (duplicate) { (*str_index) = estrndup(ZSTR_VAL(zp), ZSTR_LEN(zp)); } else { (*str_index) = ZSTR_VAL(zp); } (*str_length) = ZSTR_LEN(zp); } return status; } /*---------*/ static zend_always_inline void *compat_zend_hash_get_current_data_ptr_ex(HashTable *ht , HashPosition *pos) { zval *zp; zp = zend_hash_get_current_data_ex(ht, pos); return Z_PTR_P(zp); } #define compat_zend_hash_get_current_data_ptr(ht) \ compat_zend_hash_get_current_data_ptr_ex(ht, &(ht)->nInternalPointer) /*---------*/ static zend_always_inline void *compat_zend_hash_get_current_data_ex(HashTable *ht , HashPosition *pos) { return (void *)zend_hash_get_current_data_ex(ht, pos); } #define compat_zend_hash_get_current_data(ht) \ compat_zend_hash_get_current_data_ex(ht, &(ht)->nInternalPointer) #define compat_zend_hash_get_current_zval_ex(ht, pos) \ (zval *)compat_zend_hash_get_current_data_ex(ht, pos) #define compat_zend_hash_get_current_zval(ht) \ compat_zend_hash_get_current_zval_ex(ht, &(ht)->nInternalPointer) #else /*= PHP 5 ====================================================================*/ #ifndef HASH_KEY_NON_EXISTENT #define HASH_KEY_NON_EXISTENT HASH_KEY_NON_EXISTANT #endif #define COMPAT_HASH_PTR(_zp) (_zp) /*------------------------------------------------*/ static zend_always_inline void *zend_hash_add_ptr(HashTable *ht , zend_string *key, void *pData) { int status; status = zend_hash_quick_add(ht, ZSTR_VAL(key), (uint)(ZSTR_LEN(key) + 1) , (ulong)ZSTR_HASH(key), &pData, sizeof(void *), NULL); return (status == SUCCESS ? pData : NULL); } #define zend_hash_add_new_ptr(ht, key, pData) zend_hash_add_ptr(ht, key, pData) #define zend_hash_add_mem(ht, key, pData, size) \ zend_hash_add_ptr(ht, key, _compat_dup(pData, size, ht->persistent)) /*---------*/ static zend_always_inline void *zend_hash_str_add_ptr(HashTable *ht , const char *str, size_t len, void *pData) { int status; char *strn = _compat_dup_str(str, len, 0); status = zend_hash_add(ht, strn, len + 1, &pData, sizeof(void *), NULL); efree(strn); return (status == SUCCESS ? pData : NULL); } #define zend_hash_str_add_new_ptr(ht, str, len, pData) zend_hash_str_add_ptr(ht, str, len, pData) #define zend_hash_str_add_mem(ht, str, len, pData, size) \ zend_hash_str_add_ptr(ht, str, len, _compat_dup(pData, size, ht->persistent)) /*---------*/ static zend_always_inline void *zend_hash_index_add_ptr(HashTable *ht , zend_ulong h, void *pData) { int status; status = zend_hash_index_update(ht, (ulong)h, &pData, sizeof(void *), NULL); return (status == SUCCESS ? pData : NULL); } #define zend_hash_index_add_new_ptr(ht, h, pData) \ zend_hash_index_add_ptr(ht, h, pData) #define zend_hash_index_add_mem(ht, h, pData, size) \ zend_hash_index_add_ptr(ht, h, _compat_dup(pData, size, ht->persistent)) /*---------*/ static zend_always_inline void *zend_hash_next_index_insert_ptr(HashTable *ht , void *pData) { int status; status = zend_hash_next_index_insert(ht, &pData, sizeof(void *), NULL); return (status == SUCCESS ? pData : NULL); } #define zend_hash_next_index_insert_mem(ht, pData, size) \ zend_hash_next_index_insert_ptr(ht, _compat_dup(pData, size, ht->persistent)) /*---------*/ static zend_always_inline void *zend_hash_update_ptr(HashTable *ht , zend_string *key, void *pData) { int status; status = zend_hash_quick_update(ht, ZSTR_VAL(key), (uint)(ZSTR_LEN(key) + 1) , (ulong)ZSTR_HASH(key), &pData, sizeof(void *), NULL); return (status == SUCCESS ? pData : NULL); } #define zend_hash_update_mem(ht, key, pData, size) \ zend_hash_update_ptr(ht, key, _compat_dup(pData, size, ht->persistent)) /*---------*/ static zend_always_inline void *zend_hash_str_update_ptr(HashTable *ht , const char *str, size_t len, void *pData) { int status; char *strn = _compat_dup_str(str, len, 0); status = zend_hash_update(ht, strn, len + 1, &pData, sizeof(void *), NULL); efree(strn); return (status == SUCCESS ? pData : NULL); } #define zend_hash_str_upate_mem(ht, str, len, pData, size) \ zend_hash_str_update_ptr(ht, str, len, _compat_dup(pData, size, ht->persistent)) #define zend_hash_index_update_ptr(ht, h, pData) \ zend_hash_index_add_ptr(ht, h, pData) #define zend_hash_index_update_mem(ht, h, pData, size) \ zend_hash_index_add_mem(ht, h, pData, size) /*---------*/ static zend_always_inline void *zend_hash_find_ptr(const HashTable *ht , zend_string *key) { int status; void **p; status = zend_hash_quick_find(ht, ZSTR_VAL(key), (uint)(ZSTR_LEN(key) + 1) , (ulong)ZSTR_HASH(key), (void **)(&p)); return (status == SUCCESS ? (*p) : NULL); } /*---------*/ static zend_always_inline void *zend_hash_str_find_ptr(const HashTable *ht , const char *str, size_t len) { int status; void **p; char *strn = _compat_dup_str(str, len, 0); status = zend_hash_find(ht, strn, len + 1, (void **)(&p)); efree(strn); return (status == SUCCESS ? (*p) : NULL); } /*---------*/ static zend_always_inline void *zend_hash_index_find_ptr(const HashTable *ht , zend_ulong h) { int status; void **p; status = zend_hash_index_find(ht, h, (void **)(&p)); return (status == SUCCESS ? (*p) : NULL); } /*---------*/ static zend_always_inline zend_bool compat_zend_hash_exists(const HashTable *ht , zend_string *key) { return zend_hash_quick_exists(ht, ZSTR_VAL(key), (uint)(ZSTR_LEN(key) + 1) , (ulong)ZSTR_HASH(key)); } /*---------*/ static zend_always_inline zend_bool compat_zend_hash_str_exists(const HashTable *ht , const char *str, size_t len) { zend_bool status; char *strn = _compat_dup_str(str, len, 0); status = zend_hash_exists(ht, strn, (uint)(len + 1)); efree(strn); return status; } /*---------*/ /* Changes from original version: - Returns a zend_string - If key is a string, returned zend_string must be released. */ static zend_always_inline int compat_zend_hash_get_current_key_ex(const HashTable *ht , zend_string **str_index, zend_ulong *num_index, HashPosition *pos) { int status; char *str; uint str_length; ulong num; status = zend_hash_get_current_key_ex(ht, &str, &str_length, &num, 0, pos); if (status == HASH_KEY_IS_STRING) { (*str_index) = zend_string_init(str, str_length - 1, ht->persistent); } else if (status == HASH_KEY_IS_LONG) { (*num_index) = (zend_ulong)num; } return status; } /*---------*/ /* Diff with original : - Type casts - Return string length, without trailing null */ static zend_always_inline int compat_zend_hash_str_get_current_key_ex(const HashTable *ht , char **str_index, size_t *str_length, zend_ulong *num_index , zend_bool duplicate, HashPosition *pos) { int status; uint length; ulong num; status = zend_hash_get_current_key_ex(ht, str_index, &length, &num, duplicate, pos); if (status == HASH_KEY_IS_STRING) { (*str_length) = (size_t)(length - 1); } else if (status == HASH_KEY_IS_LONG) { (*num_index) = (zend_ulong)num; } return status; } /*---------*/ static zend_always_inline void *compat_zend_hash_get_current_data_ptr_ex(HashTable *ht , HashPosition *pos) { int status; void **p; status = zend_hash_get_current_data_ex(ht, (void **)(&p), pos); return ((status == SUCCESS) ? (*p) : NULL); } #define compat_zend_hash_get_current_data_ptr(ht) \ compat_zend_hash_get_current_data_ptr_ex(ht, NULL) /*---------*/ static zend_always_inline void *compat_zend_hash_get_current_data_ex(HashTable *ht , HashPosition *pos) { int status; void **p; status = zend_hash_get_current_data_ex(ht, (void **)(&p), pos); return ((status == SUCCESS) ? p : NULL); } #define compat_zend_hash_get_current_data(ht) \ compat_zend_hash_get_current_data_ex(ht, NULL) #define compat_zend_hash_get_current_zval_ex(ht, pos) \ *((zval **)compat_zend_hash_get_current_data_ex(ht, pos)) #define compat_zend_hash_get_current_zval(ht) \ compat_zend_hash_get_current_zval_ex(ht, NULL) /*------------------------------------------------------------*/ #define ZEND_HASH_FOREACH(_ht, indirect) do { \ HashPosition _pos; \ for (zend_hash_internal_pointer_reset_ex(_ht, &_pos) \ ;;zend_hash_move_forward_ex(_ht, &_pos)) { \ if (zend_hash_has_more_elements_ex(_ht, &_pos) != SUCCESS) break; #define ZEND_HASH_FOREACH_END() \ } \ } while (0) #define ZEND_HASH_FOREACH_PTR(_ht, _ptr) \ ZEND_HASH_FOREACH(_ht, 0); \ _ptr = compat_zend_hash_get_current_data_ptr_ex(_ht, &_pos); #define ZEND_HASH_FOREACH_NUM_KEY(_ht, _h) \ ZEND_HASH_FOREACH(_ht, 0); \ compat_zend_hash_get_current_key_ex(_ht, NULL, &_h, &_pos); #define ZEND_HASH_FOREACH_NUM_KEY_PTR(_ht, _h, _ptr) \ ZEND_HASH_FOREACH(_ht, 0); \ _ptr = compat_zend_hash_get_current_data_ptr_ex(_ht, &_pos); \ compat_zend_hash_get_current_key_ex(_ht, NULL, &_h, &_pos); /*============================================================================*/ #endif /* PHP_7 */ #endif /* _COMPAT_ZEND_HASH_H */ solr-2.4.0/pecl-compat/src/zend_string.h0000644000175000017500000001601212676753706016667 0ustar omaromar/* +----------------------------------------------------------------------+ | zend_string compatibility layer for PHP 5 & 7 | +----------------------------------------------------------------------+ | Copyright (c) 2005-2007 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Francois Laupretre | +----------------------------------------------------------------------+ */ #ifndef _COMPAT_ZEND_STRING_H #define _COMPAT_ZEND_STRING_H #ifdef PHP_7 /*============================================================================*/ #include "zend_string.h" #ifndef ZSTR_IS_PERSISTENT # define ZSTR_IS_PERSISTENT(s) (GC_FLAGS(s) & IS_STR_PERSISTENT) #endif #else /*============================================================================*/ /*---- zend_string for PHP 5 ----*/ struct _zend_string { int persistent; int hash_is_set; /* needed because computed hash may be null */ zend_ulong h; /* hash value */ uint32_t refcount; size_t len; char val[1]; }; typedef struct _zend_string zend_string; /* Shortcuts */ #define ZSTR_VAL(zstr) (zstr)->val #define ZSTR_LEN(zstr) (zstr)->len #define ZSTR_H(zstr) (zstr)->h #define ZSTR_HASH(zstr) zend_string_hash_val(zstr) #define _ZSTR_HEADER_SIZE XtOffsetOf(zend_string, val) #define _ZSTR_STRUCT_SIZE(len) (_ZSTR_HEADER_SIZE + len + 1) #define ZSTR_IS_PERSISTENT(s) (s->persistent) /*---------*/ static zend_always_inline uint32_t zend_string_refcount(zend_string *s) { return (s->refcount); } /*---------*/ static zend_always_inline uint32_t zend_string_addref(zend_string *s) { return ++(s->refcount); } /*---------*/ static zend_always_inline uint32_t zend_string_delref(zend_string *s) { return --(s->refcount); } /*---------*/ static zend_always_inline zend_ulong zend_string_hash_val(zend_string *s) { char c, *p; if (! s->hash_is_set) { /* Compute with terminating null but preserve string */ p = &(ZSTR_VAL(s)[ZSTR_LEN(s)]); c = (*p); (*p) = '\0'; ZSTR_H(s) = zend_get_hash_value(ZSTR_VAL(s), ZSTR_LEN(s)+1); (*p) = c; s->hash_is_set = 1; } return ZSTR_H(s); } /*---------*/ static zend_always_inline void zend_string_forget_hash_val(zend_string *s) { s->hash_is_set = 0; ZSTR_H(s) = 0; /* Security */ } /*---------*/ static zend_always_inline zend_string *zend_string_alloc(size_t len, int persistent) { zend_string *ret = (zend_string *)pemalloc(ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(len)), persistent); ret->persistent = persistent; zend_string_forget_hash_val(ret); ret->refcount = 1; ZSTR_LEN(ret) = len; return ret; } /*---------*/ static zend_always_inline zend_string *zend_string_safe_alloc(size_t n , size_t m, size_t l, int persistent) { zend_string *ret = (zend_string *)safe_pemalloc(n, m, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(l)), persistent); ret->persistent = persistent; zend_string_forget_hash_val(ret); ret->refcount = 1; ZSTR_LEN(ret) = l; return ret; } /*---------*/ static zend_always_inline zend_string *zend_string_init(const char *str, size_t len, int persistent) { zend_string *ret = zend_string_alloc(len, persistent); memcpy(ZSTR_VAL(ret), str, len); ZSTR_VAL(ret)[len] = '\0'; return ret; } /*---------*/ static zend_always_inline zend_string *zend_string_dup(zend_string *s, int persistent) { zend_string *target; target = zend_string_init(ZSTR_VAL(s), ZSTR_LEN(s), persistent); if (s->hash_is_set) { ZSTR_H(target) = ZSTR_H(s); target->hash_is_set = 1; } return target; } /*---------*/ static zend_always_inline zend_string *zend_string_realloc(zend_string *s , size_t len, int persistent) { zend_string *ret; if (EXPECTED(s->refcount == 1)) { ret = (zend_string *)perealloc(s, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(len)), persistent); ZSTR_LEN(ret) = len; zend_string_forget_hash_val(ret); return ret; } zend_string_delref(s); ret = zend_string_alloc(len, persistent); memcpy(ZSTR_VAL(ret), ZSTR_VAL(s), MIN(len, ZSTR_LEN(s)) + 1); return ret; } /*---------*/ static zend_always_inline zend_string *zend_string_extend(zend_string *s , size_t len, int persistent) { zend_string *ret; ZEND_ASSERT(len >= ZSTR_LEN(s)); if (EXPECTED(s->refcount == 1)) { ret = (zend_string *)perealloc(s, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(len)), persistent); ZSTR_LEN(ret) = len; zend_string_forget_hash_val(ret); return ret; } zend_string_delref(s); ret = zend_string_alloc(len, persistent); memcpy(ZSTR_VAL(ret), ZSTR_VAL(s), ZSTR_LEN(s) + 1); return ret; } /*---------*/ static zend_always_inline zend_string *zend_string_truncate(zend_string *s , size_t len, int persistent) { zend_string *ret; ZEND_ASSERT(len <= ZSTR_LEN(s)); if (EXPECTED(s->refcount == 1)) { ret = (zend_string *)perealloc(s, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(len)), persistent); ZSTR_LEN(ret) = len; zend_string_forget_hash_val(ret); return ret; } zend_string_delref(s); ret = zend_string_alloc(len, persistent); memcpy(ZSTR_VAL(ret), ZSTR_VAL(s), len + 1); return ret; } /*---------*/ static zend_always_inline zend_string *zend_string_safe_realloc(zend_string *s , size_t n, size_t m, size_t l, int persistent) { zend_string *ret; if (EXPECTED(s->refcount == 1)) { ret = (zend_string *)safe_perealloc(s, n, m, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(l)), persistent); ZSTR_LEN(ret) = (n * m) + l; zend_string_forget_hash_val(ret); return ret; } zend_string_delref(s); ret = zend_string_safe_alloc(n, m, l, persistent); memcpy(ZSTR_VAL(ret), ZSTR_VAL(s), MIN((n * m) + l, ZSTR_LEN(s)) + 1); return ret; } /*---------*/ static zend_always_inline void zend_string_free(zend_string *s) { if (s) { pefree(s, s->persistent); } } /*---------*/ static zend_always_inline void zend_string_release(zend_string *s) { if (s) { s->refcount--; if (s->refcount == 0) { zend_string_free(s); } } } /*---------*/ static zend_always_inline zend_string *zend_string_copy(zend_string *s) { zend_string_addref(s); return (s); } /*---------*/ static zend_always_inline zend_bool zend_string_equals(zend_string *s1, zend_string *s2) { return s1 == s2 || (s1->len == s2->len && !memcmp(s1->val, s2->val, s1->len)); } #define zend_string_equals_literal(str, literal) \ ((str)->len == sizeof(literal)-1 && !memcmp((str)->val, literal, sizeof(literal) - 1)) #endif /* PHP_7 */ #endif /* _COMPAT_ZEND_STRING_H */ solr-2.4.0/pecl-compat/compat.h0000644000175000017500000000523012676753706015035 0ustar omaromar/* +----------------------------------------------------------------------+ | Compatibility macros for different PHP versions | +----------------------------------------------------------------------+ | Copyright (c) 2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Francois Laupretre | +----------------------------------------------------------------------+ */ #ifndef _COMPAT_H #define _COMPAT_H #define PECL_COMPAT_VERSION 1.2 #include #include #include #include "php.h" #include "zend.h" #include "zend_extensions.h" #include "zend_API.h" #define PHP_5_0_X_API_NO 220040412 #define PHP_5_1_X_API_NO 220051025 #define PHP_5_2_X_API_NO 220060519 #define PHP_5_3_X_API_NO 220090626 #define PHP_5_4_X_API_NO 220100525 #define PHP_5_5_X_API_NO 220121212 #define PHP_5_6_X_API_NO 220131226 #if PHP_MAJOR_VERSION >= 7 # define PHP_7 #endif #ifdef HAVE_CONFIG_H # include "config.h" #endif #if HAVE_STRING_H # include #endif #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef PHP_WIN32 # include "win32/time.h" #elif defined(NETWARE) # include # include #else # include #endif #ifdef HAVE_SYS_RESOURCE_H # include #endif #ifdef HAVE_STDARG_H #include #endif #ifdef HAVE_STDLIB_H # include #endif #ifdef HAVE_UNISTD_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef PHP_WIN32 #include #else #include #endif #if ZEND_EXTENSION_API_NO >= PHP_5_6_X_API_NO #include "zend_virtual_cwd.h" #else #include "TSRM/tsrm_virtual_cwd.h" #endif #ifdef PHP_7 #include "Zend/zend_portability.h" #endif /*-- Include submodules */ #include "src/misc.h" #include "src/zend_string.h" #include "src/zend_hash.h" #endif /* _COMPAT_H */ solr-2.4.0/src/php5/php_solr.h0000644000175000017500000010712512676753706014645 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #ifndef SOLRCLIENT_H #define SOLRCLIENT_H /* #define SOLR_MEM_DEBUG 1 */ #include
#ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef HAVE_SOLR #include #include
#include
#include
#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include extern zend_module_entry solr_module_entry; #define phpext_solr_ptr &solr_module_entry /* {{{ Startup, Shutdown, Activation, Deactivation and Info functions */ PHP_MINIT_FUNCTION(solr); /* Module Startup Function */ PHP_MSHUTDOWN_FUNCTION(solr); /* Module Shutdown Function */ PHP_RINIT_FUNCTION(solr); /* Request Activation Function */ PHP_RSHUTDOWN_FUNCTION(solr); /* Request Deactivation Function */ PHP_MINFO_FUNCTION(solr); /* Module Information Display Function */ /* }}} */ #ifdef ZTS #include #endif #if ((PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 2)) #define SOLR_ZEND_ENGINE_2_2 1 #endif /* List of constants */ #include "solr_constants.h" /* List of types */ #include "solr_types.h" #ifdef ZTS # define SOLR_GLOBAL(v) TSRMG(solr_globals_id, zend_solr_globals *, v) #else # define SOLR_GLOBAL(v) (solr_globals.v) #endif #include #include "php_solr_api.h" #include "php_solr_bc_macros.h" /* {{{ Variables declared elsewhere */ ZEND_EXTERN_MODULE_GLOBALS(solr) /* ZEND_EXTERN_MODULE_GLOBALS(json) */ extern zend_class_entry *solr_ce_SolrObject; extern zend_class_entry *solr_ce_SolrInputDocument; extern zend_class_entry *solr_ce_SolrDocument; extern zend_class_entry *solr_ce_SolrDocumentField; extern zend_class_entry *solr_ce_SolrClient; extern zend_class_entry *solr_ce_SolrParams; extern zend_class_entry *solr_ce_SolrModifiableParams; extern zend_class_entry *solr_ce_SolrCollapseFunction; extern zend_class_entry *solr_ce_SolrQuery; extern zend_class_entry *solr_ce_SolrResponse; extern zend_class_entry *solr_ce_SolrQueryResponse; extern zend_class_entry *solr_ce_SolrUpdateResponse; extern zend_class_entry *solr_ce_SolrPingResponse; extern zend_class_entry *solr_ce_SolrGenericResponse; extern zend_class_entry *solr_ce_SolrUtils; extern zend_class_entry *solr_ce_SolrException; extern zend_class_entry *solr_ce_SolrIllegalOperationException; extern zend_class_entry *solr_ce_SolrIllegalArgumentException; extern zend_class_entry *solr_ce_SolrClientException; extern zend_class_entry *solr_ce_SolrServerException; extern zend_class_entry *solr_ce_SolrMissingMandatoryParameterException; extern ZEND_API zend_class_entry *zend_ce_serializable; extern ZEND_API zend_class_entry *zend_ce_arrayaccess; extern ZEND_API zend_class_entry *zend_ce_iterator; /* {{{ Aliases for external class entries */ #define solr_ce_Serializable zend_ce_serializable #define solr_ce_ArrayAccess zend_ce_arrayaccess #define solr_ce_Iterator zend_ce_iterator #define solr_ce_Exception zend_exception_get_default(TSRMLS_C) /* }}} */ extern zend_object_handlers solr_object_handlers; extern zend_object_handlers solr_document_field_handlers; extern zend_object_handlers solr_input_document_object_handlers; extern zend_object_handlers solr_client_object_handlers; extern zend_object_handlers solr_response_object_handlers; extern zend_object_handlers solr_collapse_function_object_handlers; /* }}} */ /******************************************************************************/ /** DECLARATIONS FOR EXTENSION METHODS AND FUNCTIONS **/ /******************************************************************************/ /* {{{ Extension functions */ PHP_FUNCTION(solr_get_version); /* }}} */ /* {{{ SolrObject methods */ PHP_METHOD(SolrObject, __construct); PHP_METHOD(SolrObject, __destruct); PHP_METHOD(SolrObject, __set); PHP_METHOD(SolrObject, __get); PHP_METHOD(SolrObject, __isset); PHP_METHOD(SolrObject, __unset); PHP_METHOD(SolrObject, offsetSet); PHP_METHOD(SolrObject, offsetGet); PHP_METHOD(SolrObject, offsetExists); PHP_METHOD(SolrObject, offsetUnset); PHP_METHOD(SolrObject, getPropertyNames); /* }}} */ /* {{{ SolException object methods */ PHP_METHOD(SolrException, getInternalInfo); PHP_METHOD(SolrClientException, getInternalInfo); PHP_METHOD(SolrIllegalOperationException, getInternalInfo); PHP_METHOD(SolrIllegalArgumentException, getInternalInfo); PHP_METHOD(SolrServerException, getInternalInfo); /* }}} */ /* {{{ SolrDocument methods declarations */ PHP_METHOD(SolrDocument, __construct); PHP_METHOD(SolrDocument, __destruct); PHP_METHOD(SolrDocument, __clone); PHP_METHOD(SolrDocument, __get); PHP_METHOD(SolrDocument, __set); PHP_METHOD(SolrDocument, __isset); PHP_METHOD(SolrDocument, __unset); /* Methods from Serializable */ PHP_METHOD(SolrDocument, serialize); PHP_METHOD(SolrDocument, unserialize); /* Methods from ArrayAccess */ PHP_METHOD(SolrDocument, offsetExists); PHP_METHOD(SolrDocument, offsetGet); PHP_METHOD(SolrDocument, offsetSet); PHP_METHOD(SolrDocument, offsetUnset); /* Methods from Iterator */ PHP_METHOD(SolrDocument, current); PHP_METHOD(SolrDocument, key); PHP_METHOD(SolrDocument, next); PHP_METHOD(SolrDocument, rewind); PHP_METHOD(SolrDocument, valid); PHP_METHOD(SolrDocument, clear); PHP_METHOD(SolrDocument, addField); PHP_METHOD(SolrDocument, getFieldNames); PHP_METHOD(SolrDocument, getFieldCount); PHP_METHOD(SolrDocument, getField); PHP_METHOD(SolrDocument, toArray); PHP_METHOD(SolrDocument, fieldExists); PHP_METHOD(SolrDocument, deleteField); PHP_METHOD(SolrDocument, sort); PHP_METHOD(SolrDocument, merge); PHP_METHOD(SolrDocument, getInputDocument); PHP_METHOD(SolrDocument, hasChildDocuments); PHP_METHOD(SolrDocument, getChildDocuments); PHP_METHOD(SolrDocument, getChildDocumentsCount); /* }}} */ /* {{{ SolrDocumentField methods */ PHP_METHOD(SolrDocumentField, __construct); PHP_METHOD(SolrDocumentField, __destruct); /* }}} */ /* {{{ SolrInputDocument methods declarations */ PHP_METHOD(SolrInputDocument, __construct); PHP_METHOD(SolrInputDocument, __destruct); PHP_METHOD(SolrInputDocument, __clone); PHP_METHOD(SolrInputDocument, __sleep); PHP_METHOD(SolrInputDocument, __wakeup); PHP_METHOD(SolrInputDocument, setBoost); PHP_METHOD(SolrInputDocument, getBoost); PHP_METHOD(SolrInputDocument, clear); PHP_METHOD(SolrInputDocument, addField); PHP_METHOD(SolrInputDocument, setFieldBoost); PHP_METHOD(SolrInputDocument, getFieldBoost); PHP_METHOD(SolrInputDocument, getFieldNames); PHP_METHOD(SolrInputDocument, getFieldCount); PHP_METHOD(SolrInputDocument, getField); PHP_METHOD(SolrInputDocument, toArray); PHP_METHOD(SolrInputDocument, fieldExists); PHP_METHOD(SolrInputDocument, deleteField); PHP_METHOD(SolrInputDocument, sort); PHP_METHOD(SolrInputDocument, merge); PHP_METHOD(SolrInputDocument, addChildDocument); PHP_METHOD(SolrInputDocument, getChildDocuments); PHP_METHOD(SolrInputDocument, hasChildDocuments); PHP_METHOD(SolrInputDocument, getChildDocumentsCount); PHP_METHOD(SolrInputDocument, addChildDocuments); /* }}} */ /* {{{ SolrClient methods declarations */ PHP_METHOD(SolrClient, __construct); PHP_METHOD(SolrClient, __destruct); PHP_METHOD(SolrClient, __sleep); PHP_METHOD(SolrClient, __wakeup); PHP_METHOD(SolrClient, __clone); PHP_METHOD(SolrClient, query); PHP_METHOD(SolrClient, getOptions); PHP_METHOD(SolrClient, getDebug); PHP_METHOD(SolrClient, addDocument); PHP_METHOD(SolrClient, addDocuments); PHP_METHOD(SolrClient, setServlet); PHP_METHOD(SolrClient, setResponseWriter); PHP_METHOD(SolrClient, request); PHP_METHOD(SolrClient, ping); PHP_METHOD(SolrClient, system); PHP_METHOD(SolrClient, threads); PHP_METHOD(SolrClient, deleteById); PHP_METHOD(SolrClient, deleteByIds); PHP_METHOD(SolrClient, deleteByQuery); PHP_METHOD(SolrClient, deleteByQueries); PHP_METHOD(SolrClient, getById); PHP_METHOD(SolrClient, getByIds); PHP_METHOD(SolrClient, optimize); PHP_METHOD(SolrClient, commit); PHP_METHOD(SolrClient, rollback); /* }}} */ /* {{{ SolrParams methods declarations */ PHP_METHOD(SolrParams, setParam); /* Parameter can only accept one value */ PHP_METHOD(SolrParams, addParam); /* Parameter can accept more than one value */ PHP_METHOD(SolrParams, getParams); /* Retrieves the parameters and their values */ PHP_METHOD(SolrParams, getParam); /* Retrieves a parameter value */ PHP_METHOD(SolrParams, __toString); /* Returns a string representation of the object */ PHP_METHOD(SolrParams, toString); /* Returns a string representation of the object */ PHP_METHOD(SolrParams, getPreparedParams); /* Returns the prepared parameters */ PHP_METHOD(SolrParams, serialize); /* used by serialize() */ PHP_METHOD(SolrParams, unserialize); /* used by unserialize() */ PHP_METHOD(SolrParams, __clone); /* Used to enforce the cloning of SolrParams is currently unsupported */ /* }}} */ /* {{{ SolrModifiableParams methods declarations */ PHP_METHOD(SolrModifiableParams, __construct); PHP_METHOD(SolrModifiableParams, __destruct); /* }}} */ /* {{{ SolrQuery methods declarations */ /* Constructor and Destructor */ PHP_METHOD(SolrQuery, __construct); PHP_METHOD(SolrQuery, __destruct); /* CommonQueryParameters */ PHP_METHOD(SolrQuery, setQuery); PHP_METHOD(SolrQuery, getQuery); PHP_METHOD(SolrQuery, setStart); PHP_METHOD(SolrQuery, getStart); PHP_METHOD(SolrQuery, setRows); PHP_METHOD(SolrQuery, getRows); PHP_METHOD(SolrQuery, addField); PHP_METHOD(SolrQuery, removeField); PHP_METHOD(SolrQuery, getFields); PHP_METHOD(SolrQuery, addSortField); PHP_METHOD(SolrQuery, removeSortField); PHP_METHOD(SolrQuery, getSortFields); PHP_METHOD(SolrQuery, addFilterQuery); PHP_METHOD(SolrQuery, removeFilterQuery); PHP_METHOD(SolrQuery, getFilterQueries); PHP_METHOD(SolrQuery, setShowDebugInfo); PHP_METHOD(SolrQuery, setExplainOther); PHP_METHOD(SolrQuery, setTimeAllowed); PHP_METHOD(SolrQuery, getTimeAllowed); PHP_METHOD(SolrQuery, setOmitHeader); /* CoreQueryParameters */ PHP_METHOD(SolrQuery, setEchoHandler); PHP_METHOD(SolrQuery, setEchoParams); /* SimpleFacetParameters */ PHP_METHOD(SolrQuery, setFacet); PHP_METHOD(SolrQuery, getFacet); PHP_METHOD(SolrQuery, addFacetField); PHP_METHOD(SolrQuery, removeFacetField); PHP_METHOD(SolrQuery, getFacetFields); PHP_METHOD(SolrQuery, addFacetQuery); PHP_METHOD(SolrQuery, removeFacetQuery); PHP_METHOD(SolrQuery, getFacetQueries); PHP_METHOD(SolrQuery, setFacetPrefix); PHP_METHOD(SolrQuery, getFacetPrefix); PHP_METHOD(SolrQuery, setFacetSort); PHP_METHOD(SolrQuery, getFacetSort); PHP_METHOD(SolrQuery, setFacetLimit); PHP_METHOD(SolrQuery, getFacetLimit); PHP_METHOD(SolrQuery, setFacetOffset); PHP_METHOD(SolrQuery, getFacetOffset); PHP_METHOD(SolrQuery, setFacetMinCount); PHP_METHOD(SolrQuery, getFacetMinCount); PHP_METHOD(SolrQuery, setFacetMissing); PHP_METHOD(SolrQuery, getFacetMissing); PHP_METHOD(SolrQuery, setFacetMethod); PHP_METHOD(SolrQuery, getFacetMethod); PHP_METHOD(SolrQuery, setFacetEnumCacheMinDefaultFrequency); /* Date facet parameters */ PHP_METHOD(SolrQuery, addFacetDateField); PHP_METHOD(SolrQuery, removeFacetDateField); PHP_METHOD(SolrQuery, getFacetDateFields); PHP_METHOD(SolrQuery, setFacetDateStart); PHP_METHOD(SolrQuery, getFacetDateStart); PHP_METHOD(SolrQuery, setFacetDateEnd); PHP_METHOD(SolrQuery, getFacetDateEnd); PHP_METHOD(SolrQuery, setFacetDateGap); PHP_METHOD(SolrQuery, getFacetDateGap); PHP_METHOD(SolrQuery, setFacetDateHardEnd); PHP_METHOD(SolrQuery, getFacetDateHardEnd); PHP_METHOD(SolrQuery, addFacetDateOther); PHP_METHOD(SolrQuery, removeFacetDateOther); PHP_METHOD(SolrQuery, getFacetDateOther); /* GroupParameters */ PHP_METHOD(SolrQuery, setGroup); PHP_METHOD(SolrQuery, getGroup); PHP_METHOD(SolrQuery, addGroupField); PHP_METHOD(SolrQuery, getGroupFields); PHP_METHOD(SolrQuery, addGroupFunction); PHP_METHOD(SolrQuery, getGroupFunctions); PHP_METHOD(SolrQuery, addGroupQuery); PHP_METHOD(SolrQuery, getGroupQueries); PHP_METHOD(SolrQuery, setGroupLimit); PHP_METHOD(SolrQuery, getGroupLimit); PHP_METHOD(SolrQuery, setGroupOffset); PHP_METHOD(SolrQuery, getGroupOffset); PHP_METHOD(SolrQuery, addGroupSortField); PHP_METHOD(SolrQuery, getGroupSortFields); PHP_METHOD(SolrQuery, setGroupFormat); PHP_METHOD(SolrQuery, getGroupFormat); PHP_METHOD(SolrQuery, setGroupMain); PHP_METHOD(SolrQuery, getGroupMain); PHP_METHOD(SolrQuery, setGroupNGroups); PHP_METHOD(SolrQuery, getGroupNGroups); PHP_METHOD(SolrQuery, setGroupTruncate); PHP_METHOD(SolrQuery, getGroupTruncate); PHP_METHOD(SolrQuery, setGroupFacet); PHP_METHOD(SolrQuery, getGroupFacet); PHP_METHOD(SolrQuery, setGroupCachePercent); PHP_METHOD(SolrQuery, getGroupCachePercent); /* Collapse */ PHP_METHOD(SolrQuery, collapse); /* Expand Parameters */ PHP_METHOD(SolrQuery, setExpand); PHP_METHOD(SolrQuery, getExpand); PHP_METHOD(SolrQuery, addExpandSortField); PHP_METHOD(SolrQuery, removeExpandSortField); PHP_METHOD(SolrQuery, getExpandSortFields); PHP_METHOD(SolrQuery, setExpandRows); PHP_METHOD(SolrQuery, getExpandRows); PHP_METHOD(SolrQuery, setExpandQuery); PHP_METHOD(SolrQuery, getExpandQuery); PHP_METHOD(SolrQuery, addExpandFilterQuery); PHP_METHOD(SolrQuery, removeExpandFilterQuery); PHP_METHOD(SolrQuery, getExpandFilterQueries); /* HighlightingParameters */ PHP_METHOD(SolrQuery, setHighlight); PHP_METHOD(SolrQuery, getHighlight); PHP_METHOD(SolrQuery, addHighlightField); PHP_METHOD(SolrQuery, removeHighlightField); PHP_METHOD(SolrQuery, getHighlightFields); PHP_METHOD(SolrQuery, setHighlightSnippets); PHP_METHOD(SolrQuery, getHighlightSnippets); PHP_METHOD(SolrQuery, setHighlightFragsize); PHP_METHOD(SolrQuery, getHighlightFragsize); PHP_METHOD(SolrQuery, setHighlightMergeContiguous); PHP_METHOD(SolrQuery, getHighlightMergeContiguous); PHP_METHOD(SolrQuery, setHighlightRequireFieldMatch); PHP_METHOD(SolrQuery, getHighlightRequireFieldMatch); PHP_METHOD(SolrQuery, setHighlightMaxAnalyzedChars); PHP_METHOD(SolrQuery, getHighlightMaxAnalyzedChars); PHP_METHOD(SolrQuery, setHighlightAlternateField); PHP_METHOD(SolrQuery, getHighlightAlternateField); PHP_METHOD(SolrQuery, setHighlightMaxAlternateFieldLength); PHP_METHOD(SolrQuery, getHighlightMaxAlternateFieldLength); PHP_METHOD(SolrQuery, setHighlightFormatter); PHP_METHOD(SolrQuery, getHighlightFormatter); PHP_METHOD(SolrQuery, setHighlightSimplePre); PHP_METHOD(SolrQuery, getHighlightSimplePre); PHP_METHOD(SolrQuery, setHighlightSimplePost); PHP_METHOD(SolrQuery, getHighlightSimplePost); PHP_METHOD(SolrQuery, setHighlightFragmenter); PHP_METHOD(SolrQuery, getHighlightFragmenter); PHP_METHOD(SolrQuery, setHighlightUsePhraseHighlighter); PHP_METHOD(SolrQuery, getHighlightUsePhraseHighlighter); PHP_METHOD(SolrQuery, setHighlightHighlightMultiTerm); PHP_METHOD(SolrQuery, getHighlightHighlightMultiTerm); PHP_METHOD(SolrQuery, setHighlightRegexSlop); PHP_METHOD(SolrQuery, getHighlightRegexSlop); PHP_METHOD(SolrQuery, setHighlightRegexPattern); PHP_METHOD(SolrQuery, getHighlightRegexPattern); PHP_METHOD(SolrQuery, setHighlightRegexMaxAnalyzedChars); PHP_METHOD(SolrQuery, getHighlightRegexMaxAnalyzedChars); /* StatsComponent */ PHP_METHOD(SolrQuery, setStats); PHP_METHOD(SolrQuery, getStats); PHP_METHOD(SolrQuery, addStatsField); PHP_METHOD(SolrQuery, removeStatsField); PHP_METHOD(SolrQuery, getStatsFields); PHP_METHOD(SolrQuery, addStatsFacet); PHP_METHOD(SolrQuery, removeStatsFacet); PHP_METHOD(SolrQuery, getStatsFacets); /* MoreLikeThis */ PHP_METHOD(SolrQuery, setMlt); PHP_METHOD(SolrQuery, getMlt); PHP_METHOD(SolrQuery, setMltCount); PHP_METHOD(SolrQuery, getMltCount); PHP_METHOD(SolrQuery, addMltField); PHP_METHOD(SolrQuery, removeMltField); PHP_METHOD(SolrQuery, getMltFields); PHP_METHOD(SolrQuery, addMltQueryField); PHP_METHOD(SolrQuery, removeMltQueryField); PHP_METHOD(SolrQuery, getMltQueryFields); PHP_METHOD(SolrQuery, setMltMinTermFrequency); PHP_METHOD(SolrQuery, getMltMinTermFrequency); PHP_METHOD(SolrQuery, setMltMinDocFrequency); PHP_METHOD(SolrQuery, getMltMinDocFrequency); PHP_METHOD(SolrQuery, setMltMinWordLength); PHP_METHOD(SolrQuery, getMltMinWordLength); PHP_METHOD(SolrQuery, setMltMaxWordLength); PHP_METHOD(SolrQuery, getMltMaxWordLength); PHP_METHOD(SolrQuery, setMltMaxNumTokens); PHP_METHOD(SolrQuery, getMltMaxNumTokens); PHP_METHOD(SolrQuery, setMltMaxNumQueryTerms); PHP_METHOD(SolrQuery, getMltMaxNumQueryTerms); PHP_METHOD(SolrQuery, setMltBoost); PHP_METHOD(SolrQuery, getMltBoost); /* TermsComponent */ PHP_METHOD(SolrQuery, setTerms); PHP_METHOD(SolrQuery, getTerms); PHP_METHOD(SolrQuery, setTermsField); PHP_METHOD(SolrQuery, getTermsField); PHP_METHOD(SolrQuery, setTermsLowerBound); PHP_METHOD(SolrQuery, getTermsLowerBound); PHP_METHOD(SolrQuery, setTermsUpperBound); PHP_METHOD(SolrQuery, getTermsUpperBound); PHP_METHOD(SolrQuery, setTermsIncludeLowerBound); PHP_METHOD(SolrQuery, getTermsIncludeLowerBound); PHP_METHOD(SolrQuery, setTermsIncludeUpperBound); PHP_METHOD(SolrQuery, getTermsIncludeUpperBound); PHP_METHOD(SolrQuery, setTermsMinCount); PHP_METHOD(SolrQuery, getTermsMinCount); PHP_METHOD(SolrQuery, setTermsMaxCount); PHP_METHOD(SolrQuery, getTermsMaxCount); PHP_METHOD(SolrQuery, setTermsPrefix); PHP_METHOD(SolrQuery, getTermsPrefix); PHP_METHOD(SolrQuery, setTermsLimit); PHP_METHOD(SolrQuery, getTermsLimit); PHP_METHOD(SolrQuery, setTermsReturnRaw); PHP_METHOD(SolrQuery, getTermsReturnRaw); PHP_METHOD(SolrQuery, setTermsSort); PHP_METHOD(SolrQuery, getTermsSort); /* TODO : TermVectorComponent */ /* {{{ TermVectorComponent methods not yet defined */ PHP_METHOD(SolrQuery, setTermVector); PHP_METHOD(SolrQuery, setTermVectorTermFrequency); PHP_METHOD(SolrQuery, setTermVectorDocFrequency); PHP_METHOD(SolrQuery, setTermVectorPositions); PHP_METHOD(SolrQuery, setTermVectorOffsets); PHP_METHOD(SolrQuery, setTermVectorTfIdfProduct); PHP_METHOD(SolrQuery, setTermVectorAll); PHP_METHOD(SolrQuery, addTermVectorField); PHP_METHOD(SolrQuery, addTermVectorLuceneDocId); /* }}} */ /* }}} */ /* {{{ SolrResponse methods declarations */ PHP_METHOD(SolrResponse, getHttpStatus); PHP_METHOD(SolrResponse, getHttpStatusMessage); PHP_METHOD(SolrResponse, success); PHP_METHOD(SolrResponse, getRequestUrl); PHP_METHOD(SolrResponse, getRawRequestHeaders); PHP_METHOD(SolrResponse, getRawRequest); PHP_METHOD(SolrResponse, getRawResponseHeaders); PHP_METHOD(SolrResponse, getRawResponse); PHP_METHOD(SolrResponse, getDigestedResponse); PHP_METHOD(SolrResponse, setParseMode); PHP_METHOD(SolrResponse, getArrayResponse); PHP_METHOD(SolrResponse, getResponse); /* }}} */ /* {{{ SolrQueryResponse methods */ PHP_METHOD(SolrQueryResponse, __construct); PHP_METHOD(SolrQueryResponse, __destruct); /* }}} */ /* {{{ SolrUpdateResponse methods */ PHP_METHOD(SolrUpdateResponse, __construct); PHP_METHOD(SolrUpdateResponse, __destruct); /* }}} */ /* {{{ SolrPingResponse methods declarations */ PHP_METHOD(SolrPingResponse, __construct); PHP_METHOD(SolrPingResponse, __destruct); PHP_METHOD(SolrPingResponse, getResponse); /* }}} */ /* {{{ SolrGenericResponse methods */ PHP_METHOD(SolrGenericResponse, __construct); PHP_METHOD(SolrGenericResponse, __destruct); /* }}} */ /* {{{ SolrCollapseFunction methods */ PHP_METHOD(SolrCollapseFunction, __construct); PHP_METHOD(SolrCollapseFunction, __destruct); PHP_METHOD(SolrCollapseFunction, setField); PHP_METHOD(SolrCollapseFunction, getField); PHP_METHOD(SolrCollapseFunction, setMin); PHP_METHOD(SolrCollapseFunction, getMin); PHP_METHOD(SolrCollapseFunction, setMax); PHP_METHOD(SolrCollapseFunction, getMax); PHP_METHOD(SolrCollapseFunction, setNullPolicy); PHP_METHOD(SolrCollapseFunction, getNullPolicy); PHP_METHOD(SolrCollapseFunction, setHint); PHP_METHOD(SolrCollapseFunction, getHint); PHP_METHOD(SolrCollapseFunction, setSize); PHP_METHOD(SolrCollapseFunction, getSize); PHP_METHOD(SolrCollapseFunction, __toString); PHP_METHOD(SolrCollapseFunction, __sleep); PHP_METHOD(SolrCollapseFunction, __wakeup); /* }}} */ /* {{{ SolrUtils methods declarations */ PHP_METHOD(SolrUtils, escapeQueryChars); PHP_METHOD(SolrUtils, queryPhrase); PHP_METHOD(SolrUtils, digestXmlResponse); PHP_METHOD(SolrUtils, digestJsonResponse); PHP_METHOD(SolrUtils, getSolrVersion); PHP_METHOD(SolrUtils, getSolrStats); /* }}} */ /******************************************************************************/ /** DECLARATIONS FOR HELPERS AND EXTENSION-SPECIFIC FUNCTIONS **/ /******************************************************************************/ /* {{{ HTTP request function declarations */ size_t solr_curl_write(solr_char_t *data, size_t size, size_t nmemb, void *ctx); size_t solr_curl_write_header(solr_char_t *data, size_t size, size_t nmemb, void *ctx); int solr_curl_debug_callback(CURL *curl_handle, curl_infotype infotype, solr_char_t *debug_data, size_t size, void *ctx); PHP_SOLR_API int solr_init_options(solr_client_options_t *options TSRMLS_DC); PHP_SOLR_API int solr_init_handle(solr_curl_t *sch, solr_client_options_t *options TSRMLS_DC); PHP_SOLR_API int solr_make_request(solr_client_t *client, solr_request_type_t request_type TSRMLS_DC); PHP_SOLR_API void solr_free_handle(solr_curl_t *sch); PHP_SOLR_API void solr_free_option(solr_client_options_t *options); /* }}} */ PHP_SOLR_API void solr_extension_register_constants(int type, int module_number TSRMLS_DC); PHP_SOLR_API void solr_document_register_class_constants(zend_class_entry *ce TSRMLS_DC); PHP_SOLR_API void solr_client_register_class_constants(zend_class_entry *ce TSRMLS_DC); PHP_SOLR_API void solr_query_register_class_constants(zend_class_entry *ce TSRMLS_DC); PHP_SOLR_API void solr_collapse_function_register_class_constants(zend_class_entry *ce TSRMLS_DC); PHP_SOLR_API void solr_response_register_class_properties(zend_class_entry *ce TSRMLS_DC); PHP_SOLR_API void solr_response_register_class_constants(zend_class_entry *ce TSRMLS_DC); PHP_SOLR_API void solr_exception_register_class_properties(zend_class_entry *ce TSRMLS_DC); PHP_SOLR_API void solr_set_response_object_properties(zend_class_entry *scope, zval *response_object, const solr_client_t *client, const solr_string_t *request_url, zend_bool success TSRMLS_DC); PHP_SOLR_API void solr_throw_exception_ex(zend_class_entry *exception_ce, long code TSRMLS_DC, const char *filename, int file_line, const char *function_name, char *format, ...); PHP_SOLR_API void solr_throw_exception(zend_class_entry *exception_ce, char *message, long code TSRMLS_DC, const char *filename, int file_line, const char *function_name); PHP_SOLR_API void solr_throw_solr_server_exception(solr_client_t *client,const char *requestType TSRMLS_DC); /* {{{ zval reference count post increment and decrement functions ++ and -- */ PHP_SOLR_API void solr_zval_add_ref(zval **p); PHP_SOLR_API void solr_zval_minus_ref(zval **p); /* }}} */ /* {{{ zend_hash_free functions */ PHP_SOLR_API void solr_destroy_field_list(solr_field_list_t **field_entry_ptr); PHP_SOLR_API void solr_destroy_document(void *document); PHP_SOLR_API void solr_destroy_client(void *document); PHP_SOLR_API void solr_destroy_params(void *solr_params); PHP_SOLR_API void solr_destroy_function(void *solr_function); PHP_SOLR_API void solr_destroy_param(solr_param_t **param); PHP_SOLR_API void solr_destroy_param_value(solr_param_t *param, solr_param_value_t *param_value); /* }}} */ /* {{{ used for SolrDocument field manipulations */ PHP_SOLR_API int solr_document_insert_field_value(solr_field_list_t *queue, const solr_char_t *field_value, double field_boost); PHP_SOLR_API void field_copy_constructor(solr_field_list_t **original_field_queue); /* }}} */ /* {{{ Used for comparison of document fields */ PHP_SOLR_API int solr_compare_field_name (const void *a, const void *b TSRMLS_DC); PHP_SOLR_API int solr_rcompare_field_name(const void *a, const void *b TSRMLS_DC); PHP_SOLR_API int solr_compare_field_value_count (const void *a, const void *b TSRMLS_DC); PHP_SOLR_API int solr_rcompare_field_value_count(const void *a, const void *b TSRMLS_DC); PHP_SOLR_API int solr_compare_field_boost_value (const void *a, const void *b TSRMLS_DC); PHP_SOLR_API int solr_rcompare_field_boost_value(const void *a, const void *b TSRMLS_DC); /* }}} */ PHP_SOLR_API solr_document_t *solr_init_document(long int document_index TSRMLS_DC); /* {{{ Functions for SolrParams Parameters */ PHP_SOLR_API solr_param_t *solr_create_new_param(const solr_char_t *param_name, size_t param_name_len, solr_param_type_t param_type, solr_bool allow_multiple, solr_param_value_equal_func_t value_equal_func, solr_param_fetch_func_t param_fetch_func, solr_param_value_free_func_t value_free_func, solr_char_t delimiter, solr_char_t arg_separator TSRMLS_DC); PHP_SOLR_API int solr_params_insert_param_value(solr_param_t *param, solr_param_value_t *param_value); PHP_SOLR_API int solr_params_delete_param_value(solr_param_t *param, const solr_param_value_t *target_value TSRMLS_DC); PHP_SOLR_API int solr_delete_solr_parameter(zval *objptr, solr_char_t *name, int name_length TSRMLS_DC); PHP_SOLR_API int solr_add_or_set_normal_param(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length, solr_bool allow_multiple TSRMLS_DC); PHP_SOLR_API int solr_add_simple_list_param(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC); PHP_SOLR_API int solr_add_simple_list_param_ex(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length, solr_char_t *separator TSRMLS_DC); PHP_SOLR_API int solr_add_arg_list_param(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length, solr_char_t *avalue, int avalue_length, solr_char_t delimiter, solr_char_t arg_separator TSRMLS_DC); PHP_SOLR_API int solr_add_arg_list_param_ex(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length, solr_char_t *avalue, int avalue_length, solr_char_t delimiter, solr_char_t arg_separator, solr_char_t delimiter_override TSRMLS_DC); PHP_SOLR_API solr_param_value_t* create_parameter_value_arg_list(solr_char_t *pvalue, int pvalue_length, solr_char_t *avalue, int avalue_length, solr_char_t *delimiter_override, solr_bool delimiter_overriden TSRMLS_DC); #define solr_set_normal_param(objptr, pname, pname_length, pvalue, pvalue_length) solr_add_or_set_normal_param((objptr), (pname), (pname_length), (pvalue), (pvalue_length), 0 TSRMLS_CC) #define solr_add_normal_param(objptr, pname, pname_length, pvalue, pvalue_length) solr_add_or_set_normal_param((objptr), (pname), (pname_length), (pvalue), (pvalue_length), 1 TSRMLS_CC) PHP_SOLR_API int solr_normal_param_value_equal(const solr_param_value_t *a, const solr_param_value_t *b); PHP_SOLR_API int solr_simple_list_param_value_equal(const solr_param_value_t *a, const solr_param_value_t *b); PHP_SOLR_API int solr_arg_list_param_value_equal(const solr_param_value_t *a, const solr_param_value_t *b); PHP_SOLR_API void solr_normal_param_value_fetch(solr_param_t *solr_param, solr_string_t *buffer); PHP_SOLR_API void solr_simple_list_param_value_fetch(solr_param_t *solr_param, solr_string_t *buffer); PHP_SOLR_API void solr_arg_list_param_value_fetch(solr_param_t *solr_param, solr_string_t *buffer); PHP_SOLR_API void solr_normal_param_value_display(solr_param_t *solr_param, zval *param_value_array); PHP_SOLR_API void solr_simple_list_param_value_display(solr_param_t *solr_param, zval *param_value_array); PHP_SOLR_API void solr_arg_list_param_value_display(solr_param_t *solr_param, zval *param_value_array); /* Used to display values where allow_multiple is false */ PHP_SOLR_API void solr_normal_param_value_display_string(solr_param_t *solr_param, zval *param_value); PHP_SOLR_API void solr_normal_param_value_display_integer(solr_param_t *solr_param, zval *param_value); PHP_SOLR_API void solr_normal_param_value_display_double(solr_param_t *solr_param, zval *param_value); PHP_SOLR_API void solr_normal_param_value_display_boolean(solr_param_t *solr_param, zval *param_value); PHP_SOLR_API void solr_normal_param_value_display_sort_type(solr_param_t *solr_param, zval *param_value); PHP_SOLR_API int solr_param_find(zval *objptr, solr_char_t *pname, int pname_length, solr_param_t **solr_param TSRMLS_DC); PHP_SOLR_API void solr_normal_param_value_tostring(solr_param_t *solr_param, solr_string_t *buffer, zend_bool url_encode); PHP_SOLR_API void solr_simple_list_param_value_tostring(solr_param_t *solr_param, solr_string_t *buffer, zend_bool url_encode); PHP_SOLR_API void solr_arg_list_param_value_tostring(solr_param_t *solr_param, solr_string_t *buffer, zend_bool url_encode); PHP_SOLR_API void solr_normal_param_value_free(solr_param_value_t *param_value); PHP_SOLR_API void solr_simple_list_param_value_free(solr_param_value_t *param_value); PHP_SOLR_API void solr_arg_list_param_value_free(solr_param_value_t *param_value); /* Used for removing parameter values from the list of values for that param */ PHP_SOLR_API int solr_delete_normal_param_value(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC); PHP_SOLR_API int solr_delete_simple_list_param_value(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC); PHP_SOLR_API int solr_delete_arg_list_param_value(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC); /* initialize params_t structure */ PHP_SOLR_API int solr_init_params(solr_params_t **solr_params, long int index TSRMLS_DC); /* }}} */ /* {{{ Debugging functions */ /* Debug function used to print field values in the field queue */ PHP_SOLR_API void solr_debug_print_fields(const solr_field_list_t *queue); /* Used when debugging is enabled to run in verbose mode */ PHP_SOLR_API void solr_debug_printf(const char *format, ...); /* }}} */ /* {{{ Document utility functions */ PHP_SOLR_API void solr_generate_document_xml_from_fields(xmlNode *solr_doc_node, HashTable *document_fields TSRMLS_DC); PHP_SOLR_API void solr_create_document_field_object(solr_field_list_t *field_values, zval **field_obj TSRMLS_DC); PHP_SOLR_API void solr_add_doc_node(xmlNode *root_node, solr_document_t *doc_entry TSRMLS_DC); PHP_SOLR_API xmlDocPtr solr_xml_create_xml_doc(const xmlChar *root_node_name, xmlNode **root_node_ptr); /* }}} */ /* {{{ Utility functions */ PHP_SOLR_API long solr_get_json_last_error(TSRMLS_D); PHP_SOLR_API solr_char_t *solr_get_json_error_msg(solr_json_error_codes_t error_code); PHP_SOLR_API int solr_json_to_php_native(solr_string_t *buffer, const solr_char_t *json_string, int json_string_length TSRMLS_DC); PHP_SOLR_API int solr_is_supported_response_writer(const solr_char_t * response_writer, int length); PHP_SOLR_API int solr_hashtable_get_new_index(HashTable *ht TSRMLS_DC); PHP_SOLR_API int solr_fetch_document_entry(zval *objptr, solr_document_t **doc_entry TSRMLS_DC); PHP_SOLR_API int solr_fetch_client_entry(zval *objptr, solr_client_t **solr_client TSRMLS_DC); PHP_SOLR_API int solr_fetch_params_entry(zval *objptr, solr_params_t **solr_params TSRMLS_DC); PHP_SOLR_API int solr_fetch_function_entry(zval *objptr, solr_function_t **solr_params TSRMLS_DC); PHP_SOLR_API void solr_encode_generic_xml_response(solr_string_t *buffer, const solr_char_t *serialized, int size, long int parse_mode TSRMLS_DC); PHP_SOLR_API void solr_set_return_solr_params_object(zval **return_value_ptr, zval *current_objptr TSRMLS_DC); PHP_SOLR_API void solr_escape_query_chars(solr_string_t *sbuilder, solr_char_t *unescaped, long int unescaped_length); /* serialized array to serialized SolrObject */ PHP_SOLR_API int solr_sarray_to_sobject(solr_string_t *buffer TSRMLS_DC); PHP_SOLR_API int solr_sobject_to_sarray(solr_string_t *buffer TSRMLS_DC); PHP_SOLR_API void solr_response_get_response_impl(INTERNAL_FUNCTION_PARAMETERS, int return_array); /* }}} */ /* {{{ SolrFunction Helpers (solrfunc to avoid confusion with solr_function) */ PHP_SOLR_API int solr_solrfunc_update_string(zval *obj, solr_char_t *key, int key_len, solr_char_t *value, int value_len TSRMLS_DC); PHP_SOLR_API int solr_solrfunc_fetch_string(zval *obj, solr_char_t *key, int key_len, solr_string_t **string TSRMLS_DC); PHP_SOLR_API int solr_solrfunc_return_string(zval *obj, solr_char_t *key, int key_len, zval **return_value TSRMLS_DC); PHP_SOLR_API void solr_solrfunc_to_string(solr_function_t *function, solr_string_t **dest); PHP_SOLR_API int solr_solrfunc_display_string(zval *obj, solr_char_t *key, int key_len, zval **return_value TSRMLS_DC); zend_object_value solr_collapse_function_handlers_clone_object(zval *object TSRMLS_DC); /* }}} */ /* {{{ Solr Server Exception Handling */ PHP_SOLR_API int solr_get_xml_error(solr_string_t buffer, solr_exception_t *exceptionData TSRMLS_DC); PHP_SOLR_API int solr_get_json_error(solr_string_t buffer, solr_exception_t *exceptionData TSRMLS_DC); PHP_SOLR_API int solr_get_phpnative_error(solr_string_t buffer, solr_exception_t *exceptionData TSRMLS_DC); PHP_SOLR_API int hydrate_error_zval(zval *response, solr_exception_t *exceptionData TSRMLS_DC); /* }}} */ /* {{{ Solr Object Handlers */ #if PHP_VERSION_ID < 50399 PHP_SOLR_API void solr_object_write_property(zval *object, zval *member, zval *value TSRMLS_DC); PHP_SOLR_API zval *solr_object_read_property(zval *object, zval *member, int type TSRMLS_DC); PHP_SOLR_API void solr_object_unset_property(zval *object, zval *member TSRMLS_DC); #else PHP_SOLR_API void solr_object_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC); PHP_SOLR_API zval *solr_object_read_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC); PHP_SOLR_API void solr_object_unset_property(zval *object, zval *member, const zend_literal *key TSRMLS_DC); #endif PHP_SOLR_API void solr_object_write_dimension(zval *object, zval *offset, zval *value TSRMLS_DC); PHP_SOLR_API void solr_object_unset_dimension(zval *object, zval *offset TSRMLS_DC); #if PHP_VERSION_ID < 50399 PHP_SOLR_API void solr_document_field_write_property(zval *object, zval *member, zval *value TSRMLS_DC); PHP_SOLR_API void solr_document_field_unset_property(zval *object, zval *member TSRMLS_DC); #else PHP_SOLR_API void solr_document_field_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC); PHP_SOLR_API void solr_document_field_unset_property(zval *object, zval *member, const zend_literal *key TSRMLS_DC); #endif /* }}} */ int add_phrase_field(zval *obj, solr_char_t *pname, zval *boost, zval *slop, solr_char_t *field_name, int field_name_len TSRMLS_DC); #include "solr_macros.h" #include "php_solr_dismax_query.h" #endif /* HAVE_SOLR */ #endif /* SOLRCLIENT_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/php_solr_api.h0000644000175000017500000000357212676753706015477 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Israel Ekpo | +----------------------------------------------------------------------+ */ /* $Id$ */ /** * Declaring Macro for function attributes * * This is for functions on GNU systems and Win32 systems * * On Win32 systems __declspec(dllexport) adds the export directive to the * object file so you do not need to use a .def file * * Using __declspec(dllexport) in addition to using a .def file should * not cause build errors. */ #ifndef PHP_SOLR_API_H #define PHP_SOLR_API_H #ifdef PHP_WIN32 #define PHP_SOLR_API __declspec(dllexport) #elif defined(__GNUC__) && __GNUC__ >= 4 #define PHP_SOLR_API __attribute__ ((visibility("default"))) #else #define PHP_SOLR_API #endif #endif /* PHP_SOLR_API_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/php_solr_version.h0000644000175000017500000000507512676753706016413 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_version.h" #ifndef PHP_SOLR_VERSION_H #define PHP_SOLR_VERSION_H #define PHP_SOLR_MAJOR_VERSION 2 #define PHP_SOLR_MINOR_VERSION 4 #define PHP_SOLR_PATCH_VERSION 0 #define PHP_SOLR_RELEASE_VERSION PHP_SOLR_PATCH_VERSION #define PHP_SOLR_VERSION "2.4.0" #define PHP_SOLR_DOTTED_VERSION PHP_SOLR_VERSION /** * Extension version numbers using hexadecimal numbers * * This is the numeric version of the extension, meant for easier * parsing and comparisons by programs. The PHP_SOLR_VERSION_ID define will * always follow this syntax: * * 0xXXYYZZ * * Where XX, YY and ZZ are the main version, minor version and patch numbers in * hexadecimal (using 8 bits each). All three numbers are always represented * using two digits. 1.2 would appear as "0x010200" while version 9.11.7 * appears as "0x090b07". * * This 6-digit (24 bits) hexadecimal number does not show pre-release number, * and it is always a greater number in a more recent release. It makes * comparisons with greater than and less than work. */ #define PHP_SOLR_VERSION_ID 0x020400 #define SOLR_CLIENT_USER_AGENT "PHP Solr Client 2.4.0" #endif /* PHP_SOLR_VERSION_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/php_solr_bc_macros.h0000644000175000017500000000611112676753706016646 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Israel Ekpo | +----------------------------------------------------------------------+ */ /* $Id$ */ /** * PHP 5 backward compatibility macros * * With the arrival of ZE 2.3.0, some of the member structures of the zval struct * were renamed. These macros will allow us to still be able to use the * new macros introduced since php 5.3.0 to compile code in the PHP 5.2.x series. * * We should allow up to php version 5.2.11. The latest stable release as of the * time of the initial release of this extension. */ #ifndef PHP_SOLR_BC_MACROS_H #define PHP_SOLR_BC_MACROS_H /* Retrieves the refcount */ #ifndef Z_REFCOUNT_P #define Z_REFCOUNT_P(pz) (pz)->refcount; #define Z_REFCOUNT_PP(ppz) Z_REFCOUNT_P(*(ppz)) #endif /* Sets the refcount to the specified value. */ #ifndef Z_SET_REFCOUNT_P #define Z_SET_REFCOUNT_P(pz, rc) (pz)->refcount = rc; #define Z_SET_REFCOUNT_PP(ppz) Z_SET_REFCOUNT_P((*ppz), rc) #endif /* Increases the recount by 1 */ #ifndef Z_ADDREF_P #define Z_ADDREF_P(pz) (pz)->refcount++; #define Z_ADDREF_PP(ppz) Z_ADDREF_P(*(ppz)) #endif /* Reduces the refcount by 1 */ #ifndef Z_DELREF_P #define Z_DELREF_P(pz) (pz)->refcount--; #define Z_DELREF_PP(ppz) Z_DELREF_P(*(ppz)) #endif /* Sets the isref member on the zval */ #ifndef Z_SET_ISREF_P #define Z_SET_ISREF_P(pz) (pz)->is_ref = 1; #define Z_SET_ISREF_PP(ppz) Z_SET_ISREF_P(*(ppz)) #endif /* Unsets the isref member on the zval */ #ifndef Z_UNSET_ISREF_P #define Z_UNSET_ISREF_P(pz) (pz)->is_ref = 0; #define Z_UNSET_ISREF_PP(ppz ) Z_UNSET_ISREF_P(*(ppz)) #endif /* Checks if is_ref is set on the zval */ #ifndef Z_ISREF_P #define Z_ISREF_P(pz) ((pz)->is_ref) #define Z_ISREF_PP(ppz) Z_ISREF_P(*(ppz)) #endif /* Sets the is_ref member to the specified value */ #ifndef Z_SET_ISREF_TO_P #define Z_SET_ISREF_TO_P(pz, isref) (pz)->is_ref = is_ref; #define Z_SET_ISREF_TO_PP(ppz, isref) Z_SET_ISREF_TO_P(*(ppz), isref) #endif #endif /* PHP_SOLR_BC_MACROS_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/solr_constants.h0000644000175000017500000001757012676753706016076 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #ifndef SOLR_CONSTANTS_H #define SOLR_CONSTANTS_H #include "php_solr_version.h" #define SOLR_SPACE_STRING " " /* {{{ Constants for the SolrClient with*/ #define SOLR_DEFAULT_UPDATE_SERVLET "update" #define SOLR_DEFAULT_SEARCH_SERVLET "select" #define SOLR_DEFAULT_THREADS_SERVLET "admin/threads" #define SOLR_DEFAULT_PING_SERVLET "admin/ping" #define SOLR_DEFAULT_TERMS_SERVLET "terms" #define SOLR_DEFAULT_SYSTEM_SERVLET "admin/system" #define SOLR_DEFAULT_GET_SERVLET "get" #define SOLR_PHP_SERIALIZED_RESPONSE_WRITER "phps" #define SOLR_PHP_NATIVE_RESPONSE_WRITER "phpnative" #define SOLR_XML_RESPONSE_WRITER "xml" #define SOLR_JSON_RESPONSE_WRITER "json" #define SOLR_REQUEST_DEFAULT_HOST "localhost" #define SOLR_REQUEST_DEFAULT_PATH "solr" #define SOLR_REQUEST_DEFAULT_QS_DELIMITER "&" #define SOLR_REQUEST_DEFAULT_PORT 8983L #define SOLR_CURL_MAX_WRITE_SIZE CURL_MAX_WRITE_SIZE #define SOLR_CURL_OPTIONS_LENGTH 512 /* }}} */ /* {{{ Names of Objects */ #define PHP_SOLR_OBJECT_CLASSNAME "SolrObject" #define PHP_SOLR_DOCUMENT_CLASSNAME "SolrDocument" #define PHP_SOLR_DOCUMENT_FIELD_CLASSNAME "SolrDocumentField" #define PHP_SOLR_INPUT_DOCUMENT_CLASSNAME "SolrInputDocument" #define PHP_SOLR_CLIENT_CLASSNAME "SolrClient" #define PHP_SOLR_PARAMS_CLASSNAME "SolrParams" #define PHP_SOLR_QUERY_CLASSNAME "SolrQuery" #define PHP_SOLR_COLLAPSE_FUNCTION_CLASSNAME "SolrCollapseFunction" #define PHP_SOLR_MODIFIABLE_PARAMS_CLASSNAME "SolrModifiableParams" #define PHP_SOLR_RESPONSE_CLASSNAME "SolrResponse" #define PHP_SOLR_QUERY_RESPONSE_CLASSNAME "SolrQueryResponse" #define PHP_SOLR_UPDATE_RESPONSE_CLASSNAME "SolrUpdateResponse" #define PHP_SOLR_PING_RESPONSE_CLASSNAME "SolrPingResponse" #define PHP_SOLR_GENERIC_RESPONSE_CLASSNAME "SolrGenericResponse" #define PHP_SOLR_UTILS_CLASSNAME "SolrUtils" #define PHP_SOLR_EXCEPTION_CLASSNAME "SolrException" #define PHP_SOLR_ILLEGAL_OPERATION_EXCEPTION_CLASSNAME "SolrIllegalOperationException" #define PHP_SOLR_ILLEGAL_ARGUMENT_EXCEPTION_CLASSNAME "SolrIllegalArgumentException" #define PHP_SOLR_CLIENT_EXCEPTION_CLASSNAME "SolrClientException" #define PHP_SOLR_SERVER_EXCEPTION_CLASSNAME "SolrServerException" #define PHP_SOLR_MISSING_MANDATORY_PARAMETER_EXCEPTION_CLASSNAME "SolrMissingMandatoryParameterException" /* }}} */ /* {{{ Informational constants */ #define PHP_SOLR_EXTENSION_NAME "solr" #define PHP_CURL_EXTENSION_NAME "curl" #define PHP_LIBXML_EXTENSION_NAME "libxml" #define PHP_JSON_EXTENSION_NAME "json" /* }}} */ /* {{{ Property names */ #define SOLR_INDEX_PROPERTY_NAME "_hashtable_index" #define SOLR_FIELD_NAME_PROPERTY_NAME "name" #define SOLR_FIELD_BOOST_PROPERTY_NAME "boost" #define SOLR_FIELD_VALUES_PROPERTY_NAME "values" #define SOLR_SOURCELINE_NO_PROPERTY_NAME "sourceline" #define SOLR_SOURCEFILE_PROPERTY_NAME "sourcefile" #define SOLR_ZIFNAME_PROPERTY_NAME "zif_name" #define SOLR_DISMAX_DEFAULT_PARSER "edismax" #ifdef PHP_WIN32 #define __func__ __FUNCTION__ #endif #define SOLR_FILE_LINE_FUNC __FILE__, __LINE__, __func__ /* }}} */ /* {{{ Constants for Method/Function arguments and return styles */ #define SOLR_ARG_PASS_BY_REF_FALSE 0 #define SOLR_ARG_PASS_BY_REF_TRUE 1 #define SOLR_ARG_PASS_REMAINING_BY_REF_FALSE 0 #define SOLR_ARG_PASS_REMAINING_BY_REF_TRUE 1 #define SOLR_ARG_ALLOW_NULL_FALSE 0 #define SOLR_ARG_ALLOW_NULL_TRUE 1 #define SOLR_METHOD_RETURN_REFERENCE_FALSE 0 #define SOLR_METHOD_RETURN_REFERENCE_TRUE 1 /* }}} */ /* {{{ Constants for Sorting SolrDocument Fields */ #define SOLR_SORT_ASC 1 #define SOLR_SORT_DESC 2 #define SOLR_SORT_FIELD_NAME 1 #define SOLR_SORT_FIELD_VALUE_COUNT 2 #define SOLR_SORT_FIELD_BOOST_VALUE 4 /* }}} */ /* {{{ Constants for document encoding formats */ #define SOLR_XML_ENCODE_OBJ 0L #define SOLR_XML_ENCODE_DOC 1L /* }}} */ /** * Setting this to 8 gets rid of the extra while loops in _zend_hash_init() * * _zend_hash_init loops 3 times to increase the value of the size to 8 */ #define SOLR_INITIAL_HASH_TABLE_SIZE (1<<3) /* {{{ Memory Allocation Related Constants */ #define SOLR_HASHTABLE_PERSISTENT 0 #define SOLR_DOCUMENT_PERSISTENT 0 #define SOLR_DOCUMENT_FIELD_PERSISTENT 0 #define SOLR_CLIENT_PERSISTENT 0 #define SOLR_PARAMS_PERSISTENT 0 #define SOLR_FUNCTIONS_PERSISTENT 0 /* }}} */ /* {{{ SolrException Codes : Internal and UserSpace */ /* {{{ Error codes and messages */ #define SOLR_ERROR_1000 1000L #define SOLR_ERROR_1000_MSG "Error un-serializing response" #define SOLR_ERROR_1001 1001L #define SOLR_ERROR_1001_MSG "SolrClient objects cannot be serialized or unserialized" #define SOLR_ERROR_1002 1002L #define SOLR_ERROR_1002_MSG "The '%s' property cannot be removed or set to NULL. SolrObject properties cannot be unset or set to NULL." #define SOLR_ERROR_1003 1003L #define SOLR_ERROR_1003_MSG "Error building HTTP query from parameters" #define SOLR_ERROR_1004 1004L #define SOLR_ERROR_1004_MSG "Unsuccessful HTTP request" #define SOLR_ERROR_1005 1005L #define SOLR_ERROR_1005_MSG "SolrInputDocument objects cannot be serialized or unserialized" #define SOLR_ERROR_1006 1006L #define SOLR_ERROR_1006_MSG "SolrObject instances are read-only. Properties cannot be added, updated or removed." #define SOLR_ERROR_1007 1007L #define SOLR_ERROR_1007_MSG "SolrDocumentField instances are read-only. Properties cannot be updated or removed." #define SOLR_ERROR_1008 1008L #define SOLR_ERROR_1008_MSG "Internal Error 1008 generated from %s %d %s. The observed error is a possible side-effect of an illegal/unsupported operation in userspace. Please check the documentation and try again later." #define SOLR_ERROR_1009 1009L #define SOLR_ERROR_1009_MSG "The observed error is a possible side-effect of an illegal/unsupported operation in userspace. This object cannot be cloned. Cloning of this object type is not yet supported." #define SOLR_ERROR_1010 1010L #define SOLR_ERROR_1010_MSG "Unsuccessful %s request : Response Code %ld. %s" #define SOLR_ERROR_4000 4000L #define SOLR_ERROR_4000_MSG "Invalid argument" #define SOLR_ERROR_4001 4001L #define SOLR_ERROR_4001_MSG "Illegal Operation" #define SOLR_ERROR_4002 4002L #define SOLR_ERROR_4002_MSG "Return value requested without processing output" /* }}} */ /* {{{ UserSpace Errors */ #define SOLR_ERROR_4100 4100L #define SOLR_ERROR_4100_MSG "Mandatory parameter Missing: %s" /* }}} */ /* {{{ Compile time errors */ /* }}} */ /* }}} */ #endif /* SOLR_CONSTANTS_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/solr_macros.h0000664000175000017500000001533212676753706015342 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #ifndef SOLR_MACROS_H #define SOLR_MACROS_H #include /* Macros for Object constructors and destructors declaration */ #define SOLR_CTOR(class_name, func_name, arginfo) PHP_ME(class_name, func_name, arginfo, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) #define SOLR_DTOR(class_name, func_name, arginfo) PHP_ME(class_name, func_name, arginfo, ZEND_ACC_PUBLIC | ZEND_ACC_DTOR) /* Retrieve a unique hash index for this SolrDocument. Unique for this thread */ #define SOLR_UNIQUE_DOCUMENT_INDEX() solr_hashtable_get_new_index(SOLR_GLOBAL(documents) TSRMLS_CC) /* Retrieve a unique hash index for this SolrClient. Unique for this thread */ #define SOLR_UNIQUE_CLIENT_INDEX() solr_hashtable_get_new_index(SOLR_GLOBAL(clients) TSRMLS_CC) /* Retrieve a unique hash index for this SolrParams instance. Unique for this thread */ #define SOLR_UNIQUE_PARAMS_INDEX() solr_hashtable_get_new_index(SOLR_GLOBAL(params) TSRMLS_CC) /* Retrieve a unique hash index for this SolrFunction instance. Unique for this thread */ #define SOLR_UNIQUE_FUNCTION_INDEX() solr_hashtable_get_new_index(SOLR_GLOBAL(functions) TSRMLS_CC) /* Iterates through the HashTable pointer */ #define SOLR_HASHTABLE_FOR_LOOP(HashTablePtr) \ if (HashTablePtr) for ( zend_hash_internal_pointer_reset((HashTablePtr)); \ SUCCESS == zend_hash_has_more_elements((HashTablePtr)); \ zend_hash_move_forward((HashTablePtr)) ) /* Gets a random number between 1 and SHRT_MAX */ #define SOLR_GET_RANDOM_NUMBER() abs(rand() % SHRT_MAX + 1) /* {{{ Memory Allocation Macros */ /* Used only to release truly persistent allocations */ #define SOLR_FREE_PTR(ptr) { if (ptr != NULL) { pefree(ptr,SOLR_HASHTABLE_PERSISTENT); ptr = NULL; } else { printf("\nSOLR_FREE_PTR double free() from function %s() called in %s on line %d\n", __func__, __FILE__, __LINE__); } } /* }}} */ /** * Used to retrieve xmlAttr and xmlNode values * * At this time, I am not sure if the next and previous sibling links * are guaranteed to be document order 100% of the time. * This is why I am requiring matches for the attribute and element names before * copying values from the attributes or element nodes. * Since I am not 100%, I believe it is better to be safe than sorry. * There may be a slight performance hit but at least correctness is guaranteed. */ #define solr_xml_match_node(solrXmlNode, solrXmlNodeName) ( \ xmlStrEqual(solrXmlNode->name, (xmlChar *) solrXmlNodeName) && \ solrXmlNode->children && solrXmlNode->children->content ) /* Checks if children is a valid struct */ #define solr_xml_child_content_is_valid(solrXmlNode) (solrXmlNode && solrXmlNode->children) /* Checks to prevent segmentation fault. Ensures that children is a valid struct before attempting to get content */ #define solr_xml_get_node_contents(solrXmlNode) (solr_xml_child_content_is_valid(solrXmlNode)? (solrXmlNode->children->content) : ((xmlChar *) "")) #define solr_xml_get_node_contents_int(solrXmlNode) atoi((char *)solr_xml_get_node_contents(solrXmlNode)) #define solr_xml_get_node_contents_double(solrXmlNode) xmlXPathCastStringToNumber(solr_xml_get_node_contents(solrXmlNode)) /** * Used to manage SolrQuery parameters that allow overrides by field name. * * Many parameters may be overridden on a per-field basis with the following syntax * * f..= * f..= * * @buf pointer to a solr_string_t object * @fname field name * @fname_len length of the field name * @pname a string constant representing the name of the parameter. */ #define solr_query_field_override(buf, fname, fname_len, pname) { \ if ((fname_len)) { \ solr_string_append_const((buf), "f."); \ solr_string_appends((buf), (fname), (fname_len)); \ solr_string_appendc((buf), '.'); \ } \ solr_string_append_const((buf), (pname)); \ } /* Macro for returning SolrParams objects if requested */ #define solr_return_solr_params_object() { \ if(return_value_used) { \ solr_set_return_solr_params_object((return_value_ptr), getThis() TSRMLS_CC); \ } \ } /* client macros */ #define SOLR_RESPONSE_CODE_BODY (client->handle.response_header.response_code), (client->handle.response_body.buffer.str) #define SOLR_SHOW_CURL_WARNING { \ if (client->handle.err.str) \ { \ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ((solr_char_t *) client->handle.err.str)); \ } \ } /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception */ #define HANDLE_SOLR_SERVER_ERROR(clientPtr,requestType){ \ if(clientPtr->handle.result_code == CURLE_OK){ \ solr_throw_solr_server_exception(clientPtr, (const char *)requestType TSRMLS_CC);\ } \ } /* solr_throw_exception_ex(solr_ce_SolrClientException, SOLR_ERROR_1010 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1010_MSG, requestType, SOLR_RESPONSE_CODE_BODY); \ */ #define SOLR_RETURN_THIS() { \ if(return_value_used) \ { \ RETURN_ZVAL(getThis(), 1, 0); \ } \ } /* Used to release the (solr_document_t **) pointers */ #define SOLR_FREE_DOC_ENTRIES(ptr) { \ if ((ptr) != NULL)\ { \ pefree(ptr, SOLR_DOCUMENT_PERSISTENT); \ ptr = NULL; \ } \ } /* }}} */ /* For php < 5.3.7 */ #ifndef PHP_FE_END #define PHP_FE_END {NULL,NULL,NULL} #endif #ifndef ZEND_MOD_END #define ZEND_MOD_END {NULL, NULL, NULL} #endif #endif /* SOLR_MACROS_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/solr_string.h0000644000175000017500000001157612676753706015370 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Israel Ekpo | +----------------------------------------------------------------------+ */ /* $Id$ */ #ifndef SOLR_STRING_H #define SOLR_STRING_H #include
#include #define SOLR_STRING_PERSISTENT 0 #define SOLR_STRING_START_SIZE 64 #define SOLR_STRING_INCREMENT_SIZE 128 #define SOLR_STRING_LONG_BUFFER_SIZE 16 #define SOLR_STRING_UNSIGNED_LONG_BUFFER_SIZE 32 #include "php_solr_api.h" #ifdef SOLR_DEBUG /* #define SOLR_MEM_DEBUG 1 Uncomment if you need memdebug enabled */ #endif #ifdef SOLR_MEM_DEBUG #define SOLR_MEM_DEBUG_DC , const char * mm_function, char * mm_filename, int mm_line #define SOLR_MEM_DEBUG_CC , mm_function, mm_filename, mm_line #define SOLR_MEM_DEBUG_RC , __func__, __FILE__, __LINE__ #else #define SOLR_MEM_DEBUG_DC #define SOLR_MEM_DEBUG_CC #define SOLR_MEM_DEBUG_RC #endif /** * solr_char_t * * iekpo 2009/08/28 * * Decided to create this type just in case there is a special need in the * future to use unsigned char instead of plain char to transport character * arrays within the library. * * Having this typedef will allow us to toggle easily between plain char and * unsigned char, without having to do a massive search and replace. * * There may be a few cases where casting may be needed to handle cases where * the sign of the variable is now the opposite. */ typedef char solr_char_t; /* Structure to store solr strings */ typedef struct _solr_string { solr_char_t *str; /* The buffer to store the character array. */ size_t len; /* The current length of the solr_string_t object */ size_t cap; /* The current capacity of the solr_string_t object */ } solr_string_t; #define SOLR_STRING_INITIALIZER {.str = ((solr_char_t *)0), .len = 0U, .cap = 0U} /* Appends a string constant to a solr_string_t */ #define solr_string_append_const(dest, str) solr_string_appends((dest), (solr_char_t *) str, sizeof(str)-1) /* Appends one solr_string_t to another */ #define solr_string_append_solr_string(dest, src) solr_string_appends((dest), (src)->str, (src)->len) /* Initializes the solr_string_t structure to empty values */ #define solr_string_init(dest) \ { \ (dest)->str = (solr_char_t *) 0x00; \ (dest)->len = 0U; \ (dest)->cap = 0U; \ } #define solr_strndup estrndup #define solr_strdup estrdup #define solr_strlen strlen #define solr_string_appends(dest, src, len) solr_string_appends_ex((dest), (src), (len) SOLR_MEM_DEBUG_RC) #define solr_string_appendc(dest, ch) solr_string_appendc_ex((dest), (ch) SOLR_MEM_DEBUG_RC) #define solr_string_append_long(dest, long_val) solr_string_append_long_ex((dest), (long_val) SOLR_MEM_DEBUG_RC) #define solr_string_append_unsigned_long(dest, long_val) solr_string_append_unsigned_long((dest), (long_val) SOLR_MEM_DEBUG_RC) #define solr_string_set(dest, value, length) solr_string_set_ex((dest), (value), (length) SOLR_MEM_DEBUG_RC) #define solr_string_free(dest) solr_string_free_ex((dest) SOLR_MEM_DEBUG_RC) PHP_SOLR_API void solr_string_appends_ex(solr_string_t *dest, const solr_char_t *src, size_t length SOLR_MEM_DEBUG_DC); PHP_SOLR_API void solr_string_appendc_ex(solr_string_t *dest, solr_char_t ch SOLR_MEM_DEBUG_DC); PHP_SOLR_API void solr_string_append_long_ex(solr_string_t *dest, long int long_val SOLR_MEM_DEBUG_DC); PHP_SOLR_API void solr_string_append_unsigned_long_ex(solr_string_t *dest, unsigned long int long_val SOLR_MEM_DEBUG_DC); PHP_SOLR_API void solr_string_remove_last_char(solr_string_t *dest); PHP_SOLR_API int solr_string_equal(const solr_string_t *a, const solr_string_t *b); PHP_SOLR_API void solr_string_free_ex(solr_string_t *dest SOLR_MEM_DEBUG_DC); PHP_SOLR_API void solr_string_set_ex(solr_string_t *dest, const solr_char_t *value, size_t length SOLR_MEM_DEBUG_DC); #endif /* SOLR_STRING_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/solr_types.h0000644000175000017500000003153412676753706015222 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #ifndef SOLR_TYPES_H #define SOLR_TYPES_H #include
#include #include #include #include /* Declaring workarounds for SSL private key constants */ #if LIBCURL_VERSION_NUM >= 0x071700 /* Use CURLOPT_KEYPASSWD as is */ #elif LIBCURL_VERSION_NUM >= 0x070903 #define CURLOPT_KEYPASSWD CURLOPT_SSLKEYPASSWD #else #define CURLOPT_KEYPASSWD CURLOPT_SSLCERTPASSWD #endif #include #include #include #include #include #include typedef unsigned char solr_bool; #include "solr_string.h" /* {{{ types for the http client */ typedef enum { SOLR_REQUEST_BEGIN = 0, SOLR_REQUEST_SEARCH = 1, /** 1 **/ SOLR_REQUEST_UPDATE = 2, /** 2 **/ SOLR_REQUEST_THREADS = 3, /** 3 **/ SOLR_REQUEST_PING = 4, /** 4 **/ SOLR_REQUEST_TERMS = 5, /** 5 **/ SOLR_REQUEST_SYSTEM = 6, /** 6 **/ SOLR_REQUEST_GET = 7, SOLR_REQUEST_END } solr_request_type_t; typedef enum { SOLR_SERVLET_TYPE_BEGIN = 0, SOLR_SERVLET_TYPE_SEARCH = 1, SOLR_SERVLET_TYPE_UPDATE = 2, SOLR_SERVLET_TYPE_THREADS = 4, SOLR_SERVLET_TYPE_PING = 8, SOLR_SERVLET_TYPE_TERMS = 16, SOLR_SERVLET_TYPE_SYSTEM = 32, SOLR_SERVLET_TYPE_GET = 64, SOLR_SERVLET_TYPE_END } solr_servlet_type_t; typedef enum { SOLR_PARAM_TYPE_BEGIN = 0, SOLR_PARAM_TYPE_NORMAL = 1, SOLR_PARAM_TYPE_SIMPLE_LIST = 2, SOLR_PARAM_TYPE_ARG_LIST = 4, SOLR_PARAM_TYPE_END } solr_param_type_t; typedef enum { SOLR_SORT_DIR_ASC = 0, SOLR_SORT_DIR_DESC = 1 } solr_sort_dir_t; typedef enum { SOLR_JSON_ERROR_NONE = 0, SOLR_JSON_ERROR_DEPTH, SOLR_JSON_ERROR_STATE_MISMATCH, SOLR_JSON_ERROR_CTRL_CHAR, SOLR_JSON_ERROR_SYNTAX, SOLR_JSON_ERROR_UTF8, SOLR_JSON_ERROR_SERIALIZATION } solr_json_error_codes_t; typedef struct curl_slist solr_http_header_list_t; typedef struct { solr_string_t buffer; /* Stores the HTTP request headers */ } solr_curl_send_headers_t; typedef struct _solr_curl_send_data { solr_string_t buffer; /* Stores the HTTP request data */ } solr_curl_send_data_t; typedef struct { solr_string_t buffer; /* Stores the HTTP response headers */ long int response_code; /* Stores the HTTP response code */ } solr_curl_response_headers_t; typedef struct { solr_string_t buffer; /* Stores the HTTP response data */ } solr_curl_response_data_t; typedef struct { char str[CURL_ERROR_SIZE + 1]; /* Stores the error message */ uint number; /* Stores the error number */ } solr_curl_error_t; typedef struct { solr_curl_send_headers_t request_header; solr_curl_send_data_t request_body; solr_curl_send_data_t request_body_debug; solr_curl_response_headers_t response_header; solr_curl_response_data_t response_body; solr_curl_error_t err; solr_string_t debug_data_buffer; /* Stores all the debug data */ size_t handle_status; /* Whether or not the handle is still usable */ CURLcode result_code; CURL *curl_handle; #ifdef ZTS TSRMLS_D; #endif } solr_curl_t; typedef struct { long int host_port; /* HTTP port for Solr server */ long int proxy_port; /* Proxy port for Solr server */ long int timeout; /* maximum time in seconds allowed for the http data transfer operation */ long int secure; /* Whether to connect to Solr Server using SSL/HTTPS */ long int ssl_verify_peer; /* Determines whether libcurl verifies the peer certificate */ long int ssl_verify_host; /* Determines how libcurl verifies the server certificate */ solr_string_t hostname; /* IP address or domain name */ solr_string_t path; /* Path to solr */ solr_string_t http_auth_credentials; /* HTTP Auth username:password */ solr_string_t proxy_hostname; /* IP address of domain name for the proxy server */ solr_string_t proxy_auth_credentials; /* Proxy Auth username:password */ solr_string_t ssl_cert; /* File name to a PEM-formatted private key + private certificate (concatenated in that order) */ solr_string_t ssl_key; /* File name to a PEM-formatted private key */ solr_string_t ssl_keypassword; /* The pass phrase/password for the private ssl_key */ solr_string_t ssl_cainfo; /* Name of file holding one or more certificates to verify peer with */ solr_string_t ssl_capath; /* Name of directory holding multiple CA certificates to verify peer with */ solr_string_t qs_delimiter; /* The query string delimiter */ solr_string_t response_writer; /* The response writer type (wt parameter) */ solr_string_t update_url; /* URL used for updates */ solr_string_t search_url; /* URL used for queries */ solr_string_t thread_url; /* URL used for thread monitoring */ solr_string_t ping_url; /* URL for sending ping requests */ solr_string_t terms_url; /* URL for sending terms requests */ solr_string_t system_url; /* URL for sending system requests */ solr_string_t get_url; /* URL for sending realtime get requests */ solr_string_t update_servlet; /* The update servlet */ solr_string_t search_servlet; /* The search servlet */ solr_string_t thread_servlet; /* The thread servlet */ solr_string_t ping_servlet; /* The ping servlet */ solr_string_t terms_servlet; /* The terms servlet */ solr_string_t system_servlet; /* The system info servlet */ solr_string_t get_servlet; /* The realtime get servlet */ } solr_client_options_t; typedef struct { ulong client_index; /* Unique for the SolrClient instance. Used as index in HashTables */ uint request_count; /* The number of requests made from this client */ solr_client_options_t options; /* The connection options for this client */ solr_curl_t handle; /* The Solr handle for this client */ } solr_client_t; /* }}} */ /* Types for documents and collections */ /* {{{ Types for documents and collections */ /* {{{ Types for SolrDocument fields */ typedef struct _solr_field_value_t { solr_char_t *field_value; /* The value for this field */ struct _solr_field_value_t *next; /* The next entry in the queue */ } solr_field_value_t; /** * List of Fields in a Solr Document * * @field_boost stores the boost value * @count stores how many fields there are in the list * @field_name stores the name of the field * @head the first entry in the list (if any) * @last the last entry in the list (if any) */ typedef struct { double field_boost; /* The boost value for this field */ uint count; /* The number of values in this field */ solr_char_t *field_name; /* The name of the field */ solr_field_value_t *head; /* The first value in the queue */ solr_field_value_t *last; /* The last value in the queue */ } solr_field_list_t; /* }}} */ /* {{{ Types for Documents and Document Collections */ typedef struct { ulong document_index; /* Unique for the SolrInputDocument instance. Used as index in HashTables */ uint field_count; /* Number of fields in this document */ double document_boost; /* The boost value for this document */ HashTable *fields; /* HashTable for storing all the solr_field_list_t fields */ HashTable *children; /* Hashtable for storing child documents(zval *) */ } solr_document_t; /* }}} */ /* {{{ Types for Solr Query Parameters */ typedef struct { solr_string_t value; /* The value for this parameter */ solr_string_t arg; /* The argument for this value*/ solr_char_t *delimiter_override; /* overrides the arg_list delimiter for this particular argument */ solr_bool delimiter_overriden; /* is delimiter overriden */ } solr_arg_list_value_t; typedef union { solr_string_t normal; /* Stores normal parameters */ solr_string_t simple_list; /* Stores delimited list parameters */ solr_arg_list_value_t arg_list; /* Stores parameters that have arguments */ } solr_pvc_t; typedef struct _solr_param_value_t { solr_pvc_t contents; /* A union for the contents of this value */ struct _solr_param_value_t *prev; /* The previous value in the list */ struct _solr_param_value_t *next; /* The next value in the list */ } solr_param_value_t; /* Checks if two parameter values are equal */ typedef int (*solr_param_value_equal_func_t)(const solr_param_value_t *a, const solr_param_value_t *b); /* Used to retrieve all the values for this parameter as a single solr string */ typedef void (*solr_param_fetch_func_t)(void *solr_param, solr_string_t *buffer); /* Frees the parameter value and its contents. */ typedef void (*solr_param_value_free_func_t)(solr_param_value_t *param_value); typedef struct { solr_param_type_t type; /* What type of query parameter this is */ uint count; /* The number of values for this parameter */ solr_char_t *param_name; /* The name of the parameter */ size_t param_name_length; /* The length of name of the parameter */ solr_bool allow_multiple; /* Whether this parameter should store more than one value */ solr_param_value_t *head; /* The first value in the list */ solr_param_value_t *last; /* The last value in the list */ solr_param_fetch_func_t fetch_func; /* Retrieves all the value contents as a single solr_string_t */ solr_param_value_free_func_t value_free_func; /* Frees the value and its contents */ solr_param_value_equal_func_t value_equal_func; /* Checks if two values are equal */ solr_char_t delimiter; /* Default is "," Used to separate list parameter values */ solr_char_t arg_separator; /* Used only be arg_lists to separate arguments from values */ } solr_param_t; /* Used to retrieve parameter values just for display purposes */ typedef void (*solr_param_display_func_t)(solr_param_t *solr_param, zval *param_value_array); /* Used to retrieve parameter values just for the toString() method */ /* The url_encode parameter will be ignored for now */ typedef void (*solr_param_tostring_func_t)(solr_param_t *solr_param, solr_string_t *buffer, zend_bool url_encode); typedef struct { ulong params_index; /* The index for this object in the HashTable */ uint params_count; /* The number of parameters for the query object */ HashTable *params; /* The HashTable for storing query parameters */ } solr_params_t; /* }}} */ /* {{{ solr function/localparams type */ typedef struct { ulong function_index; /* The index for this object in the HashTable */ solr_char_t *name; size_t name_length; solr_char_t *argument; size_t argument_length; HashTable *params; /* The HashTable for storing function key-val parameters */ } solr_function_t; /* }}} */ /* }}} */ /* {{{ Extension Global : This should be the last data type declared. More members may be added later. */ ZEND_BEGIN_MODULE_GLOBALS(solr) uint request_count; /* The number of times PHP_RINIT has been called */ uint document_count; /* The number of active SolrDocuments in this request */ uint client_count; /* The number of active SolrClients in this request */ uint functions_count; /* The number of active Functions in this request */ HashTable *documents; /* HashTable for storing solr_document_t documents */ HashTable *clients; /* HashTable for storing solr_client_t clients */ HashTable *params; /* HashTable for storing solr_params_t parameter containers */ HashTable *functions; /* HashTable for storing solr_function_t */ ZEND_END_MODULE_GLOBALS(solr) /* }}} */ typedef struct { int code; solr_char_t *message; } solr_exception_t; #endif /* SOLR_TYPES_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/php_solr.c0000664000175000017500000020320512676753706014636 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" #ifdef HAVE_SOLR /* PHP versions lower than 5.2.3 are not compatible or are causing tests to FAIL */ #if ((PHP_MAJOR_VERSION < 5) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 2) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 2 && PHP_RELEASE_VERSION < 3)) #error PHP 5.2.3 or newer is required. Please upgrade your php version. #endif #if LIBCURL_VERSION_NUM < 0x070F00 #error libcurl 7.15.0 or later is required. Please upgrade your libcurl version. #endif #if LIBXML_VERSION < 20616 #error libxml2 2.6.16 or later is required. Please upgrade your libxml2 version. #endif /******************************************************************************/ /** GLOBAL VARIABLE FOR THE EXTENSION **/ /******************************************************************************/ /* {{{ ZEND_DECLARE_MODULE_GLOBALS(solr) */ ZEND_DECLARE_MODULE_GLOBALS(solr) /* }}} */ /******************************************************************************/ /** OBJECT HANDLERS AND DECLARATIONS FOR CLASS ENTRIES **/ /******************************************************************************/ /* {{{ zend_class_entry declarations of the classes */ zend_class_entry *solr_ce_SolrObject; zend_class_entry *solr_ce_SolrInputDocument; zend_class_entry *solr_ce_SolrDocument; zend_class_entry *solr_ce_SolrDocumentField; zend_class_entry *solr_ce_SolrClient; zend_class_entry *solr_ce_SolrParams; zend_class_entry *solr_ce_SolrModifiableParams; zend_class_entry *solr_ce_SolrCollapseFunction; zend_class_entry *solr_ce_SolrQuery; zend_class_entry *solr_ce_SolrResponse; zend_class_entry *solr_ce_SolrQueryResponse; zend_class_entry *solr_ce_SolrUpdateResponse; zend_class_entry *solr_ce_SolrPingResponse; zend_class_entry *solr_ce_SolrGenericResponse; zend_class_entry *solr_ce_SolrUtils; zend_class_entry *solr_ce_SolrException; zend_class_entry *solr_ce_SolrIllegalOperationException; zend_class_entry *solr_ce_SolrIllegalArgumentException; zend_class_entry *solr_ce_SolrClientException; zend_class_entry *solr_ce_SolrServerException; zend_class_entry *solr_ce_SolrMissingMandatoryParameterException; /* }}} */ /* {{{ zend_object_handlers */ zend_object_handlers solr_object_handlers; zend_object_handlers solr_document_field_handlers; zend_object_handlers solr_input_document_object_handlers; zend_object_handlers solr_client_object_handlers; zend_object_handlers solr_response_object_handlers; zend_object_handlers solr_collapse_function_object_handlers; /* }}} */ /* {{{ static void php_solr_globals_ctor(zend_solr_globals *solr_globals_arg TSRMLS_DC) Global variable initializer. In ZTS mode, called once for each thread spawned. */ static void php_solr_globals_ctor(zend_solr_globals *solr_globals_arg TSRMLS_DC) { /* Initializing the counters to Zero */ solr_globals_arg->request_count = 0U; solr_globals_arg->document_count = 0U; solr_globals_arg->client_count = 0U; solr_globals_arg->functions_count = 0U; solr_globals_arg->documents = NULL; solr_globals_arg->clients = NULL; solr_globals_arg->params = NULL; solr_globals_arg->functions = NULL; } /* }}} */ /******************************************************************************/ /** DECLARING STRUCTURES FOR METHOD ARGUMENTS TYPE HINTING **/ /******************************************************************************/ /* {{{ arg_info vectors for functions and methods */ ZEND_BEGIN_ARG_INFO_EX(SolrObject__get_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, property_name) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrObject__set_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 2) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, property_name) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, property_value) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrObject_one_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, property_name) ZEND_END_ARG_INFO() /* {{{ SolrDocument arguments */ ZEND_BEGIN_ARG_INFO_EX(SolrDocument__construct_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDocument_addField_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 2) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldName) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldValue) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDocument_getField_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldName) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDocument_fieldExists_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldName) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDocument_deleteField_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldName) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDocument_sort_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, sortOrderBy) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, sortDirection) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDocument_merge_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_OBJ_INFO(SOLR_ARG_PASS_BY_REF_TRUE, sourceDoc, SolrDocument, SOLR_ARG_ALLOW_NULL_FALSE) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, overwrite) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDocument_current_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDocument_getInputDocument_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO(SolrDocument_unserialize_args, 0) ZEND_ARG_INFO(0, serialized) ZEND_END_ARG_INFO() /* }}} */ /* {{{ SolrInputDocument arguments */ ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument__construct_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument_setBoost_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, documentBoostValue) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument_addField_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 2) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldName) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldValue) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldBoostValue) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument_getFieldBoost_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldName) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument_getField_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldName) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument_setFieldBoost_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 2) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldName) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldBoostValue) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument_fieldExists_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldName) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument_deleteField_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldName) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument_sort_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, sortOrderBy) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, sortDirection) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument_merge_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_OBJ_INFO(SOLR_ARG_PASS_BY_REF_TRUE, sourceDoc, SolrInputDocument, SOLR_ARG_ALLOW_NULL_FALSE) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, overwrite) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument_addChildDocument_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_OBJ_INFO(SOLR_ARG_PASS_BY_REF_TRUE, child, SolrInputDocument, SOLR_ARG_ALLOW_NULL_FALSE) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument_addChildDocuments_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_ARRAY_INFO(SOLR_ARG_PASS_BY_REF_TRUE, docs, SOLR_ARG_ALLOW_NULL_FALSE) ZEND_END_ARG_INFO() /* }}} */ /* {{{ SolrClient arguments */ ZEND_BEGIN_ARG_INFO_EX(SolrClient_constructor_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_ARRAY_INFO(SOLR_ARG_PASS_BY_REF_FALSE, clientOptions, SOLR_ARG_ALLOW_NULL_FALSE) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_query_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_OBJ_INFO(SOLR_ARG_PASS_BY_REF_TRUE, query, SolrParams, SOLR_ARG_ALLOW_NULL_FALSE) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_addDocument_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_OBJ_INFO(SOLR_ARG_PASS_BY_REF_TRUE, doc, SolrInputDocument, SOLR_ARG_ALLOW_NULL_FALSE) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, overwrite) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, commitWithin) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_addDocuments_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_ARRAY_INFO(SOLR_ARG_PASS_BY_REF_TRUE, docs, SOLR_ARG_ALLOW_NULL_FALSE) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, overwrite) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, commitWithin) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_request_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, raw_request) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_setResponseWriter_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, responseWriter) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_commit_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 0) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, softCommit) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, waitSearcher) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, expungeDeletes) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_optimize_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 0) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, maxSegments) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, softCommit) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, waitSearcher) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_rollback_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_deleteById_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, id) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_deleteByIds_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_ARRAY_INFO(SOLR_ARG_PASS_BY_REF_FALSE, ids, SOLR_ARG_ALLOW_NULL_FALSE) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_deleteByQuery_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, query) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_deleteByQueries_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_ARRAY_INFO(SOLR_ARG_PASS_BY_REF_FALSE, queries, SOLR_ARG_ALLOW_NULL_FALSE) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_ping_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_threads_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_info_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_setServlet_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 2) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, type) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, value) ZEND_END_ARG_INFO() /* }}} */ /* {{{ SolrParams arguments */ ZEND_BEGIN_ARG_INFO_EX(SolrParams_setParam_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 2) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, name) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, value) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrParams_addParam_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 2) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, name) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, value) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrParams_toString_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 0) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, url_encode) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrParams_getParam_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, param_name) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO(SolrParams_unserialize_args, 0) ZEND_ARG_INFO(0, serialized) ZEND_END_ARG_INFO() /* }}} */ /* {{{ SolrQuery arguments */ ZEND_BEGIN_ARG_INFO_EX(SolrQuery_constructor_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 0) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, q) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_setQuery_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, q) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_setStart_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, start) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_setRows_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, rows) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_addField_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, field) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_addSortField_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, field) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, order) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_addFilterQuery_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fq) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_setShowDebugInfo_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, flag) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_setExplainOther_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, flag) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_setTimeAllowed_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, timeAllowed) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_setOmitHeader_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, flag) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_setEchoHandler_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, flag) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_setEchoParams_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, type) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_facet_get_1_0_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 0) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, field_override) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_facet_1_1_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, value) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_facet_2_1_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, value) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, field_override) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_group_1_1_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, value) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_hl_get_1_0_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 0) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, field_override) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_hl_1_1_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, value) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_hl_2_1_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, value) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, field_override) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_stats_1_1_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, value) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_mlt_1_1_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, value) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_mlt_2_2_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 2) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, field) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, boost) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_terms_1_1_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, value) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_setGroupCachePct_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, percent) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_collapse_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_OBJ_INFO(SOLR_ARG_PASS_BY_REF_TRUE, collapseFunction, SolrCollapseFunction, SOLR_ARG_ALLOW_NULL_FALSE) ZEND_END_ARG_INFO() /* }}} */ /* {{{ Solr Generic arguments */ ZEND_BEGIN_ARG_INFO_EX(Solr_no_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 0) ZEND_END_ARG_INFO() /* }}} */ /* {{{ */ ZEND_BEGIN_ARG_INFO_EX(SolrResponse_setParseMode_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 0) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, parser_mode) ZEND_END_ARG_INFO() /* }}} */ /* {{{ SolrUtils */ ZEND_BEGIN_ARG_INFO_EX(SolrUtils_escapeQueryChars_arg, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, str) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrUtils_digestXML_arg, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, xmlresponse) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, parse_mode) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrUtils_digestJson_arg, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, jsonResponse) ZEND_END_ARG_INFO() /* }}} */ ZEND_BEGIN_ARG_INFO_EX(SolrCollapseFunction_construct_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 0) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, field) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrCollapseFunction_set_size_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, size) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrCollapseFunction_set_hint_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, hint) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrCollapseFunction_set_max_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, max) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrCollapseFunction_set_min_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, min) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrCollapseFunction_set_field_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldName) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrCollapseFunction_set_null_policy_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, policy) ZEND_END_ARG_INFO() /* }}} */ /* {{{ solr_functions[] */ static zend_function_entry solr_functions[] = { PHP_FE(solr_get_version, Solr_no_args) PHP_FE_END }; /* }}} */ /* {{{ solr_object_methods */ static zend_function_entry solr_object_methods[] = { SOLR_CTOR(SolrObject, __construct, Solr_no_args) SOLR_DTOR(SolrObject, __destruct, Solr_no_args) /** Temporarily disconnected for now. May be brought back in the future. PHP_ME(SolrObject, __set, SolrObject__set_args, ZEND_ACC_PUBLIC) PHP_ME(SolrObject, __get, SolrObject__get_args, ZEND_ACC_PUBLIC) PHP_ME(SolrObject, __isset, SolrObject_one_args, ZEND_ACC_PUBLIC) PHP_ME(SolrObject, __unset, SolrObject_one_args, ZEND_ACC_PUBLIC) */ PHP_ME(SolrObject, offsetSet, SolrObject__set_args, ZEND_ACC_PUBLIC) PHP_ME(SolrObject, offsetGet, SolrObject__get_args, ZEND_ACC_PUBLIC) PHP_ME(SolrObject, offsetExists, SolrObject_one_args, ZEND_ACC_PUBLIC) PHP_ME(SolrObject, offsetUnset, SolrObject_one_args, ZEND_ACC_PUBLIC) PHP_ME(SolrObject, getPropertyNames, Solr_no_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_document_methods */ static zend_function_entry solr_document_field_methods[] = { SOLR_CTOR(SolrDocumentField, __construct, Solr_no_args) SOLR_DTOR(SolrDocumentField, __destruct, Solr_no_args) PHP_FE_END }; /* }}} */ /* {{{ solr_collapse_function_methods for the SolrCollapseFunction ce */ static zend_function_entry solr_collapse_function_methods[] = { SOLR_CTOR(SolrCollapseFunction, __construct, SolrCollapseFunction_construct_args) SOLR_DTOR(SolrCollapseFunction, __destruct, Solr_no_args) PHP_ME(SolrCollapseFunction, setField, SolrCollapseFunction_set_field_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, getField, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, setMax, SolrCollapseFunction_set_max_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, getMax, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, setMin, SolrCollapseFunction_set_min_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, getMin, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, setSize, SolrCollapseFunction_set_size_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, getSize, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, setHint, SolrCollapseFunction_set_hint_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, getHint, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, setNullPolicy, SolrCollapseFunction_set_null_policy_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, getNullPolicy, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, __toString, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, __sleep, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, __wakeup, Solr_no_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_document_methods */ static zend_function_entry solr_document_methods[] = { SOLR_CTOR(SolrDocument, __construct, SolrDocument__construct_args) SOLR_DTOR(SolrDocument, __destruct, Solr_no_args) PHP_ME(SolrDocument, __clone, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CLONE) PHP_ME(SolrDocument, __set, SolrDocument_addField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, __get, SolrDocument_getField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, __isset, SolrDocument_fieldExists_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, __unset, SolrDocument_deleteField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, offsetSet, SolrDocument_addField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, offsetGet, SolrDocument_getField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, offsetExists, SolrDocument_fieldExists_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, offsetUnset, SolrDocument_deleteField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, current, SolrDocument_current_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, key, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, next, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, rewind, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, valid, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, serialize, NULL, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, unserialize, SolrDocument_unserialize_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, clear, Solr_no_args, ZEND_ACC_PUBLIC) PHP_MALIAS(SolrDocument, reset, clear, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, addField, SolrDocument_addField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, getFieldNames, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, getFieldCount, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, getField, SolrDocument_getField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, toArray, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, fieldExists, SolrDocument_fieldExists_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, deleteField, SolrDocument_deleteField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, sort, SolrDocument_sort_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, merge, SolrDocument_merge_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, getInputDocument, SolrDocument_getInputDocument_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, getChildDocumentsCount, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, hasChildDocuments, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, getChildDocuments, Solr_no_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_input_document_methods */ static zend_function_entry solr_input_document_methods[] = { SOLR_CTOR(SolrInputDocument, __construct, SolrInputDocument__construct_args) SOLR_DTOR(SolrInputDocument, __destruct, Solr_no_args) PHP_ME(SolrInputDocument, __clone, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CLONE) PHP_ME(SolrInputDocument, __sleep, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, __wakeup, NULL, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, setBoost, SolrInputDocument_setBoost_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, getBoost, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, clear, Solr_no_args, ZEND_ACC_PUBLIC) PHP_MALIAS(SolrInputDocument, reset, clear, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, addField, SolrInputDocument_addField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, getFieldBoost, SolrInputDocument_getFieldBoost_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, setFieldBoost, SolrInputDocument_setFieldBoost_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, getFieldNames, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, getFieldCount, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, getField, SolrInputDocument_getField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, toArray, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, fieldExists, SolrInputDocument_fieldExists_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, deleteField, SolrInputDocument_deleteField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, sort, SolrInputDocument_sort_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, merge, SolrInputDocument_merge_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, addChildDocument, SolrInputDocument_addChildDocument_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, getChildDocuments, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, hasChildDocuments, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, getChildDocumentsCount, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, addChildDocuments, SolrInputDocument_addChildDocuments_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_client_methods */ static zend_function_entry solr_client_methods[] = { SOLR_CTOR(SolrClient, __construct, SolrClient_constructor_args) SOLR_DTOR(SolrClient, __destruct, Solr_no_args) PHP_ME(SolrClient, __sleep, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, __wakeup, NULL, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, __clone, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CLONE) PHP_ME(SolrClient, getOptions, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, getDebug, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, setServlet, SolrClient_setServlet_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, query, SolrClient_query_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, addDocument, SolrClient_addDocument_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, addDocuments, SolrClient_addDocuments_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, request, SolrClient_request_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, setResponseWriter, SolrClient_setResponseWriter_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, deleteById, SolrClient_deleteById_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, deleteByIds, SolrClient_deleteByIds_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, deleteByQuery, SolrClient_deleteByQuery_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, deleteByQueries, SolrClient_deleteByQueries_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, getById, SolrClient_deleteById_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, getByIds, SolrClient_deleteByIds_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, commit, SolrClient_commit_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, optimize, SolrClient_optimize_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, rollback, SolrClient_rollback_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, ping, SolrClient_ping_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, system, SolrClient_info_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, threads, SolrClient_threads_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_exception_methods. None. */ static zend_function_entry solr_exception_methods[] = { PHP_ME(SolrException, getInternalInfo, Solr_no_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_exception_methods. None. */ static zend_function_entry solr_client_exception_methods[] = { PHP_ME(SolrClientException, getInternalInfo, Solr_no_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_exception_methods. None. */ static zend_function_entry solr_server_exception_methods[] = { PHP_ME(SolrServerException, getInternalInfo, Solr_no_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_exception_methods. None. */ static zend_function_entry solr_illegal_operation_exception_methods[] = { PHP_ME(SolrIllegalOperationException, getInternalInfo, Solr_no_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_exception_methods. None. */ static zend_function_entry solr_illegal_argument_exception_methods[] = { PHP_ME(SolrIllegalArgumentException, getInternalInfo, Solr_no_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* PHP_MALIAS(SolrInputDocument, reset, clear, Solr_no_args, ZEND_ACC_PUBLIC) */ /* {{{ solr_params_methods. */ static zend_function_entry solr_params_methods[] = { PHP_ME(SolrParams, setParam, SolrParams_setParam_args, ZEND_ACC_PUBLIC) PHP_ME(SolrParams, addParam, SolrParams_addParam_args, ZEND_ACC_PUBLIC) PHP_ME(SolrParams, __toString, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrParams, toString, SolrParams_toString_args, ZEND_ACC_PUBLIC) PHP_ME(SolrParams, getParams, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrParams, getParam, SolrParams_getParam_args, ZEND_ACC_PUBLIC) PHP_ME(SolrParams, getPreparedParams, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrParams, __clone, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CLONE) PHP_ME(SolrParams, serialize, NULL, ZEND_ACC_PUBLIC) PHP_ME(SolrParams, unserialize, SolrParams_unserialize_args, ZEND_ACC_PUBLIC) PHP_MALIAS(SolrParams, add, addParam, SolrParams_addParam_args, ZEND_ACC_PUBLIC) PHP_MALIAS(SolrParams, set, setParam, SolrParams_setParam_args, ZEND_ACC_PUBLIC) PHP_MALIAS(SolrParams, get, getParam, SolrParams_getParam_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_modifiable_params_methods. */ static zend_function_entry solr_modifiable_params_methods[] = { SOLR_CTOR(SolrModifiableParams, __construct, Solr_no_args) SOLR_DTOR(SolrModifiableParams, __destruct, Solr_no_args) PHP_FE_END }; /* }}} */ /* {{{ solr_query_methods. */ static zend_function_entry solr_query_methods[] = { SOLR_CTOR(SolrQuery, __construct, SolrQuery_constructor_args) SOLR_DTOR(SolrQuery, __destruct, Solr_no_args) /* CommonQueryParameters */ PHP_ME(SolrQuery, setQuery, SolrQuery_setQuery_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getQuery, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setStart, SolrQuery_setStart_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getStart, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setRows, SolrQuery_setRows_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getRows, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addField, SolrQuery_addField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeField, SolrQuery_addField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFields, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addSortField, SolrQuery_addSortField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeSortField, SolrQuery_addField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getSortFields, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addFilterQuery, SolrQuery_addFilterQuery_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeFilterQuery, SolrQuery_addFilterQuery_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFilterQueries, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setShowDebugInfo, SolrQuery_setShowDebugInfo_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setExplainOther, SolrQuery_setExplainOther_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTimeAllowed, SolrQuery_setTimeAllowed_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTimeAllowed, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setOmitHeader, SolrQuery_setOmitHeader_args, ZEND_ACC_PUBLIC) /* CoreQueryParameters */ PHP_ME(SolrQuery, setEchoHandler, SolrQuery_setEchoHandler_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setEchoParams, SolrQuery_setEchoParams_args, ZEND_ACC_PUBLIC) /* SimpleFacetParameters */ PHP_ME(SolrQuery, setFacet, SolrQuery_facet_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacet, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addFacetField, SolrQuery_facet_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeFacetField, SolrQuery_facet_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetFields, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addFacetQuery, SolrQuery_facet_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeFacetQuery, SolrQuery_facet_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetQueries, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetPrefix, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetPrefix, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetSort, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetSort, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetLimit, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetLimit, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetOffset, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetOffset, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetMinCount, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetMinCount, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetMissing, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetMissing, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetMethod, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetMethod, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetEnumCacheMinDefaultFrequency, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) /* Date Faceting Parameters */ PHP_ME(SolrQuery, addFacetDateField, SolrQuery_facet_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeFacetDateField, SolrQuery_facet_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetDateFields, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetDateStart, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetDateStart, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetDateEnd, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetDateEnd, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetDateGap, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetDateGap, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetDateHardEnd, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetDateHardEnd, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addFacetDateOther, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeFacetDateOther, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetDateOther, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) /* SimpleGroupParameters */ PHP_ME(SolrQuery, setGroup, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroup, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addGroupField, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupFields, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addGroupFunction, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupFunctions, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addGroupQuery, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupQueries, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setGroupLimit, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupLimit, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setGroupOffset, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupOffset, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addGroupSortField, SolrQuery_addSortField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupSortFields, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setGroupFormat, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupFormat, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setGroupMain, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupMain, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setGroupNGroups, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupNGroups, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setGroupTruncate, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupTruncate, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setGroupFacet, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupFacet, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setGroupCachePercent, SolrQuery_setGroupCachePct_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupCachePercent, Solr_no_args, ZEND_ACC_PUBLIC) /* Collapse Function */ PHP_ME(SolrQuery, collapse, SolrQuery_collapse_args, ZEND_ACC_PUBLIC) /* Expand Componenet */ PHP_ME(SolrQuery, setExpand, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getExpand, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addExpandSortField, SolrQuery_addSortField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeExpandSortField, SolrQuery_addField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getExpandSortFields, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setExpandRows, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getExpandRows, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setExpandQuery, SolrQuery_setQuery_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getExpandQuery, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addExpandFilterQuery, SolrQuery_addFilterQuery_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeExpandFilterQuery, SolrQuery_addFilterQuery_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getExpandFilterQueries, Solr_no_args, ZEND_ACC_PUBLIC) /* HighlightingParameters */ PHP_ME(SolrQuery, setHighlight, SolrQuery_hl_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlight, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addHighlightField, SolrQuery_hl_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeHighlightField, SolrQuery_hl_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightFields, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightSnippets, SolrQuery_hl_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightSnippets, SolrQuery_hl_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightFragsize, SolrQuery_hl_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightFragsize, SolrQuery_hl_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightMergeContiguous, SolrQuery_hl_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightMergeContiguous, SolrQuery_hl_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightRequireFieldMatch, SolrQuery_hl_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightRequireFieldMatch, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightMaxAnalyzedChars, SolrQuery_hl_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightMaxAnalyzedChars, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightAlternateField, SolrQuery_hl_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightAlternateField, SolrQuery_hl_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightMaxAlternateFieldLength, SolrQuery_hl_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightMaxAlternateFieldLength, SolrQuery_hl_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightFormatter, SolrQuery_hl_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightFormatter, SolrQuery_hl_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightSimplePre, SolrQuery_hl_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightSimplePre, SolrQuery_hl_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightSimplePost, SolrQuery_hl_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightSimplePost, SolrQuery_hl_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightFragmenter, SolrQuery_hl_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightFragmenter, SolrQuery_hl_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightUsePhraseHighlighter, SolrQuery_hl_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightUsePhraseHighlighter, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightHighlightMultiTerm, SolrQuery_hl_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightHighlightMultiTerm, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightRegexSlop, SolrQuery_hl_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightRegexSlop, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightRegexPattern, SolrQuery_hl_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightRegexPattern, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightRegexMaxAnalyzedChars, SolrQuery_hl_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightRegexMaxAnalyzedChars, Solr_no_args, ZEND_ACC_PUBLIC) /* StatsComponent */ PHP_ME(SolrQuery, setStats, SolrQuery_stats_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getStats, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addStatsField, SolrQuery_stats_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeStatsField, SolrQuery_stats_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getStatsFields, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addStatsFacet, SolrQuery_stats_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeStatsFacet, SolrQuery_stats_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getStatsFacets, Solr_no_args, ZEND_ACC_PUBLIC) /* MoreLikeThis */ PHP_ME(SolrQuery, setMlt, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getMlt, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setMltCount, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getMltCount, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addMltField, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeMltField, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getMltFields, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addMltQueryField, SolrQuery_mlt_2_2_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeMltQueryField, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getMltQueryFields, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setMltMinTermFrequency, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getMltMinTermFrequency, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setMltMinDocFrequency, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getMltMinDocFrequency, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setMltMinWordLength, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getMltMinWordLength, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setMltMaxWordLength, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getMltMaxWordLength, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setMltMaxNumTokens, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getMltMaxNumTokens, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setMltMaxNumQueryTerms, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getMltMaxNumQueryTerms, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setMltBoost, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getMltBoost, Solr_no_args, ZEND_ACC_PUBLIC) /* TermsComponent */ PHP_ME(SolrQuery, setTerms, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTerms, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTermsField, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTermsField, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTermsLowerBound, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTermsLowerBound, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTermsUpperBound, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTermsUpperBound, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTermsIncludeLowerBound, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTermsIncludeLowerBound, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTermsIncludeUpperBound, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTermsIncludeUpperBound, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTermsMinCount, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTermsMinCount, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTermsMaxCount, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTermsMaxCount, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTermsPrefix, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTermsPrefix, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTermsLimit, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTermsLimit, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTermsReturnRaw, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTermsReturnRaw, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTermsSort, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTermsSort, Solr_no_args, ZEND_ACC_PUBLIC) /* TODO : TermVectorComponent */ PHP_FE_END }; /* }}} */ /* {{{ solr_response_methods. */ static zend_function_entry solr_response_methods[] = { PHP_ME(SolrResponse, getHttpStatus, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrResponse, getHttpStatusMessage, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrResponse, success, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrResponse, getRequestUrl, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrResponse, getRawRequestHeaders, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrResponse, getRawRequest, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrResponse, getRawResponseHeaders, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrResponse, getRawResponse, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrResponse, getDigestedResponse, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrResponse, setParseMode, SolrResponse_setParseMode_args, ZEND_ACC_PUBLIC) PHP_ME(SolrResponse, getResponse, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrResponse, getArrayResponse, Solr_no_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_query_response_methods. */ static zend_function_entry solr_query_response_methods[] = { SOLR_CTOR(SolrQueryResponse, __construct, Solr_no_args) SOLR_DTOR(SolrQueryResponse, __destruct, Solr_no_args) PHP_FE_END }; /* }}} */ /* {{{ solr_update_response_methods. */ static zend_function_entry solr_update_response_methods[] = { SOLR_CTOR(SolrUpdateResponse, __construct, Solr_no_args) SOLR_DTOR(SolrUpdateResponse, __destruct, Solr_no_args) PHP_FE_END }; /* }}} */ /* {{{ solr_ping_response_methods. */ static zend_function_entry solr_ping_response_methods[] = { SOLR_CTOR(SolrPingResponse, __construct, Solr_no_args) SOLR_DTOR(SolrPingResponse, __destruct, Solr_no_args) PHP_ME(SolrPingResponse, getResponse, Solr_no_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_generic_response_methods. */ static zend_function_entry solr_generic_response_methods[] = { SOLR_CTOR(SolrGenericResponse, __construct, Solr_no_args) SOLR_DTOR(SolrGenericResponse, __destruct, Solr_no_args) PHP_FE_END }; /* }}} */ /* {{{ solr_utils_methods. */ static zend_function_entry solr_utils_methods[] = { PHP_ME(SolrUtils, escapeQueryChars, SolrUtils_escapeQueryChars_arg, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_ME(SolrUtils, queryPhrase, SolrUtils_escapeQueryChars_arg, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_ME(SolrUtils, digestXmlResponse, SolrUtils_digestXML_arg, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_ME(SolrUtils, digestJsonResponse, SolrUtils_digestJson_arg, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_ME(SolrUtils, getSolrVersion, Solr_no_args, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_ME(SolrUtils, getSolrStats, Solr_no_args, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_FE_END }; /* }}} */ /* {{{ solr_module_deps */ static zend_module_dep solr_module_deps[] = { ZEND_MOD_REQUIRED(PHP_LIBXML_EXTENSION_NAME) ZEND_MOD_REQUIRED(PHP_JSON_EXTENSION_NAME) ZEND_MOD_END }; /* }}} */ /* {{{ solr_module_entry */ zend_module_entry solr_module_entry = { STANDARD_MODULE_HEADER_EX, NULL, solr_module_deps, PHP_SOLR_EXTENSION_NAME, solr_functions, PHP_MINIT(solr), PHP_MSHUTDOWN(solr), PHP_RINIT(solr), PHP_RSHUTDOWN(solr), PHP_MINFO(solr), PHP_SOLR_DOTTED_VERSION, /* The current extension version number. */ STANDARD_MODULE_PROPERTIES }; /* }}} */ #ifdef COMPILE_DL_SOLR ZEND_GET_MODULE(solr) #endif /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(solr) { #ifdef ZTS /* As of ZE 2.2.0, this has to be NULL. */ /* It causes a segmentation fault, if it points to an actual function */ /* Probably a bug in the Zend Engine API */ ts_allocate_dtor php_solr_globals_dtor = NULL; #endif zend_class_entry ce; memcpy(&solr_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); memcpy(&solr_document_field_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); memcpy(&solr_input_document_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); memcpy(&solr_client_object_handlers, &solr_input_document_object_handlers, sizeof(zend_object_handlers)); memcpy(&solr_collapse_function_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); solr_collapse_function_object_handlers.clone_obj = solr_collapse_function_handlers_clone_object; /* solr_object_handlers.read_property = solr_object_read_property; */ solr_object_handlers.write_property = solr_object_write_property; solr_object_handlers.write_dimension = solr_object_write_dimension; solr_object_handlers.unset_property = solr_object_unset_property; solr_object_handlers.unset_dimension = solr_object_unset_dimension; solr_document_field_handlers.write_property = solr_document_field_write_property; solr_document_field_handlers.unset_property = solr_document_field_unset_property; #ifdef ZTS ZEND_INIT_MODULE_GLOBALS(solr, php_solr_globals_ctor, php_solr_globals_dtor); #else php_solr_globals_ctor(&solr_globals TSRMLS_CC); #endif /* Register extension constants */ solr_extension_register_constants(type, module_number TSRMLS_CC); /* Register the SolrObject class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_OBJECT_CLASSNAME, solr_object_methods); solr_ce_SolrObject = zend_register_internal_class(&ce TSRMLS_CC); solr_ce_SolrObject->ce_flags |= ZEND_ACC_FINAL_CLASS; /* SolrObject implements ArrayAccess */ zend_class_implements(solr_ce_SolrObject TSRMLS_CC, 1, solr_ce_ArrayAccess); /* Register the SolrDocument class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_DOCUMENT_CLASSNAME, solr_document_methods); solr_ce_SolrDocument = zend_register_internal_class(&ce TSRMLS_CC); solr_ce_SolrDocument->ce_flags |= ZEND_ACC_FINAL_CLASS; /* This internal property will be used to map to this SolrDocument instance */ zend_declare_property_long(solr_ce_SolrDocument, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) -1, 0L, ZEND_ACC_PRIVATE TSRMLS_CC); /* Register SolrDocument class constants */ solr_document_register_class_constants(solr_ce_SolrDocument TSRMLS_CC); /* SolrDocument implements ArrayAccess, Iterator, Serializable */ zend_class_implements(solr_ce_SolrDocument TSRMLS_CC, 3, solr_ce_ArrayAccess, solr_ce_Iterator, solr_ce_Serializable); /* Register the SolrDocumentField class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_DOCUMENT_FIELD_CLASSNAME, solr_document_field_methods); solr_ce_SolrDocumentField = zend_register_internal_class(&ce TSRMLS_CC); solr_ce_SolrDocumentField->ce_flags |= ZEND_ACC_FINAL_CLASS; /* Register the name, boost and values properties */ zend_declare_property_stringl(solr_ce_SolrDocumentField, SOLR_FIELD_NAME_PROPERTY_NAME, sizeof(SOLR_FIELD_NAME_PROPERTY_NAME)-1, SOLR_SPACE_STRING, sizeof(SOLR_SPACE_STRING)-1, ZEND_ACC_PUBLIC TSRMLS_CC); zend_declare_property_double(solr_ce_SolrDocumentField, SOLR_FIELD_BOOST_PROPERTY_NAME, sizeof(SOLR_FIELD_BOOST_PROPERTY_NAME)-1, 0.0f, ZEND_ACC_PUBLIC TSRMLS_CC); zend_declare_property_null(solr_ce_SolrDocumentField, SOLR_FIELD_VALUES_PROPERTY_NAME, sizeof(SOLR_FIELD_VALUES_PROPERTY_NAME)-1, ZEND_ACC_PUBLIC TSRMLS_CC); /* Register the SolrInputDocument class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_INPUT_DOCUMENT_CLASSNAME, solr_input_document_methods); solr_ce_SolrInputDocument = zend_register_internal_class(&ce TSRMLS_CC); solr_ce_SolrInputDocument->ce_flags |= ZEND_ACC_FINAL_CLASS; /* This internal property will be used to map to this SolrDocument instance */ zend_declare_property_long(solr_ce_SolrInputDocument, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) -1, 0L, ZEND_ACC_PRIVATE TSRMLS_CC); /* Register SolrInputDocument class constants */ solr_document_register_class_constants(solr_ce_SolrInputDocument TSRMLS_CC); /* Register SolrClient Class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_CLIENT_CLASSNAME, solr_client_methods); solr_ce_SolrClient = zend_register_internal_class(&ce TSRMLS_CC); /* solr_ce_SolrClient->ce_flags |= ZEND_ACC_FINAL_CLASS; */ /* This internal property will be used to map to this SolrClient instance */ zend_declare_property_long(solr_ce_SolrClient, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) -1, 0L, ZEND_ACC_PRIVATE TSRMLS_CC); /* Register SolrClient class constants */ solr_client_register_class_constants(solr_ce_SolrClient TSRMLS_CC); /* Register the SolrParams class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_PARAMS_CLASSNAME, solr_params_methods); solr_ce_SolrParams = zend_register_internal_class(&ce TSRMLS_CC); solr_ce_SolrParams->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; zend_class_implements(solr_ce_SolrParams TSRMLS_CC, 1, solr_ce_Serializable); /* This internal property will be used to map to this SolrParams instance */ zend_declare_property_long(solr_ce_SolrParams, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) -1, 0L, ZEND_ACC_PROTECTED TSRMLS_CC); /* Register the SolrModifiableParams class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_MODIFIABLE_PARAMS_CLASSNAME, solr_modifiable_params_methods); solr_ce_SolrModifiableParams = zend_register_internal_class_ex(&ce, solr_ce_SolrParams, NULL TSRMLS_CC); /* Register the SolrQuery class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_QUERY_CLASSNAME, solr_query_methods); solr_ce_SolrQuery = zend_register_internal_class_ex(&ce, solr_ce_SolrModifiableParams, NULL TSRMLS_CC); init_solr_dismax_query(TSRMLS_C); solr_query_register_class_constants(solr_ce_SolrQuery TSRMLS_CC); /* Register the SolrCollapseFunction class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_COLLAPSE_FUNCTION_CLASSNAME, solr_collapse_function_methods); solr_ce_SolrCollapseFunction = zend_register_internal_class_ex(&ce, solr_ce_SolrCollapseFunction, NULL TSRMLS_CC); zend_declare_property_long(solr_ce_SolrCollapseFunction, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME)-1, 0l, ZEND_ACC_PROTECTED TSRMLS_CC); solr_collapse_function_register_class_constants(solr_ce_SolrCollapseFunction TSRMLS_CC); /* Register the SolrResponse base class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_RESPONSE_CLASSNAME, solr_response_methods); solr_ce_SolrResponse = zend_register_internal_class(&ce TSRMLS_CC); solr_ce_SolrResponse->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; /* Register all the properties for the SolrResponse object */ solr_response_register_class_properties(solr_ce_SolrResponse TSRMLS_CC); /* Register all the constants for the SolrResponse object */ solr_response_register_class_constants(solr_ce_SolrResponse TSRMLS_CC); /* Register the SolrQueryResponse class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_QUERY_RESPONSE_CLASSNAME, solr_query_response_methods); solr_ce_SolrQueryResponse = zend_register_internal_class_ex(&ce, solr_ce_SolrResponse, NULL TSRMLS_CC); solr_ce_SolrQueryResponse->ce_flags |= ZEND_ACC_FINAL_CLASS; /* Register the SolrUpdateResponse class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_UPDATE_RESPONSE_CLASSNAME, solr_update_response_methods); solr_ce_SolrUpdateResponse = zend_register_internal_class_ex(&ce, solr_ce_SolrResponse, NULL TSRMLS_CC); solr_ce_SolrUpdateResponse->ce_flags |= ZEND_ACC_FINAL_CLASS; /* Register the SolrPingResponse class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_PING_RESPONSE_CLASSNAME, solr_ping_response_methods); solr_ce_SolrPingResponse = zend_register_internal_class_ex(&ce, solr_ce_SolrResponse, NULL TSRMLS_CC); solr_ce_SolrPingResponse->ce_flags |= ZEND_ACC_FINAL_CLASS; /* Register the SolrGenericResponse class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_GENERIC_RESPONSE_CLASSNAME, solr_generic_response_methods); solr_ce_SolrGenericResponse = zend_register_internal_class_ex(&ce, solr_ce_SolrResponse, NULL TSRMLS_CC); solr_ce_SolrGenericResponse->ce_flags |= ZEND_ACC_FINAL_CLASS; /* Register the SolrUtils class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_UTILS_CLASSNAME, solr_utils_methods); solr_ce_SolrUtils = zend_register_internal_class(&ce TSRMLS_CC); solr_ce_SolrUtils->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; /* Register the SolrException class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_EXCEPTION_CLASSNAME, solr_exception_methods); solr_ce_SolrException = zend_register_internal_class_ex(&ce, solr_ce_Exception, NULL TSRMLS_CC); solr_exception_register_class_properties(solr_ce_SolrException TSRMLS_CC); INIT_CLASS_ENTRY(ce, PHP_SOLR_ILLEGAL_OPERATION_EXCEPTION_CLASSNAME, solr_illegal_operation_exception_methods); solr_ce_SolrIllegalOperationException = zend_register_internal_class_ex(&ce, solr_ce_SolrException, NULL TSRMLS_CC); INIT_CLASS_ENTRY(ce, PHP_SOLR_ILLEGAL_ARGUMENT_EXCEPTION_CLASSNAME, solr_illegal_argument_exception_methods); solr_ce_SolrIllegalArgumentException = zend_register_internal_class_ex(&ce, solr_ce_SolrException, NULL TSRMLS_CC); INIT_CLASS_ENTRY(ce, PHP_SOLR_CLIENT_EXCEPTION_CLASSNAME, solr_client_exception_methods); solr_ce_SolrClientException = zend_register_internal_class_ex(&ce, solr_ce_SolrException, NULL TSRMLS_CC); INIT_CLASS_ENTRY(ce, PHP_SOLR_SERVER_EXCEPTION_CLASSNAME, solr_server_exception_methods); solr_ce_SolrServerException = zend_register_internal_class_ex(&ce, solr_ce_SolrException, NULL TSRMLS_CC); INIT_CLASS_ENTRY(ce, PHP_SOLR_MISSING_MANDATORY_PARAMETER_EXCEPTION_CLASSNAME, NULL); solr_ce_SolrMissingMandatoryParameterException = zend_register_internal_class_ex(&ce, solr_ce_SolrException, NULL TSRMLS_CC); return SUCCESS; } /* }}} */ /* {{{ PHP_RINIT_FUNCTION */ PHP_RINIT_FUNCTION(solr) { zend_bool persistent = SOLR_HASHTABLE_PERSISTENT; /* Initial size of the HashTable */ uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE; ALLOC_HASHTABLE(SOLR_GLOBAL(documents)); ALLOC_HASHTABLE(SOLR_GLOBAL(clients)); ALLOC_HASHTABLE(SOLR_GLOBAL(params)); ALLOC_HASHTABLE(SOLR_GLOBAL(functions)); /* Initialize the HashTable for directory for SolrInputDocuments */ if (zend_hash_init(SOLR_GLOBAL(documents), nSize, NULL, solr_destroy_document, persistent) == FAILURE) { FREE_HASHTABLE(SOLR_GLOBAL(documents)); FREE_HASHTABLE(SOLR_GLOBAL(clients)); FREE_HASHTABLE(SOLR_GLOBAL(params)); FREE_HASHTABLE(SOLR_GLOBAL(functions)); php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to initialize hash table for documentsDirectory"); return FAILURE; } /* Initialize the HashTable for directory of SolrClients */ if (zend_hash_init(SOLR_GLOBAL(clients), nSize, NULL, solr_destroy_client, persistent) == FAILURE) { FREE_HASHTABLE(SOLR_GLOBAL(documents)); FREE_HASHTABLE(SOLR_GLOBAL(clients)); FREE_HASHTABLE(SOLR_GLOBAL(params)); FREE_HASHTABLE(SOLR_GLOBAL(functions)); php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to initialize hash table for clientsDirectory"); return FAILURE; } /* Initialize the HashTable for directory of SolrParams */ if (zend_hash_init(SOLR_GLOBAL(params), nSize, NULL, solr_destroy_params, persistent) == FAILURE) { FREE_HASHTABLE(SOLR_GLOBAL(documents)); FREE_HASHTABLE(SOLR_GLOBAL(clients)); FREE_HASHTABLE(SOLR_GLOBAL(params)); FREE_HASHTABLE(SOLR_GLOBAL(functions)); php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to initialize hash table for SolrParams"); return FAILURE; } /* Initialize the HashTable for directory of Functions */ if (zend_hash_init(SOLR_GLOBAL(functions), nSize, NULL, solr_destroy_function, persistent) == FAILURE) { FREE_HASHTABLE(SOLR_GLOBAL(documents)); FREE_HASHTABLE(SOLR_GLOBAL(clients)); FREE_HASHTABLE(SOLR_GLOBAL(params)); FREE_HASHTABLE(SOLR_GLOBAL(functions)); php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to initialize hash table for SolrFunction"); return FAILURE; } return SUCCESS; } /* }}} */ /* {{{ PHP_RSHUTDOWN_FUNCTION */ PHP_RSHUTDOWN_FUNCTION(solr) { zend_hash_destroy(SOLR_GLOBAL(documents)); zend_hash_destroy(SOLR_GLOBAL(clients)); zend_hash_destroy(SOLR_GLOBAL(params)); zend_hash_destroy(SOLR_GLOBAL(functions)); FREE_HASHTABLE(SOLR_GLOBAL(documents)); FREE_HASHTABLE(SOLR_GLOBAL(clients)); FREE_HASHTABLE(SOLR_GLOBAL(params)); FREE_HASHTABLE(SOLR_GLOBAL(functions)); return SUCCESS; } /* }}} */ /* {{{ PHP_MSHUTDOWN_FUNCTION */ PHP_MSHUTDOWN_FUNCTION(solr) { return SUCCESS; } /* }}} */ /* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(solr) { php_info_print_table_start(); php_info_print_table_header(2, "Solr Support", "enabled"); php_info_print_table_row(2, "Version", PHP_SOLR_DOTTED_VERSION); php_info_print_table_row(2, "Last Build Date", __DATE__); php_info_print_table_row(2, "Last Build Time", __TIME__); php_info_print_table_end(); } /* }}} */ #endif /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/php_solr_client.c0000644000175000017500000017353112676753706016202 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* {{{ Macros */ /* {{{ static void solr_client_init_urls(solr_client_t *solr_client) */ static void solr_client_init_urls(solr_client_t *solr_client) { solr_string_t url_prefix; solr_client_options_t *options = &(solr_client->options); memset(&url_prefix, 0, sizeof(solr_string_t)); /* Release all previously allocated URL values, if any */ solr_string_free(&(options->update_url)); solr_string_free(&(options->search_url)); solr_string_free(&(options->thread_url)); solr_string_free(&(options->ping_url)); solr_string_free(&(options->terms_url)); solr_string_free(&(options->system_url)); solr_string_free(&(options->get_url)); /* Making http://hostname:host_port/path/ */ if (options->secure) { solr_string_append_const(&url_prefix, "https://"); } else { solr_string_append_const(&url_prefix, "http://"); } solr_string_append_solr_string(&url_prefix, &(options->hostname)); solr_string_appendc(&url_prefix, ':'); solr_string_append_long(&url_prefix, options->host_port); solr_string_appendc(&url_prefix, '/'); solr_string_append_solr_string(&url_prefix, &(options->path)); solr_string_appendc(&url_prefix, '/'); /* Copying over the prefixes */ solr_string_append_solr_string(&(options->update_url), &url_prefix); solr_string_append_solr_string(&(options->search_url), &url_prefix); solr_string_append_solr_string(&(options->thread_url), &url_prefix); solr_string_append_solr_string(&(options->ping_url), &url_prefix); solr_string_append_solr_string(&(options->terms_url), &url_prefix); solr_string_append_solr_string(&(options->system_url), &url_prefix); solr_string_append_solr_string(&(options->get_url), &url_prefix); /* Making http://hostname:host_port/path/servlet/ */ solr_string_append_solr_string(&(options->update_url), &(options->update_servlet)); solr_string_append_solr_string(&(options->search_url), &(options->search_servlet)); solr_string_append_solr_string(&(options->thread_url), &(options->thread_servlet)); solr_string_append_solr_string(&(options->ping_url), &(options->ping_servlet)); solr_string_append_solr_string(&(options->terms_url), &(options->terms_servlet)); solr_string_append_solr_string(&(options->system_url), &(options->system_servlet)); solr_string_append_solr_string(&(options->get_url), &(options->get_servlet)); solr_string_append_const(&(options->update_url), "/?version=2.2&indent=on&wt="); solr_string_append_const(&(options->search_url), "/?version=2.2&indent=on&wt="); solr_string_append_const(&(options->thread_url), "/?version=2.2&indent=on&wt="); solr_string_append_const(&(options->ping_url), "/?version=2.2&indent=on&wt="); solr_string_append_const(&(options->terms_url), "/?version=2.2&indent=on&wt="); solr_string_append_const(&(options->system_url), "/?version=2.2&indent=on&wt="); solr_string_append_const(&(options->get_url), "/?version=2.2&indent=on&wt="); solr_string_append_solr_string(&(options->update_url), &(options->response_writer)); solr_string_append_solr_string(&(options->search_url), &(options->response_writer)); solr_string_append_solr_string(&(options->thread_url), &(options->response_writer)); solr_string_append_solr_string(&(options->ping_url), &(options->response_writer)); solr_string_append_solr_string(&(options->terms_url), &(options->response_writer)); solr_string_append_solr_string(&(options->system_url), &(options->response_writer)); solr_string_append_solr_string(&(options->get_url), &(options->response_writer)); solr_string_free(&url_prefix); } /* }}} */ /* {{{ static int solr_http_build_query(solr_string_t *buffer, zval *params_objptr, const solr_char_t *delimiter, int delimiter_length TSRMLS_DC) */ static int solr_http_build_query(solr_string_t *buffer, zval *params_objptr, const solr_char_t *delimiter, int delimiter_length TSRMLS_DC) { solr_params_t *solr_params = NULL; register zend_bool duplicate = 0; HashTable *params = NULL; if (solr_fetch_params_entry(params_objptr, &solr_params TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve solr_params_t"); return FAILURE; } params = solr_params->params; SOLR_HASHTABLE_FOR_LOOP(params) { solr_param_t **solr_param_ptr = NULL; solr_param_t *solr_param = NULL; solr_string_t tmp_values_buffer; char *str_index = NULL; uint str_length = 0U; ulong num_index = 0L; zend_hash_get_current_key_ex(params, &str_index, &str_length, &num_index, duplicate, ((HashPosition *)0)); zend_hash_get_current_data_ex(params, (void **) &solr_param_ptr, ((HashPosition *)0)); memset(&tmp_values_buffer, 0, sizeof(solr_string_t)); solr_param = (*solr_param_ptr); solr_param->fetch_func(solr_param, &tmp_values_buffer); solr_string_append_solr_string(buffer, &tmp_values_buffer); solr_string_appends(buffer, delimiter, delimiter_length); solr_string_free(&tmp_values_buffer); } /* SOLR_HASHTABLE_FOR_LOOP(params) */ solr_string_remove_last_char(buffer); return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API solr_client_t* solr_init_client(zval * objptr TSRMLS_DC) inititialize solr_client_t and update zval's index */ PHP_SOLR_API solr_client_t *solr_init_client(zval *objptr TSRMLS_DC) { long int client_index = SOLR_UNIQUE_CLIENT_INDEX(); solr_client_t solr_client, *solr_client_dest; zend_update_property_long(solr_ce_SolrClient, objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, client_index TSRMLS_CC); memset(&solr_client, 0, sizeof(solr_client_t)); solr_client.client_index = client_index; if (zend_hash_index_update(SOLR_GLOBAL(clients), client_index, (void *)&solr_client, sizeof(solr_client_t), (void **)&solr_client_dest) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error while registering client in HashTable"); return NULL; } return solr_client_dest; } /* }}} */ /******************************************************************************/ /** DEFINITIONS FOR SOLR CLIENT METHODS **/ /******************************************************************************/ /* {{{ proto SolrClient::__construct(array options ) Constructor for SolrClient */ PHP_METHOD(SolrClient, __construct) { zval *options = NULL; HashTable *options_ht = NULL; zval **tmp1 = NULL, **tmp2 = NULL; solr_client_t *solr_client_dest = NULL; solr_client_options_t *client_options = NULL; solr_curl_t *handle = NULL; size_t num_options = 0; long int secure = 0L; long int verify_peer = 0L; long int verify_host = 2L; long int timeout = 30L; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &options) == FAILURE) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter. The client options array is required for a SolrClient instance. It must also be passed as the only parameter"); return; } options_ht = Z_ARRVAL_P(options); num_options = zend_hash_num_elements(options_ht); if (!num_options) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "The SolrClient options cannot be an empty array"); return; } solr_client_dest = solr_init_client(getThis() TSRMLS_CC); client_options = &(solr_client_dest->options); handle = &(solr_client_dest->handle); solr_init_options(client_options TSRMLS_CC); solr_string_append_const(&(client_options->response_writer), SOLR_XML_RESPONSE_WRITER); solr_string_append_const(&(client_options->update_servlet), SOLR_DEFAULT_UPDATE_SERVLET); solr_string_append_const(&(client_options->search_servlet), SOLR_DEFAULT_SEARCH_SERVLET); solr_string_append_const(&(client_options->thread_servlet), SOLR_DEFAULT_THREADS_SERVLET); solr_string_append_const(&(client_options->ping_servlet), SOLR_DEFAULT_PING_SERVLET); solr_string_append_const(&(client_options->terms_servlet), SOLR_DEFAULT_TERMS_SERVLET); solr_string_append_const(&(client_options->system_servlet), SOLR_DEFAULT_SYSTEM_SERVLET); solr_string_append_const(&(client_options->get_servlet), SOLR_DEFAULT_GET_SERVLET); if (zend_hash_find(options_ht, "wt", sizeof("wt"), (void**) &tmp1) == SUCCESS && Z_TYPE_PP(tmp1) == IS_STRING && Z_STRLEN_PP(tmp1)) { if (solr_is_supported_response_writer((solr_char_t *) Z_STRVAL_PP(tmp1), Z_STRLEN_PP(tmp1))) { solr_string_set(&(client_options->response_writer), (const solr_char_t *) Z_STRVAL_PP(tmp1), Z_STRLEN_PP(tmp1)); } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported response writer %s. This value will be ignored", Z_STRVAL_PP(tmp1)); } } if (zend_hash_find(options_ht, "secure", sizeof("secure"), (void**) &tmp1) == SUCCESS) { if (Z_TYPE_PP(tmp1) == IS_BOOL) { secure = (long int) Z_BVAL_PP(tmp1); } else if (Z_TYPE_PP(tmp1) == IS_LONG) { secure = Z_LVAL_PP(tmp1); } } client_options->secure = secure; /** * FOR NOW LET'S LEAVE IT AT 2 : This will force and require a match on the common name * if (secure && zend_hash_find(options_ht, "ssl_verifyhost", sizeof("ssl_verifyhost"), (void**) &tmp1) == SUCCESS && Z_TYPE_PP(tmp1) == IS_LONG) { verify_host = ((Z_LVAL_PP(tmp1) > 0L && Z_LVAL_PP(tmp1) < 3L) ? Z_LVAL_PP(tmp1) : verify_host); } */ client_options->ssl_verify_host = verify_host; if (secure && zend_hash_find(options_ht, "ssl_cert", sizeof("ssl_cert"), (void**) &tmp1) == SUCCESS && Z_TYPE_PP(tmp1) == IS_STRING && Z_STRLEN_PP(tmp1)) { verify_peer = 1L; solr_string_appends(&(client_options->ssl_cert), (solr_char_t *) Z_STRVAL_PP(tmp1), Z_STRLEN_PP(tmp1)); } if (secure && zend_hash_find(options_ht, "ssl_key", sizeof("ssl_key"), (void**) &tmp1) == SUCCESS && Z_TYPE_PP(tmp1) == IS_STRING && Z_STRLEN_PP(tmp1)) { verify_peer = 1L; solr_string_appends(&(client_options->ssl_key), (solr_char_t *) Z_STRVAL_PP(tmp1), Z_STRLEN_PP(tmp1)); } if (secure && zend_hash_find(options_ht, "ssl_keypassword", sizeof("ssl_keypassword"), (void**) &tmp1) == SUCCESS && Z_TYPE_PP(tmp1) == IS_STRING && Z_STRLEN_PP(tmp1)) { verify_peer = 1L; solr_string_appends(&(client_options->ssl_keypassword), (solr_char_t *) Z_STRVAL_PP(tmp1), Z_STRLEN_PP(tmp1)); } if (secure && zend_hash_find(options_ht, "ssl_cainfo", sizeof("ssl_cainfo"), (void**) &tmp1) == SUCCESS && Z_TYPE_PP(tmp1) == IS_STRING && Z_STRLEN_PP(tmp1)) { verify_peer = 1L; solr_string_appends(&(client_options->ssl_cainfo), (solr_char_t *) Z_STRVAL_PP(tmp1), Z_STRLEN_PP(tmp1)); } if (secure && zend_hash_find(options_ht, "ssl_capath", sizeof("ssl_capath"), (void**) &tmp1) == SUCCESS && Z_TYPE_PP(tmp1) == IS_STRING && Z_STRLEN_PP(tmp1)) { verify_peer = 1L; solr_string_appends(&(client_options->ssl_capath), (solr_char_t *) Z_STRVAL_PP(tmp1), Z_STRLEN_PP(tmp1)); } client_options->ssl_verify_peer = verify_peer; if (zend_hash_find(options_ht, "hostname", sizeof("hostname"), (void**) &tmp1) == SUCCESS && Z_TYPE_PP(tmp1) == IS_STRING && Z_STRLEN_PP(tmp1)) { solr_string_appends(&(client_options->hostname), (solr_char_t *) Z_STRVAL_PP(tmp1), Z_STRLEN_PP(tmp1)); } else { solr_string_append_const(&(client_options->hostname), SOLR_REQUEST_DEFAULT_HOST); } if (zend_hash_find(options_ht, "port", sizeof("port"), (void**) &tmp1) == SUCCESS && Z_TYPE_PP(tmp1) == IS_LONG) { client_options->host_port = Z_LVAL_PP(tmp1); } else if (zend_hash_find(options_ht, "port", sizeof("port"), (void**) &tmp1) == SUCCESS && Z_TYPE_PP(tmp1) == IS_STRING && Z_STRLEN_PP(tmp1)) { long int host_port = atol(Z_STRVAL_PP(tmp1)); if (host_port) { client_options->host_port = host_port; } else { client_options->host_port = SOLR_REQUEST_DEFAULT_PORT; } } else { client_options->host_port = SOLR_REQUEST_DEFAULT_PORT; } if (zend_hash_find(options_ht, "timeout", sizeof("timeout"), (void**) &tmp1) == SUCCESS) { long int timeout_value = 30L; if (Z_TYPE_PP(tmp1) == IS_LONG) { timeout_value = Z_LVAL_PP(tmp1); } else if (Z_TYPE_PP(tmp1) == IS_STRING && Z_STRLEN_PP(tmp1)) { timeout_value = atol(Z_STRVAL_PP(tmp1)); } timeout = ((timeout_value > 0L) ? timeout_value : timeout); } client_options->timeout = timeout; if (zend_hash_find(options_ht, "path", sizeof("path"), (void**) &tmp1) == SUCCESS && Z_TYPE_PP(tmp1) == IS_STRING && Z_STRLEN_PP(tmp1)) { char *path_to_solr = Z_STRVAL_PP(tmp1); size_t path_to_solr_start = 0; size_t length_adjustment = 0; if (path_to_solr[0] == '/') { path_to_solr_start = length_adjustment = 1; } if (path_to_solr[Z_STRLEN_PP(tmp1)] == '/') { length_adjustment++; } solr_string_appends(&(client_options->path), Z_STRVAL_PP(tmp1) + path_to_solr_start, Z_STRLEN_PP(tmp1) - length_adjustment); } else { solr_string_append_const(&(client_options->path), SOLR_REQUEST_DEFAULT_PATH); } if (zend_hash_find(options_ht, "query_string_delimiter", sizeof("query_string_delimiter"), (void**) &tmp1) == SUCCESS && Z_TYPE_PP(tmp1) == IS_STRING) { solr_string_appends(&(client_options->qs_delimiter), Z_STRVAL_PP(tmp1), Z_STRLEN_PP(tmp1)); } else { solr_string_append_const(&(client_options->qs_delimiter), SOLR_REQUEST_DEFAULT_QS_DELIMITER); } if (zend_hash_find(options_ht, "login", sizeof("login"), (void**) &tmp1) == SUCCESS && Z_TYPE_PP(tmp1) == IS_STRING && zend_hash_find(options_ht, "password", sizeof("password"), (void**) &tmp2) == SUCCESS && Z_TYPE_PP(tmp2) == IS_STRING) { solr_string_appends(&(client_options->http_auth_credentials), Z_STRVAL_PP(tmp1), Z_STRLEN_PP(tmp1)); solr_string_appendc(&(client_options->http_auth_credentials), ':'); solr_string_appends(&(client_options->http_auth_credentials), Z_STRVAL_PP(tmp2), Z_STRLEN_PP(tmp2)); } if (zend_hash_find(options_ht, "proxy_host", sizeof("proxy_host"), (void**) &tmp1) == SUCCESS && Z_TYPE_PP(tmp1) == IS_STRING) { solr_string_appends(&(client_options->proxy_hostname), Z_STRVAL_PP(tmp1), Z_STRLEN_PP(tmp1)); } if (zend_hash_find(options_ht, "proxy_port", sizeof("proxy_port"), (void**) &tmp1) == SUCCESS) { long int proxy_port_value = 0L; if (Z_TYPE_PP(tmp1) == IS_LONG) { proxy_port_value = Z_LVAL_PP(tmp1); } else if (Z_TYPE_PP(tmp1) == IS_STRING && Z_STRLEN_PP(tmp1)) { proxy_port_value = atol(Z_STRVAL_PP(tmp1)); } if (proxy_port_value > 0L) { client_options->proxy_port = proxy_port_value; } } if (zend_hash_find(options_ht, "proxy_login", sizeof("proxy_login"), (void**)&tmp1) == SUCCESS && Z_TYPE_PP(tmp1) == IS_STRING && zend_hash_find(options_ht, "proxy_password", sizeof("proxy_password"), (void**)&tmp2) == SUCCESS && Z_TYPE_PP(tmp2) == IS_STRING) { solr_string_appends(&(client_options->proxy_auth_credentials), Z_STRVAL_PP(tmp1), Z_STRLEN_PP(tmp1)); solr_string_appendc(&(client_options->proxy_auth_credentials), ':'); solr_string_appends(&(client_options->proxy_auth_credentials), Z_STRVAL_PP(tmp2), Z_STRLEN_PP(tmp2)); } solr_init_handle(handle, client_options TSRMLS_CC); SOLR_GLOBAL(client_count)++; } /* }}} */ /* {{{ proto SolrClient::__destruct(void) Destructor for SolrClient */ PHP_METHOD(SolrClient, __destruct) { solr_client_t *solr_client = NULL; if (solr_fetch_client_entry(getThis(), &solr_client TSRMLS_CC) == SUCCESS) { zend_hash_index_del(SOLR_GLOBAL(clients), solr_client->client_index); /* Keep track of how many SolrClient instances we have. */ SOLR_GLOBAL(client_count)--; return ; } } /* }}} */ /* {{{ proto SolrClient::__sleep(void) Should not be called directly. Serialization is not supported. */ PHP_METHOD(SolrClient, __sleep) { solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1001 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1001_MSG); } /* }}} */ /* {{{ proto SolrClient::__wakeup(void) Should not be called directly. Serialization is not supported. */ PHP_METHOD(SolrClient, __wakeup) { solr_init_client(getThis() TSRMLS_CC); solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1001 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1001_MSG); } /* }}} */ /* {{{ proto SolrClient::__clone(void) Should not be called directly. Cloning is not supported. */ PHP_METHOD(SolrClient, __clone) { solr_client_t *solr_client_ptr = NULL; solr_curl_t *handle = NULL; solr_client_ptr = solr_init_client(getThis() TSRMLS_CC); handle = &(solr_client_ptr->handle); solr_init_options(&(solr_client_ptr->options) TSRMLS_CC); solr_init_handle(handle, &(solr_client_ptr->options) TSRMLS_CC); solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_4001 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Cloning of SolrClient objects is currently not supported"); } /* }}} */ /* {{{ proto bool SolrClient::setServelet(int servlet_type, string new_value) Changes the specified servlet type to a new value */ PHP_METHOD(SolrClient, setServlet) { long int servlet_type_value = 0L; solr_char_t *new_servlet_value = NULL; int new_servlet_value_length = 0; solr_client_t *client = NULL; solr_servlet_type_t servlet_type = SOLR_SERVLET_TYPE_BEGIN; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &servlet_type_value, &new_servlet_value, &new_servlet_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter."); RETURN_FALSE; } if (!new_servlet_value_length) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid servlet value."); RETURN_FALSE; } /* Retrieve the client entry */ if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client"); RETURN_FALSE; } servlet_type = (solr_servlet_type_t) servlet_type_value; switch(servlet_type) { case SOLR_SERVLET_TYPE_SEARCH : { solr_string_set(&(client->options.search_servlet), new_servlet_value, new_servlet_value_length); } break; case SOLR_SERVLET_TYPE_TERMS : { solr_string_set(&(client->options.terms_servlet), new_servlet_value, new_servlet_value_length); } break; case SOLR_SERVLET_TYPE_UPDATE : { solr_string_set(&(client->options.update_servlet), new_servlet_value, new_servlet_value_length); } break; case SOLR_SERVLET_TYPE_THREADS : { solr_string_set(&(client->options.thread_servlet), new_servlet_value, new_servlet_value_length); } break; case SOLR_SERVLET_TYPE_PING : { solr_string_set(&(client->options.ping_servlet), new_servlet_value, new_servlet_value_length); } break; case SOLR_SERVLET_TYPE_SYSTEM : { solr_string_set(&(client->options.system_servlet), new_servlet_value, new_servlet_value_length); } break; default : { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid Servlet type %ld specified. Value discarded.", servlet_type_value); RETURN_FALSE; } } RETURN_TRUE; } /* }}} */ // client->handle.err.str client->handle.request_body_debug.buffer.str /* {{{ proto SolrQueryResponse SolrClient::query(SolrParams query) Sends a name-value pair request to the Solr server. */ PHP_METHOD(SolrClient, query) { zval *solr_params_obj = NULL; solr_client_t *client = NULL; solr_params_t *solr_params = NULL; solr_string_t *buffer = NULL; solr_char_t *delimiter = NULL; int delimiter_length = 0; zend_bool success = 1; solr_request_type_t solr_request_type = SOLR_REQUEST_SEARCH; solr_string_t *request_url = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Return value requested but output not processed."); return; } /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &solr_params_obj, solr_ce_SolrParams) == FAILURE) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_4000_MSG); return; } /* Retrieve the client entry */ if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client"); return; } /* Make sure the SolrParams object passed is a valid one */ if (solr_fetch_params_entry(solr_params_obj, &solr_params TSRMLS_CC) == FAILURE) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "SolrParams parameter passed is not a valid one."); return ; } /* The SolrParams instance must contain at least one parameter */ if (zend_hash_num_elements(solr_params->params) < 1) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "SolrParams parameter passed contains no parameters."); return ; } buffer = &(client->handle.request_body.buffer); /* Get rid of all the data from the previous request */ solr_string_free(buffer); delimiter = client->options.qs_delimiter.str; delimiter_length = client->options.qs_delimiter.len; /* Remove wt if any */ zend_hash_del(solr_params->params, "wt", sizeof("wt")-1); if (solr_http_build_query(buffer, solr_params_obj, delimiter, delimiter_length TSRMLS_CC) == FAILURE) { solr_throw_exception_ex(solr_ce_SolrException, SOLR_ERROR_1003 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Error building HTTP query from parameters"); return; } /* Always reset the URLs before making any request */ solr_client_init_urls(client); request_url = &(client->options.search_url); /* terms.fl is a required parameter for the TermsComponent */ if (zend_hash_exists(solr_params->params, "terms.fl", sizeof("terms.fl")-1)) { /* Change the request type to a TermsComponent request */ solr_request_type = SOLR_REQUEST_TERMS; request_url =&(client->options.terms_url); } /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, solr_request_type TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"query"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } object_init_ex(return_value, solr_ce_SolrQueryResponse); solr_set_response_object_properties(solr_ce_SolrQueryResponse, return_value, client, request_url, success TSRMLS_CC); } /* }}} */ /* {{{ proto SolrUpdateResponse SolrClient::addDocument(SolrInputDocument doc [, bool overwrite [, int commitWithin]]) Adds a document to the Solr server. */ PHP_METHOD(SolrClient, addDocument) { zval *solr_input_doc = NULL; zend_bool overwrite = 1; long int commitWithin = 0L; solr_document_t *doc_entry = NULL; solr_client_t *client = NULL; HashTable *document_fields; xmlNode *root_node = NULL; xmlDoc *doc_ptr = NULL; char *overwriteValue = NULL; int format = 1; int size = 0; xmlChar *request_string = NULL; zend_bool success = 1; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|bl", &solr_input_doc, solr_ce_SolrInputDocument, &overwrite, &commitWithin) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter."); return; } if (solr_fetch_document_entry(solr_input_doc, &doc_entry TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "SolrInputDocument is not valid. Object not present in HashTable"); return; } document_fields = doc_entry->fields; /* Document must contain at least one field */ if (0 == zend_hash_num_elements(document_fields)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "SolrInputDocument has no fields"); return; } /* Retrieve the client entry */ if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client"); return; } doc_ptr = solr_xml_create_xml_doc((xmlChar *) "add", &root_node); overwriteValue = (overwrite)? "true" : "false"; xmlNewProp(root_node, (xmlChar *) "overwrite", (xmlChar *) overwriteValue); if (commitWithin > 0L) { auto char commitWithinBuffer[32]; memset(commitWithinBuffer, 0, sizeof(commitWithinBuffer)); php_sprintf(commitWithinBuffer, "%ld", commitWithin); xmlNewProp(root_node, (xmlChar *) "commitWithin", (xmlChar *) commitWithinBuffer); } solr_add_doc_node(root_node, doc_entry TSRMLS_CC); xmlIndentTreeOutput = 1; xmlDocDumpFormatMemoryEnc(doc_ptr, &request_string, &size, "UTF-8", format); /* The XML request we are sending to Solr */ solr_string_set(&(client->handle.request_body.buffer), (solr_char_t *) request_string, size); xmlFree(request_string); xmlFreeDoc(doc_ptr); /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_UPDATE TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"update"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } if (return_value_used) { object_init_ex(return_value, solr_ce_SolrUpdateResponse); solr_set_response_object_properties(solr_ce_SolrUpdateResponse, return_value, client, &(client->options.update_url), success TSRMLS_CC); } } /* }}} */ /* {{{ proto SolrUpdateResponse SolrClient::addDocuments(array docs [, bool overwrite [, int commitWithin]]) Adds an array of SolrInputDocuments to the Solr server. */ PHP_METHOD(SolrClient, addDocuments) { zval *docs_array = NULL; zend_bool overwrite = 1; long int commitWithin = 0L; HashTable *solr_input_docs; size_t num_input_docs = 0; solr_client_t *client = NULL; solr_document_t **doc_entries = NULL; size_t curr_pos = 0U; xmlNode *root_node = NULL; xmlDoc *doc_ptr = NULL; xmlChar *overwriteValue = NULL; size_t pos = 0U; solr_document_t *current_doc_entry = NULL; int format = 1; int size = 0; zend_bool success = 1; xmlChar *request_string = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|bl", &docs_array, &overwrite, &commitWithin) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } solr_input_docs = Z_ARRVAL_P(docs_array); num_input_docs = zend_hash_num_elements(solr_input_docs); if(!num_input_docs) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "The array parameter passed is empty"); return; } /* This should be released if there is an error */ doc_entries = (solr_document_t **) pemalloc((sizeof(solr_document_t *) * (num_input_docs + 1)), SOLR_DOCUMENT_PERSISTENT); memset(doc_entries, 0, sizeof(solr_document_t *) * (num_input_docs + 1)); /* Please check all the SolrInputDocument instances passed via the array */ SOLR_HASHTABLE_FOR_LOOP(solr_input_docs) { zval **solr_input_doc = NULL; solr_document_t *doc_entry = NULL; HashTable *document_fields; zend_hash_get_current_data_ex(solr_input_docs, (void **) &solr_input_doc, ((HashPosition *)0)); if (Z_TYPE_PP(solr_input_doc) != IS_OBJECT || !instanceof_function(Z_OBJCE_PP(solr_input_doc), solr_ce_SolrInputDocument TSRMLS_CC)) { SOLR_FREE_DOC_ENTRIES(doc_entries); solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "SolrInputDocument number %u is not a valid SolrInputDocument instance", (curr_pos + 1U)); return; } if (solr_fetch_document_entry((*solr_input_doc), &doc_entry TSRMLS_CC) == FAILURE) { SOLR_FREE_DOC_ENTRIES(doc_entries); solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "SolrInputDocument number %u is not valid. Object not present in HashTable", (curr_pos + 1U)); return; } document_fields = doc_entry->fields; /* SolrInputDocument must contain at least one field */ if (0 == zend_hash_num_elements(document_fields)) { SOLR_FREE_DOC_ENTRIES(doc_entries); solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "SolrInputDocument number %u has no fields", (curr_pos + 1U)); return; } doc_entries[curr_pos] = doc_entry; curr_pos++; } /* Mark the end of the list */ doc_entries[curr_pos] = NULL; /* All the input documents have been validated. We can now retrieve the client entry */ if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { SOLR_FREE_DOC_ENTRIES(doc_entries); php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client from HashTable"); return; } doc_ptr = solr_xml_create_xml_doc((xmlChar *) "add", &root_node); overwriteValue = (overwrite) ? (xmlChar *) "true" : (xmlChar *) "false"; xmlNewProp(root_node, (xmlChar *) "overwrite", overwriteValue); if (commitWithin > 0L) { auto char commitWithinBuffer[32]; memset(commitWithinBuffer, 0, sizeof(commitWithinBuffer)); php_sprintf(commitWithinBuffer, "%ld", commitWithin); xmlNewProp(root_node, (xmlChar *) "commitWithin", (xmlChar *) commitWithinBuffer); } /* Grab the first (solr_document_t *) pointer */ current_doc_entry = doc_entries[pos]; while(current_doc_entry != NULL) { solr_add_doc_node(root_node, current_doc_entry TSRMLS_CC); pos++; /* Grab the next (solr_document_t *) pointer */ current_doc_entry = doc_entries[pos]; } /* We are done with the doc_entries pointer */ SOLR_FREE_DOC_ENTRIES(doc_entries); xmlIndentTreeOutput = 1; xmlDocDumpFormatMemoryEnc(doc_ptr, &request_string, &size, "UTF-8", format); /* The XML request we are sending to Solr */ solr_string_set(&(client->handle.request_body.buffer), (solr_char_t *) request_string, size); xmlFree(request_string); xmlFreeDoc(doc_ptr); /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_UPDATE TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"update"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } if (return_value_used) { object_init_ex(return_value, solr_ce_SolrUpdateResponse); solr_set_response_object_properties(solr_ce_SolrUpdateResponse, return_value, client, &(client->options.update_url), success TSRMLS_CC); } } /* }}} */ /* {{{ proto SolrUpdateResponse SolrClient::request(string request_string) Allows the user to send a manual XML update request */ PHP_METHOD(SolrClient, request) { solr_char_t *request_string = NULL; int request_length = 0; solr_client_t *client = NULL; zend_bool success = 1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &request_string, &request_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } if (!request_length) { solr_throw_exception(solr_ce_SolrIllegalArgumentException, "Invalid request length. Request string is empty.", SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC); return; } if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client from HashTable"); return; } /* The update request we are sending to Solr */ solr_string_set(&(client->handle.request_body.buffer), request_string, request_length); /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_UPDATE TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"update"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } if (return_value_used) { object_init_ex(return_value, solr_ce_SolrUpdateResponse); solr_set_response_object_properties(solr_ce_SolrUpdateResponse, return_value, client, &(client->options.update_url), success TSRMLS_CC); } } /* }}} */ /* {{{ proto SolrUpdateResponse SolrClient::deleteById(string id) Allows the user to delete a document by id */ PHP_METHOD(SolrClient, deleteById) { solr_char_t *id = NULL; int id_length = 0L; solr_client_t *client = NULL; xmlNode *root_node = NULL; xmlDoc *doc_ptr = NULL; xmlChar *escaped_id_value = NULL; int format = 1; int size = 0; xmlChar *request_string = NULL; zend_bool success = 1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &id, &id_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } if (!id_length) { solr_throw_exception(solr_ce_SolrIllegalArgumentException, "Invalid id parameter", SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC); return; } if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client from HashTable"); return; } doc_ptr = solr_xml_create_xml_doc((xmlChar *) "delete", &root_node); escaped_id_value = xmlEncodeEntitiesReentrant(doc_ptr, (xmlChar *) id); xmlNewChild(root_node, NULL, (xmlChar *) "id", escaped_id_value); xmlFree(escaped_id_value); xmlIndentTreeOutput = 1; xmlDocDumpFormatMemoryEnc(doc_ptr, &request_string, &size, "UTF-8", format); /* The XML request we are sending to Solr */ solr_string_set(&(client->handle.request_body.buffer), (solr_char_t *) request_string, size); xmlFree(request_string); xmlFreeDoc(doc_ptr); /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_UPDATE TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"update"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } if (return_value_used) { object_init_ex(return_value, solr_ce_SolrUpdateResponse); solr_set_response_object_properties(solr_ce_SolrUpdateResponse, return_value, client, &(client->options.update_url), success TSRMLS_CC); } } /* }}} */ /* {{{ proto SolrUpdateResponse SolrClient::request(array ids) Allows the user to delete a set of documents by ids. This should be an array of strings */ PHP_METHOD(SolrClient, deleteByIds) { zval *ids_array = NULL; HashTable *doc_ids = NULL; size_t num_ids = 0; xmlNode *root_node = NULL; xmlDoc *doc_ptr = NULL; zend_bool invalid_param = 0; size_t error_pos = 1, current_position = 1; solr_client_t *client = NULL; int format = 1; int size = 0; xmlChar *request_string = NULL; zend_bool success = 1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &ids_array) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } doc_ids = Z_ARRVAL_P(ids_array); num_ids = zend_hash_num_elements(doc_ids); if(!num_ids) { solr_throw_exception(solr_ce_SolrIllegalArgumentException, "The array parameter passed is empty", SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC); return; } doc_ptr = solr_xml_create_xml_doc((xmlChar *) "delete", &root_node); SOLR_HASHTABLE_FOR_LOOP(doc_ids) { zval **id_zval = NULL; zend_hash_get_current_data_ex(doc_ids, (void **) &id_zval, ((HashPosition *)0)); if (Z_TYPE_PP(id_zval) == IS_STRING && Z_STRLEN_PP(id_zval)) { xmlChar *escaped_id_value = xmlEncodeEntitiesReentrant(doc_ptr, (xmlChar *) Z_STRVAL_PP(id_zval)); xmlNewChild(root_node, NULL, (xmlChar *) "id", escaped_id_value); xmlFree(escaped_id_value); } else { invalid_param = 1; /* This id is not a valid string */ error_pos = current_position; goto end_doc_ids_loop; } current_position++; } end_doc_ids_loop : if (invalid_param) { xmlFreeDoc(doc_ptr); solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Id number %u is not a valid string", error_pos); return; } if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client from HashTable"); return; } xmlIndentTreeOutput = 1; xmlDocDumpFormatMemoryEnc(doc_ptr, &request_string, &size, "UTF-8", format); /* The XML request we are sending to Solr */ solr_string_set(&(client->handle.request_body.buffer), (solr_char_t *) request_string, size); xmlFree(request_string); xmlFreeDoc(doc_ptr); /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_UPDATE TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"update"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } if (return_value_used) { object_init_ex(return_value, solr_ce_SolrUpdateResponse); solr_set_response_object_properties(solr_ce_SolrUpdateResponse, return_value, client, &(client->options.update_url), success TSRMLS_CC); } } /* }}} */ /* {{{ proto SolrUpdateResponse SolrClient::deleteByQuery(string query) Allows the user to delete a set of documents matching the query */ PHP_METHOD(SolrClient, deleteByQuery) { solr_char_t *query = NULL; int query_length = 0L; solr_client_t *client = NULL; xmlNode *root_node = NULL; xmlDoc *doc_ptr = NULL; xmlChar *escaped_query_value = NULL; int format = 1; int size = 0; xmlChar *request_string = NULL; zend_bool success = 1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &query, &query_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } if (!query_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "The query parameter is not a valid id"); return; } if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client from HashTable"); return; } doc_ptr = solr_xml_create_xml_doc((xmlChar *) "delete", &root_node); escaped_query_value = xmlEncodeEntitiesReentrant(doc_ptr, (xmlChar *) query); xmlNewChild(root_node, NULL, (xmlChar *) "query", escaped_query_value); xmlFree(escaped_query_value); xmlIndentTreeOutput = 1; xmlDocDumpFormatMemoryEnc(doc_ptr, &request_string, &size, "UTF-8", format); /* The XML request we are sending to Solr */ solr_string_set(&(client->handle.request_body.buffer), (solr_char_t *) request_string, size); xmlFree(request_string); xmlFreeDoc(doc_ptr); /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_UPDATE TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"update"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } if (return_value_used) { object_init_ex(return_value, solr_ce_SolrUpdateResponse); solr_set_response_object_properties(solr_ce_SolrUpdateResponse, return_value, client, &(client->options.update_url), success TSRMLS_CC); } } /* }}} */ /* {{{ proto SolrQueryResponse SolrClient::getById(string id) Get Document By Id. Utilizes Solr Realtime Get (RTG) */ PHP_METHOD(SolrClient, getById) { solr_client_t *client; solr_char_t *id; int id_len = 0; solr_string_t query_string; int success = 1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &id, &id_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } /* Always reset the URLs before making any request */ solr_client_init_urls(client); solr_string_init(&query_string); solr_string_appends(&query_string, "id=", sizeof("id=")-1); solr_string_appends(&query_string, id, id_len); solr_string_append_solr_string(&(client->handle.request_body.buffer), &query_string); if (solr_make_request(client, SOLR_REQUEST_GET TSRMLS_CC) == FAILURE) { /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"get"); success = 0; } if (return_value_used) { object_init_ex(return_value, solr_ce_SolrQueryResponse); solr_set_response_object_properties(solr_ce_SolrQueryResponse, return_value, client, &(client->options.get_url), success TSRMLS_CC); } solr_string_free(&query_string); } /* }}} */ /* {{{ proto SolrQueryResponse SolrClient::getByIds(array ids) Get Documents by their Ids. Utilizes Solr Realtime Get (RTG) */ PHP_METHOD(SolrClient, getByIds) { solr_client_t *client; HashTable *ids = NULL; zval *ids_z = NULL; zend_bool invalid_param = 0; solr_string_t query_string; size_t current_position = 0; int success = 1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &ids_z) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Internal Error: Cannot fetch client object"); return; } ids = Z_ARRVAL_P(ids_z); if (ids->nNumOfElements < 1) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, 4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter: at least 1 ID is required. Passed an empty array.", current_position); } /* Always reset the URLs before making any request */ solr_client_init_urls(client); solr_string_init(&query_string); solr_string_appends(&query_string, "ids=", sizeof("ids=")-1); SOLR_HASHTABLE_FOR_LOOP(ids) { zval **id_zv = NULL; zend_hash_get_current_data(ids, (void **) &id_zv); if (Z_TYPE_PP(id_zv) == IS_STRING && Z_STRLEN_PP(id_zv)) { solr_string_appends(&query_string, Z_STRVAL_PP(id_zv), Z_STRLEN_PP(id_zv)); solr_string_appendc(&query_string, ','); } else { invalid_param = 1; goto solr_getbyids_exit; } current_position++; } solr_getbyids_exit: if (invalid_param) { solr_string_free(&query_string); solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, 4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid id at position %ld", current_position); return; } solr_string_remove_last_char(&query_string); solr_string_append_solr_string(&(client->handle.request_body.buffer), &query_string); if (solr_make_request(client, SOLR_REQUEST_GET TSRMLS_CC) == FAILURE) { /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"get"); success = 0; } if (return_value_used) { object_init_ex(return_value, solr_ce_SolrQueryResponse); solr_set_response_object_properties(solr_ce_SolrQueryResponse, return_value, client, &(client->options.get_url), success TSRMLS_CC); } solr_string_set_ex(&(client->handle.request_body.buffer),(solr_char_t *)0x00, 0); solr_string_free(&query_string); } /* }}} */ /* {{{ proto void SolrClient::setResponseWriter(string responseWriter) Allows the user to specify which response writer to use */ PHP_METHOD(SolrClient, setResponseWriter) { solr_char_t *wt = NULL; int wt_length = 0L; solr_client_t *client = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &wt, &wt_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } if (!wt_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "The response writer is not a valid string"); return; } if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client from HashTable"); return; } if (solr_is_supported_response_writer((const solr_char_t *) wt, wt_length)) { /* The response writer used to present the response from Solr */ solr_string_set(&(client->options.response_writer), (solr_char_t *) wt, wt_length); } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported response writer %s. This value will be ignored", wt); } } /* }}} */ /* {{{ proto SolrUpdateResponse SolrClient::deleteByQueries(array queries) Allows the user to delete a set of documents matching the queries specified */ PHP_METHOD(SolrClient, deleteByQueries) { zval *queries_array = NULL; HashTable *doc_queries = NULL; size_t num_queries = 0; xmlNode *root_node = NULL; xmlDoc *doc_ptr = NULL; zend_bool invalid_param = 0; size_t error_pos, current_position = 1; solr_client_t *client = NULL; int format = 1; int size = 0; xmlChar *request_string = NULL; zend_bool success = 1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &queries_array) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } doc_queries = Z_ARRVAL_P(queries_array); num_queries = zend_hash_num_elements(doc_queries); if(!num_queries) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "The array parameter passed is empty"); return; } doc_ptr = solr_xml_create_xml_doc((xmlChar *) "delete", &root_node); SOLR_HASHTABLE_FOR_LOOP(doc_queries) { zval **query_zval = NULL; zend_hash_get_current_data_ex(doc_queries, (void **) &query_zval, ((HashPosition *)0)); if (Z_TYPE_PP(query_zval) == IS_STRING && Z_STRLEN_PP(query_zval)) { xmlChar *escaped_query_value = xmlEncodeEntitiesReentrant(doc_ptr, (xmlChar *) Z_STRVAL_PP(query_zval)); xmlNewChild(root_node, NULL, (xmlChar *) "query", escaped_query_value); xmlFree(escaped_query_value); } else { invalid_param = 1; /* This query is not a valid string */ error_pos = current_position; goto end_doc_queries_loop; } current_position++; } end_doc_queries_loop : if (invalid_param) { xmlFreeDoc(doc_ptr); solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Query number %u is not a valid query string", error_pos); return; } if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client from HashTable"); return; } xmlIndentTreeOutput = 1; xmlDocDumpFormatMemoryEnc(doc_ptr, &request_string, &size, "UTF-8", format); /* The XML request we are sending to Solr */ solr_string_set(&(client->handle.request_body.buffer), (solr_char_t *) request_string, size); xmlFree(request_string); xmlFreeDoc(doc_ptr); /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_UPDATE TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"update"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } if (return_value_used) { object_init_ex(return_value, solr_ce_SolrUpdateResponse); solr_set_response_object_properties(solr_ce_SolrUpdateResponse, return_value, client, &(client->options.update_url), success TSRMLS_CC); } } /* }}} */ /* {{{ proto SolrUpdateResponse SolrClient::optimize([string maxSegments [, bool softCommit [, bool waitSearcher]]) Sends an optimize XML request to the server. */ PHP_METHOD(SolrClient, optimize) { zend_bool softCommit = 0, waitSearcher = 1; char *maxSegments = "1"; int maxSegmentsLen = sizeof("1")-1; char *softCommitValue, *waitSearcherValue; xmlNode *root_node = NULL; xmlDoc *doc_ptr = NULL; solr_client_t *client = NULL; int format = 1; int size = 0; xmlChar *request_string = NULL; zend_bool success = 1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sbb", &maxSegments, &maxSegmentsLen, &softCommit, &waitSearcher) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } softCommitValue = (softCommit)? "true" : "false"; waitSearcherValue = (waitSearcher)? "true" : "false"; doc_ptr = solr_xml_create_xml_doc((xmlChar *) "optimize", &root_node); xmlNewProp(root_node, (xmlChar *) "maxSegments", (xmlChar *) maxSegments); xmlNewProp(root_node, (xmlChar *) "softCommit", (xmlChar *) softCommitValue); xmlNewProp(root_node, (xmlChar *) "waitSearcher", (xmlChar *) waitSearcherValue); if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client from HashTable"); return; } xmlIndentTreeOutput = 1; xmlDocDumpFormatMemoryEnc(doc_ptr, &request_string, &size, "UTF-8", format); /* The XML request we are sending to Solr */ solr_string_set(&(client->handle.request_body.buffer), (solr_char_t *) request_string, size); xmlFree(request_string); xmlFreeDoc(doc_ptr); /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_UPDATE TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"update"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } if (return_value_used) { object_init_ex(return_value, solr_ce_SolrUpdateResponse); solr_set_response_object_properties(solr_ce_SolrUpdateResponse, return_value, client, &(client->options.update_url), success TSRMLS_CC); } } /* }}} */ /* {{{ proto SolrUpdateResponse SolrClient::commit( [bool softCommit [, bool waitSearcher [, bool expungeDeletes]]]) Sends a commit XML request to the server. */ PHP_METHOD(SolrClient, commit) { zend_bool softCommit = 0, waitSearcher = 1, expungeDeletes = 0; char *softCommitValue, *waitSearcherValue, *expungeDeletesValue; xmlNode *root_node = NULL; xmlDoc *doc_ptr = NULL; solr_client_t *client = NULL; int format = 1; int size = 0; xmlChar *request_string = NULL; zend_bool success = 1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|bbb", &softCommit, &waitSearcher, &expungeDeletes) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } softCommitValue = (softCommit)? "true" : "false"; waitSearcherValue = (waitSearcher)? "true" : "false"; expungeDeletesValue = (expungeDeletes)? "true": "false"; doc_ptr = solr_xml_create_xml_doc((xmlChar *) "commit", &root_node); xmlNewProp(root_node, (xmlChar *) "softCommit", (xmlChar *) softCommitValue); xmlNewProp(root_node, (xmlChar *) "waitSearcher", (xmlChar *) waitSearcherValue); xmlNewProp(root_node, (xmlChar *) "expungeDeletes", (xmlChar *) expungeDeletesValue); if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client from HashTable"); return; } xmlIndentTreeOutput = 1; xmlDocDumpFormatMemoryEnc(doc_ptr, &request_string, &size, "UTF-8", format); /* The XML request we are sending to Solr */ solr_string_set(&(client->handle.request_body.buffer), (solr_char_t *) request_string, size); xmlFree(request_string); xmlFreeDoc(doc_ptr); /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_UPDATE TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"update"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } if (return_value_used) { object_init_ex(return_value, solr_ce_SolrUpdateResponse); solr_set_response_object_properties(solr_ce_SolrUpdateResponse, return_value, client, &(client->options.update_url), success TSRMLS_CC); } } /* }}} */ /* {{{ proto SolrUpdateResponse SolrClient::rollback(void) Sends a rollback XML request to the server. */ PHP_METHOD(SolrClient, rollback) { xmlNode *root_node = NULL; zend_bool success = 1; xmlDoc *doc_ptr = NULL; solr_client_t *client = NULL; int format = 1; int size = 0; xmlChar *request_string = NULL; doc_ptr = solr_xml_create_xml_doc((xmlChar *) "rollback", &root_node); if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client from HashTable"); return; } xmlIndentTreeOutput = 1; xmlDocDumpFormatMemoryEnc(doc_ptr, &request_string, &size, "UTF-8", format); /* The XML request we are sending to Solr */ solr_string_set(&(client->handle.request_body.buffer), (solr_char_t *) request_string, size); xmlFree(request_string); xmlFreeDoc(doc_ptr); /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_UPDATE TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"update"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } if (return_value_used) { object_init_ex(return_value, solr_ce_SolrUpdateResponse); solr_set_response_object_properties(solr_ce_SolrUpdateResponse, return_value, client, &(client->options.update_url), success TSRMLS_CC); } } /* }}} */ /* {{{ proto SolrPingResponse SolrClient::ping() Sends a HEAD request to check if the server is still up and running. */ PHP_METHOD(SolrClient, ping) { solr_client_t *client = NULL; zend_bool success = 1; /* Retrieve the client entry */ if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client"); return; } /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_PING TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"ping"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } if (return_value_used) { object_init_ex(return_value, solr_ce_SolrPingResponse); solr_set_response_object_properties(solr_ce_SolrPingResponse, return_value, client, &(client->options.ping_url), success TSRMLS_CC); } } /* }}} */ /* {{{ proto SolrGenericResponse SolrClient::threads() Sends a request to get info about threads. */ PHP_METHOD(SolrClient, threads) { zend_bool success = 1; solr_client_t *client = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Return value requested but output not processed."); return; } /* Retrieve the client entry */ if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client"); return; } /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_THREADS TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"threads"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } object_init_ex(return_value, solr_ce_SolrGenericResponse); solr_set_response_object_properties(solr_ce_SolrGenericResponse, return_value, client, &(client->options.thread_url), success TSRMLS_CC); } /* }}} */ /* {{{ proto SolrGenericResponse SolrClient::info() Sends a request to get system info. */ PHP_METHOD(SolrClient, system) { zend_bool success = 1; solr_client_t *client = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Return value requested but output not processed."); return; } /* Retrieve the client entry */ if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client"); return; } /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_SYSTEM TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"system"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } if (return_value_used) { object_init_ex(return_value, solr_ce_SolrGenericResponse); solr_set_response_object_properties(solr_ce_SolrGenericResponse, return_value, client, &(client->options.system_url), success TSRMLS_CC); } } /* }}} */ /* {{{ proto array SolrClient::getOptions() Returns all the options for this client. */ PHP_METHOD(SolrClient, getOptions) { solr_client_t *client = NULL; solr_client_options_t *options = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Return value requested but output not processed."); return; } /* Retrieve the client entry */ if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client"); return; } options = &(client->options); array_init(return_value); add_assoc_long(return_value, "timeout", options->timeout); add_assoc_bool(return_value, "secure", (int) options->secure); add_assoc_stringl(return_value, "hostname", options->hostname.str, options->hostname.len, 1); add_assoc_stringl(return_value, "wt", options->response_writer.str, options->response_writer.len, 1); add_assoc_long(return_value, "port", options->host_port); add_assoc_stringl(return_value, "proxy_host", options->proxy_hostname.str, options->proxy_hostname.len, 1); add_assoc_long(return_value, "proxy_port", options->proxy_port); add_assoc_stringl(return_value, "path", options->path.str, options->path.len, 1); add_assoc_stringl(return_value, "http_auth", options->http_auth_credentials.str, options->http_auth_credentials.len, 1); add_assoc_stringl(return_value, "proxy_auth", options->proxy_auth_credentials.str, options->proxy_auth_credentials.len, 1); add_assoc_bool(return_value, "ssl_verify_peer", (int) options->ssl_verify_peer); add_assoc_long(return_value, "ssl_verify_host", options->ssl_verify_host); add_assoc_stringl(return_value, "ssl_cert", options->ssl_cert.str, options->ssl_cert.len, 1); add_assoc_stringl(return_value, "ssl_key", options->ssl_key.str, options->ssl_key.len, 1); add_assoc_stringl(return_value, "ssl_keypassword", options->ssl_keypassword.str, options->ssl_keypassword.len, 1); add_assoc_stringl(return_value, "ssl_cainfo", options->ssl_cainfo.str, options->ssl_cainfo.len, 1); add_assoc_stringl(return_value, "ssl_capath", options->ssl_capath.str, options->ssl_capath.len, 1); } /* }}} */ /* {{{ proto string SolrClient::getDebug() Returns all debug data captured in the process of making the request. */ PHP_METHOD(SolrClient, getDebug) { solr_client_t *client = NULL; solr_curl_t *handle = NULL; zend_bool duplicate_string = 1; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Return value requested but output not processed."); return; } /* Retrieve the client entry */ if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client"); return; } handle = &(client->handle); if (!handle->debug_data_buffer.len) { RETURN_NULL(); } RETVAL_STRINGL(handle->debug_data_buffer.str, handle->debug_data_buffer.len, duplicate_string); } /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/php_solr_collapse_function.c0000644000175000017500000002564512676753706020435 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: | | Omar Shaban | +----------------------------------------------------------------------+ */ #include "php_solr.h" /* {{{ proto void SolrFunction::__construct([string field]) Constructor. */ PHP_METHOD(SolrCollapseFunction, __construct) { long int index = SOLR_UNIQUE_FUNCTION_INDEX(); uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE; solr_function_t *solr_function_dest = NULL; solr_function_t solr_function; zval *objptr = getThis(); solr_char_t *param_name = (solr_char_t *)"field"; int param_name_len = sizeof("field"); solr_string_t field_str; solr_char_t *field_name = NULL; int field_name_len = 0; memset(&solr_function, 0, sizeof(solr_function_t)); if (zend_hash_index_update(SOLR_GLOBAL(functions),index,(void *) &solr_function, sizeof(solr_function_t), (void **) &solr_function_dest) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error while registering query parameters in HashTable"); return ; } zend_update_property_long(solr_ce_SolrCollapseFunction, objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, index TSRMLS_CC); solr_function_dest->function_index = index; solr_function_dest->name_length = strlen("collapse"); solr_function_dest->name = (solr_char_t *)"collapse"; /* Allocated memory for the params HashTable using fast cache for HashTables */ ALLOC_HASHTABLE(solr_function_dest->params); zend_hash_init(solr_function_dest->params, nSize, NULL, (dtor_func_t) solr_string_free_ex, SOLR_FUNCTIONS_PERSISTENT); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error Parsing Parameters"); return; } if (field_name_len > 0 ){ memset(&field_str, 0, sizeof(solr_string_t)); solr_string_set(&field_str, (solr_char_t *)field_name, field_name_len); if(zend_hash_update(solr_function_dest->params, param_name, param_name_len, (void **)&field_str, sizeof(solr_string_t), NULL) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); } } Z_OBJ_HT_P(getThis()) = &solr_collapse_function_object_handlers; } /* }}} */ /* {{{ proto void SolrFunction::__destruct(void) Destructor. */ PHP_METHOD(SolrCollapseFunction, __destruct) { solr_function_t *function = NULL; /* Retrieve the document entry for this SolrDocument */ if (solr_fetch_function_entry(getThis(), &function TSRMLS_CC) == SUCCESS ) { zend_hash_index_del(SOLR_GLOBAL(functions), function->function_index); } return; } /* {{{ proto string SolrFunction::setField(string field) Set the field that is being collapsed on. The field must be a single valued String, Int or Float. */ PHP_METHOD(SolrCollapseFunction, setField) { solr_char_t *key = "field", *arg; int key_len = sizeof("field"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::getField(void) Get Collapse Field */ PHP_METHOD(SolrCollapseFunction, getField) { solr_char_t *key = "field"; int key_len = sizeof("field"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::setMin(string value) Selects the group heads by the min value of a numeric field or function query. */ PHP_METHOD(SolrCollapseFunction, setMin) { solr_char_t *key = "min", *arg; int key_len = sizeof("min"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::setMax(string value) Selects the group heads by the max value of a numeric field or function query. */ PHP_METHOD(SolrCollapseFunction, setMax) { solr_char_t *key = "max", *arg; int key_len = sizeof("max"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::getMin(void) Get min parameter */ PHP_METHOD(SolrCollapseFunction, getMin) { solr_char_t *key = "min"; int key_len = sizeof("min"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::getMax(void) Get max parameter */ PHP_METHOD(SolrCollapseFunction, getMax) { solr_char_t *key = "max"; int key_len = sizeof("max"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::setSize(void) Sets the initial size of the collapse data structures when collapsing on a numeric field only */ PHP_METHOD(SolrCollapseFunction, setSize) { solr_char_t *key = "size", *arg; int key_len = sizeof("size"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::getSize(void) Get size parameter */ PHP_METHOD(SolrCollapseFunction, getSize) { solr_char_t *key = "size"; int key_len = sizeof("size"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::setHint(void) Set collapse hint Currently there is only one hint available "top_fc", which stands for top level FieldCache */ PHP_METHOD(SolrCollapseFunction, setHint) { solr_char_t *key = "hint", *arg; int key_len = sizeof("hint"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::getHint(void) Get Hint */ PHP_METHOD(SolrCollapseFunction, getHint) { solr_char_t *key = "hint"; int key_len = sizeof("hint"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::setNullPolicy(void) Sets the NULL Policy. Accepts ignore, expand, or collapse */ PHP_METHOD(SolrCollapseFunction, setNullPolicy) { solr_char_t *key = "nullPolicy", *arg; int key_len = sizeof("nullPolicy"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::getNullPolicy(void) Get NullPolicy */ PHP_METHOD(SolrCollapseFunction, getNullPolicy) { solr_char_t *key = "nullPolicy"; int key_len = sizeof("nullPolicy"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::__toString(void) String value of the function object */ PHP_METHOD(SolrCollapseFunction, __toString) { solr_function_t *collapse_func; solr_string_t *buffer = NULL; if(solr_fetch_function_entry(getThis(), &collapse_func TSRMLS_CC) == FAILURE) { RETURN_NULL(); } buffer = (solr_string_t *)emalloc(sizeof(solr_string_t)); memset(buffer, 0, sizeof(solr_string_t)); solr_solrfunc_to_string(collapse_func, &buffer); ZVAL_STRINGL(return_value, buffer->str, buffer->len, 0); efree(buffer); } /* }}} */ /* {{{ proto SolrClient::__sleep(void) Should not be called directly. Serialization is not supported. */ PHP_METHOD(SolrCollapseFunction, __sleep) { solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1001 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Serialization of SolrCollapseFunction objects is currently not supported"); } /* }}} */ /* {{{ proto SolrClient::__wakeup(void) Should not be called directly. Serialization is not supported. */ PHP_METHOD(SolrCollapseFunction, __wakeup) { solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1001 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Unserialization of SolrCollapseFunction objects is currently not supported"); } /* }}} */ /* {{{ throw exception on cloning (clone handler) */ zend_object_value solr_collapse_function_handlers_clone_object(zval *object TSRMLS_DC) { zend_object_value retval; zend_object *fake; retval = zend_objects_new(&fake, zend_standard_class_def TSRMLS_CC); solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_4001 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Cloning of SolrCollapseFunction objects is currently not supported"); return retval; } /* }}} */ solr-2.4.0/src/php5/php_solr_document.c0000644000175000017500000012662612676753706016545 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /** ************************************************************************ **/ /** DEFINITIONS FOR SOLR DOCUMENT METHODS **/ /** ************************************************************************ **/ /* {{{ static int solr_document_set_field(zval *objptr, solr_char_t *field_name, int field_name_length, solr_char_t *field_value, int field_value_length TSRMLS_DC) */ static int solr_document_set_field(zval *objptr, solr_char_t *field_name, int field_name_length, solr_char_t *field_value, int field_value_length TSRMLS_DC) { double field_boost = 0.0f; solr_document_t *doc_entry = NULL; if (!field_name_length) { return FAILURE; } if (!field_value_length) { return FAILURE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(objptr, &doc_entry TSRMLS_CC) == SUCCESS) { solr_field_list_t **field_values_ptr = NULL; solr_field_list_t *field_values = NULL; /* If the field already exists in the SolrDocument instance append the value to the field list queue */ if (zend_hash_find(doc_entry->fields, field_name, field_name_length, (void **) &field_values_ptr) == SUCCESS) { if (solr_document_insert_field_value(*field_values_ptr, field_value, field_boost) == FAILURE) { return FAILURE; } } else { /* Otherwise, create a new one and add it to the hash table */ field_values = (solr_field_list_t *) pemalloc(sizeof(solr_field_list_t), SOLR_DOCUMENT_FIELD_PERSISTENT); memset(field_values, 0, sizeof(solr_field_list_t)); field_values_ptr = &field_values; field_values->count = 0L; field_values->field_boost = 0.0; field_values->field_name = (solr_char_t *) pestrdup(field_name,SOLR_DOCUMENT_FIELD_PERSISTENT); field_values->head = NULL; field_values->last = NULL; if (solr_document_insert_field_value(field_values, field_value, field_boost) == FAILURE) { solr_destroy_field_list(&field_values); return FAILURE; } if (zend_hash_add(doc_entry->fields, field_name, field_name_length, (void *) field_values_ptr, sizeof(solr_field_list_t *), (void **) NULL) == FAILURE) { solr_destroy_field_list(&field_values); return FAILURE; } /* Increment field count only when HEAD is added */ doc_entry->field_count++; } return SUCCESS; } return FAILURE; } /* }}} */ /* {{{ static int solr_document_get_field(zval *objptr, zval *return_value, solr_char_t *field_name, int field_name_length TSRMLS_DC) */ static int solr_document_get_field(zval *objptr, zval *return_value, solr_char_t *field_name, int field_name_length TSRMLS_DC) { solr_document_t *doc_entry = NULL; if (!field_name_length) { return FAILURE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(objptr, &doc_entry TSRMLS_CC) == SUCCESS) { solr_field_list_t **field_values = NULL; if (zend_hash_find(doc_entry->fields, (char *)field_name, field_name_length, (void **) &field_values) == SUCCESS) { solr_create_document_field_object(*field_values, &return_value TSRMLS_CC); /* The field was retrieved, so we're done here */ return SUCCESS; } return FAILURE; } return FAILURE; } /* }}} */ /* {{{ static int solr_document_remove_field(zval *objptr, solr_char_t *field_name, int field_name_length TSRMLS_DC) */ static int solr_document_remove_field(zval *objptr, solr_char_t *field_name, int field_name_length TSRMLS_DC) { solr_document_t *doc_entry = NULL; if (!field_name_length) { return FAILURE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(objptr, &doc_entry TSRMLS_CC) == SUCCESS) { if (zend_hash_del(doc_entry->fields, field_name, field_name_length) == SUCCESS) { doc_entry->field_count--; return SUCCESS; } return FAILURE; } return FAILURE; } /* }}} */ /* {{{ static int solr_document_field_exists(zval *objptr, solr_char_t *field_name, int field_name_length TSRMLS_DC) */ static int solr_document_field_exists(zval *objptr, solr_char_t *field_name, int field_name_length TSRMLS_DC) { solr_document_t *doc_entry = NULL; if (!field_name_length) { return FAILURE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(objptr, &doc_entry TSRMLS_CC) == SUCCESS) { if (zend_hash_exists(doc_entry->fields, field_name, field_name_length)) { return SUCCESS; } else { return FAILURE; } } return FAILURE; } /* }}} */ /* {{{ static void solr_serialize_document_object(HashTable *document_fields, xmlChar **buffer, int *size TSRMLS_DC) */ static void solr_serialize_document_object(HashTable *document_fields, xmlChar **buffer, int *size TSRMLS_DC) { xmlNode *root_node = NULL, *fields_node = NULL; xmlDoc *doc_ptr = NULL; int format = 1; if(!buffer) { return; } doc_ptr = solr_xml_create_xml_doc((xmlChar *) "solr_document", &root_node); fields_node = xmlNewChild(root_node, NULL, (xmlChar *) "fields", NULL); SOLR_HASHTABLE_FOR_LOOP(document_fields) { solr_field_list_t **field = NULL; solr_char_t *doc_field_name = NULL; solr_field_value_t *doc_field_value = NULL; xmlNode *field_node = NULL; zend_hash_get_current_data_ex(document_fields, (void **) &field, ((HashPosition *)0)); doc_field_name = (*field)->field_name; doc_field_value = (*field)->head; field_node = xmlNewChild(fields_node, NULL, (xmlChar *) "field", NULL); xmlNewProp(field_node, (xmlChar *) "name", (xmlChar *) doc_field_name); /* Loop through all the values for this field */ while(doc_field_value != NULL) { xmlChar *escaped_field_value = xmlEncodeEntitiesReentrant(doc_ptr, (xmlChar *) doc_field_value->field_value); xmlNewChild(field_node, NULL, (xmlChar *) "field_value", escaped_field_value); /* Release the memory allocated by xmlEncodeEntitiesReentrant */ xmlFree(escaped_field_value); /* Grab the next value for this field if any */ doc_field_value = doc_field_value->next; } /* while(doc_field_value != NULL) */ } /* SOLR_HASHTABLE_FOR_LOOP(document_fields) */ xmlIndentTreeOutput = 1; xmlDocDumpFormatMemoryEnc(doc_ptr, buffer, size, "UTF-8", format); xmlFreeDoc(doc_ptr); } /* }}} */ /* {{{ static void solr_unserialize_document_field(HashTable *document_fields, xmlNode *field_node TSRMLS_DC) */ static void solr_unserialize_document_field(HashTable *document_fields, xmlNode *field_node TSRMLS_DC) { solr_char_t *field_name = NULL; xmlNode *xml_curr_value = NULL; solr_field_list_t *field_values = (solr_field_list_t *) pemalloc(sizeof(solr_field_list_t), SOLR_DOCUMENT_FIELD_PERSISTENT); memset(field_values, 0, sizeof(solr_field_list_t)); field_name = (solr_char_t *) solr_xml_get_node_contents(field_node->properties); field_values->count = 0L; field_values->field_boost = 0.0f; field_values->field_name = (solr_char_t *) pestrdup(field_name, SOLR_DOCUMENT_FIELD_PERSISTENT); field_values->head = NULL; field_values->last = NULL; /* Grab the first field node */ xml_curr_value = field_node->children; /* Looping through all the field_value nodes */ while(xml_curr_value != NULL) { /* No assumptions. It must be the field value nodes */ if (xml_curr_value->type == XML_ELEMENT_NODE && solr_xml_match_node(xml_curr_value, "field_value")) { solr_char_t *field_value = (solr_char_t *) solr_xml_get_node_contents(xml_curr_value); /* Add this value to the list of values */ if (solr_document_insert_field_value(field_values, field_value, 0.0f) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error adding field value during SolrDocument unserialization"); } } /* Move to the next field_value */ xml_curr_value = xml_curr_value->next; } /* All the values have been retrieved for this field. Now let's drop the field in the HashTable */ if (zend_hash_add(document_fields, field_name, strlen(field_name), (void *) &field_values, sizeof(solr_field_list_t *), (void **) NULL) == FAILURE) { solr_destroy_field_list(&field_values); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error adding field values to HashTable during SolrDocument unserialization"); return; } } /* }}} */ /* {{{ static int solr_unserialize_child_documents(xmlDoc *doc, solr_document_t *doc_entry TSRMLS_DC) * 1. retrieve doc hashes * 2. base64_decode * 3. unserialize (call php method) * 4. add child to solr_doc_t.children */ static int solr_unserialize_child_documents(xmlDoc *doc, solr_document_t *doc_entry TSRMLS_DC) { xmlXPathContext *xp_ctx = NULL; xmlXPathObject *xp_obj = NULL; xmlNodeSet *result = NULL; xmlChar *hash, *xp_expression; int num_nodes = 0, idx = 0, hash_len = 0; /* unserialize vars */ php_unserialize_data_t var_hash; zval *solr_doc_zv = NULL; xp_expression = (xmlChar *)"/solr_document/child_docs/dochash"; xp_ctx = xmlXPathNewContext(doc); xp_obj = xmlXPathEvalExpression(xp_expression, xp_ctx); result = xp_obj->nodesetval; num_nodes = result->nodeNr; if (num_nodes > 0) { for (;idx < num_nodes; idx++) { char *sdoc; /* serialized document string */ unsigned char *sdoc_copy, *str_end; hash = result->nodeTab[idx]->children->content; sdoc = (char *)php_base64_decode((const unsigned char*)hash, strlen((char *)hash), &hash_len); memset(&var_hash, 0, sizeof(php_unserialize_data_t)); PHP_VAR_UNSERIALIZE_INIT(var_hash); MAKE_STD_ZVAL(solr_doc_zv); sdoc_copy = (unsigned char *)strdup(sdoc); efree(sdoc); str_end = (unsigned char *) (sdoc_copy + strlen((const char *)sdoc_copy)); if (!php_var_unserialize(&solr_doc_zv, (const unsigned char **)&sdoc_copy, str_end, &var_hash TSRMLS_CC)){ PHP_VAR_UNSERIALIZE_DESTROY(var_hash); php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to unserialize child document"); xmlXPathFreeContext(xp_ctx); xmlXPathFreeObject(xp_obj); return FAILURE; } if (zend_hash_next_index_insert(doc_entry->children, &solr_doc_zv, sizeof(zval *), NULL) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to add child document to parent document post-unserialize"); } PHP_VAR_UNSERIALIZE_DESTROY(var_hash); } } xmlXPathFreeContext(xp_ctx); xmlXPathFreeObject(xp_obj); return SUCCESS; } /* }}} */ static int solr_unserialize_document_fields(xmlDoc *doc, HashTable *document_fields TSRMLS_DC) { xmlXPathContext *xpathctxt = NULL; xmlChar *xpath_expression = NULL; xmlXPathObject *xpathObj = NULL; xmlNodeSet *result = NULL; register size_t num_nodes = 0U; register size_t i = 0U; xpathctxt = xmlXPathNewContext(doc); if (!xpathctxt) { xmlFreeDoc(doc); php_error_docref(NULL TSRMLS_CC, E_WARNING, "A valid XML xpath context could not be created"); return FAILURE; } xpath_expression = (xmlChar *) "/solr_document/fields/field/@name"; xpathObj = xmlXPathEval(xpath_expression, xpathctxt); if (!xpathObj) { xmlXPathFreeContext(xpathctxt); xmlFreeDoc(doc); php_error_docref(NULL TSRMLS_CC, E_WARNING, "A valid XML xpath object could not be created from the expression"); return FAILURE; } result = xpathObj->nodesetval; if (!result) { xmlXPathFreeContext(xpathctxt); xmlXPathFreeObject(xpathObj); xmlFreeDoc(doc); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Document has no fields"); return FAILURE; } num_nodes = result->nodeNr; i = 0U; if (!num_nodes) { xmlXPathFreeContext(xpathctxt); xmlXPathFreeObject(xpathObj); xmlFreeDoc(doc); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Document has no fields"); return FAILURE; } for (i = 0U; i < num_nodes; i++) { xmlNode *currNode = result->nodeTab[i]; /* Absolutely No assumptions. I have to make sure that this is the name attribute */ if (currNode->type == XML_ATTRIBUTE_NODE && solr_xml_match_node(currNode, "name")) { /* Get the field node */ xmlNode *field_xml_node = currNode->parent; /* Retrieve all the values for this field and put them in the HashTable */ solr_unserialize_document_field(document_fields, field_xml_node TSRMLS_CC); } } xmlXPathFreeContext(xpathctxt); xmlXPathFreeObject(xpathObj); return SUCCESS; } /* {{{ static int solr_unserialize_document_object(HashTable *document_fields, char *serialized, int size TSRMLS_DC) */ static int solr_unserialize_document_object(solr_document_t *doc_entry, char *serialized, int size TSRMLS_DC) { xmlDoc *doc = NULL; doc = xmlReadMemory(serialized, size, NULL, "UTF-8", 0); if (!doc) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "The serialized document string is invalid"); return FAILURE; } if (solr_unserialize_document_fields(doc, doc_entry->fields TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to unserialize document fields"); return FAILURE; } if (solr_unserialize_child_documents(doc, doc_entry TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to unserialize document fields"); return FAILURE; } xmlFreeDoc(doc); return SUCCESS; } /* }}} */ /* {{{ proto void SolrDocument::__construct(void) SolrDocument constructor */ PHP_METHOD(SolrDocument, __construct) { zval *objptr = getThis(); ulong document_index = SOLR_UNIQUE_DOCUMENT_INDEX(); if (solr_init_document(document_index TSRMLS_CC) == NULL) { return; } /* Set the value of the internal id property */ zend_update_property_long(solr_ce_SolrDocument, objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, document_index TSRMLS_CC); /* Overriding the default object handlers */ Z_OBJ_HT_P(objptr) = &solr_input_document_object_handlers; } /* }}} */ /* {{{ proto void SolrDocument::__destruct(void) Destructor for SolrDocument */ PHP_METHOD(SolrDocument, __destruct) { solr_document_t *doc_entry = NULL; /* Retrieve the document entry for this SolrDocument */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { zend_hash_index_del(SOLR_GLOBAL(documents), doc_entry->document_index); /* Keep track of how many SolrDocument instances we currently have */ SOLR_GLOBAL(document_count)--; return ; } } /* }}} */ /* {{{ proto SolrDocument::__clone(void) Clone method for SolrDocument */ PHP_METHOD(SolrDocument, __clone) { zval *objptr = getThis(); solr_document_t new_solr_doc; solr_document_t *new_doc_entry = NULL, *old_doc_entry = NULL; ulong document_index = SOLR_UNIQUE_DOCUMENT_INDEX(); memset(&new_solr_doc, 0, sizeof(solr_document_t)); new_doc_entry = &new_solr_doc; /* Retrieve the document entry for the original SolrDocument */ if (solr_fetch_document_entry(objptr, &old_doc_entry TSRMLS_CC) == FAILURE) { return ; } /* Duplicate the doc_entry contents */ memcpy(new_doc_entry, old_doc_entry, sizeof(solr_document_t)); /* Override the document index with a new one and create a new HashTable */ new_doc_entry->document_index = document_index; /* Allocate new memory for the fields HashTable, using fast cache for HashTables */ ALLOC_HASHTABLE(new_doc_entry->fields); ALLOC_HASHTABLE(new_doc_entry->children); /* Initializing the hash table used for storing fields in this SolrDocument */ zend_hash_init(new_doc_entry->fields, old_doc_entry->fields->nTableSize, NULL, (dtor_func_t) solr_destroy_field_list, SOLR_DOCUMENT_FIELD_PERSISTENT); zend_hash_init(new_doc_entry->children, old_doc_entry->children->nTableSize, NULL, ZVAL_PTR_DTOR, SOLR_DOCUMENT_FIELD_PERSISTENT); /* Copy the contents of the old fields HashTable to the new SolrDocument */ zend_hash_copy(new_doc_entry->fields, old_doc_entry->fields, (copy_ctor_func_t) field_copy_constructor, NULL, sizeof(solr_field_list_t *)); zend_hash_copy(new_doc_entry->children, old_doc_entry->children, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); /* Add the document entry to the directory of documents */ zend_hash_index_update(SOLR_GLOBAL(documents), document_index, (void *) new_doc_entry, sizeof(solr_document_t), NULL); /* Set the value of the internal id property */ zend_update_property_long(solr_ce_SolrDocument, objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, document_index TSRMLS_CC); /* Keep track of how many SolrDocument instances we currently have */ SOLR_GLOBAL(document_count)++; } /* }}} */ /* {{{ proto SolrDocument::__set(string fieldname, string field_value) Magic method for setting field names. */ PHP_METHOD(SolrDocument, __set) { solr_char_t *field_name = NULL; int field_name_length = 0; solr_char_t *field_value = NULL; int field_value_length = 0; /* Process the parameters passed to the method */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &field_name, &field_name_length, &field_value, &field_value_length) == FAILURE) { RETURN_FALSE; } if (solr_document_set_field(getThis(), field_name, field_name_length, field_value, field_value_length TSRMLS_CC) == SUCCESS) { RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto SolrDocumentField SolrDocument::__get(string fieldname) Magic method for getting a field. */ PHP_METHOD(SolrDocument, __get) { solr_char_t *field_name = NULL; int field_name_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (solr_document_get_field(getThis(), return_value, field_name, field_name_length TSRMLS_CC) == FAILURE) { RETURN_NULL(); } } /* }}} */ /* {{{ proto bool SolrDocument::__isset(string field_name) Checks if a field exists */ PHP_METHOD(SolrDocument, __isset) { solr_char_t *field_name = NULL; int field_name_length = 0; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (solr_document_field_exists(getThis(), field_name, field_name_length TSRMLS_CC) == SUCCESS) { RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto bool SolrDocument::__unset(string fieldname) Removes a field from the document. */ PHP_METHOD(SolrDocument, __unset) { solr_char_t *field_name = NULL; int field_name_length = 0; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (solr_document_remove_field(getThis(), field_name, field_name_length TSRMLS_CC) == SUCCESS) { RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto void SolrDocument::offsetSet(string field_name, string field_value) Sets the specified field in the document */ PHP_METHOD(SolrDocument, offsetSet) { solr_char_t *field_name = NULL; int field_name_length = 0; solr_char_t *field_value = NULL; int field_value_length = 0; /* Process the parameters passed to the method */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &field_name, &field_name_length, &field_value, &field_value_length) == FAILURE) { return; } if (solr_document_set_field(getThis(), field_name, field_name_length, field_value, field_value_length TSRMLS_CC) == SUCCESS) { return; } } /* }}} */ /* {{{ proto SolrDocumentField SolrDocument::offsetGet(string field_name) Returns the request field. */ PHP_METHOD(SolrDocument, offsetGet) { solr_char_t *field_name = NULL; int field_name_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (solr_document_get_field(getThis(), return_value, field_name, field_name_length TSRMLS_CC) == FAILURE) { RETURN_NULL(); } } /* }}} */ /* {{{ proto bool SolrDocument::offsetExists(string fieldname) Checks if the request field exists in the document */ PHP_METHOD(SolrDocument, offsetExists) { solr_char_t *field_name = NULL; int field_name_length = 0; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (solr_document_field_exists(getThis(), field_name, field_name_length TSRMLS_CC) == SUCCESS) { RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto void SolrDocument::offsetUnset(string fieldname) Removes the specified field from the document */ PHP_METHOD(SolrDocument, offsetUnset) { solr_char_t *field_name = NULL; int field_name_length = 0; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { return; } if (solr_document_remove_field(getThis(), field_name, field_name_length TSRMLS_CC) == SUCCESS) { return; } } /* }}} */ /* {{{ proto void SolrDocument::rewind(void) Resets the internal pointer. */ PHP_METHOD(SolrDocument, rewind) { solr_document_t *doc_entry = NULL; HashTable *doc_fields = NULL; if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == FAILURE) { return; } doc_fields = doc_entry->fields; zend_hash_internal_pointer_reset(doc_fields); } /* }}} */ /* {{{ proto SolrDocumentField SolrDocument::current(void) Retrieves the current field. */ PHP_METHOD(SolrDocument, current) { solr_document_t *doc_entry = NULL; HashTable *doc_fields = NULL; solr_field_list_t **field_values = NULL; if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == FAILURE) { return; } doc_fields = doc_entry->fields; zend_hash_get_current_data_ex(doc_fields, (void **) &field_values, NULL); if(field_values && *field_values ) { solr_create_document_field_object(*field_values, &return_value TSRMLS_CC); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrDocument::key(void) Retrieves the current key. */ PHP_METHOD(SolrDocument, key) { solr_document_t *doc_entry = NULL; char *fieldname = NULL; uint fieldname_length = 0U; ulong num_index = 0L; HashTable *doc_fields = NULL; register zend_bool duplicate = 0; if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == FAILURE) { return; } doc_fields = doc_entry->fields; zend_hash_get_current_key_ex(doc_fields, &fieldname, &fieldname_length, &num_index, duplicate, NULL); RETURN_STRINGL(fieldname, fieldname_length, 1); } /* }}} */ /* {{{ proto void SolrDocument::next(void) Moves the internal pointer to the next field. */ PHP_METHOD(SolrDocument, next) { solr_document_t *doc_entry = NULL; HashTable *doc_fields = NULL; if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == FAILURE) { return; } doc_fields = doc_entry->fields; zend_hash_move_forward(doc_fields); } /* }}} */ /* {{{ proto bool SolrDocument::valid(void) Checks if the current internal pointer position is still valid. */ PHP_METHOD(SolrDocument, valid) { solr_document_t *doc_entry = NULL; HashTable *doc_fields = NULL; zend_bool is_valid = 0; if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == FAILURE) { return; } doc_fields = doc_entry->fields; is_valid = (zend_bool) ( SUCCESS == zend_hash_has_more_elements(doc_fields) ); RETURN_BOOL(is_valid); } /* }}} */ /* {{{ proto string SolrDocument::serialize(void) Custom SolrDocument serializer. Returns an XML document string representing the object. */ PHP_METHOD(SolrDocument, serialize) { solr_document_t *doc_entry = NULL; HashTable *doc_fields = NULL; char *serialized = NULL; int size = 0; /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == FAILURE) { RETURN_NULL(); } doc_fields = doc_entry->fields; solr_serialize_document_object(doc_fields, (xmlChar **) &serialized, &size TSRMLS_CC); if (size) { RETVAL_STRINGL(serialized, size, 1); xmlFree(serialized); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto void SolrDocument::unserialize(string serialized_xml) Custom SolrDocument unserializer. Brings the object back to life. */ PHP_METHOD(SolrDocument, unserialize) { solr_char_t *serialized = NULL; int serialized_length = 0; zval *objptr = getThis(); ulong document_index = SOLR_UNIQUE_DOCUMENT_INDEX(); uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE; solr_document_t solr_doc; solr_document_t *doc_entry = NULL, *doc_ptr = NULL; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &serialized, &serialized_length) == FAILURE) { RETURN_FALSE; } memset(&solr_doc, 0, sizeof(solr_document_t)); doc_entry = &solr_doc; doc_entry->document_index = document_index; doc_entry->field_count = 0L; doc_entry->document_boost = 0; /* Allocated memory for the fields HashTable using fast cache for HashTables */ ALLOC_HASHTABLE(doc_entry->fields); ALLOC_HASHTABLE(doc_entry->children); /* Initializing the hash table used for storing fields in this SolrDocument */ zend_hash_init(doc_entry->fields, nSize, NULL, (dtor_func_t) solr_destroy_field_list, SOLR_DOCUMENT_FIELD_PERSISTENT); zend_hash_init(doc_entry->children, nSize, NULL, ZVAL_PTR_DTOR, SOLR_DOCUMENT_FIELD_PERSISTENT); /* Let's check one more time before insert into the HashTable */ if (zend_hash_index_exists(SOLR_GLOBAL(documents), document_index)) { pefree(doc_entry->fields, SOLR_DOCUMENT_FIELD_PERSISTENT); return; } /* Add the document entry to the directory of documents */ zend_hash_index_update(SOLR_GLOBAL(documents), document_index, (void *) doc_entry, sizeof(solr_document_t), (void **) &doc_ptr); /* Set the value of the internal id property */ zend_update_property_long(solr_ce_SolrDocument, objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, document_index TSRMLS_CC); /* Keep track of how many SolrDocument instances we currently have */ SOLR_GLOBAL(document_count)++; /* Overriding the default object handlers */ Z_OBJ_HT_P(objptr) = &solr_input_document_object_handlers; if (solr_unserialize_document_object(doc_ptr, serialized, serialized_length TSRMLS_CC) == FAILURE) { return; } doc_ptr->field_count = zend_hash_num_elements(doc_ptr->fields); } /* }}} */ /* {{{ proto bool SolrDocument::clear(void) Resets the current object. Discards all the fields and resets the document boost to zero. */ PHP_METHOD(SolrDocument, clear) { solr_document_t *doc_entry = NULL; if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { doc_entry->document_boost = 0.0; doc_entry->field_count = 0L; zend_hash_clean(doc_entry->fields); RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto bool SolrDocument::addField(string fieldname, string value) Adds a field to the document */ PHP_METHOD(SolrDocument, addField) { solr_char_t *field_name = NULL; int field_name_length = 0; solr_char_t *field_value = NULL; int field_value_length = 0; /* Process the parameters passed to the method */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &field_name, &field_name_length, &field_value, &field_value_length) == FAILURE) { RETURN_FALSE; } if (solr_document_set_field(getThis(), field_name, field_name_length, field_value, field_value_length TSRMLS_CC) == SUCCESS) { RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto array SolrDocument::getFieldNames(void) Returns an array of fields names in the document. */ PHP_METHOD(SolrDocument, getFieldNames) { solr_document_t *doc_entry = NULL; /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { HashTable *fields_ht = NULL; register zend_bool duplicate = 0; array_init(return_value); fields_ht = doc_entry->fields; SOLR_HASHTABLE_FOR_LOOP(fields_ht) { char *fieldname = NULL; uint fieldname_length = 0U; ulong num_index = 0L; solr_field_list_t **field = NULL; zend_bool duplicate_field_name = 1; zend_hash_get_current_key_ex(fields_ht, &fieldname, &fieldname_length, &num_index, duplicate, NULL); zend_hash_get_current_data_ex(fields_ht, (void **) &field, NULL); add_next_index_stringl(return_value, (*field)->field_name, fieldname_length, duplicate_field_name); } /* We are done */ return; } RETURN_FALSE; } /* }}} */ /* {{{ proto int SolrDocument::getFieldCount(void) Returns the number of fields in this document. Multi-value fields are only counted once. */ PHP_METHOD(SolrDocument, getFieldCount) { solr_document_t *doc_entry = NULL; /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { RETURN_LONG(zend_hash_num_elements(doc_entry->fields)); } RETURN_FALSE; } /* }}} */ /* {{{ proto SolrDocumentField SolrDocument::getField(string fieldname) Retrieves the requested field */ PHP_METHOD(SolrDocument, getField) { solr_char_t *field_name = NULL; int field_name_length = 0; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (solr_document_get_field(getThis(), return_value, field_name, field_name_length TSRMLS_CC) == FAILURE) { RETURN_FALSE; } } /* }}} */ /* {{{ proto array SolrDocument::toArray(void) Returns an array representation of the SolrDocument object. */ PHP_METHOD(SolrDocument, toArray) { solr_document_t *doc_entry = NULL; zval *fields_array = NULL; /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { HashTable *fields_ht; register zend_bool duplicate = 0; MAKE_STD_ZVAL(fields_array); array_init(return_value); array_init(fields_array); add_assoc_double(return_value, "document_boost", doc_entry->document_boost); add_assoc_long(return_value, "field_count", doc_entry->field_count); add_assoc_zval(return_value, "fields", fields_array); fields_ht = doc_entry->fields; SOLR_HASHTABLE_FOR_LOOP(fields_ht) { solr_char_t *fieldname = NULL; uint fieldname_length = 0U; ulong num_index = 0L; solr_field_list_t **field = NULL; zval *current_field = NULL; MAKE_STD_ZVAL(current_field); zend_hash_get_current_key_ex(fields_ht, (char **) &fieldname, &fieldname_length, &num_index, duplicate, NULL); zend_hash_get_current_data_ex(fields_ht, (void **) &field, NULL); solr_create_document_field_object(*field, ¤t_field TSRMLS_CC); add_next_index_zval(fields_array, current_field); } /* We are done */ return; } RETURN_FALSE; } /* }}} */ /* {{{ proto bool SolrDocument::fieldExists(string fieldname) Checks if the field exists. */ PHP_METHOD(SolrDocument, fieldExists) { solr_char_t *field_name = NULL; int field_name_length = 0; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (solr_document_field_exists(getThis(), field_name, field_name_length TSRMLS_CC) == SUCCESS) { RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto bool SolrDocument::deleteField(string field_name) Removes the requested field. */ PHP_METHOD(SolrDocument, deleteField) { solr_char_t *field_name = NULL; int field_name_length = 0; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (solr_document_remove_field(getThis(), field_name, field_name_length TSRMLS_CC) == SUCCESS) { RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto bool SolrDocument::sort(int sort_criterion [, int sort_direction]) Sorts the fields in the document */ PHP_METHOD(SolrDocument, sort) { long int order_by = 0L; long int sort_direction = SOLR_SORT_ASC; solr_document_t *doc_entry = NULL; int renumber = 0; /* The pointer to the comparison function used by zend_qsort */ compare_func_t comparison_function = (compare_func_t) NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &order_by, &sort_direction) == FAILURE) { RETURN_FALSE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == FAILURE) { RETURN_FALSE; } /* {{{ Select the appropriate comparison function */ switch(order_by) { case SOLR_SORT_FIELD_NAME : /* Sorting by field name */ { switch(sort_direction) { case SOLR_SORT_ASC : comparison_function = solr_compare_field_name; break; case SOLR_SORT_DESC : comparison_function = solr_rcompare_field_name; break; } } break; /* case SOLR_SORT_FIELD_NAME */ case SOLR_SORT_FIELD_VALUE_COUNT : /* Sorting by number of values per field */ { switch(sort_direction) { case SOLR_SORT_ASC : comparison_function = solr_compare_field_value_count; break; case SOLR_SORT_DESC : comparison_function = solr_rcompare_field_value_count; break; } } break; /* case SOLR_SORT_FIELD_VALUE_COUNT */ case SOLR_SORT_FIELD_BOOST_VALUE : /* Sorting by field boost values */ { switch(sort_direction) { case SOLR_SORT_ASC : comparison_function = solr_compare_field_boost_value; break; case SOLR_SORT_DESC : comparison_function = solr_rcompare_field_boost_value; break; } } break; /* case SOLR_SORT_FIELD_BOOST_VALUE */ default : /* Undefined sort criteria */ RETURN_FALSE; break; } /* }}} switch(order_by) */ /* Undefined sort direction. It was not ASC or DESC */ if (!comparison_function) { RETURN_FALSE; } if (zend_hash_sort(doc_entry->fields, zend_qsort, comparison_function, renumber TSRMLS_CC) == FAILURE) { RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* {{{ proto bool SolrDocument::merge(SolrDocument source [, bool override]) Merges source to the current SolrDocument. */ PHP_METHOD(SolrDocument, merge) { solr_document_t *destination_document = NULL; solr_document_t *source_document = NULL; copy_ctor_func_t p_copy_ctor = (copy_ctor_func_t) field_copy_constructor; /* The destination SolrDocument instance */ zval *destination_document_zval = getThis(); /* The source SolrDocument instance */ zval *source_document_zval = NULL; /* Should we skip fields that already exist in destination */ zend_bool overwrite = (zend_bool) 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|b", &source_document_zval, solr_ce_SolrDocument, &overwrite) == FAILURE) { RETURN_FALSE; } if (solr_fetch_document_entry(source_document_zval, &source_document TSRMLS_CC) == FAILURE) { RETURN_FALSE; } if (solr_fetch_document_entry(destination_document_zval, &destination_document TSRMLS_CC) == FAILURE) { RETURN_FALSE; } if (zend_hash_num_elements(source_document->fields) == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Source SolrDocument has no fields. Source"); RETURN_FALSE; } /* Copy the fields in the source HashTable to the destination HashTable */ zend_hash_merge(destination_document->fields, source_document->fields, p_copy_ctor, NULL, sizeof(solr_field_list_t *), (int) overwrite); /* Update the field count */ destination_document->field_count = (uint) zend_hash_num_elements(destination_document->fields); RETURN_TRUE; } /* }}} */ static void solr_add_child_input_documents_from_documents(HashTable * children, solr_document_t *new_doc_entry TSRMLS_DC) { SOLR_HASHTABLE_FOR_LOOP(children) { zval *solr_input_doc = NULL; zval **solr_doc = NULL; zend_hash_get_current_data_ex(children, (void **)&solr_doc, (HashPosition *) 0); zend_call_method_with_0_params(solr_doc, Z_OBJCE_PP(solr_doc), NULL, "getinputdocument", &solr_input_doc); if (zend_hash_next_index_insert(new_doc_entry->children, &solr_input_doc, sizeof (zval *), NULL) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to convert child SolrDocument to SolrInputDocument"); } } } /* {{{ proto SolrInputDocument SolrDocument::getInputDocument(void) Returns a SolrInputDocument equivalent of the object. */ PHP_METHOD(SolrDocument, getInputDocument) { zval *objptr = getThis(); zval *input_objptr = (*return_value_ptr); solr_document_t new_solr_doc; solr_document_t *new_doc_entry = NULL, *old_doc_entry = NULL; ulong document_index = SOLR_UNIQUE_DOCUMENT_INDEX(); if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "SolrInputDocument object requested without processing output."); return; } memset(&new_solr_doc, 0, sizeof(solr_document_t)); new_doc_entry = &new_solr_doc; /* Retrieve the document entry for the original SolrDocument */ if (solr_fetch_document_entry(objptr, &old_doc_entry TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "SolrDocument could not be fetched."); return; } object_init_ex(input_objptr, solr_ce_SolrInputDocument); /* Duplicate the doc_entry contents */ memcpy(new_doc_entry, old_doc_entry, sizeof(solr_document_t)); /* Override the document index with a new one and create a new HashTable */ new_doc_entry->document_index = document_index; /* Allocate new memory for the fields HashTable, using fast cache for HashTables */ ALLOC_HASHTABLE(new_doc_entry->fields); ALLOC_HASHTABLE(new_doc_entry->children); /* Initializing the hash table used for storing fields in this SolrDocument */ zend_hash_init(new_doc_entry->fields, old_doc_entry->fields->nTableSize, NULL, (dtor_func_t) solr_destroy_field_list, SOLR_DOCUMENT_FIELD_PERSISTENT); zend_hash_init(new_doc_entry->children, old_doc_entry->children->nTableSize, NULL, ZVAL_PTR_DTOR, SOLR_DOCUMENT_FIELD_PERSISTENT); /* Copy the contents of the old fields HashTable to the new SolrDocument */ zend_hash_copy(new_doc_entry->fields, old_doc_entry->fields, (copy_ctor_func_t) field_copy_constructor, NULL, sizeof(solr_field_list_t *)); /* call getInputDocument on each child SolrDocument and store children */ if (zend_hash_num_elements(old_doc_entry->children) > 0) { solr_add_child_input_documents_from_documents(old_doc_entry->children, new_doc_entry TSRMLS_CC); } /* Add the document entry to the directory of documents */ zend_hash_index_update(SOLR_GLOBAL(documents), document_index, (void *) new_doc_entry, sizeof(solr_document_t), NULL); /* Set the value of the internal id property */ zend_update_property_long(solr_ce_SolrInputDocument, input_objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, document_index TSRMLS_CC); /* Keep track of how many SolrDocument instances we currently have */ SOLR_GLOBAL(document_count)++; } /* }}} */ /* {{{ proto array SolrInputDocument::getChildDocuments( void ) Returns child documents or null if none */ PHP_METHOD(SolrDocument, getChildDocuments) { solr_document_t *solr_doc = NULL; if (solr_fetch_document_entry(getThis(), &solr_doc TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to fetch document entry for current object"); return; } if (zend_hash_num_elements(solr_doc->children) > 0) { array_init(return_value); zend_hash_init(Z_ARRVAL_P(return_value), zend_hash_num_elements(solr_doc->children), NULL, ZVAL_PTR_DTOR, 0); zend_hash_copy(Z_ARRVAL_P(return_value), solr_doc->children, (copy_ctor_func_t)zval_add_ref, NULL, sizeof(zval *)); } } /* }}} */ /* {{{ proto bool SolrInputDocument::hasChildDocuments( void ) Checks whether this document has child documents */ PHP_METHOD(SolrDocument, hasChildDocuments) { solr_document_t *solr_doc = NULL; if (solr_fetch_document_entry(getThis(), &solr_doc TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to fetch document entry for current object"); return; } if (zend_hash_num_elements(solr_doc->children) > 0) { RETURN_TRUE; } else { RETURN_FALSE; } } /* }}} */ /* {{{ proto int SolrInputDocument::getChildDocumentsCount( void ) Returns the number of child documents */ PHP_METHOD(SolrDocument, getChildDocumentsCount) { solr_document_t *solr_doc = NULL; if (solr_fetch_document_entry(getThis(), &solr_doc TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to fetch document entry for current object"); return; } Z_TYPE_P(return_value) = IS_LONG; Z_LVAL_P(return_value) = zend_hash_num_elements(solr_doc->children); } /* }}} */ /* {{{ proto SolrDocumentField::__construct(void) Constructor */ PHP_METHOD(SolrDocumentField, __construct) { Z_OBJ_HT_P(getThis()) = &solr_document_field_handlers; } /* }}} */ /* {{{ proto SolrDocumentField::__destruct(void) Destructor */ PHP_METHOD(SolrDocumentField, __destruct) { } /* }}} */ /* {{{ PHP_SOLR_API void solr_document_field_write_property(zval *object, zval *member, zval *value TSRMLS_DC) */ #if PHP_VERSION_ID < 50399 PHP_SOLR_API void solr_document_field_write_property(zval *object, zval *member, zval *value TSRMLS_DC) #else PHP_SOLR_API void solr_document_field_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC) #endif { solr_throw_exception(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1007_MSG, SOLR_ERROR_1007 TSRMLS_CC, SOLR_FILE_LINE_FUNC); /* if (Z_TYPE_P(member) == IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempting to set value for [%s] property in a SolrDocumentField instance", Z_STRVAL_P(member)); } */ } /* }}} */ /* {{{ PHP_SOLR_API void solr_document_field_unset_property(zval *object, zval *member TSRMLS_DC) */ #if PHP_VERSION_ID < 50399 PHP_SOLR_API void solr_document_field_unset_property(zval *object, zval *member TSRMLS_DC) #else PHP_SOLR_API void solr_document_field_unset_property(zval *object, zval *member, const zend_literal *key TSRMLS_DC) #endif { solr_throw_exception(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1007_MSG, SOLR_ERROR_1007 TSRMLS_CC, SOLR_FILE_LINE_FUNC); /* if (Z_TYPE_P(member) == IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempting to remove [%s] property in a SolrDocumentField instance", Z_STRVAL_P(member)); } */ } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/php_solr_exception.c0000644000175000017500000001571512676753706016721 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* {{{ static void solr_prepare_internal_info(zval *objptr, zval *return_value TSRMLS_DC) */ static void solr_prepare_internal_info(zval *objptr, zval *return_value TSRMLS_DC) { zval *line_no = zend_read_property(Z_OBJCE_P(objptr), objptr, SOLR_SOURCELINE_NO_PROPERTY_NAME, sizeof(SOLR_SOURCELINE_NO_PROPERTY_NAME)-1, 0 TSRMLS_CC); zval *solr_file = zend_read_property(Z_OBJCE_P(objptr), objptr, SOLR_SOURCEFILE_PROPERTY_NAME, sizeof(SOLR_SOURCEFILE_PROPERTY_NAME)-1, 0 TSRMLS_CC); zval *solr_zif_name = zend_read_property(Z_OBJCE_P(objptr), objptr, SOLR_ZIFNAME_PROPERTY_NAME, sizeof(SOLR_ZIFNAME_PROPERTY_NAME)-1, 0 TSRMLS_CC); long int source_line = Z_LVAL_P(line_no); char *solr_source_file = Z_STRVAL_P(solr_file); char *solr_zifname = Z_STRVAL_P(solr_zif_name); array_init(return_value); add_assoc_long(return_value, SOLR_SOURCELINE_NO_PROPERTY_NAME, source_line); add_assoc_string(return_value, SOLR_SOURCEFILE_PROPERTY_NAME, solr_source_file, 1); add_assoc_string(return_value, SOLR_ZIFNAME_PROPERTY_NAME, solr_zifname, 1); } /* }}} */ /* {{{ void solr_throw_exception_ex(zend_class_entry *exception_ce, long code TSRMLS_DC, const char *filename, int file_line, const char *function_name, char *format, ...) */ PHP_SOLR_API void solr_throw_exception_ex(zend_class_entry *exception_ce, long code TSRMLS_DC, const char *filename, int file_line, const char *function_name, char *format, ...) { char *message = NULL; #ifdef SOLR_ZEND_ENGINE_2_2 size_t max_buffer_len = 2048; /* This should be sufficient to hold the buffer */ #endif zval *objptr = NULL; va_list args; va_start(args,format); /* If this is PHP 5.2.x, since ap_php_vasprintf is only present in 5.3 */ #ifdef SOLR_ZEND_ENGINE_2_2 /* Allocate max_buffer_len bytes to hold the buffer */ message = (char *) malloc( sizeof(char) * max_buffer_len); memset(message, 0, sizeof(char) * max_buffer_len); ap_php_vslprintf(message, max_buffer_len, format, args); #else /* Preparing the message string from the format and variable argument list, if any. */ ap_php_vasprintf(&message, format, args); #endif va_end(args); /* Retrieves the thrown object and updates the properties */ objptr = zend_throw_exception(exception_ce, message, code TSRMLS_CC); /* This is the line number in the source file where it was thrown */ zend_update_property_long(exception_ce, objptr, SOLR_SOURCELINE_NO_PROPERTY_NAME, sizeof(SOLR_SOURCELINE_NO_PROPERTY_NAME)-1, file_line TSRMLS_CC); /* This is the line source file where it was thrown */ zend_update_property_string(exception_ce, objptr, SOLR_SOURCEFILE_PROPERTY_NAME, sizeof(SOLR_SOURCEFILE_PROPERTY_NAME)-1, (char *) filename TSRMLS_CC); /* This is the C function where it was thrown */ zend_update_property_string(exception_ce, objptr, SOLR_ZIFNAME_PROPERTY_NAME, sizeof(SOLR_ZIFNAME_PROPERTY_NAME)-1, (char *) function_name TSRMLS_CC); /* message must be freed */ if (message != NULL) { free(message); } } /* }}} */ /* {{{ void solr_throw_exception(zend_class_entry *exception_ce, char *message, long code TSRMLS_DC, const char *filename, int file_line, const char *function_name) */ PHP_SOLR_API void solr_throw_exception(zend_class_entry *exception_ce, char *message, long code TSRMLS_DC, const char *filename, int file_line, const char *function_name) { /* Retrieves the thrown object and updates the properties */ zval *objptr = zend_throw_exception(exception_ce, message, code TSRMLS_CC); /* This is the line number in the source file where it was thrown */ zend_update_property_long(exception_ce, objptr, SOLR_SOURCELINE_NO_PROPERTY_NAME, sizeof(SOLR_SOURCELINE_NO_PROPERTY_NAME)-1, file_line TSRMLS_CC); /* This is the line source file where it was thrown */ zend_update_property_string(exception_ce, objptr, SOLR_SOURCEFILE_PROPERTY_NAME, sizeof(SOLR_SOURCEFILE_PROPERTY_NAME)-1, (char *) filename TSRMLS_CC); /* This is the C function where it was thrown */ zend_update_property_string(exception_ce, objptr, SOLR_ZIFNAME_PROPERTY_NAME, sizeof(SOLR_ZIFNAME_PROPERTY_NAME)-1, (char *) function_name TSRMLS_CC); } /* }}} */ /* Macro for preparing the return value array */ #define solr_exception_return_internal_info() { \ if (return_value_used) { \ solr_prepare_internal_info(getThis(), return_value TSRMLS_CC); \ } else { \ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Return value requested but output not processed."); \ } \ } /* {{{ proto array SolrException::getInternalInfo(void) Returns the internal API information where the exception was generated */ PHP_METHOD(SolrException, getInternalInfo) { solr_exception_return_internal_info() } /* }}} */ /* {{{ proto array SolrClientException::getInternalInfo(void) Returns the internal API information where the exception was generated */ PHP_METHOD(SolrClientException, getInternalInfo) { solr_exception_return_internal_info() } /* }}} */ /* {{{ proto array SolrIllegalOperationException::getInternalInfo(void) Returns the internal API information where the exception was generated */ PHP_METHOD(SolrIllegalOperationException, getInternalInfo) { solr_exception_return_internal_info() } /* }}} */ /* {{{ proto array SolrIllegalArgumentException::getInternalInfo(void) Returns the internal API information where the exception was generated */ PHP_METHOD(SolrIllegalArgumentException, getInternalInfo) { solr_exception_return_internal_info() } /* }}} */ /* {{{ proto array SolrServerException::getInternalInfo(void) Returns the internal API information where the exception was generated */ PHP_METHOD(SolrServerException, getInternalInfo) { solr_exception_return_internal_info() } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/php_solr_input_document.c0000644000175000017500000007054012676753706017755 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /** ************************************************************************ **/ /** DEFINITIONS FOR SOLR INPUT DOCUMENT METHODS **/ /** ************************************************************************ **/ /* {{{ proto void SolrInputDocument::__construct() SolrInputDocument constructor */ PHP_METHOD(SolrInputDocument, __construct) { zval *objptr = getThis(); uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE; ulong document_index = SOLR_UNIQUE_DOCUMENT_INDEX(); auto solr_document_t solr_doc; solr_document_t *doc_entry = NULL, *doc_ptr = NULL; memset(&solr_doc, 0, sizeof(solr_document_t)); doc_entry = &solr_doc; doc_entry->document_index = document_index; doc_entry->field_count = 0L; doc_entry->document_boost = 0.0f; /* Allocated memory for the fields HashTable using fast cache for HashTables */ ALLOC_HASHTABLE(doc_entry->fields); ALLOC_HASHTABLE(doc_entry->children); /* Initializing the hash table used for storing fields in this SolrDocument */ zend_hash_init(doc_entry->fields, nSize, NULL, (dtor_func_t) solr_destroy_field_list, SOLR_DOCUMENT_FIELD_PERSISTENT); zend_hash_init(doc_entry->children, nSize, NULL, ZVAL_PTR_DTOR, SOLR_DOCUMENT_FIELD_PERSISTENT); /* Let's check one more time before insert into the HashTable */ if (zend_hash_index_exists(SOLR_GLOBAL(documents), document_index)) { pefree(doc_entry->fields, SOLR_DOCUMENT_FIELD_PERSISTENT); pefree(doc_entry->children, SOLR_DOCUMENT_FIELD_PERSISTENT); return; } /* Add the document entry to the directory of documents */ zend_hash_index_update(SOLR_GLOBAL(documents), document_index, (void *) doc_entry, sizeof(solr_document_t), (void **) &doc_ptr); /* Set the value of the internal id property */ zend_update_property_long(solr_ce_SolrInputDocument, objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, document_index TSRMLS_CC); /* Keep track of how many SolrDocument instances we currently have */ SOLR_GLOBAL(document_count)++; /* Overriding the default object handlers */ Z_OBJ_HT_P(objptr) = &solr_input_document_object_handlers; } /* }}} */ /* {{{ proto void SolrInputDocument::__destruct(void) Destructor for SolrInputDocument */ PHP_METHOD(SolrInputDocument, __destruct) { solr_document_t *doc_entry = NULL; /* Retrieve the document entry for this SolrDocument */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { zend_hash_index_del(SOLR_GLOBAL(documents), doc_entry->document_index); /* Keep track of how many SolrDocument instances we currently have */ SOLR_GLOBAL(document_count)--; return ; } } /* }}} */ /* {{{ proto void SolrInputDocument::__clone(void) Clones the current object. Not to be called directly. */ PHP_METHOD(SolrInputDocument, __clone) { zval *objptr = getThis(); solr_document_t new_solr_doc; solr_document_t *new_doc_entry = NULL, *old_doc_entry = NULL; ulong document_index = SOLR_UNIQUE_DOCUMENT_INDEX(); memset(&new_solr_doc, 0, sizeof(solr_document_t)); new_doc_entry = &new_solr_doc; /* Retrieve the document entry for the original SolrDocument */ if (solr_fetch_document_entry(objptr, &old_doc_entry TSRMLS_CC) == FAILURE) { return ; } /* Duplicate the doc_entry contents */ memcpy(new_doc_entry, old_doc_entry, sizeof(solr_document_t)); /* Override the document index with a new one and create a new HashTable */ new_doc_entry->document_index = document_index; /* Allocate new memory for the fields HashTable, using fast cache for HashTables */ ALLOC_HASHTABLE(new_doc_entry->fields); ALLOC_HASHTABLE(new_doc_entry->children); /* Initializing the hash table used for storing fields in this SolrDocument */ zend_hash_init(new_doc_entry->fields, old_doc_entry->fields->nTableSize, NULL, (dtor_func_t) solr_destroy_field_list, SOLR_DOCUMENT_FIELD_PERSISTENT); zend_hash_init(new_doc_entry->children, old_doc_entry->children->nTableSize, NULL, ZVAL_PTR_DTOR, SOLR_DOCUMENT_FIELD_PERSISTENT); /* Copy the contents of the old fields HashTable to the new SolrDocument */ zend_hash_copy(new_doc_entry->fields, old_doc_entry->fields, (copy_ctor_func_t) field_copy_constructor, NULL, sizeof(solr_field_list_t *)); zend_hash_copy(new_doc_entry->children, old_doc_entry->children, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); /* Add the document entry to the directory of documents */ zend_hash_index_update(SOLR_GLOBAL(documents), document_index, (void *) new_doc_entry, sizeof(solr_document_t), NULL); /* Set the value of the internal id property */ zend_update_property_long(solr_ce_SolrInputDocument, objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, document_index TSRMLS_CC); /* Keep track of how many SolrDocument instances we currently have */ SOLR_GLOBAL(document_count)++; } /* }}} */ /* {{{ proto void SolrInputDocument::__sleep(void) Should not be called directly. Serialization is not supported. */ PHP_METHOD(SolrInputDocument, __sleep) { solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1005 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1005_MSG); } /* }}} */ /* {{{ proto void SolrInputDocument::__wakeup(void) Should not be called directly. Serialization is not supported. */ PHP_METHOD(SolrInputDocument, __wakeup) { solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1005 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1005_MSG); } /* }}} */ /* {{{ proto bool SolrInputDocument::setBoost(float document_boost) Sets the boost for the document. */ PHP_METHOD(SolrInputDocument, setBoost) { double boost_value = 0.0f; solr_document_t *doc_entry = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &boost_value) == FAILURE) { RETURN_FALSE; } /* If the submitted boost_value is negative. */ if (boost_value < 0.0) { RETURN_FALSE; } /* Retrieve the document entry for this SolrDocument */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { doc_entry->document_boost = boost_value; RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto float SolrInputDocument::getBoost(void) Retrieves the boost for the document. */ PHP_METHOD(SolrInputDocument, getBoost) { solr_document_t *doc_entry = NULL; if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { RETURN_DOUBLE(doc_entry->document_boost); } RETURN_FALSE; } /* }}} */ /* {{{ proto bool SolrInputDocument::clear(void) Discards all the fields and resets the document boost to zero. */ PHP_METHOD(SolrInputDocument, clear) { solr_document_t *doc_entry = NULL; if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { doc_entry->document_boost = 0.0; doc_entry->field_count = 0L; zend_hash_clean(doc_entry->fields); RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto bool SolrInputDocument::addField(string field_name, field_value [, float field_boost]) Adds a field to the document. Can be called multiple times. */ PHP_METHOD(SolrInputDocument, addField) { solr_char_t *field_name = NULL; int field_name_length = 0; solr_char_t *field_value = NULL; int field_value_length = 0; double field_boost = 0.0f; solr_document_t *doc_entry = NULL; /* Process the parameters passed to the method */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|d", &field_name, &field_name_length, &field_value, &field_value_length, &field_boost) == FAILURE) { RETURN_FALSE; } if (!field_name_length) { RETURN_FALSE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { solr_field_list_t **field_values_ptr = NULL; solr_field_list_t *field_values = NULL; /* If the field already exists in the SolrDocument instance append the value to the field list queue */ if (zend_hash_find(doc_entry->fields, field_name, field_name_length, (void **) &field_values_ptr) == SUCCESS) { if (solr_document_insert_field_value(*field_values_ptr, field_value, field_boost) == FAILURE) { RETURN_FALSE; } } else { /* Otherwise, create a new one and add it to the hash table */ field_values = (solr_field_list_t *) pemalloc(sizeof(solr_field_list_t), SOLR_DOCUMENT_FIELD_PERSISTENT); memset(field_values, 0, sizeof(solr_field_list_t)); field_values_ptr = &field_values; field_values->count = 0L; field_values->field_boost = 0.0; field_values->field_name = (solr_char_t *) pestrdup(field_name,SOLR_DOCUMENT_FIELD_PERSISTENT); field_values->head = NULL; field_values->last = NULL; if (solr_document_insert_field_value(field_values, field_value, field_boost) == FAILURE) { solr_destroy_field_list(&field_values); RETURN_FALSE; } if (zend_hash_add(doc_entry->fields, field_name, field_name_length, (void *) field_values_ptr, sizeof(solr_field_list_t *), (void **) NULL) == FAILURE) { solr_destroy_field_list(&field_values); RETURN_FALSE; } /* Increment field count only when HEAD is added */ doc_entry->field_count++; } RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto bool SolrInputDocument::setFieldBoost(string fieldname, float boost_value) Sets the boost for the specified field. */ PHP_METHOD(SolrInputDocument, setFieldBoost) { solr_char_t *field_name = NULL; int field_name_length = 0; double field_boost = 0.0; solr_document_t *doc_entry = NULL; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sd", &field_name, &field_name_length, &field_boost) == FAILURE) { RETURN_FALSE; } if (!field_name_length) { RETURN_FALSE; } if (field_boost < 0.0) { RETURN_FALSE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { solr_field_list_t **field_values = NULL; /* If the field already exists in the SolrDocument instance append the value to the field list queue */ if (zend_hash_find(doc_entry->fields, (char *) field_name, field_name_length, (void **) &field_values) == SUCCESS) { (*field_values)->field_boost = field_boost; RETURN_TRUE; } RETURN_FALSE; } RETURN_FALSE; } /* }}} */ /* {{{ proto float SolrInputDocument::getFieldBoost(string fieldname) Returns the boost value for the specified field. */ PHP_METHOD(SolrInputDocument, getFieldBoost) { solr_char_t *field_name = NULL; int field_name_length = 0; solr_document_t *doc_entry = NULL; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (!field_name_length) { RETURN_FALSE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { solr_field_list_t **field_values = NULL; if (zend_hash_find(doc_entry->fields, (char *) field_name, field_name_length, (void **) &field_values) == SUCCESS) { RETURN_DOUBLE((*field_values)->field_boost); } RETURN_FALSE; } RETURN_FALSE; } /* }}} */ /* {{{ proto array SolrInputDocument::getFieldNames(void) Returns an array of all the field names in the document. */ PHP_METHOD(SolrInputDocument, getFieldNames) { solr_document_t *doc_entry = NULL; /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { HashTable *fields_ht = doc_entry->fields; register zend_bool duplicate = 0; array_init(return_value); SOLR_HASHTABLE_FOR_LOOP(fields_ht) { char *fieldname = NULL; uint fieldname_length = 0U; ulong num_index = 0L; solr_field_list_t **field = NULL; zend_bool duplicate_field_name = 1; zend_hash_get_current_key_ex(fields_ht, &fieldname, &fieldname_length, &num_index, duplicate, NULL); zend_hash_get_current_data_ex(fields_ht, (void **) &field, NULL); add_next_index_string(return_value, (char *) (*field)->field_name, duplicate_field_name); } /* We are done */ return; } RETURN_FALSE; } /* }}} */ /* {{{ proto int SolrInputDocument::getFieldCount(void) Returns the number of fields in document. Multivalued fields are only counted once. */ PHP_METHOD(SolrInputDocument, getFieldCount) { solr_document_t *doc_entry = NULL; /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { RETURN_LONG(zend_hash_num_elements(doc_entry->fields)); } RETURN_FALSE; } /* }}} */ /* {{{ proto SolrDocumentField SolrInputDocument::getField(string fieldname) Returns the requested field. */ PHP_METHOD(SolrInputDocument, getField) { solr_char_t *field_name = NULL; int field_name_length = 0; solr_document_t *doc_entry = NULL; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (!field_name_length) { RETURN_FALSE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { solr_field_list_t **field_values = NULL; if (zend_hash_find(doc_entry->fields, (char *)field_name, field_name_length, (void **) &field_values) == SUCCESS) { solr_create_document_field_object(*field_values, &return_value TSRMLS_CC); /* The field was retrieved, so we're done here */ return ; } RETURN_FALSE; } RETURN_FALSE; } /* }}} */ /* {{{ proto array SolrInputDocument::toArray(void) Returns an array representation of the object. */ PHP_METHOD(SolrInputDocument, toArray) { solr_document_t *doc_entry = NULL; zval *fields_array = NULL; /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { register zend_bool duplicate = 0; HashTable *fields_ht; MAKE_STD_ZVAL(fields_array); array_init(return_value); array_init(fields_array); add_assoc_double(return_value, "document_boost", doc_entry->document_boost); add_assoc_long(return_value, "field_count", doc_entry->field_count); add_assoc_zval(return_value, "fields", fields_array); fields_ht = doc_entry->fields; SOLR_HASHTABLE_FOR_LOOP(fields_ht) { solr_char_t *fieldname = NULL; uint fieldname_length = 0U; ulong num_index = 0L; solr_field_list_t **field = NULL; zval *current_field = NULL; MAKE_STD_ZVAL(current_field); zend_hash_get_current_key_ex(fields_ht, (char **) &fieldname, &fieldname_length, &num_index, duplicate, NULL); zend_hash_get_current_data_ex(fields_ht, (void **) &field, NULL); solr_create_document_field_object(*field, ¤t_field TSRMLS_CC); add_next_index_zval(fields_array, current_field); } /* We are done */ return; } RETURN_FALSE; } /* }}} */ /* {{{ proto bool SolrInputDocument::fieldExists(string field_name) Checks if the field name exists in the document. */ PHP_METHOD(SolrInputDocument, fieldExists) { solr_char_t *field_name = NULL; int field_name_length = 0; solr_document_t *doc_entry = NULL; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (!field_name_length) { RETURN_FALSE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { if (zend_hash_exists(doc_entry->fields, (char *) field_name, field_name_length)) { RETURN_TRUE; } else { RETURN_FALSE; } } RETURN_FALSE; } /* }}} */ /* {{{ proto bool SolrInputDocument::deleteField(string field_name) Removes the request field from the document. */ PHP_METHOD(SolrInputDocument, deleteField) { solr_char_t *field_name = NULL; int field_name_length = 0; solr_document_t *doc_entry = NULL; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (!field_name_length) { RETURN_FALSE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { if (zend_hash_del(doc_entry->fields, (char *) field_name, field_name_length) == SUCCESS) { doc_entry->field_count--; RETURN_TRUE; } RETURN_FALSE; } RETURN_FALSE; } /* }}} */ /* {{{ proto bool SolrInputDocument::sort(int sort_criterion [, int sort_direction]) Sorts the document fields by the specified criterion. */ PHP_METHOD(SolrInputDocument, sort) { long int order_by = 0L; long int sort_direction = SOLR_SORT_ASC; solr_document_t *doc_entry = NULL; int renumber = 0; /* The pointer to the comparison function used by zend_qsort */ compare_func_t comparison_function = (compare_func_t) NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &order_by, &sort_direction) == FAILURE) { RETURN_FALSE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == FAILURE) { RETURN_FALSE; } /* {{{ Select the appropriate comparison function */ switch(order_by) { case SOLR_SORT_FIELD_NAME : /* Sorting by field name */ { switch(sort_direction) { case SOLR_SORT_ASC : comparison_function = solr_compare_field_name; break; case SOLR_SORT_DESC : comparison_function = solr_rcompare_field_name; break; } } break; /* case SOLR_SORT_FIELD_NAME */ case SOLR_SORT_FIELD_VALUE_COUNT : /* Sorting by number of values per field */ { switch(sort_direction) { case SOLR_SORT_ASC : comparison_function = solr_compare_field_value_count; break; case SOLR_SORT_DESC : comparison_function = solr_rcompare_field_value_count; break; } } break; /* case SOLR_SORT_FIELD_VALUE_COUNT */ case SOLR_SORT_FIELD_BOOST_VALUE : /* Sorting by field boost values */ { switch(sort_direction) { case SOLR_SORT_ASC : comparison_function = solr_compare_field_boost_value; break; case SOLR_SORT_DESC : comparison_function = solr_rcompare_field_boost_value; break; } } break; /* case SOLR_SORT_FIELD_BOOST_VALUE */ default : /* Undefined sort criteria */ RETURN_FALSE; break; } /* }}} switch(order_by) */ /* Undefined sort direction. It was not ASC or DESC */ if (!comparison_function) { RETURN_FALSE; } if (zend_hash_sort(doc_entry->fields, zend_qsort, comparison_function, renumber TSRMLS_CC) == FAILURE) { RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* {{{ proto bool SolrInputDocument::merge(SolrInputDocument source [, bool override]) Merges the source document to the current object. */ PHP_METHOD(SolrInputDocument, merge) { solr_document_t *destination_document = NULL; solr_document_t *source_document = NULL; /* The destination SolrDocument instance */ zval * destination_document_zval = getThis(); /* The source SolrDocument instance */ zval *source_document_zval = NULL; /* Should we skip fields that already exist in destination */ zend_bool overwrite = (zend_bool) 0; copy_ctor_func_t p_copy_ctor = (copy_ctor_func_t) field_copy_constructor; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|b", &source_document_zval, solr_ce_SolrInputDocument, &overwrite) == FAILURE) { RETURN_FALSE; } if (solr_fetch_document_entry(source_document_zval, &source_document TSRMLS_CC) == FAILURE) { RETURN_FALSE; } if (solr_fetch_document_entry(destination_document_zval, &destination_document TSRMLS_CC) == FAILURE) { RETURN_FALSE; } if (zend_hash_num_elements(source_document->fields) == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Source SolrInputDocument has no fields. Source documentId"); RETURN_FALSE; } /* Copy the fields in the source HashTable to the destination HashTable */ zend_hash_merge(destination_document->fields, source_document->fields, p_copy_ctor, NULL, sizeof(solr_field_list_t *), (int) overwrite); /* Update the field count */ destination_document->field_count = (uint) zend_hash_num_elements(destination_document->fields); RETURN_TRUE; } /* }}} */ /* {{{ proto void SolrInputDocument::addChildDocument(SolrInputDocument child) Adds a child document */ PHP_METHOD(SolrInputDocument, addChildDocument) { zval *child_obj = NULL; solr_document_t *solr_doc = NULL, *child_doc_entry = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &child_obj, solr_ce_SolrInputDocument) == FAILURE) { RETURN_FALSE; } if (solr_fetch_document_entry(getThis(), &solr_doc TSRMLS_CC) == FAILURE) { solr_throw_exception_ex(solr_ce_SolrException, SOLR_ERROR_1008 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Internal Error: Unable to fetch document_entry."); return; } if (solr_fetch_document_entry(child_obj, &child_doc_entry TSRMLS_CC) == FAILURE) { solr_throw_exception_ex(solr_ce_SolrException, SOLR_ERROR_1008 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Internal Error: Unable to fetch document_entry for child document."); return; } /* SolrInputDocument must contain at least one field */ if (0 == zend_hash_num_elements(child_doc_entry->fields)) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Child document has no fields"); return; } if (zend_hash_next_index_insert(solr_doc->children, &child_obj, sizeof(zval *), NULL) == FAILURE) { solr_throw_exception_ex(solr_ce_SolrException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Internal Error: Unable to add child to the hashtable."); } else { Z_ADDREF_P(child_obj); } } /* }}} */ /* {{{ proto void SolrInputDocument::addChildDocuments(array) Adds a child documents */ PHP_METHOD(SolrInputDocument, addChildDocuments) { HashTable *solr_input_docs; solr_document_t *solr_doc = NULL; zval *docs_array = NULL; int num_input_docs = 0, curr_pos = 0; size_t pos = 0U; zval **input_docs = NULL, *current_input_doc = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &docs_array) == FAILURE) { return; } if (solr_fetch_document_entry(getThis(), &solr_doc TSRMLS_CC) == FAILURE) { solr_throw_exception_ex(solr_ce_SolrException, SOLR_ERROR_1008 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Internal Error: Unable to fetch document_entry."); } solr_input_docs = Z_ARRVAL_P(docs_array); num_input_docs = zend_hash_num_elements(solr_input_docs); if(!num_input_docs) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "The array parameter passed is empty"); return; } /* This should be released if there is an error */ input_docs = (zval **) pemalloc((sizeof(zval *) * (num_input_docs + 1)), SOLR_DOCUMENT_PERSISTENT); memset(input_docs, 0, sizeof(zval *) * (num_input_docs + 1)); /* Please check all the SolrInputDocument instances passed via the array */ SOLR_HASHTABLE_FOR_LOOP(solr_input_docs) { zval **solr_input_doc = NULL; solr_document_t *doc_entry = NULL; HashTable *document_fields; zend_hash_get_current_data_ex(solr_input_docs, (void **) &solr_input_doc, ((HashPosition *)0)); if (Z_TYPE_PP(solr_input_doc) != IS_OBJECT || !instanceof_function(Z_OBJCE_PP(solr_input_doc), solr_ce_SolrInputDocument TSRMLS_CC)) { SOLR_FREE_DOC_ENTRIES(input_docs); solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "SolrInputDocument number %u is not a valid SolrInputDocument instance", (curr_pos + 1U)); return; } if (solr_fetch_document_entry((*solr_input_doc), &doc_entry TSRMLS_CC) == FAILURE) { SOLR_FREE_DOC_ENTRIES(input_docs); solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "SolrInputDocument number %u is not valid. Object not present in HashTable", (curr_pos + 1U)); return; } document_fields = doc_entry->fields; /* SolrInputDocument must contain at least one field */ if (0 == zend_hash_num_elements(document_fields)) { SOLR_FREE_DOC_ENTRIES(input_docs); solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "SolrInputDocument number %u has no fields", (curr_pos + 1U)); return; } input_docs[curr_pos] = *solr_input_doc; curr_pos++; } /* Grab the first (solr_document_t *) pointer */ current_input_doc = input_docs[pos]; while(current_input_doc != NULL) { if (zend_hash_next_index_insert(solr_doc->children, ¤t_input_doc, sizeof(zval *), NULL) == FAILURE) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "SolrInputDocument number %u has no fields", (pos + 1U)); SOLR_FREE_DOC_ENTRIES(input_docs); return; } Z_ADDREF_P(current_input_doc); pos++; current_input_doc = input_docs[pos]; } SOLR_FREE_DOC_ENTRIES(input_docs); } /* }}} */ /* {{{ proto array SolrInputDocument::getChildDocuments( void ) Returns child documents or null if none */ PHP_METHOD(SolrInputDocument, getChildDocuments) { solr_document_t *solr_doc = NULL; if (solr_fetch_document_entry(getThis(), &solr_doc TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to fetch document entry for current object"); } if (zend_hash_num_elements(solr_doc->children) > 0) { array_init(return_value); zend_hash_init(Z_ARRVAL_P(return_value), zend_hash_num_elements(solr_doc->children), NULL, ZVAL_PTR_DTOR, 0); zend_hash_copy(Z_ARRVAL_P(return_value), solr_doc->children, (copy_ctor_func_t)zval_add_ref, NULL, sizeof(zval *)); } } /* }}} */ /* {{{ proto bool SolrInputDocument::hasChildDocuments (void) Checks whether this document has got child documents */ PHP_METHOD(SolrInputDocument, hasChildDocuments) { solr_document_t *solr_doc = NULL; if (solr_fetch_document_entry(getThis(), &solr_doc TSRMLS_CC)) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to fetch document entry for current object"); } if (zend_hash_num_elements(solr_doc->children) > 0) { RETURN_TRUE; } else { RETURN_FALSE; } } /* }}} */ /* {{{ proto int SolrInputDocument::getChildDocumentsCount (void) Returns the number of child documents */ PHP_METHOD(SolrInputDocument, getChildDocumentsCount) { solr_document_t *solr_doc = NULL; if (solr_fetch_document_entry(getThis(), &solr_doc TSRMLS_CC)) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to fetch document entry for current object"); } Z_LVAL_P(return_value) = zend_hash_num_elements(solr_doc->children); Z_TYPE_P(return_value) = IS_LONG; } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/php_solr_object.c0000644000175000017500000002543412676753706016170 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* {{{ PHP_SOLR_API void solr_object_write_property(zval *object, zval *member, zval *value TSRMLS_DC) */ #if PHP_VERSION_ID < 50399 PHP_SOLR_API void solr_object_write_property(zval *object, zval *member, zval *value TSRMLS_DC) #else PHP_SOLR_API void solr_object_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC) #endif { solr_throw_exception(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1006_MSG, SOLR_ERROR_1006 TSRMLS_CC, SOLR_FILE_LINE_FUNC); if (Z_TYPE_P(member) == IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempting to set value for [%s] property in a SolrObject instance", Z_STRVAL_P(member)); } } /* }}} */ /* {{{ PHP_SOLR_API void solr_object_write_dimension(zval *object, zval *offset, zval *value TSRMLS_DC) */ PHP_SOLR_API void solr_object_write_dimension(zval *object, zval *offset, zval *value TSRMLS_DC) { solr_throw_exception(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1006_MSG, SOLR_ERROR_1006 TSRMLS_CC, SOLR_FILE_LINE_FUNC); if (Z_TYPE_P(offset) == IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempting to set value for [%s] property in a SolrObject instance", Z_STRVAL_P(offset)); } } /* }}} */ /* {{{ PHP_SOLR_API void solr_object_unset_property(zval *object, zval *member TSRMLS_DC) */ #if PHP_VERSION_ID < 50399 PHP_SOLR_API void solr_object_unset_property(zval *object, zval *member TSRMLS_DC) #else PHP_SOLR_API void solr_object_unset_property(zval *object, zval *member, const zend_literal *key TSRMLS_DC) #endif { solr_throw_exception(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1006_MSG, SOLR_ERROR_1006 TSRMLS_CC, SOLR_FILE_LINE_FUNC); if (Z_TYPE_P(member) == IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempting to remove [%s] property in a SolrObject instance", Z_STRVAL_P(member)); } } /* }}} */ /* {{{ PHP_SOLR_API void solr_object_unset_dimension(zval *object, zval *offset TSRMLS_DC) */ PHP_SOLR_API void solr_object_unset_dimension(zval *object, zval *offset TSRMLS_DC) { solr_throw_exception(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1006_MSG, SOLR_ERROR_1006 TSRMLS_CC, SOLR_FILE_LINE_FUNC); if (Z_TYPE_P(offset) == IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempting to remove [%s] property in a SolrObject instance", Z_STRVAL_P(offset)); } } /* }}} */ /* {{{ PHP_SOLR_API zval *solr_object_read_property(zval *object, zval *member, int type TSRMLS_DC) */ #if PHP_VERSION_ID < 50399 PHP_SOLR_API zval *solr_object_read_property(zval *object, zval *member, int type TSRMLS_DC) #else PHP_SOLR_API zval *solr_object_read_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC) #endif { zval **value = &EG(uninitialized_zval_ptr); char *name = NULL; HashTable *properties = NULL; /* zend_object *zobject = NULL; */ if (Z_TYPE_P(member) != IS_STRING) { return (*value); } SOLR_HASHTABLE_FOR_LOOP(properties) { char *property_name = NULL; uint property_name_len = 0U; ulong num_index = 0L; zend_hash_get_current_key_ex(properties, &property_name, &property_name_len, &num_index, 0, NULL); /* If the property name is in the HashTable */ if (property_name && !strcmp(property_name, name)) { zend_hash_get_current_data_ex(properties, (void **) &value, NULL); } } return (*value); } /* }}} */ /* {{{ proto SolrObject::__construct(void) Constructor for SolrObject */ PHP_METHOD(SolrObject, __construct) { Z_OBJ_HT_P(getThis()) = &solr_object_handlers; } /* }}} */ /* {{{ proto SolrObject::__destruct(void) Destructor for SolrObject. */ PHP_METHOD(SolrObject, __destruct) { } /* }}} */ /* {{{ proto void SolrObject::__set(string property_name, mixed value) Magic method for setting/updating property values. */ PHP_METHOD(SolrObject, __set) { } /* }}} */ /* {{{ proto mixed SolrObject::__get(string property_name) Magic method for retrieving properties. */ PHP_METHOD(SolrObject, __get) { solr_char_t *name = NULL; int name_len = 0; zval *property = NULL; zend_bool copy_value = 1; void *dtor = NULL; /* Process the parameters passed to the method */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { RETURN_FALSE; } property = zend_read_property(solr_ce_SolrObject, getThis(), name, name_len, 0 TSRMLS_CC); if (property) { RETURN_ZVAL(property, copy_value, dtor); } } /* }}} */ /* {{{ proto bool SolrObject::__isset(string property_name) Magic method for checking if a property exists in the object. */ PHP_METHOD(SolrObject, __isset) { solr_char_t *name = NULL; int name_len = 0; zend_object *zobject = NULL; void **value = NULL; /* Process the parameters passed to the method */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { RETURN_FALSE; } zobject = zend_objects_get_address(getThis() TSRMLS_CC); zend_hash_find(zobject->properties, name, name_len, (void **) &value); if (value) { RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto void SolrObject::__unset(string property_name) Magic method for removing the specified property. */ PHP_METHOD(SolrObject, __unset) { solr_char_t *name = NULL; int name_len = 0; /* Process the parameters passed to the method */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { return; } solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1002 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1002_MSG, name); RETURN_FALSE; } /* }}} */ /* {{{ proto void SolrObject::offsetSet(string key, mixed value) Sets the specified key to value. */ PHP_METHOD(SolrObject, offsetSet) { solr_char_t *name = NULL; int name_len = 0; zval *prop = NULL; /* Process the parameters passed to the method */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", &name, &name_len, &prop) == FAILURE) { RETURN_FALSE; } if (prop && prop->type == IS_NULL) { solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1002 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1002_MSG, name); return ; } zend_update_property(Z_OBJCE_P(getThis()), getThis(), name, name_len, prop TSRMLS_CC); } /* }}} */ /* {{{ proto mixed SolrObject::offsetGet(string key) Retrieves the requested key. */ PHP_METHOD(SolrObject, offsetGet) { solr_char_t *name = NULL; int name_len = 0; zend_object *zobject = zend_objects_get_address(getThis() TSRMLS_CC); HashTable *properties = zobject->properties; zval **property_value = NULL; zend_bool copy_value = 1; void *dtor = NULL; /* Process the parameters passed to the method */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { RETURN_FALSE; } SOLR_HASHTABLE_FOR_LOOP(properties) { char *property_name = NULL; uint property_name_len = 0U; ulong num_index = 0L; zend_hash_get_current_key_ex(properties, &property_name, &property_name_len, &num_index, 0, NULL); /* If the property name is in the HashTable */ if (property_name && !strcmp(property_name, name)) { zend_hash_get_current_data_ex(properties, (void **) &property_value, NULL); goto job_complete; } } job_complete : zend_hash_internal_pointer_reset(properties); if (property_value && (*property_value)) { RETURN_ZVAL((*property_value), copy_value, dtor); } } /* }}} */ /* {{{ proto bool SolrObject::offsetExists(string key) Checks if the key exists. */ PHP_METHOD(SolrObject, offsetExists) { solr_char_t *name = NULL; int name_len = 0; zend_object *zobject = zend_objects_get_address(getThis() TSRMLS_CC); HashTable *properties = zobject->properties; zend_bool property_exists = 0; /* Process the parameters passed to the method */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { RETURN_FALSE; } SOLR_HASHTABLE_FOR_LOOP(properties) { char *property_name = NULL; uint property_name_len = 0U; ulong num_index = 0L; zend_hash_get_current_key_ex(properties, &property_name, &property_name_len, &num_index, 0, NULL); /* If the property name is in the HashTable */ if (property_name && !strcmp(property_name, name)) { property_exists = 1; goto job_complete; } } job_complete : if (properties) { zend_hash_internal_pointer_reset(properties); } RETURN_BOOL(property_exists); } /* }}} */ /* {{{ proto void SolrObject::offsetUnset(string key) Removes the specified key. */ PHP_METHOD(SolrObject, offsetUnset) { solr_char_t *name = NULL; int name_len = 0; /* Process the parameters passed to the method */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { return; } solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1002 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1002_MSG, name); RETURN_FALSE; } /* }}} */ /* {{{ proto array SolrObject::getPropertyNames(void) Returns an array of all the properties/keys in the object. */ PHP_METHOD(SolrObject, getPropertyNames) { zend_object *zobject = zend_objects_get_address(getThis() TSRMLS_CC); HashTable *properties = zobject->properties; array_init(return_value); SOLR_HASHTABLE_FOR_LOOP(properties) { char *property_name = NULL; uint property_name_length = 0U; ulong num_index = 0L; zend_hash_get_current_key_ex(properties, &property_name, &property_name_length, &num_index, 0, NULL); add_next_index_stringl(return_value, property_name, property_name_length-1, 1); } } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/php_solr_params.c0000644000175000017500000007444712676753706016215 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* {{{ static void solr_serialize_xml_set_param_props(xmlNode *xml_param_node, solr_param_t *param) */ static void solr_serialize_xml_set_param_props(xmlNode *xml_param_node, solr_param_t *param) { char tmp_buffer[32]; /* This should be enough to hold any value */ memset(tmp_buffer, 0, sizeof(tmp_buffer)); /* Set the name attribute on the param node */ xmlNewProp(xml_param_node, (xmlChar *) "name", (xmlChar *) param->param_name); php_sprintf(tmp_buffer, "%d", param->type); /* Set the type attribute on the param node */ xmlNewProp(xml_param_node, (xmlChar *) "type", (xmlChar *) tmp_buffer); php_sprintf(tmp_buffer, "%d", param->allow_multiple); /* Set the allow_multiple attribute on the param node */ xmlNewProp(xml_param_node, (xmlChar *) "allow_multiple", (xmlChar *) tmp_buffer); php_sprintf(tmp_buffer, "%u", param->count); /* Set the count attribute on the param node */ xmlNewProp(xml_param_node, (xmlChar *) "count", (xmlChar *) tmp_buffer); php_sprintf(tmp_buffer, "%d", param->delimiter); /* Set the delimiter attribute on the param node */ xmlNewProp(xml_param_node, (xmlChar *) "delimiter", (xmlChar *) tmp_buffer); php_sprintf(tmp_buffer, "%d", param->arg_separator); /* Set the arg_separator attribute on the param node */ xmlNewProp(xml_param_node, (xmlChar *) "arg_separator", (xmlChar *) tmp_buffer); } /* }}} */ /* {{{ static void solr_serialize_normal_param_value(xmlNode *xml_params_node, solr_param_t *param) */ static void solr_serialize_normal_param_value(xmlNode *xml_params_node, solr_param_t *param) { xmlNode *xml_param_node = xmlNewChild(xml_params_node, NULL, (xmlChar *) "param", NULL); solr_param_value_t *curr_value = param->head; solr_serialize_xml_set_param_props(xml_param_node, param); while(curr_value != NULL) { xmlChar *param_value_txt = xmlEncodeEntitiesReentrant(xml_params_node->doc, (xmlChar *) curr_value->contents.normal.str); xmlNewChild(xml_param_node, NULL, (xmlChar *) "param_value", param_value_txt); xmlFree(param_value_txt); curr_value = curr_value->next; /* Go to the next value in the list */ } } /* }}} */ /* {{{ static void solr_serialize_simple_list_param_value(xmlNode *xml_params_node, solr_param_t *param) */ static void solr_serialize_simple_list_param_value(xmlNode *xml_params_node, solr_param_t *param) { xmlNode *xml_param_node = xmlNewChild(xml_params_node, NULL, (xmlChar *) "param", NULL); solr_param_value_t *curr_value = param->head; solr_serialize_xml_set_param_props(xml_param_node, param); while(curr_value != NULL) { xmlChar *param_value_txt = xmlEncodeEntitiesReentrant(xml_params_node->doc, (xmlChar *) curr_value->contents.simple_list.str); xmlNewChild(xml_param_node, NULL, (xmlChar *) "param_value", param_value_txt); xmlFree(param_value_txt); curr_value = curr_value->next; /* Go to the next value in the list */ } } /* }}} */ /* {{{ static void solr_serialize_arg_list_param_value(xmlNode *xml_params_node, solr_param_t *param) */ static void solr_serialize_arg_list_param_value(xmlNode *xml_params_node, solr_param_t *param) { xmlNode *xml_param_node = xmlNewChild(xml_params_node, NULL, (xmlChar *) "param", NULL); solr_param_value_t *curr_value = param->head; solr_serialize_xml_set_param_props(xml_param_node, param); while(curr_value != NULL) { xmlChar *param_value_txt = xmlEncodeEntitiesReentrant(xml_params_node->doc, (xmlChar *) curr_value->contents.arg_list.value.str); xmlChar *arg_value_txt = xmlEncodeEntitiesReentrant(xml_params_node->doc, (xmlChar *) curr_value->contents.arg_list.arg.str); xmlNode *xml_param_value = xmlNewChild(xml_param_node, NULL, (xmlChar *) "param_value", param_value_txt); xmlNewProp(xml_param_value, (xmlChar *) "argument", arg_value_txt); xmlFree(param_value_txt); xmlFree(arg_value_txt); curr_value = curr_value->next; /* Go to the next value in the list */ } } /* }}} */ /* {{{ static int solr_serialize_solr_params_object(xmlChar **serialized, int *size, zval *objptr TSRMLS_DC) */ static int solr_serialize_solr_params_object(xmlChar **serialized, int *size, zval *objptr TSRMLS_DC) { solr_params_t *solr_params = NULL; xmlNode *xml_solr_params = NULL, *xml_params = NULL; xmlDoc *doc_ptr = NULL; HashTable *params = NULL; int format = 1; if (solr_fetch_params_entry(objptr, &solr_params TSRMLS_CC) == FAILURE) { return FAILURE; } if (!serialized || !size || !objptr) { return FAILURE; } doc_ptr = solr_xml_create_xml_doc((xmlChar *) "solr_params", &xml_solr_params); xml_params = xmlNewChild(xml_solr_params, NULL, (xmlChar *) "params", NULL); params = solr_params->params; SOLR_HASHTABLE_FOR_LOOP(params) { solr_param_t **solr_param_ptr = NULL; zend_hash_get_current_data_ex(params, (void **) &solr_param_ptr, ((HashPosition *)0)); switch((*solr_param_ptr)->type) { case SOLR_PARAM_TYPE_NORMAL : { solr_serialize_normal_param_value(xml_params, (*solr_param_ptr)); } break; case SOLR_PARAM_TYPE_SIMPLE_LIST : { solr_serialize_simple_list_param_value(xml_params, (*solr_param_ptr)); } break; case SOLR_PARAM_TYPE_ARG_LIST : { solr_serialize_arg_list_param_value(xml_params, (*solr_param_ptr)); } break; default : { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Solr Param Type %d", (*solr_param_ptr)->type); } } } xmlIndentTreeOutput = 1; xmlDocDumpFormatMemoryEnc(doc_ptr, serialized, size, "UTF-8", format); xmlFreeDoc(doc_ptr); return SUCCESS; } /* }}} */ /* {{{ static void solr_unserialize_get_param_normal(xmlNode *normal_param, HashTable *params_ht TSRMLS_DC) */ static void solr_unserialize_get_param_normal(xmlNode *normal_param, HashTable *params_ht TSRMLS_DC) { solr_char_t *param_name = NULL; size_t param_name_len = 0U; solr_bool allow_multiple = 0; solr_param_type_t param_type = SOLR_PARAM_TYPE_NORMAL; xmlAttr *currAttr = normal_param->properties; solr_param_t *param = NULL; xmlNode *currNode = normal_param->children; solr_param_value_equal_func_t equal_func = solr_normal_param_value_equal; solr_param_fetch_func_t fetch_func = (solr_param_fetch_func_t) solr_normal_param_value_fetch; solr_param_value_free_func_t free_func = solr_normal_param_value_free; /* Grab the name and setting for this parameter */ while(currAttr != NULL) { if (solr_xml_match_node(currAttr, "name")) { param_name = (solr_char_t *) solr_xml_get_node_contents(currAttr); param_name_len = solr_strlen(param_name); } if (solr_xml_match_node(currAttr, "allow_multiple")) { allow_multiple = solr_xml_get_node_contents_int(currAttr); } currAttr = currAttr->next; } param = solr_create_new_param(param_name, param_name_len, param_type, allow_multiple, equal_func, fetch_func, free_func, '&', 0 TSRMLS_CC); /* Retrieve all the values for this parameter */ while(currNode != NULL) { if (solr_xml_match_node(currNode, "param_value")) { xmlChar *pvalue = solr_xml_get_node_contents(currNode); size_t pvalue_length = solr_strlen((char *)pvalue); solr_param_value_t *parameter_value = (solr_param_value_t *) pemalloc(sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); memset(parameter_value, 0, sizeof(solr_param_value_t)); solr_string_appends(&(parameter_value->contents.normal), (solr_char_t *) pvalue, pvalue_length); solr_params_insert_param_value(param, parameter_value); } currNode = currNode->next; } /* Add this parameter to the hash table */ if (zend_hash_add(params_ht, (char *) param_name, param_name_len, (void *) ¶m, sizeof(solr_param_t *), (void **) NULL) == FAILURE) { /* Release all the memory allocated to this paramter */ solr_destroy_param(¶m); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error from %s %s", __func__, (char *) param_name); return; } } /* }}} */ /* {{{ static void solr_unserialize_get_param_simple_list(xmlNode *list_param, HashTable *params_ht TSRMLS_DC) */ static void solr_unserialize_get_param_simple_list(xmlNode *list_param, HashTable *params_ht TSRMLS_DC) { solr_char_t *param_name = NULL; size_t param_name_len = 0U; solr_bool allow_multiple = 0; solr_param_type_t param_type = SOLR_PARAM_TYPE_SIMPLE_LIST; solr_param_t *param = NULL; xmlNode *currNode = list_param->children; xmlAttr *currAttr = list_param->properties; solr_param_value_equal_func_t equal_func = solr_simple_list_param_value_equal; solr_param_fetch_func_t fetch_func = (solr_param_fetch_func_t) solr_simple_list_param_value_fetch; solr_param_value_free_func_t free_func = solr_simple_list_param_value_free; /* Grab the name and setting for this parameter */ while(currAttr != NULL) { if (solr_xml_match_node(currAttr, "name")) { param_name = (solr_char_t *) solr_xml_get_node_contents(currAttr); param_name_len = solr_strlen(param_name); } if (solr_xml_match_node(currAttr, "allow_multiple")) { allow_multiple = solr_xml_get_node_contents_int(currAttr); } currAttr = currAttr->next; } param = solr_create_new_param(param_name, param_name_len, param_type, allow_multiple, equal_func, fetch_func, free_func, ',', 0 TSRMLS_CC); /* Retrieve all the values for this parameter */ while(currNode != NULL) { if (solr_xml_match_node(currNode, "param_value")) { solr_char_t *pvalue = (solr_char_t *) solr_xml_get_node_contents(currNode); size_t pvalue_length = solr_strlen(pvalue); solr_param_value_t *parameter_value = (solr_param_value_t *) pemalloc(sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); memset(parameter_value, 0, sizeof(solr_param_value_t)); solr_string_appends(&(parameter_value->contents.simple_list), pvalue, pvalue_length); solr_params_insert_param_value(param, parameter_value); } currNode = currNode->next; } /* Add this parameter to the hash table */ if (zend_hash_add(params_ht, (char *) param_name, param_name_len, (void *) ¶m, sizeof(solr_param_t *), (void **) NULL) == FAILURE) { /* Release all the memory allocated to this paramter */ solr_destroy_param(¶m); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error from %s %s", __func__, (char *) param_name); return; } } /* }}} */ /* {{{ static void solr_unserialize_get_param_arg_list(xmlNode *sort_param, HashTable *params_ht TSRMLS_DC) */ static void solr_unserialize_get_param_arg_list(xmlNode *sort_param, HashTable *params_ht TSRMLS_DC) { solr_char_t *param_name = NULL; size_t param_name_len = 0U; solr_bool allow_multiple = 0; solr_char_t delimiter = 0; solr_char_t separator = 0; xmlAttr *currAttr = sort_param->properties; solr_param_type_t param_type = SOLR_PARAM_TYPE_ARG_LIST; solr_param_t *param = NULL; xmlNode *currNode = sort_param->children; solr_param_value_equal_func_t equal_func = solr_arg_list_param_value_equal; solr_param_fetch_func_t fetch_func = (solr_param_fetch_func_t) solr_arg_list_param_value_fetch; solr_param_value_free_func_t free_func = solr_arg_list_param_value_free; /* Grab the name and setting for this parameter */ while(currAttr != NULL) { if (solr_xml_match_node(currAttr, "name")) { param_name = (solr_char_t *) solr_xml_get_node_contents(currAttr); param_name_len = solr_strlen(param_name); } if (solr_xml_match_node(currAttr, "allow_multiple")) { allow_multiple = solr_xml_get_node_contents_int(currAttr); } if (solr_xml_match_node(currAttr, "delimiter")) { delimiter = solr_xml_get_node_contents_int(currAttr); } if (solr_xml_match_node(currAttr, "arg_separator")) { separator = solr_xml_get_node_contents_int(currAttr); } currAttr = currAttr->next; } param = solr_create_new_param(param_name, param_name_len, param_type, allow_multiple, equal_func, fetch_func, free_func, delimiter, separator TSRMLS_CC); /* Retrieve all the values for this parameter */ while(currNode != NULL) { if (solr_xml_match_node(currNode, "param_value")) { solr_char_t *pvalue = (solr_char_t *) solr_xml_get_node_contents(currNode); xmlAttr *argument = currNode->properties; /* the argument is the only property */ solr_char_t *avalue = (solr_char_t *) solr_xml_get_node_contents(argument); size_t pvalue_length = solr_strlen(pvalue); size_t avalue_length = solr_strlen(avalue); solr_param_value_t *parameter_value = (solr_param_value_t *) pemalloc(sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); memset(parameter_value, 0, sizeof(solr_param_value_t)); solr_string_appends(&(parameter_value->contents.arg_list.value), pvalue, pvalue_length); solr_string_appends(&(parameter_value->contents.arg_list.arg), avalue, avalue_length); solr_params_insert_param_value(param, parameter_value); } currNode = currNode->next; } /* Add this parameter to the hash table */ if (zend_hash_add(params_ht, (char *) param_name, param_name_len, (void *) ¶m, sizeof(solr_param_t *), (void **) NULL) == FAILURE) { /* Release all the memory allocated to this paramter */ solr_destroy_param(¶m); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error from %s %s", __func__, (char *) param_name); return; } } /* }}} */ /* {{{ static int solr_unserialize_solr_params_object(const char *serialized, int size, zval *objptr TSRMLS_DC) */ static int solr_unserialize_solr_params_object(const char *serialized, int size, zval *objptr TSRMLS_DC) { solr_params_t *solr_params = NULL; long int params_index = SOLR_UNIQUE_PARAMS_INDEX(); solr_params_t tmp_solr_params; uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE; HashTable *params_ht = NULL; xmlDoc *doc = NULL; xmlXPathContext *xpathctxt; const xmlChar *xpath_expression = (xmlChar *) "/solr_params/params/param/@type"; xmlXPathObject *xpathObj; xmlNodeSet *result = NULL; register size_t num_nodes; register size_t i = 0U; int return_status = SUCCESS; zend_update_property_long(Z_OBJCE_P(objptr), objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, params_index TSRMLS_CC); memset(&tmp_solr_params, 0, sizeof(solr_params_t)); if (zend_hash_index_update(SOLR_GLOBAL(params), params_index, (void *) &tmp_solr_params, sizeof(solr_params_t), (void **) &solr_params) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while registering SolrParam object in HashTable"); return FAILURE; } solr_params->params_index = params_index; /* Allocate memory for the parameters HashTable using fast cache for HashTables */ ALLOC_HASHTABLE(solr_params->params); zend_hash_init(solr_params->params, nSize, NULL, (dtor_func_t) solr_destroy_param, SOLR_PARAMS_PERSISTENT); params_ht = solr_params->params; doc = xmlReadMemory(serialized, size, NULL, "UTF-8", 0); if (doc == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while parsing serialized XML string"); return FAILURE; } xpathctxt = xmlXPathNewContext(doc); if (xpathctxt == NULL) { xmlFreeDoc(doc); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while creating XML Xpath context"); return FAILURE; } xpathObj = xmlXPathEval(xpath_expression, xpathctxt); if (xpathObj == NULL) { xmlXPathFreeContext(xpathctxt); xmlFreeDoc(doc); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while evaluation XML Xpath expression"); return FAILURE; } result = xpathObj->nodesetval; if (result == NULL) { xmlXPathFreeObject(xpathObj); xmlXPathFreeContext(xpathctxt); xmlFreeDoc(doc); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while extracting result from XML xpath object during unserialization"); return FAILURE; } num_nodes = result->nodeNr; /* Number of parameter nodes matches in the xmlDocument */ /* Loop through all the parameter nodes and create an entry in the HashTable for each one */ for (i = 0U; i < num_nodes; i++) { xmlNode *currNode = result->nodeTab[i]; /* Absolutely No assumptions. I have to make sure that this is an attribute node */ if (currNode->type == XML_ATTRIBUTE_NODE) { /* Find out what type of parameter this is */ const solr_param_type_t param_type = solr_xml_get_node_contents_int(currNode); /* Get the /solr_params/params/param node */ xmlNode *param_xml_node = currNode->parent; /* Handle each parameter type separately */ switch(param_type) { case SOLR_PARAM_TYPE_NORMAL : { solr_unserialize_get_param_normal(param_xml_node, params_ht TSRMLS_CC); } break; case SOLR_PARAM_TYPE_SIMPLE_LIST : { solr_unserialize_get_param_simple_list(param_xml_node, params_ht TSRMLS_CC); } break; case SOLR_PARAM_TYPE_ARG_LIST : { solr_unserialize_get_param_arg_list(param_xml_node, params_ht TSRMLS_CC); } break; default : { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter type"); return_status = FAILURE; goto loop_complete; } } /* End switch */ } /* End if (currNode->type == XML_ATTRIBUTE_NODE) */ } /* End for */ loop_complete: xmlXPathFreeObject(xpathObj); xmlXPathFreeContext(xpathctxt); xmlFreeDoc(doc); return return_status; } /* }}} */ /* {{{ proto SolrParams::__clone(void) Should never be called directly. Throws exceptions whenever there is an attempt to clone a SolrParams instance */ PHP_METHOD(SolrParams, __clone) { long int params_index = SOLR_UNIQUE_PARAMS_INDEX(); solr_params_t *solr_params_dest = NULL; zend_update_property_long(solr_ce_SolrModifiableParams, getThis(), SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, params_index TSRMLS_CC); solr_init_params(&solr_params_dest, params_index TSRMLS_CC); solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_4001 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Cloning of SolrParams object instances is currently not supported"); } /* }}} */ /* {{{ proto SolrParams::setParam(string param_name, string param_value) Sets the parameter to the specified value */ PHP_METHOD(SolrParams, setParam) { solr_char_t *param_name = NULL; int param_name_length = 0; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", ¶m_name, ¶m_name_length, ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrParams::addParam(string param_name, string param_value) Adds another param_name to the object. */ PHP_METHOD(SolrParams, addParam) { solr_char_t *param_name = NULL; int param_name_length = 0; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", ¶m_name, ¶m_name_length, ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrParams::getParam(string param_name) Retrieves a parameter value */ PHP_METHOD(SolrParams, getParam) { solr_char_t *param_name = NULL; int param_name_length = 0; solr_param_t *solr_param = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", ¶m_name, ¶m_name_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_FALSE; } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "return value requested without processing output."); return; } if (!param_name_length) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter name"); RETURN_NULL(); } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } if (!solr_param) { /* This should never happen unless there is a logic error in solr_param_find() */ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Very severe internal error while fetching (solr_param_t **) from solr_param_find() %s", __func__); return; } switch(solr_param->type) { case SOLR_PARAM_TYPE_NORMAL : { if (solr_param->allow_multiple) { array_init(return_value); solr_normal_param_value_display(solr_param, return_value); return; } else { solr_normal_param_value_display_string(solr_param, return_value); return; } } break; case SOLR_PARAM_TYPE_SIMPLE_LIST : { array_init(return_value); solr_simple_list_param_value_display(solr_param, return_value); return; } break; case SOLR_PARAM_TYPE_ARG_LIST : { array_init(return_value); solr_arg_list_param_value_display(solr_param, return_value); return; } break; default : { /* This should never happen. However, never say never! */ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameter type in switch case %s", __func__); } } /* END switch(solr_param->type) */ } /* }}} */ /* {{{ proto array SolrParams::getPreparedParams(void) Returns an array of all the parameters (url-encoded) as they will be sent in the name-value pair POST request. */ PHP_METHOD(SolrParams, getPreparedParams) { solr_params_t *solr_params = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Return value requested but output not processed."); return; } array_init(return_value); /* Retrieve the document entry for this SolrDocument */ if (solr_fetch_params_entry(getThis(), &solr_params TSRMLS_CC) == SUCCESS) { HashTable *params = solr_params->params; SOLR_HASHTABLE_FOR_LOOP(params) { solr_param_t **solr_param_ptr = NULL; solr_param_t *solr_param; solr_string_t tmp_buffer; zend_hash_get_current_data_ex(params, (void **) &solr_param_ptr, NULL); solr_param = (*solr_param_ptr); memset(&tmp_buffer, 0, sizeof(solr_string_t)); solr_param->fetch_func(solr_param, &tmp_buffer); add_assoc_stringl(return_value, (*solr_param_ptr)->param_name, tmp_buffer.str, tmp_buffer.len, 1); solr_string_free(&tmp_buffer); } return; } php_error_docref(NULL TSRMLS_CC, E_WARNING, "SolrParams instance could not be retrieved from HashTable"); RETURN_NULL(); } /* }}} */ /* {{{ proto array SolrParams::getParams(void) Returns an array of the parameters in the object. The values are not url-encoded. */ PHP_METHOD(SolrParams, getParams) { solr_params_t *solr_params = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Return value requested but output not processed."); return; } array_init(return_value); /* Retrieve the document entry for this SolrDocument */ if (solr_fetch_params_entry(getThis(), &solr_params TSRMLS_CC) == SUCCESS) { HashTable *params = solr_params->params; SOLR_HASHTABLE_FOR_LOOP(params) { solr_param_t **solr_param_ptr = NULL; solr_param_display_func_t display_func = NULL; zval *current_param = NULL; zend_hash_get_current_data_ex(params, (void **) &solr_param_ptr, NULL); switch((*solr_param_ptr)->type) { case SOLR_PARAM_TYPE_NORMAL : { display_func = solr_normal_param_value_display; } break; case SOLR_PARAM_TYPE_SIMPLE_LIST : { display_func = solr_simple_list_param_value_display; } break; case SOLR_PARAM_TYPE_ARG_LIST : { display_func = solr_arg_list_param_value_display; } break; default : { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter type"); } } MAKE_STD_ZVAL(current_param); array_init(current_param); add_assoc_zval(return_value, (*solr_param_ptr)->param_name, current_param); display_func((*solr_param_ptr), current_param); } return; } php_error_docref(NULL TSRMLS_CC, E_WARNING, "SolrParams instance could not be retrieved from HashTable"); RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrParams::__toString(void) Returns a string representation of the object */ PHP_METHOD(SolrParams, __toString) { solr_params_t *solr_params = NULL; register zend_bool url_encode = 0; /* Retrieve the document entry for this SolrDocument */ if (solr_fetch_params_entry(getThis(), &solr_params TSRMLS_CC) == SUCCESS) { HashTable *params = solr_params->params; solr_string_t tmp_buffer; memset(&tmp_buffer, 0, sizeof(solr_string_t)); SOLR_HASHTABLE_FOR_LOOP(params) { solr_param_t **solr_param_ptr = NULL; solr_param_tostring_func_t tostring_func = NULL; zend_hash_get_current_data_ex(params, (void **) &solr_param_ptr, NULL); switch((*solr_param_ptr)->type) { case SOLR_PARAM_TYPE_NORMAL : { tostring_func = solr_normal_param_value_tostring; } break; case SOLR_PARAM_TYPE_SIMPLE_LIST : { tostring_func = solr_simple_list_param_value_tostring; } break; case SOLR_PARAM_TYPE_ARG_LIST : { tostring_func = solr_arg_list_param_value_tostring; } break; default : { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter type"); } } tostring_func((*solr_param_ptr), &(tmp_buffer), url_encode); solr_string_appendc(&(tmp_buffer), '&'); } if (tmp_buffer.str && tmp_buffer.len) { solr_string_remove_last_char(&(tmp_buffer)); RETVAL_STRINGL((char *) tmp_buffer.str, tmp_buffer.len, 1); solr_string_free(&(tmp_buffer)); return; } } RETVAL_STRINGL(SOLR_SPACE_STRING, sizeof(SOLR_SPACE_STRING)-1, 1); } /* }}} */ /* {{{ proto string SolrParams::toString(void) Returns a string representation of the object */ PHP_METHOD(SolrParams, toString) { solr_params_t *solr_params = NULL; zend_bool url_encode = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &url_encode) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); return; } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Return value requested but output not processed."); return; } /* Retrieve the document entry for this SolrDocument */ if (solr_fetch_params_entry(getThis(), &solr_params TSRMLS_CC) == SUCCESS) { HashTable *params = solr_params->params; solr_string_t tmp_buffer; memset(&tmp_buffer, 0, sizeof(solr_string_t)); SOLR_HASHTABLE_FOR_LOOP(params) { solr_param_t **solr_param_ptr = NULL; solr_param_tostring_func_t tostring_func = NULL; zend_hash_get_current_data_ex(params, (void **) &solr_param_ptr, NULL); switch((*solr_param_ptr)->type) { case SOLR_PARAM_TYPE_NORMAL : { tostring_func = solr_normal_param_value_tostring; } break; case SOLR_PARAM_TYPE_SIMPLE_LIST : { tostring_func = solr_simple_list_param_value_tostring; } break; case SOLR_PARAM_TYPE_ARG_LIST : { tostring_func = solr_arg_list_param_value_tostring; } break; default : { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter type"); } } tostring_func((*solr_param_ptr), &(tmp_buffer), url_encode); solr_string_appendc(&(tmp_buffer), '&'); } if (tmp_buffer.str && tmp_buffer.len) { solr_string_remove_last_char(&(tmp_buffer)); RETVAL_STRINGL((char *) tmp_buffer.str, tmp_buffer.len, 1); solr_string_free(&(tmp_buffer)); return; } } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrParams::serialize(void) Returns a string representation of the object. Used for custom serialization. */ PHP_METHOD(SolrParams, serialize) { xmlChar *serialized = NULL; int size = 0; if (solr_serialize_solr_params_object(&serialized, &size, getThis() TSRMLS_CC) == FAILURE || !serialized || !size) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to serialize object"); RETURN_NULL(); } RETVAL_STRINGL((char *) serialized, size, 1); xmlFree(serialized); } /* }}} */ /* {{{ proto void SolrParams::unserialize(string serialized) Brings the serialized object back to life. */ PHP_METHOD(SolrParams, unserialize) { char *serialized_object = NULL; int serialized_object_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &serialized_object, &serialized_object_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if(serialized_object_len == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_unserialize_solr_params_object(serialized_object, serialized_object_len, getThis() TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error during unserialization"); } } /* }}} */ /* {{{ proto void SolrModifiableParams::__construct(void) Constructor. */ PHP_METHOD(SolrModifiableParams, __construct) { long int params_index = SOLR_UNIQUE_PARAMS_INDEX(); solr_params_t *solr_params_dest = NULL; zend_update_property_long(solr_ce_SolrModifiableParams, getThis(), SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, params_index TSRMLS_CC); solr_init_params(&solr_params_dest, params_index TSRMLS_CC); } /* }}} */ /* {{{ proto void SolrModifiableParams::__destruct(void) Destructor. */ PHP_METHOD(SolrModifiableParams, __destruct) { solr_params_t *solr_params = NULL; /* Retrieve the document entry for this SolrDocument */ if (solr_fetch_params_entry(getThis(), &solr_params TSRMLS_CC) == SUCCESS) { zend_hash_index_del(SOLR_GLOBAL(params), solr_params->params_index); return ; } } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/php_solr_query.c0000644000175000017500000051145112676753706016066 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* Outstanding Work/Changes */ /* TODO: Change SolrQuery::getTermsSort() to return integer */ /* TODO: Change SolrQuery::getFacetSort() to return integer */ /** * Note about methods implementation: * * One reason why each SolrQuery has custom code is because each method * could require separate tweaking. * * At this point in time, even though most of the SolrQuery methods share * basic features, I still believe that is a better idea to write separate code * for each method implementation. * * This will make the methods easier to maintain because * * from time to time, Solr modifies the way some of the request parameters are * submitted or processed. * * Hence, it is currently more logical to make each method an independent entity. */ /* {{{ proto SolrQuery::__construct([string q]) Constructor for SolrQuery */ PHP_METHOD(SolrQuery, __construct) { solr_char_t *q = NULL; int query_length = 0; solr_params_t *solr_params_dest = NULL; solr_params_t solr_params; long int params_index = SOLR_UNIQUE_PARAMS_INDEX(); uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE; zend_error_handling error_handling; zend_replace_error_handling(EH_THROW, solr_ce_SolrIllegalArgumentException, &error_handling TSRMLS_CC); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &q, &query_length) == FAILURE) { zend_restore_error_handling(&error_handling TSRMLS_CC); return; } zend_restore_error_handling(&error_handling TSRMLS_CC); zend_update_property_long(solr_ce_SolrQuery, getThis(), SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, params_index TSRMLS_CC); memset(&solr_params, 0, sizeof(solr_params_t)); if (zend_hash_index_update(SOLR_GLOBAL(params), params_index, (void *) &solr_params, sizeof(solr_params_t), (void **) &solr_params_dest) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error while registering query parameters in HashTable"); return ; } solr_params_dest->params_index = params_index; solr_params_dest->params_count = 0U; /* Allocated memory for the parameters HashTable using fast cache for HashTables */ ALLOC_HASHTABLE(solr_params_dest->params); zend_hash_init(solr_params_dest->params, nSize, NULL, (dtor_func_t) solr_destroy_param, SOLR_PARAMS_PERSISTENT); if (query_length) { if (solr_set_normal_param(getThis(), (solr_char_t *) "q", sizeof("q")-1, q, query_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while setting query parameter"); return; } } } /* }}} */ /* {{{ proto SolrQuery::__destruct() Destructor for SolrQuery */ PHP_METHOD(SolrQuery, __destruct) { solr_params_t *solr_params = NULL; /* Retrieve the entry for this SolrParams instance */ if (solr_fetch_params_entry(getThis(), &solr_params TSRMLS_CC) == SUCCESS) { zend_hash_index_del(SOLR_GLOBAL(params), solr_params->params_index); return ; } /* This would only happen if user attempted an illegal operation */ php_error_docref(NULL TSRMLS_CC, E_ERROR, SOLR_ERROR_1008_MSG, SOLR_FILE_LINE_FUNC); } /* }}} */ /* {{{ CommonQueryParameters */ /* {{{ proto SolrQuery SolrQuery::setQuery(string q) Sets the q parameter */ PHP_METHOD(SolrQuery, setQuery) { solr_char_t *param_name = (solr_char_t *) "q"; int param_name_length = sizeof("q")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setStart(int start) Sets the start parameter */ PHP_METHOD(SolrQuery, setStart) { solr_char_t *param_name = (solr_char_t *) "start"; int param_name_length = sizeof("start")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setRows(int rows) Sets the rows parameter */ PHP_METHOD(SolrQuery, setRows) { solr_char_t *param_name = (solr_char_t *) "rows"; int param_name_length = sizeof("rows")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addField(string fl) Adds another fl parameter */ PHP_METHOD(SolrQuery, addField) { solr_char_t *param_name = (solr_char_t *) "fl"; int param_name_length = sizeof("fl")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_simple_list_param(getThis(), param_name, param_name_length, param_value, param_value_length TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addSortField(string fl [, int sort_direction]) Adds another sort parameter */ PHP_METHOD(SolrQuery, addSortField) { solr_char_t *param_name = (solr_char_t *) "sort"; int param_name_length = sizeof("sort")-1; solr_char_t *param_value = NULL; int param_value_length = 0; long int sort_direction = 1L; solr_sort_dir_t sort_order = SOLR_SORT_DIR_DESC; solr_char_t *avalue = NULL; int avalue_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", ¶m_value, ¶m_value_length, &sort_direction) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } sort_order = (sort_direction < 0L || sort_direction > 1L) ? SOLR_SORT_DIR_DESC : (solr_sort_dir_t) sort_direction; avalue = (sort_order) ? "desc" : "asc"; avalue_length = solr_strlen(avalue); if (solr_add_arg_list_param(getThis(), param_name, param_name_length, param_value, param_value_length, avalue, avalue_length, ',', ' ' TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addFiterQuery(string fq) Adds another fq parameter */ PHP_METHOD(SolrQuery, addFilterQuery) { solr_char_t *param_name = (solr_char_t *) "fq"; int param_name_length = sizeof("fq")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setShowDebugInfo(bool flag) Sets the debugQuery parameter */ PHP_METHOD(SolrQuery, setShowDebugInfo) { solr_char_t *param_name = (solr_char_t *) "debugQuery"; int param_name_length = sizeof("debugQuery")-1; zend_bool show_debug_info = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &show_debug_info) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!show_debug_info) { solr_delete_solr_parameter(getThis(), param_name, param_name_length TSRMLS_CC); solr_return_solr_params_object(); return; } if (solr_set_normal_param(getThis(), param_name, param_name_length, "true", sizeof("true")-1) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error adding debugging info "); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setExplainOther(string explainOther) Sets the explainOther parameter */ PHP_METHOD(SolrQuery, setExplainOther) { solr_char_t *param_name = (solr_char_t *) "explainOther"; int param_name_length = sizeof("explainOther")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTimeAllowed(int milliseconds) Sets the maximum time in milliseconds allowed for the query */ PHP_METHOD(SolrQuery, setTimeAllowed) { solr_char_t *param_name = (solr_char_t *) "timeAllowed"; int param_name_length = sizeof("timeAllowed")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setOmitHeader(bool flag) Sets the omitHeader parameter */ PHP_METHOD(SolrQuery, setOmitHeader) { solr_char_t *param_name = (solr_char_t *) "omitHeader"; int param_name_length = sizeof("omitHeader")-1; int param_value_length = 0; zend_bool omit_header = 0; solr_char_t *omit_header_str = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &omit_header) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } omit_header_str = (omit_header)? "true" : "false"; param_value_length = solr_strlen(omit_header_str); if (solr_set_normal_param(getThis(), param_name, param_name_length, omit_header_str, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, omit_header_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* }}} END OF CommonQueryParameters */ /* {{{ CoreQueryParameters */ /* {{{ proto SolrQuery SolrQuery::setEchoHandler(bool flag) Sets the echoHandler parameter */ PHP_METHOD(SolrQuery, setEchoHandler) { solr_char_t *param_name = (solr_char_t *) "echoHandler"; int param_name_length = sizeof("echoHandler")-1; int param_value_length = 0; zend_bool echo_handler = 0; solr_char_t *echo_handler_str = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &echo_handler) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } echo_handler_str = (echo_handler)? "true" : "false"; param_value_length = solr_strlen(echo_handler_str); if (solr_set_normal_param(getThis(), param_name, param_name_length, echo_handler_str, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, echo_handler_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setEchoParams(string value) Sets the echoParams parameter */ PHP_METHOD(SolrQuery, setEchoParams) { solr_char_t *param_name = (solr_char_t *) "echoParams"; int param_name_length = sizeof("echoParams")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* }}} END OF CoreQueryParameters */ /* {{{ SimpleFacetParameters */ /* {{{ proto SolrQuery SolrQuery::setFacet(bool value) Sets the facet parameter */ PHP_METHOD(SolrQuery, setFacet) { solr_char_t *param_name = (solr_char_t *) "facet"; int param_name_length = sizeof("facet")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_length = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_length, bool_flag_str, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addFacetField(string value) Sets the facet.field parameter */ PHP_METHOD(SolrQuery, addFacetField) { solr_char_t *param_name = (solr_char_t *) "facet.field"; int param_name_len = sizeof("facet.field")-1; solr_char_t *param_value = NULL; int param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add param value %s to %s ", param_value, param_name); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addFacetQuery(string value) Adds another facet.query parameter */ PHP_METHOD(SolrQuery, addFacetQuery) { solr_char_t *param_name = (solr_char_t *) "facet.query"; int param_name_length = sizeof("facet.query")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetPrefix(string value [, string field_override]) Sets the facet.prefix parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetPrefix) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; int param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.prefix"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetSort(int value [, string field_override]) Sets the facet.sort parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetSort) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Parameter value */ solr_char_t *param_value = NULL; int param_value_len = 0; long int sort_type = 0L; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|s", &sort_type, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.sort"); param_value = ((sort_type)? "count" : "index"); param_value_len = solr_strlen(param_value); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetLimit(string value [, string field_override]) Sets the facet.limit parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetLimit) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; int param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.limit"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetOffset(string value [, string field_override]) Sets the facet.offset parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetOffset) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; int param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.offset"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetMinCount(string value [, string field_override]) Sets the facet.mincount parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetMinCount) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; int param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.mincount"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetMissing(bool value [, string field_override]) Sets the facet.missing parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetMissing) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Parameter value */ solr_char_t *param_value = NULL; int param_value_len = 0; zend_bool bool_flag = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b|s", &bool_flag, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.missing"); param_value = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(param_value); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetMethod(string value [, string field_override]) Sets the facet.method parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetMethod) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; int param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.method"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetEnumCacheMinDefaultFrequency(string value [, string field_override]) Sets the facet.enum.cache.minDf parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetEnumCacheMinDefaultFrequency) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; int param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.enum.cache.minDf"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ Date facet parameters */ /* {{{ proto SolrQuery SolrQuery::addFacetDateField(string value) Adds another facet.date parameter. */ PHP_METHOD(SolrQuery, addFacetDateField) { solr_char_t *param_name = (solr_char_t *) "facet.date"; int param_name_length = sizeof("facet.date")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetDateStart(string value [, string field_override]) Sets the facet.date.start parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetDateStart) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; int param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.date.start"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetDateEnd(string value [, string field_override]) Sets the facet.date.end parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetDateEnd) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; int param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.date.end"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetDateGap(string value [, string field_override]) Sets the facet.date.gap parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetDateGap) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; int param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.date.gap"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetDateHardEnd(bool value [, string field_override]) Sets the facet.date.hardend parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetDateHardEnd) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Parameter value */ solr_char_t *param_value = NULL; int param_value_len = 0; zend_bool bool_flag = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b|s", &bool_flag, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.date.hardend"); param_value = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(param_value); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addFacetDateOther(string value [, string field_override]) Sets the facet.date.other parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, addFacetDateOther) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; int param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.date.other"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* }}} End of date facet parameters */ /* }}} End of SimpleFacetParameters */ /* {{{ SimpleGroupParameters */ /* {{{ proto SolrQuery SolrQuery::setGroup(bool value) Enable result grouping (group parameter) */ PHP_METHOD(SolrQuery, setGroup) { solr_char_t *param_name = (solr_char_t *) "group"; int param_name_length = sizeof("group")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_length = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_length, bool_flag_str, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto bool SolrQuery::getGroup() Returns true if grouping is enabled */ PHP_METHOD(SolrQuery, getGroup) { solr_char_t *param_name = (solr_char_t *) "group"; int param_name_length = sizeof("group")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addGroupField(string value) Adds a group.field parameter */ PHP_METHOD(SolrQuery, addGroupField) { solr_char_t *param_name = (solr_char_t *) "group.field"; int param_name_len = sizeof("group.field")-1; solr_char_t *param_value = NULL; int param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add param value %s to %s ", param_value, param_name); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto string SolrQuery::getGroupFields() Returns all the group fields (group.field parameter values) */ PHP_METHOD(SolrQuery, getGroupFields) { solr_char_t *param_name = (solr_char_t *) "group.field"; int param_name_length = sizeof("group.field")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_normal_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addGroupFunction(string value) Adds a group function (group.func parameter) */ PHP_METHOD(SolrQuery, addGroupFunction) { solr_char_t *param_name = (solr_char_t *) "group.func"; int param_name_len = sizeof("group.func")-1; solr_char_t *param_value = NULL; int param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add param value %s to %s ", param_value, param_name); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto string SolrQuery::getGroupFunctions() Returns all the group functions (group.func parameters) */ PHP_METHOD(SolrQuery, getGroupFunctions) { solr_char_t *param_name = (solr_char_t *) "group.func"; int param_name_length = sizeof("group.func")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_normal_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addGroupQuery(string value) Sets the group.query parameter */ PHP_METHOD(SolrQuery, addGroupQuery) { solr_char_t *param_name = (solr_char_t *) "group.query"; int param_name_len = sizeof("group.query")-1; solr_char_t *param_value = NULL; int param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add param value %s to %s ", param_value, param_name); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto string SolrQuery::getGroupQueries() Returns all the group.query parameter values */ PHP_METHOD(SolrQuery, getGroupQueries) { solr_char_t *param_name = (solr_char_t *) "group.query"; int param_name_length = sizeof("group.query")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_normal_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setGroupLimit(string value) Sets the group.limit parameter. */ PHP_METHOD(SolrQuery, setGroupLimit) { solr_char_t *param_name = (solr_char_t *) "group.limit"; int param_name_len = sizeof("group.limit")-1; solr_char_t *param_value = NULL; int param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add param value %s to %s ", param_value, param_name); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto int SolrQuery::getGroupLimit() Returns the group.limit value */ PHP_METHOD(SolrQuery, getGroupLimit) { solr_char_t *param_name = (solr_char_t *) "group.limit"; int param_name_length = sizeof("group.limit")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setGroupOffset(int offset) Sets the group.offset parameter. */ PHP_METHOD(SolrQuery, setGroupOffset) { solr_char_t *param_name = (solr_char_t *) "group.offset"; int param_name_len = sizeof("group.offset")-1; solr_char_t *param_value = NULL; int param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add param value %s to %s ", param_value, param_name); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto int SolrQuery::getGroupOffset() Returns the group.offset value */ PHP_METHOD(SolrQuery, getGroupOffset) { solr_char_t *param_name = (solr_char_t *) "group.offset"; int param_name_length = sizeof("group.offset")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addGroupSortField(string sort[, integer direction]) Add a group sort field (group.sort parameter). */ PHP_METHOD(SolrQuery, addGroupSortField) { solr_char_t *param_name = (solr_char_t *) "group.sort"; int param_name_length = sizeof("group.sort")-1; solr_char_t *param_value = NULL; int param_value_length = 0; long int sort_direction = 1L; solr_sort_dir_t sort_order = SOLR_SORT_DIR_DESC; solr_char_t *avalue = NULL; int avalue_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", ¶m_value, ¶m_value_length, &sort_direction) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } sort_order = (sort_direction < 0L || sort_direction > 1L) ? SOLR_SORT_DIR_DESC : (solr_sort_dir_t) sort_direction; avalue = (sort_order) ? "desc" : "asc"; avalue_length = solr_strlen(avalue); if (solr_add_arg_list_param(getThis(), param_name, param_name_length, param_value, param_value_length, avalue, avalue_length, ',', ' ' TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto array SolrQuery::getGroupSortFields() Returns the group.sort value */ PHP_METHOD(SolrQuery, getGroupSortFields) { solr_char_t *param_name = (solr_char_t *) "group.sort"; int param_name_length = sizeof("group.sort")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_arg_list_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setGroupFormat(string value) Sets the group.format parameter. */ PHP_METHOD(SolrQuery, setGroupFormat) { solr_char_t *param_name = (solr_char_t *) "group.format"; int param_name_len = sizeof("group.format")-1; solr_char_t *param_value = NULL; int param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add param value %s to %s ", param_value, param_name); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto string SolrQuery::getGroupFormat() Returns the group.format value */ PHP_METHOD(SolrQuery, getGroupFormat) { solr_char_t *param_name = (solr_char_t *) "group.format"; int param_name_length = sizeof("group.format")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_string(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setGroupMain(bool value) Sets the group.main parameter */ PHP_METHOD(SolrQuery, setGroupMain) { solr_char_t *param_name = (solr_char_t *) "group.main"; int param_name_length = sizeof("group.main")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_length = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_length, bool_flag_str, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto bool SolrQuery::getGroupMain() Returns the group.main value */ PHP_METHOD(SolrQuery, getGroupMain) { solr_char_t *param_name = (solr_char_t *) "group.main"; int param_name_length = sizeof("group.main")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setGroupNGroups(bool value) Sets the group.ngroups parameter */ PHP_METHOD(SolrQuery, setGroupNGroups) { solr_char_t *param_name = (solr_char_t *) "group.ngroups"; int param_name_length = sizeof("group.ngroups")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_length = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_length, bool_flag_str, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto bool SolrQuery::getGroupNGroups() Returns the group.ngroups value */ PHP_METHOD(SolrQuery, getGroupNGroups) { solr_char_t *param_name = (solr_char_t *) "group.ngroups"; int param_name_length = sizeof("group.ngroups")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setGroupTruncate(bool value) Sets the group.truncate parameter */ PHP_METHOD(SolrQuery, setGroupTruncate) { solr_char_t *param_name = (solr_char_t *) "group.truncate"; int param_name_length = sizeof("group.truncate")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_length = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_length, bool_flag_str, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto bool SolrQuery::getGroupTruncate() Returns the group.truncate value */ PHP_METHOD(SolrQuery, getGroupTruncate) { solr_char_t *param_name = (solr_char_t *) "group.truncate"; int param_name_length = sizeof("group.truncate")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setGroupFacet(bool value) Sets the group.facet parameter */ PHP_METHOD(SolrQuery, setGroupFacet) { solr_char_t *param_name = (solr_char_t *) "group.facet"; int param_name_length = sizeof("group.facet")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_length = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_length, bool_flag_str, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto bool SolrQuery::getGroupFacet() Returns the group.facet value */ PHP_METHOD(SolrQuery, getGroupFacet) { solr_char_t *param_name = (solr_char_t *) "group.facet"; int param_name_length = sizeof("group.facet")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setGroupCachePercent(int value) sets the group cache percent group.cache.percent value */ PHP_METHOD(SolrQuery, setGroupCachePercent) { solr_char_t *param_name = (solr_char_t *) "group.cache.percent"; int param_name_length = sizeof ("group.cache.percent")-1; long cache_pct = 0; solr_char_t pval[4]; int pval_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &cache_pct)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } if (cache_pct < 0 || cache_pct > 100) { solr_throw_exception(solr_ce_SolrIllegalArgumentException, "Group cache percent must be between 0 and 100", SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC); RETURN_NULL(); } snprintf (pval, sizeof(pval), "%ld", cache_pct); pval_len = strlen(pval); if (solr_add_or_set_normal_param(getThis(), param_name, param_name_length, pval, pval_len, 0 TSRMLS_CC)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, pval); efree(pval); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto int SolrQuery::getGroupCachePercent() Gets the group cache percent group.cache.percent value */ PHP_METHOD(SolrQuery, getGroupCachePercent) { solr_char_t *param_name = (solr_char_t *) "group.cache.percent"; int param_name_length = sizeof("group.cache.percent")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* }}} End of SimpleGroupParameters */ /* {{{ proto SolrQuery SolrQuery::collapse(SolrCollapseFunction collapseFunction) Collapse a Solr Query */ PHP_METHOD(SolrQuery, collapse) { solr_char_t *param_name = (solr_char_t *) "fq"; int param_name_len = sizeof("fq")-1; zval *collapse_func_obj; solr_function_t *collapse_func; solr_string_t *buffer = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &collapse_func_obj) == FAILURE) { RETURN_NULL(); } if(solr_fetch_function_entry(collapse_func_obj, &collapse_func TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal Error Unable to fetch function from functions global"); RETURN_NULL(); } /* validate */ if (!zend_hash_exists(collapse_func->params, "field", sizeof("field"))) { solr_throw_exception_ex(solr_ce_SolrMissingMandatoryParameterException,SOLR_ERROR_4100 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_4100_MSG, "field"); } buffer = (solr_string_t *)pemalloc(sizeof(solr_string_t), SOLR_STRING_PERSISTENT); memset(buffer, 0, sizeof(solr_string_t)); solr_solrfunc_to_string(collapse_func, &buffer); if (solr_add_or_set_normal_param(getThis(), param_name, param_name_len, buffer->str, buffer->len, 1 TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, buffer->str); } solr_string_free(buffer); pefree(buffer, SOLR_STRING_PERSISTENT); solr_return_solr_params_object(); } /* }}} */ /* {{{ Expand Parameters */ /* {{{ proto SolrQuery SolrQuery::setExpand(bool value) Sets the expand parameter. This enables or disables group expanding. */ PHP_METHOD(SolrQuery, setExpand) { solr_char_t *param_name = (solr_char_t *) "expand"; int param_name_length = sizeof("expand")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_length = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_length, bool_flag_str, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto bool SolrQuery::getExpand() Returns true if group expanding is enabled */ PHP_METHOD(SolrQuery, getExpand) { solr_char_t *param_name = (solr_char_t *) "expand"; int param_name_length = sizeof("expand")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addExpandSortField(string sort[, integer direction]) Orders the documents within the expanded groups (expand.sort parameter). */ PHP_METHOD(SolrQuery, addExpandSortField) { solr_char_t *param_name = (solr_char_t *) "expand.sort"; int param_name_length = sizeof("expand.sort")-1; solr_char_t *param_value = NULL; int param_value_length = 0; long int sort_direction = 1L; solr_sort_dir_t sort_order = SOLR_SORT_DIR_DESC; solr_char_t *avalue = NULL; int avalue_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", ¶m_value, ¶m_value_length, &sort_direction) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } sort_order = (sort_direction < 0L || sort_direction > 1L) ? SOLR_SORT_DIR_DESC : (solr_sort_dir_t) sort_direction; avalue = (sort_order) ? "desc" : "asc"; avalue_length = solr_strlen(avalue); if (solr_add_arg_list_param(getThis(), param_name, param_name_length, param_value, param_value_length, avalue, avalue_length, ',', ' ' TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeExpandSortField(string field) Removes an expand sort field from the expand.sort parameter. */ PHP_METHOD(SolrQuery, removeExpandSortField) { solr_char_t *pname = (solr_char_t *) "expand.sort"; int pname_length = sizeof("expand.sort")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_arg_list_param_value(getThis(), pname, pname_length, param_value, param_value_length TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto string SolrQuery::getExpandSortFields() returns an array of fields */ PHP_METHOD(SolrQuery, getExpandSortFields) { solr_char_t *param_name = (solr_char_t *) "expand.sort"; int param_name_length = sizeof("expand.sort")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_normal_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setExpandRows(int rows) Sets the number of rows to display in each group (expand.rows). Server Default 5 */ PHP_METHOD(SolrQuery, setExpandRows) { solr_char_t *param_name = (solr_char_t *) "expand.rows"; int param_name_length = sizeof("expand.rows")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto int SolrQuery::getExpandRows() Returns The number of rows to display in each group (expand.rows) */ PHP_METHOD(SolrQuery, getExpandRows) { solr_char_t *param_name = (solr_char_t *) "expand.rows"; int param_name_length = sizeof("expand.rows")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setExpandQuery(string q) Sets the expand.q parameter. Overrides the main q parameter, determines which documents to include in the main group. */ PHP_METHOD(SolrQuery, setExpandQuery) { solr_char_t *param_name = (solr_char_t *) "expand.q"; int param_name_length = sizeof("expand.q")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto string SolrQuery::getExpandQuery() Returns the expand query expand.q parameter */ PHP_METHOD(SolrQuery, getExpandQuery) { solr_char_t *param_name = (solr_char_t *) "expand.q"; int param_name_length = sizeof("expand.q")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_string(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addExpandFilterQuery(string fq) Overrides main fq's, determines which documents to include in the main group. */ PHP_METHOD(SolrQuery, addExpandFilterQuery) { solr_char_t *param_name = (solr_char_t *) "expand.fq"; int param_name_length = sizeof("expand.fq")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeExpandFilterQuery(string fq) Removes an expand filter query. */ PHP_METHOD(SolrQuery, removeExpandFilterQuery) { solr_char_t *pname = (solr_char_t *) "expand.fq"; int pname_length = sizeof("expand.fq")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_normal_param_value(getThis(), pname, pname_length, param_value, param_value_length TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto array SolrQuery::getExpandFilterQueries() Returns the expand filter queries */ PHP_METHOD(SolrQuery, getExpandFilterQueries) { solr_char_t *param_name = (solr_char_t *) "expand.fq"; int param_name_length = sizeof("expand.fq")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_normal_param_value_display(solr_param, return_value); } /* }}} */ /* }}} */ /* {{{ HighlightingParameters */ /* {{{ proto SolrQuery SolrQuery::setHighlight(bool value) Sets the hl parameter. This enables or disables highlighting. */ PHP_METHOD(SolrQuery, setHighlight) { solr_char_t *param_name = (solr_char_t *) "hl"; int param_name_length = sizeof("hl")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_length = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_length, bool_flag_str, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addHighlightField(string value) Adds another hl.fl parameter. */ PHP_METHOD(SolrQuery, addHighlightField) { solr_char_t *list_param_name = (solr_char_t *) "hl.fl"; int list_param_name_len = sizeof("hl.fl")-1; solr_char_t *list_param_value = NULL; int list_param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &list_param_value, &list_param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_simple_list_param(getThis(), list_param_name, list_param_name_len, list_param_value, list_param_value_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add param value %s to %s list ", list_param_value, list_param_name); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightSnippets(string value [, string field_override]) Sets the hl.snippets parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setHighlightSnippets) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; int param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "hl.snippets"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightFragsize(string value [, string field_override]) Sets the hl.fragsize parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setHighlightFragsize) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; int param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "hl.fragsize"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightMergeContiguous(bool flag [, string field_override]) Sets the hl.mergeContiguous parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setHighlightMergeContiguous) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Parameter value */ solr_char_t *param_value = NULL; int param_value_len = 0; zend_bool bool_flag = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b|s", &bool_flag, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "hl.mergeContiguous"); param_value = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(param_value); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightRequireFieldMatch(bool flag) Sets the hl.requireFieldMatch. */ PHP_METHOD(SolrQuery, setHighlightRequireFieldMatch) { solr_char_t *param_name = (solr_char_t *) "hl.requireFieldMatch"; int param_name_length = sizeof("hl.requireFieldMatch")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_length = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_length, bool_flag_str, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightMaxAnalyzedChars(string value) Sets the hl.maxAnalyzedChars parameter */ PHP_METHOD(SolrQuery, setHighlightMaxAnalyzedChars) { solr_char_t *param_name = (solr_char_t *) "hl.maxAnalyzedChars"; int param_name_length = sizeof("hl.maxAnalyzedChars")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightAlternateField(string value [, string field_override]) Sets the hl.alternateField parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setHighlightAlternateField) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; int param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "hl.alternateField"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightMaxAlternateFieldLength(string value [, string field_override]) Sets the hl.maxAlternateFieldLength parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setHighlightMaxAlternateFieldLength) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; int param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "hl.maxAlternateFieldLength"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightFormatter(string value [, string field_override]) Sets the hl.formatter parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setHighlightFormatter) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = "simple"; int param_value_len = sizeof("simple")-1; /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "hl.formatter"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightSimplePre(string value [, string field_override]) Sets the hl.simple.pre parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setHighlightSimplePre) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = ""; int param_value_len = sizeof("")-1; /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "hl.simple.pre"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightSimplePost(string value [, string field_override]) Sets the hl.simple.post parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setHighlightSimplePost) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = ""; int param_value_len = sizeof("")-1; /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "hl.simple.post"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightFragmenter(string value [, string field_override]) Sets the hl.fragmenter parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setHighlightFragmenter) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; int param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "hl.fragmenter"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightUsePhraseHighlighter(bool flag) Sets the hl.usePhraseHighlighter parameter. */ PHP_METHOD(SolrQuery, setHighlightUsePhraseHighlighter) { solr_char_t *param_name = (solr_char_t *) "hl.usePhraseHighlighter"; int param_name_length = sizeof("hl.usePhraseHighlighter")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_length = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_length, bool_flag_str, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightHighlightMultiTerm(bool flag) Sets the hl.highlightMultiTerm parameter. */ PHP_METHOD(SolrQuery, setHighlightHighlightMultiTerm) { solr_char_t *param_name = (solr_char_t *) "hl.highlightMultiTerm"; int param_name_length = sizeof("hl.highlightMultiTerm")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_length = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_length, bool_flag_str, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightRegexSlop(string value) Sets the hl.regex.slop parameter. */ PHP_METHOD(SolrQuery, setHighlightRegexSlop) { solr_char_t *param_name = (solr_char_t *) "hl.regex.slop"; int param_name_length = sizeof("hl.regex.slop")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightRegexPattern(string value) Sets the hl.regex.pattern parameter. */ PHP_METHOD(SolrQuery, setHighlightRegexPattern) { solr_char_t *param_name = (solr_char_t *) "hl.regex.pattern"; int param_name_length = sizeof("hl.regex.pattern")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightRegexMaxAnalyzedChars(string value) Sets the hl.regex.maxAnalyzedChars parameter. */ PHP_METHOD(SolrQuery, setHighlightRegexMaxAnalyzedChars) { solr_char_t *param_name = (solr_char_t *) "hl.regex.maxAnalyzedChars"; int param_name_length = sizeof("hl.regex.maxAnalyzedChars")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* }}} End of HighlightingParameters */ /* {{{ StatsComponent */ /* {{{ proto SolrQuery SolrQuery::setStats(bool flag) Sets the stats parameter. Enables or disables stats */ PHP_METHOD(SolrQuery, setStats) { solr_char_t *param_name = (solr_char_t *) "stats"; int param_name_length = sizeof("stats")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_length = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_length, bool_flag_str, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addStatsField(string value) Adds another stats.field parameter. */ PHP_METHOD(SolrQuery, addStatsField) { solr_char_t *param_name = (solr_char_t *) "stats.field"; int param_name_length = sizeof("stats.field")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error adding parameter %s=%s ", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addStatsFacet(string value) Adds another stats.facet parameter. */ PHP_METHOD(SolrQuery, addStatsFacet) { solr_char_t *param_name = (solr_char_t *) "stats.facet"; int param_name_length = sizeof("stats.facet")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error adding parameter %s=%s ", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* }}} End of StatsComponent */ /* {{{ MoreLikeThis */ /* {{{ proto SolrQuery SolrQuery::setMlt(bool flag) Sets the mlt parameter. Enables or disables the moreLikeThis component */ PHP_METHOD(SolrQuery, setMlt) { solr_char_t *param_name = (solr_char_t *) "mlt"; int param_name_length = sizeof("mlt")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_length = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_length, bool_flag_str, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setMltCount(string value) Sets the mlt.count parameter. */ PHP_METHOD(SolrQuery, setMltCount) { solr_char_t *param_name = (solr_char_t *) "mlt.count"; int param_name_length = sizeof("mlt.count")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addMltField(string field) Adds another field name to the mlt.fl parameter. */ PHP_METHOD(SolrQuery, addMltField) { solr_char_t *list_param_name = (solr_char_t *) "mlt.fl"; int list_param_name_len = sizeof("mlt.fl")-1; solr_char_t *list_param_value = NULL; int list_param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &list_param_value, &list_param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_simple_list_param(getThis(), list_param_name, list_param_name_len, list_param_value, list_param_value_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add param value %s to %s list ", list_param_value, list_param_name); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addMltQueryField(string value, string boost) Adds another query field and boost value to the mlt.qf parameter. */ PHP_METHOD(SolrQuery, addMltQueryField) { solr_char_t *param_name = (solr_char_t *) "mlt.qf"; int param_name_length = sizeof("mlt.qf")-1; solr_char_t *query_field = NULL; int query_field_length = 0; solr_char_t *boost_value = "1.0"; int boost_value_length = sizeof("1.0"); /* TODO: make boost optional parameter. */ /* If boost is not sent, then the index time boost is used */ /* This will involve re-doing all the arg_list functions to allow optional args. */ /* Temporary solution is to use SolrQuery::add("mlt.qf", "value"). This should be documented. */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &query_field, &query_field_length, &boost_value, &boost_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_arg_list_param(getThis(), param_name, param_name_length, query_field, query_field_length, boost_value, boost_value_length, ' ', '^' TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setMltMinTermFrequency(string value) Sets the mlt.mintf parameter. */ PHP_METHOD(SolrQuery, setMltMinTermFrequency) { solr_char_t *param_name = (solr_char_t *) "mlt.mintf"; int param_name_length = sizeof("mlt.mintf")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setMltMinDocFrequency(string value) Sets the mlt.mindf parameter. */ PHP_METHOD(SolrQuery, setMltMinDocFrequency) { solr_char_t *param_name = (solr_char_t *) "mlt.mindf"; int param_name_length = sizeof("mlt.mindf")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setMltMinWordLength(string value) Sets the mlt.minwl parameter. */ PHP_METHOD(SolrQuery, setMltMinWordLength) { solr_char_t *param_name = (solr_char_t *) "mlt.minwl"; int param_name_length = sizeof("mlt.minwl")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setMltMaxWordLength(string value) Sets the mlt.maxwl parameter. */ PHP_METHOD(SolrQuery, setMltMaxWordLength) { solr_char_t *param_name = (solr_char_t *) "mlt.maxwl"; int param_name_length = sizeof("mlt.maxwl")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setMltMaxNumTokens(string value) Sets the mlt.maxntp parameter. */ PHP_METHOD(SolrQuery, setMltMaxNumTokens) { solr_char_t *param_name = (solr_char_t *) "mlt.maxntp"; int param_name_length = sizeof("mlt.maxntp")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setMltMaxNumQueryTerms(string value) Sets the mlt.maxqt parameter. */ PHP_METHOD(SolrQuery, setMltMaxNumQueryTerms) { solr_char_t *param_name = (solr_char_t *) "mlt.maxqt"; int param_name_length = sizeof("mlt.maxqt")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setMltBoost(bool flag) Sets the mlt.boost parameter. */ PHP_METHOD(SolrQuery, setMltBoost) { solr_char_t *param_name = (solr_char_t *) "mlt.boost"; int param_name_length = sizeof("mlt.boost")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_length = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_length, bool_flag_str, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* }}} End of MoreLikeThis */ /* {{{ TermsComponent */ /* {{{ proto SolrQuery SolrQuery::setTerms(bool flag) Sets the terms parameter. This flag enables or disables the TermsComponent */ PHP_METHOD(SolrQuery, setTerms) { solr_char_t *param_name = (solr_char_t *) "terms"; int param_name_length = sizeof("terms")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_length = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_length, bool_flag_str, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTermsField(string field) Sets the terms.fl parameter. */ PHP_METHOD(SolrQuery, setTermsField) { solr_char_t *param_name = (solr_char_t *) "terms.fl"; int param_name_length = sizeof("terms.fl")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTermsLowerBound(string value) Sets the terms.lower parameter. */ PHP_METHOD(SolrQuery, setTermsLowerBound) { solr_char_t *param_name = (solr_char_t *) "terms.lower"; int param_name_length = sizeof("terms.lower")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTermsUpperBound(string value) Sets the terms.upper parameter. */ PHP_METHOD(SolrQuery, setTermsUpperBound) { solr_char_t *param_name = (solr_char_t *) "terms.upper"; int param_name_length = sizeof("terms.upper")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTermsIncludeLowerBound(string value) Sets the terms.lower.incl parameter. */ PHP_METHOD(SolrQuery, setTermsIncludeLowerBound) { solr_char_t *param_name = (solr_char_t *) "terms.lower.incl"; int param_name_length = sizeof("terms.lower.incl")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_length = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_length, bool_flag_str, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTermsIncludeUpperBound(string value) Sets the terms.upper.incl parameter. */ PHP_METHOD(SolrQuery, setTermsIncludeUpperBound) { solr_char_t *param_name = (solr_char_t *) "terms.upper.incl"; int param_name_length = sizeof("terms.upper.incl")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_length = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_length, bool_flag_str, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTermsMinCount(string value) Sets the terms.mincount parameter. */ PHP_METHOD(SolrQuery, setTermsMinCount) { solr_char_t *param_name = (solr_char_t *) "terms.mincount"; int param_name_length = sizeof("terms.mincount")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTermsMaxCount(string value) Sets the terms.maxcount parameter. */ PHP_METHOD(SolrQuery, setTermsMaxCount) { solr_char_t *param_name = (solr_char_t *) "terms.maxcount"; int param_name_length = sizeof("terms.maxcount")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTermsPrefix(string value) Sets the terms.prefix parameter. */ PHP_METHOD(SolrQuery, setTermsPrefix) { solr_char_t *param_name = (solr_char_t *) "terms.prefix"; int param_name_length = sizeof("terms.prefix")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTermsLimit(string value) Sets the terms.limit parameter. */ PHP_METHOD(SolrQuery, setTermsLimit) { solr_char_t *param_name = (solr_char_t *) "terms.limit"; int param_name_length = sizeof("terms.limit")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTermsReturnRaw(bool flag) Sets the terms.raw parameter. */ PHP_METHOD(SolrQuery, setTermsReturnRaw) { solr_char_t *param_name = (solr_char_t *) "terms.raw"; int param_name_length = sizeof("terms.raw")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_length = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_length, bool_flag_str, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTermsSort(int sort) Sets the terms.sort parameter. */ PHP_METHOD(SolrQuery, setTermsSort) { solr_char_t *param_name = (solr_char_t *) "terms.sort"; int param_name_length = sizeof("terms.sort")-1; long int sort_type = 0L; solr_char_t *sort_type_str = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &sort_type) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } sort_type_str = ((sort_type)? "count" : "index"); param_value_length = solr_strlen(sort_type_str); if (solr_set_normal_param(getThis(), param_name, param_name_length, sort_type_str, param_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, sort_type_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* }}} End of TermsComponent */ /* {{{ Value removal methods */ /* {{{ proto SolrQuery SolrQuery::removeField(string fl) Removes a field from the fl parameter */ PHP_METHOD(SolrQuery, removeField) { solr_char_t *pname = (solr_char_t *) "fl"; int pname_length = sizeof("fl")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_simple_list_param_value(getThis(), pname, pname_length, param_value, param_value_length TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeSortField(string fl) Removes a sort field from the sort parameter. */ PHP_METHOD(SolrQuery, removeSortField) { solr_char_t *pname = (solr_char_t *) "sort"; int pname_length = sizeof("sort")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_arg_list_param_value(getThis(), pname, pname_length, param_value, param_value_length TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeFilterQuery(string fq) Removes one of the fq parameter. */ PHP_METHOD(SolrQuery, removeFilterQuery) { solr_char_t *pname = (solr_char_t *) "fq"; int pname_length = sizeof("fq")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_normal_param_value(getThis(), pname, pname_length, param_value, param_value_length TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeFacetField(string field) Removes one of fields from the facet.field parameter. */ PHP_METHOD(SolrQuery, removeFacetField) { solr_char_t *pname = (solr_char_t *) "facet.field"; int pname_length = sizeof("facet.field")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_normal_param_value(getThis(), pname, pname_length, param_value, param_value_length TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeFacetQuery(string facet_query) Removes one of the facet.query parameters. */ PHP_METHOD(SolrQuery, removeFacetQuery) { solr_char_t *pname = (solr_char_t *) "facet.query"; int pname_length = sizeof("facet.query")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_normal_param_value(getThis(), pname, pname_length, param_value, param_value_length TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeFacetDateField(string date_field) Removes one of the facet.date parameters. */ PHP_METHOD(SolrQuery, removeFacetDateField) { solr_char_t *pname = (solr_char_t *) "facet.date"; int pname_length = sizeof("facet.date")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_normal_param_value(getThis(), pname, pname_length, param_value, param_value_length TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeFacetDateOther(string value [, string field_override]) Removes one of the facet.date.other parameters. Also accepts an optional field override. */ PHP_METHOD(SolrQuery, removeFacetDateOther) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; int param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; int field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.date.other"); solr_delete_normal_param_value(getThis(), fbuf.str, fbuf.len, param_value, param_value_len TSRMLS_CC); solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeHighlightField(string field) Removes one of the fields from the hl.fl parameter. */ PHP_METHOD(SolrQuery, removeHighlightField) { solr_char_t *pname = (solr_char_t *) "hl.fl"; int pname_length = sizeof("hl.fl")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_simple_list_param_value(getThis(), pname, pname_length, param_value, param_value_length TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeStatsField(string field) Removes one of the stats.field parameters. */ PHP_METHOD(SolrQuery, removeStatsField) { solr_char_t *pname = (solr_char_t *) "stats.field"; int pname_length = sizeof("stats.field")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_normal_param_value(getThis(), pname, pname_length, param_value, param_value_length TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeStatsFacet(string value) Removes one of the stats.facet parameters. */ PHP_METHOD(SolrQuery, removeStatsFacet) { solr_char_t *pname = (solr_char_t *) "stats.facet"; int pname_length = sizeof("stats.facet")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_normal_param_value(getThis(), pname, pname_length, param_value, param_value_length TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeMltField(string field) Removes one of the fields from the mlt.fl parameter. */ PHP_METHOD(SolrQuery, removeMltField) { solr_char_t *pname = (solr_char_t *) "mlt.fl"; int pname_length = sizeof("mlt.fl")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_simple_list_param_value(getThis(), pname, pname_length, param_value, param_value_length TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeMltQueryField(string field) Removes one of the values from the mlt.qf parameter. */ PHP_METHOD(SolrQuery, removeMltQueryField) { solr_char_t *pname = (solr_char_t *) "mlt.qf"; int pname_length = sizeof("mlt.qf")-1; solr_char_t *param_value = NULL; int param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_arg_list_param_value(getThis(), pname, pname_length, param_value, param_value_length TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* }}} End of Value removal methods */ /* {{{ Begin getter methods */ /* {{{ proto string SolrQuery::getQuery() Returns the query */ PHP_METHOD(SolrQuery, getQuery) { solr_char_t *param_name = (solr_char_t *) "q"; int param_name_length = sizeof("q")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_string(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getStart() Returns the start parameter */ PHP_METHOD(SolrQuery, getStart) { solr_char_t *param_name = (solr_char_t *) "start"; int param_name_length = sizeof("start")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getRows() Returns the rows parameter */ PHP_METHOD(SolrQuery, getRows) { solr_char_t *param_name = (solr_char_t *) "rows"; int param_name_length = sizeof("rows")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto array SolrQuery::getFields() Returns the fields */ PHP_METHOD(SolrQuery, getFields) { solr_char_t *param_name = (solr_char_t *) "fl"; int param_name_length = sizeof("fl")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_simple_list_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto array SolrQuery::getSortFields() Returns all the sort fields */ PHP_METHOD(SolrQuery, getSortFields) { solr_char_t *param_name = (solr_char_t *) "sort"; int param_name_length = sizeof("sort")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_arg_list_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getFilterQueries() Returns all the filter queries */ PHP_METHOD(SolrQuery, getFilterQueries) { solr_char_t *param_name = (solr_char_t *) "fq"; int param_name_length = sizeof("fq")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_normal_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getTimeAllowed() Returns the maximum time in milliseconds allowed for the search query */ PHP_METHOD(SolrQuery, getTimeAllowed) { solr_char_t *param_name = (solr_char_t *) "timeAllowed"; int param_name_length = sizeof("timeAllowed")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto bool SolrQuery::getFacet() Returns true is faceting is enabled */ PHP_METHOD(SolrQuery, getFacet) { solr_char_t *param_name = (solr_char_t *) "facet"; int param_name_length = sizeof("facet")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getFacetFields() Returns all the facet fields */ PHP_METHOD(SolrQuery, getFacetFields) { solr_char_t *param_name = (solr_char_t *) "facet.field"; int param_name_length = sizeof("facet.field")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_normal_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getFacetQueries() Returns all the facet queries */ PHP_METHOD(SolrQuery, getFacetQueries) { solr_char_t *param_name = (solr_char_t *) "facet.query"; int param_name_length = sizeof("facet.query")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_normal_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getFacetPrefix([string field_override]) Returns the prefix for the facet */ PHP_METHOD(SolrQuery, getFacetPrefix) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.prefix"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_string(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto int SolrQuery::getFacetSort([string field_override]) Returns the facet sort state (for the field, if it was overridden) */ PHP_METHOD(SolrQuery, getFacetSort) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.sort"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_sort_type(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto int SolrQuery::getFacetLimit([string field_override]) Returns the maximum number of items for the facet */ PHP_METHOD(SolrQuery, getFacetLimit) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.limit"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_integer(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto int SolrQuery::getFacetOffset([string field_override]) Returns the offset into the list of constraints */ PHP_METHOD(SolrQuery, getFacetOffset) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.offset"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_integer(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto int SolrQuery::getFacetMinCount([string field_override]) Returns the minimum count for the facet */ PHP_METHOD(SolrQuery, getFacetMinCount) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.mincount"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_integer(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto bool SolrQuery::getFacetMissing([string field_override]) Returns the facet.missing parameter */ PHP_METHOD(SolrQuery, getFacetMissing) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.missing"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_boolean(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrQuery::getFacetMethod([string field_override]) Returns the facet.method parameter */ PHP_METHOD(SolrQuery, getFacetMethod) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.method"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_string(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto array SolrQuery::getFacetDateFields() Returns all the facet.date fields */ PHP_METHOD(SolrQuery, getFacetDateFields) { solr_char_t *param_name = (solr_char_t *) "facet.date"; int param_name_length = sizeof("facet.date")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_normal_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getFacetDateStart([string field_override]) Returns the facet.date.start parameter */ PHP_METHOD(SolrQuery, getFacetDateStart) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.date.start"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_string(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrQuery::getFacetDateEnd([string field_override]) Returns the facet.date.end parameter */ PHP_METHOD(SolrQuery, getFacetDateEnd) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.date.end"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_string(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrQuery::getFacetDateGap([string field_override]) Returns the facet.date.gap */ PHP_METHOD(SolrQuery, getFacetDateGap) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.date.gap"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_string(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto bool SolrQuery::getFacetDateHardEnd([string field_override]) Returns the facet.date.hardend parameter */ PHP_METHOD(SolrQuery, getFacetDateHardEnd) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.date.hardend"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_boolean(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrQuery::getFacetDateOther([string field_override]) Returns the facet.date.other parameter */ PHP_METHOD(SolrQuery, getFacetDateOther) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.date.other"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { array_init(return_value); solr_normal_param_value_display(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto bool SolrQuery::getHighlight() Returns the state of the hl parameter */ PHP_METHOD(SolrQuery, getHighlight) { solr_char_t *param_name = (solr_char_t *) "hl"; int param_name_length = sizeof("hl")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto array SolrQuery::getHighlightFields() Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightFields) { solr_char_t *param_name = (solr_char_t *) "hl.fl"; int param_name_length = sizeof("hl.fl")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_simple_list_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getHighlightSnippets([string field_override]) Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightSnippets) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "hl.snippets"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_integer(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto int SolrQuery::getHighlightFragsize([string field_override]) Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightFragsize) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "hl.fragsize"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_integer(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto bool SolrQuery::getHighlightMergeContiguous([string field_override]) Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightMergeContiguous) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "hl.mergeContiguous"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_boolean(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto bool SolrQuery::getHighlightRequireFieldMatch() Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightRequireFieldMatch) { solr_char_t *param_name = (solr_char_t *) "hl.requireFieldMatch"; int param_name_length = sizeof("hl.requireFieldMatch")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getHighlightMaxAnalyzedChars() Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightMaxAnalyzedChars) { solr_char_t *param_name = (solr_char_t *) "hl.maxAnalyzedChars"; int param_name_length = sizeof("hl.maxAnalyzedChars")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getHighlightAlternateField([string field_override]) Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightAlternateField) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "hl.alternateField"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_string(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto int SolrQuery::getHighlightMaxAlternateFieldLength([string field_override]) Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightMaxAlternateFieldLength) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "hl.maxAlternateFieldLength"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_integer(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrQuery::getHighlightFormatter([string field_override]) Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightFormatter) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "hl.formatter"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_string(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrQuery::getHighlightSimplePre([string field_override]) Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightSimplePre) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "hl.simple.pre"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_string(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrQuery::getHighlightSimplePost([string field_override]) Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightSimplePost) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "hl.simple.post"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_string(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrQuery::getHighlightFragmenter([string field_override]) Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightFragmenter) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; int field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "hl.fragmenter"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_string(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto bool SolrQuery::getHighlightUsePhraseHighlighter() Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightUsePhraseHighlighter) { solr_char_t *param_name = (solr_char_t *) "hl.usePhraseHighlighter"; int param_name_length = sizeof("hl.usePhraseHighlighter")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto bool SolrQuery::getHighlightHighlightMultiTerm() Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightHighlightMultiTerm) { solr_char_t *param_name = (solr_char_t *) "hl.highlightMultiTerm"; int param_name_length = sizeof("hl.highlightMultiTerm")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto float SolrQuery::getHighlightRegexSlop() Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightRegexSlop) { solr_char_t *param_name = (solr_char_t *) "hl.regex.slop"; int param_name_length = sizeof("hl.regex.slop")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_double(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getHighlightRegexPattern() Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightRegexPattern) { solr_char_t *param_name = (solr_char_t *) "hl.regex.pattern"; int param_name_length = sizeof("hl.regex.pattern")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_string(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getHighlightRegexMaxAnalyzedChars() Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightRegexMaxAnalyzedChars) { solr_char_t *param_name = (solr_char_t *) "hl.regex.maxAnalyzedChars"; int param_name_length = sizeof("hl.regex.maxAnalyzedChars")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto bool SolrQuery::getStats() Returns the status of the stats parameter */ PHP_METHOD(SolrQuery, getStats) { solr_char_t *param_name = (solr_char_t *) "stats"; int param_name_length = sizeof("stats")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto array SolrQuery::getStatsFields() Returns the stats.field parameters */ PHP_METHOD(SolrQuery, getStatsFields) { solr_char_t *param_name = (solr_char_t *) "stats.field"; int param_name_length = sizeof("stats.field")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_normal_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getStatsFacets() Returns all the stats facets */ PHP_METHOD(SolrQuery, getStatsFacets) { solr_char_t *param_name = (solr_char_t *) "stats.facet"; int param_name_length = sizeof("stats.facet")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_normal_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto bool SolrQuery::getMlt() Returns the parameter */ PHP_METHOD(SolrQuery, getMlt) { solr_char_t *param_name = (solr_char_t *) "mlt"; int param_name_length = sizeof("mlt")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getMltCount() Returns the parameter */ PHP_METHOD(SolrQuery, getMltCount) { solr_char_t *param_name = (solr_char_t *) "mlt.count"; int param_name_length = sizeof("mlt.count")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto array SolrQuery::getMltFields() Returns the parameter */ PHP_METHOD(SolrQuery, getMltFields) { solr_char_t *param_name = (solr_char_t *) "mlt.fl"; int param_name_length = sizeof("mlt.fl")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_simple_list_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto array SolrQuery::getMltQueryFields() Returns the parameter */ PHP_METHOD(SolrQuery, getMltQueryFields) { solr_char_t *param_name = (solr_char_t *) "mlt.qf"; int param_name_length = sizeof("mlt.qf")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_arg_list_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getMltMinTermFrequency() Returns the parameter */ PHP_METHOD(SolrQuery, getMltMinTermFrequency) { solr_char_t *param_name = (solr_char_t *) "mlt.mintf"; int param_name_length = sizeof("mlt.mintf")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getMltMinDocFrequency() Returns the parameter */ PHP_METHOD(SolrQuery, getMltMinDocFrequency) { solr_char_t *param_name = (solr_char_t *) "mlt.mindf"; int param_name_length = sizeof("mlt.mindf")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getMltMinWordLength() Returns the parameter */ PHP_METHOD(SolrQuery, getMltMinWordLength) { solr_char_t *param_name = (solr_char_t *) "mlt.minwl"; int param_name_length = sizeof("mlt.minwl")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getMltMaxWordLength() Returns the parameter */ PHP_METHOD(SolrQuery, getMltMaxWordLength) { solr_char_t *param_name = (solr_char_t *) "mlt.maxwl"; int param_name_length = sizeof("mlt.maxwl")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getMltMaxNumTokens() Returns the parameter */ PHP_METHOD(SolrQuery, getMltMaxNumTokens) { solr_char_t *param_name = (solr_char_t *) "mlt.maxntp"; int param_name_length = sizeof("mlt.maxntp")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getMltMaxNumQueryTerms() Returns the parameter */ PHP_METHOD(SolrQuery, getMltMaxNumQueryTerms) { solr_char_t *param_name = (solr_char_t *) "mlt.maxqt"; int param_name_length = sizeof("mlt.maxqt")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto bool SolrQuery::getMltBoost() Returns the parameter */ PHP_METHOD(SolrQuery, getMltBoost) { solr_char_t *param_name = (solr_char_t *) "mlt.boost"; int param_name_length = sizeof("mlt.boost")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto bool SolrQuery::getTerms() Returns the parameter */ PHP_METHOD(SolrQuery, getTerms) { solr_char_t *param_name = (solr_char_t *) "terms"; int param_name_length = sizeof("terms")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getTermsField() Returns the parameter */ PHP_METHOD(SolrQuery, getTermsField) { solr_char_t *param_name = (solr_char_t *) "terms.fl"; int param_name_length = sizeof("terms.fl")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_string(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getTermsLowerBound() Returns the parameter */ PHP_METHOD(SolrQuery, getTermsLowerBound) { solr_char_t *param_name = (solr_char_t *) "terms.lower"; int param_name_length = sizeof("terms.lower")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_string(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getTermsUpperBound() Returns the parameter */ PHP_METHOD(SolrQuery, getTermsUpperBound) { solr_char_t *param_name = (solr_char_t *) "terms.upper"; int param_name_length = sizeof("terms.upper")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_string(solr_param, return_value); } /* }}} */ /* {{{ proto bool SolrQuery::getTermsIncludeLowerBound() Returns the parameter */ PHP_METHOD(SolrQuery, getTermsIncludeLowerBound) { solr_char_t *param_name = (solr_char_t *) "terms.lower.incl"; int param_name_length = sizeof("terms.lower.incl")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto bool SolrQuery::getTermsIncludeUpperBound() Returns the parameter */ PHP_METHOD(SolrQuery, getTermsIncludeUpperBound) { solr_char_t *param_name = (solr_char_t *) "terms.upper.incl"; int param_name_length = sizeof("terms.upper.incl")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getTermsMinCount() Returns the parameter */ PHP_METHOD(SolrQuery, getTermsMinCount) { solr_char_t *param_name = (solr_char_t *) "terms.mincount"; int param_name_length = sizeof("terms.mincount")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getTermsMaxCount() Returns the parameter */ PHP_METHOD(SolrQuery, getTermsMaxCount) { solr_char_t *param_name = (solr_char_t *) "terms.maxcount"; int param_name_length = sizeof("terms.maxcount")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getTermsPrefix() Returns the parameter */ PHP_METHOD(SolrQuery, getTermsPrefix) { solr_char_t *param_name = (solr_char_t *) "terms.prefix"; int param_name_length = sizeof("terms.prefix")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_string(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getTermsLimit() Returns the parameter */ PHP_METHOD(SolrQuery, getTermsLimit) { solr_char_t *param_name = (solr_char_t *) "terms.limit"; int param_name_length = sizeof("terms.limit")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto bool SolrQuery::getTermsReturnRaw() Returns the parameter */ PHP_METHOD(SolrQuery, getTermsReturnRaw) { solr_char_t *param_name = (solr_char_t *) "terms.raw"; int param_name_length = sizeof("terms.raw")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getTermsSort() Returns the parameter */ PHP_METHOD(SolrQuery, getTermsSort) { solr_char_t *param_name = (solr_char_t *) "terms.sort"; int param_name_length = sizeof("terms.sort")-1; solr_param_t *solr_param = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_sort_type(solr_param, return_value); } /* }}} */ /* }}} End of getter methods */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/php_solr_response.c0000644000175000017500000003145212676753706016555 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* {{{ Macro for extracting property values using string constants */ #define solr_read_response_object_property(objptr, name, silent) zend_read_property(Z_OBJCE_P(objptr), objptr, name, sizeof(name)-1, silent TSRMLS_CC) /* }}} */ /* {{{ proto int SolrResponse::getHttpStatus(void) Returns the value of the http_status property. */ PHP_METHOD(SolrResponse, getHttpStatus) { zend_bool silent = 1; zval *objptr = getThis(); zval *http_status = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } http_status = solr_read_response_object_property(objptr, "http_status", silent); RETURN_LONG(Z_LVAL_P(http_status)); } /* }}} */ /* {{{ proto string SolrResponse::getHttpStatusMessage(void) Returns the http_status_message property. */ PHP_METHOD(SolrResponse, getHttpStatusMessage) { zend_bool silent = 1; zval *objptr = getThis(); zval *http_status_message = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } http_status_message = solr_read_response_object_property(objptr, "http_status_message", silent); RETURN_STRINGL(Z_STRVAL_P(http_status_message), Z_STRLEN_P(http_status_message), 1); } /* }}} */ /* {{{ proto bool SolrResponse::success(void) Returns whether the request was successful or not. */ PHP_METHOD(SolrResponse, success) { zend_bool silent = 1; zval *objptr = getThis(); zval *success = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } success = solr_read_response_object_property(objptr, "success", silent); RETURN_BOOL(Z_BVAL_P(success)); } /* }}} */ /* {{{ proto string SolrResponse::getRequestUrl(void) Returns the URL used for the request. */ PHP_METHOD(SolrResponse, getRequestUrl) { zend_bool silent = 1; zval *objptr = getThis(); zval *prop = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } prop = solr_read_response_object_property(objptr, "http_request_url", silent); RETURN_STRINGL(Z_STRVAL_P(prop), Z_STRLEN_P(prop), 1); } /* }}} */ /* {{{ proto string SolrResponse::getRawRequestHeaders(void) Returns the raw http request headers sent to the server. */ PHP_METHOD(SolrResponse, getRawRequestHeaders) { zend_bool silent = 1; zval *objptr = getThis(); zval *prop = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } prop = solr_read_response_object_property(objptr, "http_raw_request_headers", silent); RETURN_STRINGL(Z_STRVAL_P(prop), Z_STRLEN_P(prop), 1); } /* }}} */ /* {{{ proto string SolrResponse::getRawRequest(void) Returns the raw http request sent to the server. */ PHP_METHOD(SolrResponse, getRawRequest) { zend_bool silent = 1; zval *objptr = getThis(); zval *prop = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } prop = solr_read_response_object_property(objptr, "http_raw_request", silent); RETURN_STRINGL(Z_STRVAL_P(prop), Z_STRLEN_P(prop), 1); } /* }}} */ /* {{{ proto string SolrResponse::getRawResponseHeaders(void) Returns the raw http response headers from the server. */ PHP_METHOD(SolrResponse, getRawResponseHeaders) { zend_bool silent = 1; zval *objptr = getThis(); zval *prop = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } prop = solr_read_response_object_property(objptr, "http_raw_response_headers", silent); RETURN_STRINGL(Z_STRVAL_P(prop), Z_STRLEN_P(prop), 1); } /* }}} */ /* {{{ proto string SolrResponse::getRawResponse(void) Returns the raw http response from the server. */ PHP_METHOD(SolrResponse, getRawResponse) { zend_bool silent = 1; zval *objptr = getThis(); zval *prop = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } prop = solr_read_response_object_property(objptr, "http_raw_response", silent); if (Z_STRLEN_P(prop)) { RETURN_STRINGL(Z_STRVAL_P(prop), Z_STRLEN_P(prop), 1); } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrResponse::getDigestedResponse(void) Returns the serialized object string derived from the XML response. */ PHP_METHOD(SolrResponse, getDigestedResponse) { zend_bool silent = 0; zval *objptr = getThis(); zval *prop = NULL; if (!return_value_used) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); return; } prop = solr_read_response_object_property(objptr, "http_digested_response", silent); if (Z_STRLEN_P(prop)) { RETURN_STRINGL(Z_STRVAL_P(prop), Z_STRLEN_P(prop), 1); } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrReponse::setParseMode([bool parse_mode]) Sets the parsing mode. This determines whether documents will be parsed as SolrObjects or SolrDocuments. */ PHP_METHOD(SolrResponse, setParseMode) { long int parse_mode = 0L; zval *objptr = getThis(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &parse_mode) == FAILURE) { RETURN_FALSE; } parse_mode = ((parse_mode < 0L) ? 0L : ((parse_mode > 1L) ? 1L : parse_mode)); zend_update_property_long(Z_OBJCE_P(objptr), objptr, "parser_mode", sizeof("parser_mode")-1, parse_mode TSRMLS_CC); RETURN_TRUE; } /* }}} */ /* {{{ proto SolrObject SolrResponse::getResponse(void) Returns the response object from the server. */ PHP_METHOD(SolrResponse, getResponse) { solr_response_get_response_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU,0); } /* }}} */ /* {{{ proto array SolrResponse::getArrayResponse(void) Returns the response array from the server. */ PHP_METHOD(SolrResponse, getArrayResponse) { solr_response_get_response_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU,1); } /* }}} */ /** * Digest solr server raw response * and return SolrObject or array */ PHP_SOLR_API void solr_response_get_response_impl( INTERNAL_FUNCTION_PARAMETERS, int return_array) { zend_bool silent = 0; zval *objptr = getThis(); if (return_value_used) { zval *response_writer = solr_read_response_object_property(objptr, "response_writer", silent); zval *raw_response = solr_read_response_object_property(objptr, "http_raw_response", silent); zval *success = solr_read_response_object_property(objptr, "success", silent); zval *parser_mode = solr_read_response_object_property(objptr, "parser_mode", silent); if (Z_BVAL_P(success) && Z_STRLEN_P(raw_response)) { solr_string_t buffer; php_unserialize_data_t var_hash; const unsigned char *raw_resp; size_t raw_res_length; const unsigned char *str_end; int successful = 1; memset(&buffer, 0, sizeof(solr_string_t)); if (Z_STRLEN_P(response_writer)) { if (0 == strcmp(Z_STRVAL_P(response_writer), SOLR_XML_RESPONSE_WRITER)) { /* SOLR_XML_RESPONSE_WRITER */ /* Convert from XML serialization to PHP serialization format */ solr_encode_generic_xml_response(&buffer, Z_STRVAL_P(raw_response), Z_STRLEN_P(raw_response), Z_LVAL_P(parser_mode) TSRMLS_CC); if(return_array) { solr_sobject_to_sarray(&buffer TSRMLS_CC); } } else if (0 == strcmp(Z_STRVAL_P(response_writer), SOLR_PHP_NATIVE_RESPONSE_WRITER) || 0 == strcmp(Z_STRVAL_P(response_writer), SOLR_PHP_SERIALIZED_RESPONSE_WRITER)) { /* SOLR_PHP_NATIVE_RESPONSE_WRITER */ /* Response string is already in Native PHP serialization format */ solr_string_set(&buffer, Z_STRVAL_P(raw_response), Z_STRLEN_P(raw_response)); if(!return_array) { solr_sarray_to_sobject(&buffer TSRMLS_CC); } } else if (0 == strcmp(Z_STRVAL_P(response_writer), SOLR_JSON_RESPONSE_WRITER)) { int json_translation_result = solr_json_to_php_native(&buffer, Z_STRVAL_P(raw_response), Z_STRLEN_P(raw_response) TSRMLS_CC); /* SOLR_JSON_RESPONSE_WRITER */ /* Convert from JSON serialization to PHP serialization format */ if (json_translation_result > 0) { solr_throw_exception_ex(solr_ce_SolrException, SOLR_ERROR_1000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, solr_get_json_error_msg(json_translation_result)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error in JSON->PHP conversion. JSON Error Code %d", json_translation_result); } if(!return_array) { solr_sarray_to_sobject(&buffer TSRMLS_CC); } } } if (buffer.len) { zend_update_property_stringl(Z_OBJCE_P(objptr), objptr, "http_digested_response", sizeof("http_digested_response")-1, buffer.str, buffer.len TSRMLS_CC); } memset(&var_hash, 0, sizeof(php_unserialize_data_t)); PHP_VAR_UNSERIALIZE_INIT(var_hash); raw_resp = (unsigned char *) buffer.str; raw_res_length = buffer.len; str_end = (unsigned char *) (raw_resp + raw_res_length); if (!php_var_unserialize(&return_value, &raw_resp, str_end, &var_hash TSRMLS_CC)) { successful = 0; solr_throw_exception_ex(solr_ce_SolrException, SOLR_ERROR_1000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1000_MSG); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error unserializing raw response."); } PHP_VAR_UNSERIALIZE_DESTROY(var_hash); solr_string_free(&buffer); if (successful) { /* Overriding the default object handlers */ Z_OBJ_HT_P(return_value) = &solr_object_handlers; } return ; } RETURN_NULL(); } else { php_error_docref(NULL TSRMLS_CC, E_NOTICE, SOLR_ERROR_4002_MSG); } } /* {{{ proto string SolrPingResponse::getResponse(void) Ping responses are always empty. Returns null. */ PHP_METHOD(SolrPingResponse, getResponse) { /* Ping responses are not serialized */ if (return_value_used) { RETURN_NULL(); } } /* }}} */ /* {{{ proto SolrPingResponse::__construct(void) Constructor */ PHP_METHOD(SolrPingResponse, __construct) { } /* }}} */ /* {{{ proto SolrPingResponse::__destruct(void) Destructor */ PHP_METHOD(SolrPingResponse, __destruct) { } /* }}} */ /* {{{ proto SolrQueryResponse::__construct(void) Constructor */ PHP_METHOD(SolrQueryResponse, __construct) { } /* }}} */ /* {{{ proto SolrQueryResponse::__destruct(void) Destructor */ PHP_METHOD(SolrQueryResponse, __destruct) { } /* }}} */ /* {{{ proto SolrUpdateResponse::__construct(void) Constructor */ PHP_METHOD(SolrUpdateResponse, __construct) { } /* }}} */ /* {{{ proto SolrUpdateResponse::__destruct(void) Destructor */ PHP_METHOD(SolrUpdateResponse, __destruct) { } /* }}} */ /* {{{ proto SolrGenericResponse::__construct(void) Constructor */ PHP_METHOD(SolrGenericResponse, __construct) { } /* }}} */ /* {{{ proto SolrGenericResponse::__destruct(void) Destructor */ PHP_METHOD(SolrGenericResponse, __destruct) { } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/php_solr_utils.c0000644000175000017500000001740412676753706016060 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* {{{ proto string SolrUtils::escapeQueryChars(string unescaped) Escapes the lucene string */ PHP_METHOD(SolrUtils, escapeQueryChars) { solr_char_t *unescaped = NULL; solr_string_t sbuilder; int unescaped_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &unescaped, &unescaped_length) == FAILURE) { RETURN_FALSE; } if (!unescaped_length) { RETURN_NULL(); } memset(&sbuilder, 0, sizeof(solr_string_t)); solr_escape_query_chars(&sbuilder, unescaped, unescaped_length); RETVAL_STRINGL(sbuilder.str, sbuilder.len, 1); solr_string_free(&sbuilder); } /* }}} */ /* {{{ proto string SolrUtils::queryPhrase(string unescaped) Prepares a phrase from an unescaped lucene string. */ PHP_METHOD(SolrUtils, queryPhrase) { solr_char_t *unescaped = NULL; solr_string_t sbuilder; int unescaped_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &unescaped, &unescaped_length) == FAILURE) { RETURN_FALSE; } if (!unescaped_length) { RETURN_NULL(); } memset(&sbuilder, 0, sizeof(solr_string_t)); solr_string_appendc(&sbuilder, '"'); solr_escape_query_chars(&sbuilder, unescaped, unescaped_length); solr_string_appendc(&sbuilder, '"'); RETVAL_STRINGL(sbuilder.str, sbuilder.len, 1); solr_string_free(&sbuilder); } /* }}} */ /* {{{ proto string SolrUtils::digestXMLResponse(string xml_response [, int parse_mode]) Digests the xml response into a php serialize string. */ PHP_METHOD(SolrUtils, digestXmlResponse) { solr_char_t *xmlresponse = NULL; int xmlresponse_len = 0; long int parse_mode = 0L; solr_string_t sbuilder; unsigned char *raw_resp = NULL, *str_end = NULL; size_t raw_res_length = 0; php_unserialize_data_t var_hash; int successful = 1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &xmlresponse, &xmlresponse_len, &parse_mode) == FAILURE) { RETURN_FALSE; } if (!xmlresponse_len) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Raw response is empty"); RETURN_NULL(); } parse_mode = ((parse_mode < 0L) ? 0L : ((parse_mode > 1L) ? 1L : parse_mode)); memset(&sbuilder, 0, sizeof(solr_string_t)); solr_encode_generic_xml_response(&sbuilder, xmlresponse, xmlresponse_len, parse_mode TSRMLS_CC); if (sbuilder.str == NULL || sbuilder.len == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Raw response was not valid"); RETURN_NULL(); } memset(&var_hash, 0, sizeof(php_unserialize_data_t)); PHP_VAR_UNSERIALIZE_INIT(var_hash); raw_resp = (unsigned char *) sbuilder.str; raw_res_length = sbuilder.len; str_end = (unsigned char *) (raw_resp + raw_res_length); if (!php_var_unserialize(&return_value, (const unsigned char **) &raw_resp, str_end, &var_hash TSRMLS_CC)) { solr_throw_exception_ex(solr_ce_SolrException, SOLR_ERROR_1000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1000_MSG); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error unserializing raw response."); successful = 0; } PHP_VAR_UNSERIALIZE_DESTROY(var_hash); solr_string_free(&sbuilder); if (successful) { /* Overriding the default object handlers */ Z_OBJ_HT_P(return_value) = &solr_object_handlers; } } /* }}} */ /* {{{ proto string SolrUtils::digestJsonResponse(string jsonResponse) Digests the json response into a php serialize string. */ PHP_METHOD(SolrUtils, digestJsonResponse) { solr_char_t *jsonResponse = NULL; int jsonResponse_len = 0; unsigned char *raw_resp = NULL, *str_end = NULL; solr_string_t buffer; php_unserialize_data_t var_hash; size_t raw_res_length; int successful = 1; int json_translation_result; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &jsonResponse, &jsonResponse_len) == FAILURE) { RETURN_FALSE; } memset(&buffer, 0, sizeof(solr_string_t)); json_translation_result = solr_json_to_php_native(&buffer, jsonResponse, jsonResponse_len TSRMLS_CC); if (json_translation_result > 0) { solr_throw_exception_ex(solr_ce_SolrException, SOLR_ERROR_1000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, solr_get_json_error_msg(json_translation_result)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error in JSON->PHP conversion. JSON Error Code %d", json_translation_result); }else{ solr_sarray_to_sobject(&buffer TSRMLS_CC); } memset(&var_hash, 0, sizeof(php_unserialize_data_t)); PHP_VAR_UNSERIALIZE_INIT(var_hash); raw_resp = (unsigned char *) buffer.str; raw_res_length = buffer.len; str_end = (unsigned char *) (raw_resp + raw_res_length); if (!php_var_unserialize( &return_value, (const unsigned char **)&raw_resp, str_end, &var_hash TSRMLS_CC) ) { solr_throw_exception_ex(solr_ce_SolrException, SOLR_ERROR_1000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1000_MSG); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error unserializing raw response."); successful = 0; } solr_string_free(&buffer); PHP_VAR_UNSERIALIZE_DESTROY(var_hash); if (successful) { /* Overriding the default object handlers */ Z_OBJ_HT_P(return_value) = &solr_object_handlers; } } /* }}} */ /* {{{ proto string SolrUtils::getSolrVersion(void) Returns the current extension version */ PHP_METHOD(SolrUtils, getSolrVersion) { #ifdef SOLR_DEBUG char * version; asprintf(&version,"%s (DEBUG)", PHP_SOLR_DOTTED_VERSION); ZVAL_STRING(return_value, version, 1); #else RETURN_STRING(PHP_SOLR_DOTTED_VERSION, 1); #endif } /* }}} */ /* {{{ proto array SolrUtils::getSolrStats(void) Returns the number of active documents, clients and SolrParam objects in the current thread. */ PHP_METHOD(SolrUtils, getSolrStats) { int document_count = zend_hash_num_elements(SOLR_GLOBAL(documents)); int client_count = zend_hash_num_elements(SOLR_GLOBAL(clients)); int params_count = zend_hash_num_elements(SOLR_GLOBAL(params)); array_init(return_value); add_assoc_long(return_value, "document_count", document_count); add_assoc_long(return_value, "client_count", client_count); add_assoc_long(return_value, "params_count", params_count); } /* }}} */ /* {{{ proto string solr_get_version(void) Returns the current extension version */ PHP_FUNCTION(solr_get_version) { #ifdef SOLR_DEBUG char * version; asprintf(&version,"%s (DEBUG)", PHP_SOLR_DOTTED_VERSION); ZVAL_STRING(return_value, version, 1); #else RETURN_STRING(PHP_SOLR_DOTTED_VERSION, 1); #endif } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/solr_functions_client.c0000644000175000017500000007147112676753706017423 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* {{{ PHP_SOLR_API int solr_init_options(solr_client_options_t *options TSRMLS_DC) */ PHP_SOLR_API int solr_init_options(solr_client_options_t *options TSRMLS_DC) { solr_string_init(&(options->hostname)); solr_string_init(&(options->path)); solr_string_init(&(options->http_auth_credentials)); solr_string_init(&(options->proxy_hostname)); solr_string_init(&(options->proxy_auth_credentials)); solr_string_init(&(options->ssl_cert)); solr_string_init(&(options->ssl_key)); solr_string_init(&(options->ssl_keypassword)); solr_string_init(&(options->ssl_cainfo)); solr_string_init(&(options->ssl_capath)); solr_string_init(&(options->qs_delimiter)); solr_string_init(&(options->response_writer)); solr_string_init(&(options->update_url)); solr_string_init(&(options->search_url)); solr_string_init(&(options->thread_url)); solr_string_init(&(options->ping_url)); solr_string_init(&(options->terms_url)); solr_string_init(&(options->system_url)); solr_string_init(&(options->get_url)); solr_string_init(&(options->update_servlet)); solr_string_init(&(options->search_servlet)); solr_string_init(&(options->thread_servlet)); solr_string_init(&(options->ping_servlet)); solr_string_init(&(options->terms_servlet)); solr_string_init(&(options->system_servlet)); solr_string_init(&(options->get_servlet)); return SUCCESS; } /* }}} */ /* {{{ static void solr_set_initial_handle_options(solr_curl_t **sch, solr_client_options_t *options TSRMLS_DC) */ static void solr_set_initial_curl_handle_options(solr_curl_t **sch_ptr, solr_client_options_t *options TSRMLS_DC) { solr_curl_t * sch = *sch_ptr; /** Setup all the required CURL options here **/ curl_easy_setopt(sch->curl_handle, CURLOPT_NOPROGRESS, 1L); curl_easy_setopt(sch->curl_handle, CURLOPT_VERBOSE, 1L); curl_easy_setopt(sch->curl_handle, CURLOPT_ERRORBUFFER, sch->err.str); curl_easy_setopt(sch->curl_handle, CURLOPT_WRITEFUNCTION, solr_curl_write); curl_easy_setopt(sch->curl_handle, CURLOPT_WRITEDATA, (void *) sch); curl_easy_setopt(sch->curl_handle, CURLOPT_HEADERFUNCTION, solr_curl_write_header); curl_easy_setopt(sch->curl_handle, CURLOPT_HEADERDATA, (void *) sch); curl_easy_setopt(sch->curl_handle, CURLOPT_DEBUGFUNCTION, solr_curl_debug_callback); curl_easy_setopt(sch->curl_handle, CURLOPT_DEBUGDATA, (void *) sch); curl_easy_setopt(sch->curl_handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); /** #if LIBCURL_VERSION_NUM >= 0x071304 curl_easy_setopt(sch->curl_handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP); #endif */ curl_easy_setopt(sch->curl_handle, CURLOPT_DNS_CACHE_TIMEOUT, 120L); curl_easy_setopt(sch->curl_handle, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(sch->curl_handle, CURLOPT_MAXREDIRS, 16L); /* prevent infinite redirects */ curl_easy_setopt(sch->curl_handle, CURLOPT_UNRESTRICTED_AUTH, 0L); #ifdef ZTS curl_easy_setopt(sch->curl_handle, CURLOPT_NOSIGNAL, 1L); /** Needed in multi-threaded environments **/ #endif curl_easy_setopt(sch->curl_handle, CURLOPT_TIMEOUT, options->timeout); curl_easy_setopt(sch->curl_handle, CURLOPT_USERAGENT, SOLR_CLIENT_USER_AGENT); /* If the login and password options are passed, send the authentication headers */ if (options->http_auth_credentials.len) { curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_easy_setopt(sch->curl_handle, CURLOPT_USERPWD, options->http_auth_credentials.str); } /* If there is proxy info, send it too */ if (options->proxy_hostname.len) { curl_easy_setopt(sch->curl_handle, CURLOPT_PROXY, options->proxy_hostname.str); if (options->proxy_port) { curl_easy_setopt(sch->curl_handle, CURLOPT_PROXYPORT, options->proxy_port); } if (options->proxy_auth_credentials.len) { curl_easy_setopt(sch->curl_handle, CURLOPT_PROXYUSERPWD, options->proxy_auth_credentials.str); } } /* * When negotiating an SSL connection, the server sends a certificate indicating its identity. * cURL verifies whether the certificate is authentic */ if (options->secure) { /* The name of the PEM-formatted private key and private certificate concatenated */ if (options->ssl_cert.len) { curl_easy_setopt(sch->curl_handle, CURLOPT_SSLCERT, options->ssl_cert.str); curl_easy_setopt(sch->curl_handle, CURLOPT_SSLCERTTYPE, "PEM"); } /* The name of the PEM-formatted private key, if certificate and private key are separate */ if (options->ssl_key.len) { curl_easy_setopt(sch->curl_handle, CURLOPT_SSLKEY, options->ssl_key.str); curl_easy_setopt(sch->curl_handle, CURLOPT_SSLKEYTYPE, "PEM"); } /* Password for the PEM-formatted private key */ if (options->ssl_keypassword.len) { curl_easy_setopt(sch->curl_handle, CURLOPT_KEYPASSWD, options->ssl_keypassword.str); } /* The file holding one or more CA certificates to verify the peer with */ if (options->ssl_cainfo.len) { curl_easy_setopt(sch->curl_handle, CURLOPT_CAINFO, options->ssl_cainfo.str); } /* The directory holding multiple CA certificates to verify the peer with */ if (options->ssl_capath.len) { curl_easy_setopt(sch->curl_handle, CURLOPT_CAPATH , options->ssl_capath.str); } /* * Whether curl verifies the authenticity of the host name of server * Based on the Common name section of the certificate */ if (options->ssl_verify_peer && options->ssl_verify_host) { curl_easy_setopt(sch->curl_handle, CURLOPT_SSL_VERIFYHOST, options->ssl_verify_host); } /* * Verify the authenticity of the peer's certificate * This authentication is based on a chain of digital signatures, * rooted in certification authority (CA) certificates. * * If something is not right, the connection will not be valid */ curl_easy_setopt(sch->curl_handle, CURLOPT_SSL_VERIFYPEER, options->ssl_verify_peer); } } /* }}} */ /* {{{ PHP_SOLR_API int solr_init_handle(solr_curl_t *sch, solr_client_options_t *options TSRMLS_DC) */ PHP_SOLR_API int solr_init_handle(solr_curl_t *sch, solr_client_options_t *options TSRMLS_DC) { sch->response_header.response_code = 0L; memset(sch->err.str, 0, sizeof(sch->err.str)); sch->curl_handle = curl_easy_init(); if (NULL == sch->curl_handle) { return FAILURE; } sch->result_code = CURLE_OK; sch->handle_status = 1; #ifdef ZTS sch->tsrm_ls = TSRMLS_C; #endif solr_string_init(&(sch->request_header.buffer)); solr_string_init(&(sch->request_body.buffer)); solr_string_init(&(sch->request_body_debug.buffer)); solr_string_init(&(sch->response_header.buffer)); solr_string_init(&(sch->response_body.buffer)); solr_string_init(&(sch->debug_data_buffer)); solr_set_initial_curl_handle_options(&(sch), options TSRMLS_CC); return SUCCESS; } /* }}} */ /** * solr_curl_write * * Called by libcurl as soon as there is response body data received that needs to be saved. * * The size of the data pointed to by *data is size multiplied with nmemb, it will not be zero terminated * * The *ctx parameter is the solr_curl pointer */ /* {{{ size_t solr_curl_write(solr_char_t *data, size_t size, size_t nmemb, void *ctx) */ size_t solr_curl_write(solr_char_t *data, size_t size, size_t nmemb, void *ctx) { size_t length = (size * nmemb); solr_curl_t *sch = (solr_curl_t *) ctx; solr_string_appends(&(sch->response_body.buffer), data, length); return length; } /* }}} */ /** * solr_curl_write_header * * Called by libcurl as soon as it has received header data * * It will be called once for each header and only complete header lines are passed on to the callback. * * Note: header lines may not be null-terminated so beware. * * The *ctx parameter is the solr_curl pointer */ /* {{{ size_t solr_curl_write_header(solr_char_t *data, size_t size, size_t nmemb, void *ctx) */ size_t solr_curl_write_header(solr_char_t *data, size_t size, size_t nmemb, void *ctx) { size_t length = (size * nmemb); solr_curl_t *sch = (solr_curl_t *) ctx; solr_string_appends(&(sch->response_header.buffer), data, length); return length; } /* }}} */ /** * solr_curl_debug_callback * * The infotype parameter is one of : * * 0 = CURLINFO_TEXT * 1 = CURLINFO_HEADER_IN (Response Headers) * 2 = CURLINFO_HEADER_OUT (Request Headers) * 3 = CURLINFO_DATA_IN (Response Body) * 4 = CURLINFO_DATA_OUT (Request Body) * 5 = CURLINFO_SSL_DATA_IN * 6 = CURLINFO_SSL_DATA_OUT * * The debug_data parameter is not null-terminated but is exactly size characters * * The ctx parameter is a solr_curl * pointer */ /* {{{ int solr_curl_debug_callback(CURL *curl_handle, curl_infotype infotype, solr_char_t *debug_data, size_t size, void *ctx) */ int solr_curl_debug_callback(CURL *curl_handle, curl_infotype infotype, solr_char_t *debug_data, size_t size, void *ctx) { solr_curl_t *sch = (solr_curl_t *) ctx; /* TODO : Check why this function is still called after destructor has been called */ if (!sch->handle_status) { return 0; } switch(infotype) { case CURLINFO_HEADER_OUT : /* Capture the Actual Request Headers Sent to Server */ { solr_string_appends(&(sch->request_header.buffer), debug_data, size); } break; case CURLINFO_DATA_OUT : /* Capture the Actual Request Body Sent to Server */ { solr_string_appends(&(sch->request_body_debug.buffer), debug_data, size); } break; default : { /* do nothing */ } break; } /* Captures ALL debug information */ solr_string_appends(&(sch->debug_data_buffer), debug_data, size); return 0; } /* }}} */ /* {{{ PHP_SOLR_API int solr_make_request(solr_client_t *client, solr_request_type_t request_type TSRMLS_DC) */ PHP_SOLR_API int solr_make_request(solr_client_t *client, solr_request_type_t request_type TSRMLS_DC) { solr_curl_t *sch = &(client->handle); solr_client_options_t *options = &(client->options); solr_http_header_list_t *header_list = NULL; int return_status = SUCCESS; CURLcode info_status = CURLE_OK; header_list = curl_slist_append(header_list, "Accept-Charset: utf-8"); header_list = curl_slist_append(header_list, "Keep-Alive: 300"); header_list = curl_slist_append(header_list, "Connection: keep-alive"); /* Disable the Expect: 100-continue header. Jetty gets confused with this header */ header_list = curl_slist_append(header_list, "Expect:"); /* Reset the buffers */ solr_string_free(&sch->request_header.buffer); solr_string_free(&sch->request_body_debug.buffer); solr_string_free(&sch->response_body.buffer); solr_string_free(&sch->response_header.buffer); solr_string_free(&sch->debug_data_buffer); curl_easy_reset(sch->curl_handle); solr_set_initial_curl_handle_options(&(sch), options TSRMLS_CC); /* Reset the CURL options if the handle is reused */ curl_easy_setopt(sch->curl_handle, CURLOPT_HEADER, 0L); curl_easy_setopt(sch->curl_handle, CURLOPT_POST, 0L); curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPGET, 0L); curl_easy_setopt(sch->curl_handle, CURLOPT_NOBODY, 0L); curl_easy_setopt(sch->curl_handle, CURLOPT_POSTFIELDSIZE, 0L); curl_easy_setopt(sch->curl_handle, CURLOPT_POSTFIELDS, NULL); curl_easy_setopt(sch->curl_handle, CURLOPT_URL, NULL); curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPHEADER, NULL); switch(request_type) { case SOLR_REQUEST_SEARCH : /* HTTP FORM POST */ { header_list = curl_slist_append(header_list, "Content-Type: application/x-www-form-urlencoded;charset=UTF-8"); curl_easy_setopt(sch->curl_handle, CURLOPT_POST, 1L); curl_easy_setopt(sch->curl_handle, CURLOPT_URL, options->search_url.str); curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPHEADER, header_list); curl_easy_setopt(sch->curl_handle, CURLOPT_POSTFIELDSIZE, sch->request_body.buffer.len); curl_easy_setopt(sch->curl_handle, CURLOPT_POSTFIELDS, sch->request_body.buffer.str); } break; case SOLR_REQUEST_TERMS : /* HTTP FORM POST */ { header_list = curl_slist_append(header_list, "Content-Type: application/x-www-form-urlencoded;charset=UTF-8"); curl_easy_setopt(sch->curl_handle, CURLOPT_POST, 1L); curl_easy_setopt(sch->curl_handle, CURLOPT_URL, options->terms_url.str); curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPHEADER, header_list); curl_easy_setopt(sch->curl_handle, CURLOPT_POSTFIELDSIZE, sch->request_body.buffer.len); curl_easy_setopt(sch->curl_handle, CURLOPT_POSTFIELDS, sch->request_body.buffer.str); } break; case SOLR_REQUEST_UPDATE : /* HTTP XML POST */ { header_list = curl_slist_append(header_list, "Content-Type: text/xml;charset=UTF-8"); curl_easy_setopt(sch->curl_handle, CURLOPT_POST, 1L); curl_easy_setopt(sch->curl_handle, CURLOPT_URL, options->update_url.str); curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPHEADER, header_list); curl_easy_setopt(sch->curl_handle, CURLOPT_POSTFIELDSIZE, sch->request_body.buffer.len); curl_easy_setopt(sch->curl_handle, CURLOPT_POSTFIELDS, sch->request_body.buffer.str); } break; case SOLR_REQUEST_THREADS : /* HTTP GET */ { curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPGET, 1L); curl_easy_setopt(sch->curl_handle, CURLOPT_URL, options->thread_url.str); curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPHEADER, header_list); } break; case SOLR_REQUEST_PING : /* HTTP HEAD REQUEST. */ { curl_easy_setopt(sch->curl_handle, CURLOPT_HEADER, 1L); curl_easy_setopt(sch->curl_handle, CURLOPT_NOBODY, 1L); curl_easy_setopt(sch->curl_handle, CURLOPT_URL, options->ping_url.str); curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPHEADER, header_list); } break; case SOLR_REQUEST_SYSTEM: /* HTTP GET to fetch system info */ { curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPGET, 1L); curl_easy_setopt(sch->curl_handle, CURLOPT_URL, options->system_url.str); curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPHEADER, header_list); } break; case SOLR_REQUEST_GET: solr_string_appendc(&(options->get_url), '&'); solr_string_append_solr_string(&(options->get_url), &(sch->request_body.buffer)); curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPGET, 1L); curl_easy_setopt(sch->curl_handle, CURLOPT_URL, options->get_url.str); curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPHEADER, header_list); break; default : { return_status = FAILURE; } break; } sch->result_code = curl_easy_perform(sch->curl_handle); info_status = curl_easy_getinfo(sch->curl_handle, CURLINFO_RESPONSE_CODE, &(sch->response_header.response_code)); if (info_status != CURLE_OK) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "HTTP Transfer status could not be retrieved successfully"); return_status = FAILURE; } if (sch->result_code != CURLE_OK) { /* commented by: Omar Shaban */ /* php_error_docref(NULL TSRMLS_CC, E_WARNING, "Solr HTTP Error : '%s' ", curl_easy_strerror(sch->result_code)); */ solr_throw_exception_ex(solr_ce_SolrClientException, SOLR_ERROR_1004 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Solr HTTP Error %d: '%s' ",sch->result_code, curl_easy_strerror(sch->result_code)); return_status = FAILURE; } if (sch->response_header.response_code != 200L) { return_status = FAILURE; } curl_slist_free_all(header_list); return return_status; } /* }}} */ /** Deallocates memory associated with the Solr CURL Handle. **/ /* {{{ PHP_SOLR_API void solr_free_handle(solr_curl_t *sch) */ PHP_SOLR_API void solr_free_handle(solr_curl_t *sch) { solr_string_free(&((sch)->request_header.buffer)); solr_string_free(&((sch)->request_body.buffer)); solr_string_free(&((sch)->request_body_debug.buffer)); solr_string_free(&((sch)->response_header.buffer)); solr_string_free(&((sch)->response_body.buffer)); solr_string_free(&((sch)->debug_data_buffer)); sch->handle_status = 0; curl_easy_cleanup((sch)->curl_handle); sch->curl_handle = NULL; } /* }}} */ /* {{{ PHP_SOLR_API void solr_free_options(solr_client_options_t *options) */ PHP_SOLR_API void solr_free_options(solr_client_options_t *options) { solr_string_free(&((options)->hostname)); solr_string_free(&((options)->http_auth_credentials)); solr_string_free(&((options)->path)); solr_string_free(&((options)->proxy_auth_credentials)); solr_string_free(&((options)->ssl_cert)); solr_string_free(&((options)->ssl_key)); solr_string_free(&((options)->ssl_keypassword)); solr_string_free(&((options)->ssl_cainfo)); solr_string_free(&((options)->ssl_capath)); solr_string_free(&((options)->proxy_hostname)); solr_string_free(&((options)->qs_delimiter)); solr_string_free(&((options)->response_writer)); solr_string_free(&((options)->update_url)); solr_string_free(&((options)->search_url)); solr_string_free(&((options)->thread_url)); solr_string_free(&((options)->ping_url)); solr_string_free(&((options)->terms_url)); solr_string_free(&((options)->system_url)); solr_string_free(&((options)->get_url)); solr_string_free(&((options)->update_servlet)); solr_string_free(&((options)->search_servlet)); solr_string_free(&((options)->thread_servlet)); solr_string_free(&((options)->ping_servlet)); solr_string_free(&((options)->terms_servlet)); solr_string_free(&((options)->system_servlet)); solr_string_free(&((options)->get_servlet)); } /* }}} */ /* {{{ PHP_SOLR_API void solr_destroy_client(void *client) */ PHP_SOLR_API void solr_destroy_client(void *client) { solr_client_t *solr_client = (solr_client_t *) client; if (solr_client) { solr_free_options(&(solr_client->options)); solr_free_handle(&(solr_client->handle)); solr_client = NULL; } } /* }}} */ /* {{{ PHP_SOLR_API int solr_get_xml_error(solr_string_t buffer, solr_exception_t *exceptionData TSRMLS_DC) */ PHP_SOLR_API int solr_get_xml_error(solr_string_t buffer, solr_exception_t *exceptionData TSRMLS_DC) { xmlDoc *doc = xmlReadMemory((const char *)buffer.str, buffer.len, NULL, "UTF-8", XML_PARSE_RECOVER); xmlXPathContext *xpathContext = NULL; xmlXPathObject *xpathObject = NULL; xmlChar *xpathExpression = (unsigned char *)"/response/lst[@name='error']"; xmlNode * nodeCurser; const unsigned char * nodePropName = (const unsigned char *)"name"; if (!doc) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error loading XML document"); return 1; } /* Create xpath evaluation context */ xpathContext = xmlXPathNewContext(doc); if(xpathContext == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error creating xml xpath context"); xmlFreeDoc(doc); return 1; } /* Evaluate xpath expression */ xpathObject = xmlXPathEvalExpression(xpathExpression, xpathContext); if(xpathObject == NULL){ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error evaluating xml xpath expression"); xmlFreeDoc(doc); return 1; } if(!xpathObject->nodesetval){ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Xpath Error: no elements found"); xmlXPathFreeObject(xpathObject); xmlFreeDoc(doc); return 1; } nodeCurser = xpathObject->nodesetval->nodeTab[0]->children; while (nodeCurser != NULL) { if (xmlHasProp(nodeCurser, nodePropName)) { if (strcmp((const char *)xmlGetProp(nodeCurser,nodePropName), (const char *)"msg") == 0) { exceptionData->message = (solr_char_t *)estrdup((const char *)nodeCurser->children->content); } else if(strcmp((const char *)xmlGetProp(nodeCurser,nodePropName),"code") == 0) { exceptionData->code = atoi((const char *)nodeCurser->children->content); } else if(strcmp( (const char *)xmlGetProp(nodeCurser, nodePropName), (const char *) "trace") == 0) { exceptionData->message = (solr_char_t *)estrdup((const char *)nodeCurser->children->content); } } nodeCurser = nodeCurser->next; } xmlXPathFreeObject(xpathObject); xmlXPathFreeContext(xpathContext); xmlFreeDoc(doc); return 0; } /* }}} */ /* {{{ PHP_SOLR_API int hydrate_error_zval(zval *response, solr_exception_t *exceptionData TSRMLS_DC) */ PHP_SOLR_API int hydrate_error_zval(zval *response, solr_exception_t *exceptionData TSRMLS_DC) { char * key = "error"; int keyLen = 5; zval **errorPP = (zval **) NULL, *errorP; zval **msgZvalPP=(zval **) NULL, **codeZval = (zval **) NULL; if ( zend_hash_find( Z_ARRVAL_P(response), key, keyLen+1, (void **) &errorPP) == SUCCESS) { errorP = *errorPP; if (zend_hash_exists(HASH_OF(errorP), "msg", sizeof("msg"))) { if (zend_hash_find(Z_ARRVAL_P(errorP), "msg", sizeof("msg"), (void **) &msgZvalPP) == SUCCESS) { exceptionData->message = (solr_char_t *)estrdup(Z_STRVAL(**msgZvalPP)); } else { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Undefined variable: %s", "msg"); return 1; } } else if (zend_hash_exists(HASH_OF(errorP), "trace", sizeof("trace"))) { if (zend_hash_find(Z_ARRVAL_P(errorP), "trace", sizeof("trace"), (void **) &msgZvalPP) == SUCCESS) { exceptionData->message = (solr_char_t *)estrdup(Z_STRVAL(**msgZvalPP)); } else { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Undefined variable: %s", "trace"); return 1; } } else{ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unable to find %s in error response zval", "message or trace" ); return 1; } if (zend_hash_find(Z_ARRVAL_P(errorP), "code", sizeof("code"), (void **) &codeZval) == SUCCESS) { exceptionData->code = (int)Z_LVAL_PP(codeZval); } else { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unable to find element with key %s in error response zval","code" ); return 1; } } else { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unable to find %s in error response", "error element" ); return 1; } return 0; } /* }}} */ /* {{{ PHP_SOLR_API int solr_get_json_error(solr_string_t buffer, solr_exception_t *exceptionData TSRMLS_DC) */ PHP_SOLR_API int solr_get_json_error(solr_string_t buffer, solr_exception_t *exceptionData TSRMLS_DC) { zval *jsonResponse; zval *errorP; zval **errorPP=(zval **)NULL,**msgZvalPP=(zval **)NULL,**codeZval=(zval **)NULL; HashTable *errorHashTable; char * key = "error"; int keyLen = 5; long nSize = 1000; MAKE_STD_ZVAL(jsonResponse); php_json_decode(jsonResponse, (char *) buffer.str, buffer.len, 1, 1024L TSRMLS_CC); if (Z_TYPE_P(jsonResponse) == IS_NULL) { zval_ptr_dtor(&jsonResponse); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to parse Solr Server Error Response. JSON serialization error"); return 1; } ALLOC_HASHTABLE(errorHashTable); zend_hash_init(errorHashTable, nSize, NULL, NULL, 0); if( zend_hash_find( Z_ARRVAL_P(jsonResponse), key, keyLen+1, (void **) &errorPP) == SUCCESS) { errorP = *errorPP; if (zend_hash_find(Z_ARRVAL_P(errorP), "code", sizeof("code"), (void **) &codeZval) == SUCCESS) { exceptionData->code = (int)Z_LVAL_PP(codeZval); } else { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unable to find %s in json error response","code" ); } if(zend_hash_exists(HASH_OF(errorP), "msg", sizeof("msg"))) { if(zend_hash_find(Z_ARRVAL_P(errorP), "msg", sizeof("msg"), (void **) &msgZvalPP) == SUCCESS) { exceptionData->message = (solr_char_t *)estrdup(Z_STRVAL(**msgZvalPP)); } } else if (!exceptionData->message && zend_hash_exists(HASH_OF(errorP), "trace", sizeof("trace"))) { if(zend_hash_find(Z_ARRVAL_P(errorP), "trace", sizeof("trace"), (void **) &msgZvalPP) == SUCCESS) { exceptionData->message = (solr_char_t *)estrdup(Z_STRVAL(**msgZvalPP)); } else { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Undefined variable: %s","trace" ); } } else { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unable to find %s in error response zval","message" ); return 1; } }else{ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Undefined variable: %s",key ); } zval_ptr_dtor(&jsonResponse); zend_hash_destroy(errorHashTable); FREE_HASHTABLE(errorHashTable); return 0; } /* }}} */ /* {{{ PHP_SOLR_API int solr_get_phpnative_error(solr_string_t buffer, solr_exception_t *exceptionData TSRMLS_DC) */ PHP_SOLR_API int solr_get_phpnative_error(solr_string_t buffer, solr_exception_t *exceptionData TSRMLS_DC) { zval * response_obj; php_unserialize_data_t var_hash; const unsigned char * raw_resp = (const unsigned char *) buffer.str; const unsigned char * str_end = (const unsigned char *) (buffer.str + buffer.len); ALLOC_INIT_ZVAL(response_obj); PHP_VAR_UNSERIALIZE_INIT(var_hash); if(!php_var_unserialize(&response_obj, &raw_resp, str_end, &var_hash TSRMLS_CC)) { /* There is a known issue, that solr responses will not always be * with the dictated response format, as jetty or tomcat may return errors in their format */ PHP_VAR_UNSERIALIZE_DESTROY(var_hash); zval_ptr_dtor(&response_obj); return 1; } hydrate_error_zval(response_obj, exceptionData TSRMLS_CC); PHP_VAR_UNSERIALIZE_DESTROY(var_hash); zval_ptr_dtor(&response_obj); return 0; } /* }}} */ /* {{{ PHP_SOLR_API void solr_throw_solr_server_exception(solr_client_t *client,const char * requestType TSRMLS_DC) parse the solr server response and throw a SolrServerException */ PHP_SOLR_API void solr_throw_solr_server_exception(solr_client_t *client,const char * requestType TSRMLS_DC) { const char * response_writer = (char *) client->options.response_writer.str; solr_exception_t *exceptionData; exceptionData = (solr_exception_t*) emalloc(sizeof(solr_exception_t )); exceptionData->code = 0; memset(exceptionData, 0, sizeof(solr_exception_t)); if( 0 == strcmp(response_writer, SOLR_XML_RESPONSE_WRITER)){ if(solr_get_xml_error(client->handle.response_body.buffer, exceptionData TSRMLS_CC) != SUCCESS) { /* fallback to normal exception */ solr_throw_exception_ex(solr_ce_SolrClientException, SOLR_ERROR_1010 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1010_MSG, requestType, SOLR_RESPONSE_CODE_BODY); return; } } if( 0 == strcmp(response_writer, SOLR_JSON_RESPONSE_WRITER)) { if(solr_get_json_error(client->handle.response_body.buffer, exceptionData TSRMLS_CC) != SUCCESS) { solr_throw_exception_ex(solr_ce_SolrClientException, SOLR_ERROR_1010 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1010_MSG, requestType, SOLR_RESPONSE_CODE_BODY); } } if( 0 == strcmp(response_writer, SOLR_PHP_NATIVE_RESPONSE_WRITER) || 0 == strcmp(response_writer, SOLR_PHP_SERIALIZED_RESPONSE_WRITER)) { if(solr_get_phpnative_error(client->handle.response_body.buffer,exceptionData TSRMLS_CC) != SUCCESS) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unable to parse serialized php response" ); } } if(exceptionData->code == 0){ solr_throw_exception_ex(solr_ce_SolrClientException, SOLR_ERROR_1010 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1010_MSG, requestType, SOLR_RESPONSE_CODE_BODY); }else if (exceptionData->code > 0 && exceptionData->message){ solr_throw_exception_ex(solr_ce_SolrServerException, exceptionData->code TSRMLS_CC, SOLR_FILE_LINE_FUNC, exceptionData->message); } else { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to parse solr exception message, Internal Error" ); } if(exceptionData->message != NULL) { efree(exceptionData->message); } efree(exceptionData); } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/solr_functions_debug.c0000644000175000017500000001106412676753706017223 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Omar Shaban | | Israel Ekpo | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* {{{ void solr_debug_printf(const char *format, ...) */ PHP_SOLR_API void solr_debug_printf(const char *format, ...) { #ifdef SOLR_DEBUG va_list args; va_start(args,format); vprintf(format,args); va_end(args); #endif } /* }}} */ /* {{{ void solr_debug_print_fields(const solr_field_list_t *field_list) */ PHP_SOLR_API void solr_debug_print_fields(const solr_field_list_t *field_list) { /* Used to debug field inserted */ } /* }}} */ /** * print_xpath_nodes: * @nodes: the nodes set. * @output: the output file handle. * * Prints the @nodes content to @output. */ /* {{{ void print_xpath_nodes(xmlNodeSetPtr nodes, FILE* output) */ PHP_SOLR_API void print_xpath_nodes(xmlNodeSetPtr nodes, FILE* output) { xmlNodePtr cur; int size; int i; assert(output); size = (nodes) ? nodes->nodeNr : 0; fprintf(output, "Result (%d nodes):\n", size); for(i = 0; i < size; ++i) { assert(nodes->nodeTab[i]); if(nodes->nodeTab[i]->type == XML_NAMESPACE_DECL) { xmlNsPtr ns; ns = (xmlNsPtr)nodes->nodeTab[i]; cur = (xmlNodePtr)ns->next; if(cur->ns) { fprintf(output, "= namespace \"%s\"=\"%s\" for node %s:%s\n", ns->prefix, ns->href, cur->ns->href, cur->name); } else { fprintf(output, "= namespace \"%s\"=\"%s\" for node %s\n", ns->prefix, ns->href, cur->name); } } else if(nodes->nodeTab[i]->type == XML_ELEMENT_NODE) { cur = nodes->nodeTab[i]; if(cur->ns) { fprintf(output, "= element node \"%s:%s\"\n", cur->ns->href, cur->name); } else { fprintf(output, "= element node \"%s\"\n", cur->name); } } else { cur = nodes->nodeTab[i]; fprintf(output, "= node \"%s\": type %d\n", cur->name, cur->type); } } } /* }}} */ /* {{{ void print_children (xmlNode * node) */ PHP_SOLR_API void print_children (xmlNode * node) { fprintf(stdout,"\n================- start print children -=================\n"); while (node != NULL) { if(node->ns) { fprintf(stdout, "= element node \"%s:%s\"\n", node->ns->href,node->name); } else { fprintf(stdout, "= element node \"%s\"\n", node->name); } if(node->type == XML_ELEMENT_NODE){ xmlNode * cur2 = node->children; while (cur2 != NULL) { if(strcmp((const char *)cur2->name,"text")==0) { fprintf(stdout, "= element node \"%s\", text: %s\n",cur2->name,cur2->content); }else{ fprintf(stdout, "= element node \"%s\"\n", cur2->name); } cur2 = cur2->next; } } if(node->children != NULL) { print_children(node->children); } node = node->next; } fprintf(stdout,"\n======================- end -=====================\n"); } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/solr_functions_document.c0000644000175000017500000003307212676753706017756 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Israel Ekpo | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* {{{ void field_copy_constructor(solr_field_list_t **original_field_queue) */ PHP_SOLR_API void field_copy_constructor(solr_field_list_t **original_field_queue) { solr_field_list_t *new_field_queue = NULL; solr_field_value_t *ptr = (*original_field_queue)->head; if (ptr == NULL) { return; } new_field_queue = (solr_field_list_t *) pemalloc(sizeof(solr_field_list_t), SOLR_DOCUMENT_FIELD_PERSISTENT); new_field_queue->count = 0L; new_field_queue->field_name = (solr_char_t *) pestrdup((char *) (*original_field_queue)->field_name, SOLR_DOCUMENT_FIELD_PERSISTENT); new_field_queue->head = NULL; new_field_queue->last = NULL; new_field_queue->field_boost = (*original_field_queue)->field_boost; while(ptr != NULL) { solr_document_insert_field_value(new_field_queue, ptr->field_value, 0); ptr = ptr->next; } *original_field_queue = new_field_queue; } /* }}} */ /* {{{ PHP_SOLR_API solr_document_t *solr_init_document(long int document_index) * create and allocate a solr_document_t with the specified index */ PHP_SOLR_API solr_document_t *solr_init_document(long int document_index TSRMLS_DC) { solr_document_t *doc_entry = NULL, *doc_ptr = NULL; solr_document_t solr_doc; uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE; memset(&solr_doc, 0, sizeof(solr_document_t)); doc_entry = &solr_doc; doc_entry->document_index = document_index; doc_entry->field_count = 0L; doc_entry->document_boost = 0.0f; /* Allocated memory for the fields HashTable using fast cache for HashTables */ ALLOC_HASHTABLE(doc_entry->fields); ALLOC_HASHTABLE(doc_entry->children); /* Initializing the hash table used for storing fields in this SolrDocument */ zend_hash_init(doc_entry->fields, nSize, NULL, (dtor_func_t) solr_destroy_field_list, SOLR_DOCUMENT_FIELD_PERSISTENT); zend_hash_init(doc_entry->children, nSize, NULL, ZVAL_PTR_DTOR, SOLR_DOCUMENT_FIELD_PERSISTENT); /* Let's check one more time before insert into the HashTable */ if (zend_hash_index_exists(SOLR_GLOBAL(documents), document_index)) { pefree(doc_entry->fields, SOLR_DOCUMENT_FIELD_PERSISTENT); zend_hash_destroy(doc_entry->children); pefree(doc_entry->fields, SOLR_DOCUMENT_FIELD_PERSISTENT); return NULL; } /* Add the document entry to the directory of documents */ zend_hash_index_update(SOLR_GLOBAL(documents), document_index, (void *) doc_entry, sizeof(solr_document_t), (void **) &doc_ptr); /* Keep track of how many SolrDocument instances we currently have */ SOLR_GLOBAL(document_count)++; return doc_ptr; } /* }}} */ /* {{{ PHP_SOLR_API int solr_document_insert_field_value(solr_field_list_t *queue, const solr_char_t *field_value, double field_boost) */ PHP_SOLR_API int solr_document_insert_field_value(solr_field_list_t *queue, const solr_char_t *field_value, double field_boost) { solr_field_value_t *new_entry = (solr_field_value_t *) pemalloc(sizeof(solr_field_value_t), SOLR_DOCUMENT_FIELD_PERSISTENT); if (new_entry == NULL) { return FAILURE; } new_entry->field_value = (solr_char_t *) pestrdup((char *) field_value, SOLR_DOCUMENT_FIELD_PERSISTENT); if (new_entry->field_value == NULL) { return FAILURE; } new_entry->next = NULL; if (queue->head == NULL) { /* This is the first and only item in the field list */ queue->head = new_entry; queue->last = new_entry; /* Update the field boost value */ if (field_boost > 0.0) { queue->field_boost = field_boost; } } else { /* There are already entries in the list. */ /* Append to the end of the queue */ queue->last->next = new_entry; /* Set the last item in the queue to the latest entry */ queue->last = new_entry; /* Update the field boost value */ if (field_boost > 0.0) { if (queue->field_boost > 0.0) { queue->field_boost *= field_boost; } else { queue->field_boost = field_boost; } } } queue->count++; return SUCCESS; } /* }}} */ /* {{{ void solr_destroy_document(void *document) */ PHP_SOLR_API void solr_destroy_document(void *document) { solr_document_t *doc_entry = (solr_document_t *) document; /* Release all the field_lists one at a time with solr_destroy_field_list */ zend_hash_destroy(doc_entry->fields); /* Deallocate memory for the fields HashTable */ pefree(doc_entry->fields, SOLR_DOCUMENT_FIELD_PERSISTENT); if (doc_entry->children) { zend_hash_destroy(doc_entry->children); pefree(doc_entry->children, SOLR_DOCUMENT_FIELD_PERSISTENT); } } /* }}} */ /* {{{ void solr_destroy_field_list(solr_field_list_t **field_entry_ptr) */ PHP_SOLR_API void solr_destroy_field_list(solr_field_list_t **field_entry_ptr) { solr_field_list_t *field_entry = *field_entry_ptr; solr_field_value_t *tmp = NULL; solr_field_value_t *current_field_value = field_entry->head; /* Go through the list and free all the values */ while(current_field_value != NULL) { tmp = current_field_value->next; pefree(current_field_value->field_value, SOLR_DOCUMENT_FIELD_PERSISTENT); pefree(current_field_value, SOLR_DOCUMENT_FIELD_PERSISTENT); current_field_value = tmp; } field_entry->head = NULL; field_entry->last = NULL; pefree(field_entry->field_name, SOLR_DOCUMENT_FIELD_PERSISTENT); pefree(field_entry, SOLR_DOCUMENT_FIELD_PERSISTENT); } /* }}} */ /* Comparison functions for field entries */ /* {{{ int solr_compare_field_name(const void *a, const void *b TSRMLS_DC) */ PHP_SOLR_API int solr_compare_field_name(const void *a, const void *b TSRMLS_DC) { const Bucket *x = *((Bucket **) a); const Bucket *y = *((Bucket **) b); const solr_field_list_t *first = *((solr_field_list_t **) x->pData); const solr_field_list_t *second = *((solr_field_list_t **) y->pData); const int diff = strcmp((char *) first->field_name, (char *) second->field_name); const int result = ((diff > 0) ? 1 : ((diff < 0) ? -1 : 0)); return result; } /* }}} */ /* {{{ int solr_rcompare_field_name(const void *a, const void *b TSRMLS_DC) */ PHP_SOLR_API int solr_rcompare_field_name(const void *a, const void *b TSRMLS_DC) { return (solr_compare_field_name(a, b TSRMLS_CC) * -1); } /* }}} */ /* {{{ int solr_compare_field_value_count(const void *a, const void *b TSRMLS_DC) */ PHP_SOLR_API int solr_compare_field_value_count(const void *a, const void *b TSRMLS_DC) { const Bucket *x = *((Bucket **) a); const Bucket *y = *((Bucket **) b); const solr_field_list_t *first = *((solr_field_list_t **) x->pData); const solr_field_list_t *second = *((solr_field_list_t **) y->pData); const int diff = first->count - second->count; const int result = ((diff > 0) ? 1 : ((diff < 0) ? -1 : 0)); return result; } /* }}} */ /* {{{ int solr_rcompare_field_value_count(const void *a, const void *b TSRMLS_DC) */ PHP_SOLR_API int solr_rcompare_field_value_count(const void *a, const void *b TSRMLS_DC) { return (solr_compare_field_value_count(a, b TSRMLS_CC) * -1); } /* }}} */ /* {{{ int solr_compare_field_boost_value(const void *a, const void *b TSRMLS_DC) */ PHP_SOLR_API int solr_compare_field_boost_value(const void *a, const void *b TSRMLS_DC) { const Bucket *x = *((Bucket **) a); const Bucket *y = *((Bucket **) b); const solr_field_list_t *first = *((solr_field_list_t **) x->pData); const solr_field_list_t *second = *((solr_field_list_t **) y->pData); const double diff = first->field_boost - second->field_boost; const int result = ((diff > 0.0) ? 1 : ((diff < 0.0) ? -1 : 0)); return result; } /* }}} */ /* {{{ int solr_rcompare_field_boost_value(const void *a, const void *b TSRMLS_DC) */ PHP_SOLR_API int solr_rcompare_field_boost_value(const void *a, const void *b TSRMLS_DC) { return (solr_compare_field_boost_value(a, b TSRMLS_CC) * -1); } /* }}} */ /* {{{ PHP_SOLR_API void solr_create_document_field_object(solr_field_list_t *field_values, zval **field_obj TSRMLS_DC) */ PHP_SOLR_API void solr_create_document_field_object(solr_field_list_t *field_values, zval **field_obj TSRMLS_DC) { zval *doc_field = *field_obj; zval *field_values_array = NULL; solr_field_value_t *curr_ptr = NULL; MAKE_STD_ZVAL(field_values_array); array_init(field_values_array); curr_ptr = field_values->head; while(curr_ptr != NULL) { solr_char_t *current_value = curr_ptr->field_value; add_next_index_string(field_values_array, current_value, 1); curr_ptr = curr_ptr->next; } object_init_ex(doc_field, solr_ce_SolrDocumentField); zend_update_property_string(solr_ce_SolrDocumentField, doc_field, SOLR_FIELD_NAME_PROPERTY_NAME, sizeof(SOLR_FIELD_NAME_PROPERTY_NAME)-1, field_values->field_name TSRMLS_CC); zend_update_property_double(solr_ce_SolrDocumentField, doc_field, SOLR_FIELD_BOOST_PROPERTY_NAME, sizeof(SOLR_FIELD_BOOST_PROPERTY_NAME)-1, field_values->field_boost TSRMLS_CC); zend_update_property(solr_ce_SolrDocumentField, doc_field, SOLR_FIELD_VALUES_PROPERTY_NAME, sizeof(SOLR_FIELD_VALUES_PROPERTY_NAME)-1, field_values_array TSRMLS_CC); zval_ptr_dtor(&field_values_array); Z_OBJ_HT_P(doc_field) = &solr_document_field_handlers; } /* }}} */ /* {{{ PHP_SOLR_API void solr_create_document_field_object(solr_field_list_t *field_values, zval **field_obj TSRMLS_DC) constructs the element when adding a document to the index */ PHP_SOLR_API void solr_add_doc_node(xmlNode *root_node, solr_document_t *doc_entry TSRMLS_DC) { HashTable *document_fields = NULL; xmlNode *solr_doc_node = NULL; document_fields = doc_entry->fields; solr_doc_node = xmlNewChild(root_node, NULL, (xmlChar *) "doc", NULL); if (doc_entry->document_boost > 0.0f) { auto char tmp_buffer[256]; /* Scratch pad for converting numeric values to strings */ memset(tmp_buffer, 0, sizeof(tmp_buffer)); php_gcvt(doc_entry->document_boost, EG(precision), '.', 'e' , (char *)tmp_buffer); xmlNewProp(solr_doc_node, (xmlChar *) "boost", (xmlChar *) tmp_buffer); } solr_generate_document_xml_from_fields(solr_doc_node, document_fields TSRMLS_CC); if (zend_hash_num_elements(doc_entry->children) > 0) { SOLR_HASHTABLE_FOR_LOOP(doc_entry->children) { zval **doc_obj = NULL; solr_document_t *child_doc_entry = NULL; zend_hash_get_current_data_ex(doc_entry->children, (void **)&doc_obj, ((HashPosition *)0)); if (solr_fetch_document_entry(*doc_obj, &child_doc_entry TSRMLS_CC) == SUCCESS) { solr_add_doc_node(solr_doc_node, child_doc_entry TSRMLS_CC); } } } } /* }}} */ /* {{{ static void solr_generate_document_xml_from_fields(xmlNode *solr_doc_node, HashTable *document_fields) */ PHP_SOLR_API void solr_generate_document_xml_from_fields(xmlNode *solr_doc_node, HashTable *document_fields TSRMLS_DC) { xmlDoc *doc_ptr = solr_doc_node->doc; SOLR_HASHTABLE_FOR_LOOP(document_fields) { solr_char_t *doc_field_name; solr_field_value_t *doc_field_value; solr_field_list_t **field = NULL; zend_bool is_first_value = 1; /* Turn on first value flag */ zend_hash_get_current_data_ex(document_fields, (void **) &field, ((HashPosition *)0)); doc_field_name = (*field)->field_name; doc_field_value = (*field)->head; /* Loop through all the values for this field */ while(doc_field_value != NULL) { xmlChar *escaped_field_value = xmlEncodeEntitiesReentrant(doc_ptr, (xmlChar *) doc_field_value->field_value); xmlNode *solr_field_node = xmlNewChild(solr_doc_node, NULL, (xmlChar *) "field", escaped_field_value); xmlNewProp(solr_field_node, (xmlChar *) "name", (xmlChar *) doc_field_name); /* Set the boost attribute if this is the first value */ if (is_first_value && (*field)->field_boost > 0.0f) { auto char tmp_boost_value_buffer[256]; memset(tmp_boost_value_buffer, 0, sizeof(tmp_boost_value_buffer)); php_gcvt((*field)->field_boost, EG(precision), '.', 'e' , tmp_boost_value_buffer); xmlNewProp(solr_field_node, (xmlChar *) "boost", (xmlChar *) tmp_boost_value_buffer); is_first_value = 0; /* Turn off the flag */ } /* Release the memory allocated by xmlEncodeEntitiesReentrant */ xmlFree(escaped_field_value); /* Grab the next value for this field if any */ doc_field_value = doc_field_value->next; } /* while(doc_field_value != NULL) */ } /* SOLR_HASHTABLE_FOR_LOOP(document_fields) */ } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/solr_functions_helpers.c0000644000175000017500000015156312676753706017610 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" #if !(PHP_MAJOR_VERSION==5 && PHP_MINOR_VERSION==2) ZEND_EXTERN_MODULE_GLOBALS(json) #endif /** ************************************************************************ **/ /** FUNCTIONS FOR DECLARING CONSTANTS **/ /** ************************************************************************ **/ /* {{{ void solr_extension_register_constants(int type, int module_number TSRMLS_DC) */ PHP_SOLR_API void solr_extension_register_constants(int type, int module_number TSRMLS_DC) { REGISTER_LONG_CONSTANT("SOLR_MAJOR_VERSION", PHP_SOLR_MAJOR_VERSION, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SOLR_MINOR_VERSION", PHP_SOLR_MINOR_VERSION, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SOLR_PATCH_VERSION", PHP_SOLR_PATCH_VERSION, CONST_CS | CONST_PERSISTENT); REGISTER_STRING_CONSTANT("SOLR_EXTENSION_VERSION", PHP_SOLR_DOTTED_VERSION, CONST_CS | CONST_PERSISTENT); } /* }}} */ /* {{{ void solr_document_register_class_constants(zend_class_entry * ce TSRMLS_DC) */ PHP_SOLR_API void solr_document_register_class_constants(zend_class_entry *ce TSRMLS_DC) { zend_declare_class_constant_long(ce, "SORT_DEFAULT", sizeof("SORT_DEFAULT")-1, SOLR_SORT_ASC TSRMLS_CC); zend_declare_class_constant_long(ce, "SORT_ASC", sizeof("SORT_ASC")-1, SOLR_SORT_ASC TSRMLS_CC); zend_declare_class_constant_long(ce, "SORT_DESC", sizeof("SORT_DESC")-1, SOLR_SORT_DESC TSRMLS_CC); zend_declare_class_constant_long(ce, "SORT_FIELD_NAME", sizeof("SORT_FIELD_NAME")-1, SOLR_SORT_FIELD_NAME TSRMLS_CC); zend_declare_class_constant_long(ce, "SORT_FIELD_VALUE_COUNT", sizeof("SORT_FIELD_VALUE_COUNT")-1, SOLR_SORT_FIELD_VALUE_COUNT TSRMLS_CC); zend_declare_class_constant_long(ce, "SORT_FIELD_BOOST_VALUE", sizeof("SORT_FIELD_BOOST_VALUE")-1, SOLR_SORT_FIELD_BOOST_VALUE TSRMLS_CC); } /* }}} */ /* {{{ void solr_collapse_function_register_class_constants(zend_class_entry * ce TSRMLS_DC) */ PHP_SOLR_API void solr_collapse_function_register_class_constants(zend_class_entry *ce TSRMLS_DC) { zend_declare_class_constant_string(ce, "NULLPOLICY_IGNORE", sizeof("NULLPOLICY_IGNORE")-1, "ignore" TSRMLS_CC); zend_declare_class_constant_string(ce, "NULLPOLICY_EXPAND", sizeof("NULLPOLICY_EXPAND")-1, "expand" TSRMLS_CC); zend_declare_class_constant_string(ce, "NULLPOLICY_COLLAPSE", sizeof("NULLPOLICY_COLLAPSE")-1, "collapse" TSRMLS_CC); } /* }}} */ /* {{{ void solr_client_register_class_constants(zend_class_entry *ce TSRMLS_DC) */ PHP_SOLR_API void solr_client_register_class_constants(zend_class_entry *ce TSRMLS_DC) { zend_declare_class_constant_long(ce, "SEARCH_SERVLET_TYPE", sizeof("SEARCH_SERVLET_TYPE")-1, SOLR_SERVLET_TYPE_SEARCH TSRMLS_CC); zend_declare_class_constant_long(ce, "UPDATE_SERVLET_TYPE", sizeof("UPDATE_SERVLET_TYPE")-1, SOLR_SERVLET_TYPE_UPDATE TSRMLS_CC); zend_declare_class_constant_long(ce, "THREADS_SERVLET_TYPE", sizeof("THREADS_SERVLET_TYPE")-1, SOLR_SERVLET_TYPE_THREADS TSRMLS_CC); zend_declare_class_constant_long(ce, "PING_SERVLET_TYPE", sizeof("PING_SERVLET_TYPE")-1, SOLR_SERVLET_TYPE_PING TSRMLS_CC); zend_declare_class_constant_long(ce, "TERMS_SERVLET_TYPE", sizeof("TERMS_SERVLET_TYPE")-1, SOLR_SERVLET_TYPE_TERMS TSRMLS_CC); zend_declare_class_constant_long(ce, "SYSTEM_SERVLET_TYPE", sizeof("SYSTEM_SERVLET_TYPE")-1, SOLR_SERVLET_TYPE_SYSTEM TSRMLS_CC); zend_declare_class_constant_string(ce, "DEFAULT_SEARCH_SERVLET", sizeof("DEFAULT_SEARCH_SERVLET")-1, SOLR_DEFAULT_SEARCH_SERVLET TSRMLS_CC); zend_declare_class_constant_string(ce, "DEFAULT_UPDATE_SERVLET", sizeof("DEFAULT_UPDATE_SERVLET")-1, SOLR_DEFAULT_UPDATE_SERVLET TSRMLS_CC); zend_declare_class_constant_string(ce, "DEFAULT_THREADS_SERVLET", sizeof("DEFAULT_THREADS_SERVLET")-1, SOLR_DEFAULT_THREADS_SERVLET TSRMLS_CC); zend_declare_class_constant_string(ce, "DEFAULT_PING_SERVLET", sizeof("DEFAULT_PING_SERVLET")-1, SOLR_DEFAULT_PING_SERVLET TSRMLS_CC); zend_declare_class_constant_string(ce, "DEFAULT_TERMS_SERVLET", sizeof("DEFAULT_TERMS_SERVLET")-1, SOLR_DEFAULT_TERMS_SERVLET TSRMLS_CC); zend_declare_class_constant_string(ce, "DEFAULT_SYSTEM_SERVLET", sizeof("DEFAULT_SYSTEM_SERVLET")-1, SOLR_DEFAULT_SYSTEM_SERVLET TSRMLS_CC); } /* }}} */ /* {{{ void solr_response_register_class_properties(zend_class_entry *ce TSRMLS_DC) */ PHP_SOLR_API void solr_response_register_class_properties(zend_class_entry *ce TSRMLS_DC) { zend_declare_property_long(ce, "http_status", sizeof("http_status")-1, 0L, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(ce, "parser_mode", sizeof("parser_mode")-1, 0L, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(ce, "success", sizeof("success")-1, 0L, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(ce, "response_writer", sizeof("response_writer")-1, SOLR_SPACE_STRING, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(ce, "http_status_message", sizeof("http_status_message")-1, SOLR_SPACE_STRING, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(ce, "http_request_url", sizeof("http_request_url")-1, SOLR_SPACE_STRING, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(ce, "http_raw_request_headers", sizeof("http_raw_request_headers")-1, SOLR_SPACE_STRING, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(ce, "http_raw_request", sizeof("http_raw_request")-1, SOLR_SPACE_STRING, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(ce, "http_raw_response_headers", sizeof("http_raw_response_headers")-1, SOLR_SPACE_STRING, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(ce, "http_raw_response", sizeof("http_raw_response")-1, SOLR_SPACE_STRING, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(ce, "http_digested_response", sizeof("http_digested_response")-1, SOLR_SPACE_STRING, ZEND_ACC_PROTECTED TSRMLS_CC); } /* }}} */ /* {{{ void solr_exception_register_class_properties(zend_class_entry *ce TSRMLS_DC) */ PHP_SOLR_API void solr_exception_register_class_properties(zend_class_entry *ce TSRMLS_DC) { zend_declare_property_long(ce, SOLR_SOURCELINE_NO_PROPERTY_NAME, sizeof(SOLR_SOURCELINE_NO_PROPERTY_NAME)-1, __LINE__, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(ce, SOLR_SOURCEFILE_PROPERTY_NAME, sizeof(SOLR_SOURCEFILE_PROPERTY_NAME)-1, __FILE__, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(ce, SOLR_ZIFNAME_PROPERTY_NAME, sizeof(SOLR_ZIFNAME_PROPERTY_NAME)-1, (char *) __func__, ZEND_ACC_PROTECTED TSRMLS_CC); } /* }}} */ /* {{{ void solr_response_register_class_constants(zend_class_entry *ce TSRMLS_DC) */ PHP_SOLR_API void solr_response_register_class_constants(zend_class_entry *ce TSRMLS_DC) { zend_declare_class_constant_long(ce, "PARSE_SOLR_OBJ", sizeof("PARSE_SOLR_OBJ")-1, 0L TSRMLS_CC); zend_declare_class_constant_long(ce, "PARSE_SOLR_DOC", sizeof("PARSE_SOLR_DOC")-1, 1L TSRMLS_CC); } /* }}} */ /* {{{ void solr_query_register_class_constants(zend_class_entry *ce TSRMLS_DC) */ PHP_SOLR_API void solr_query_register_class_constants(zend_class_entry *ce TSRMLS_DC) { zend_declare_class_constant_long(ce, "ORDER_ASC", sizeof("ORDER_ASC")-1, SOLR_SORT_DIR_ASC TSRMLS_CC); zend_declare_class_constant_long(ce, "ORDER_DESC", sizeof("ORDER_DESC")-1, SOLR_SORT_DIR_DESC TSRMLS_CC); zend_declare_class_constant_long(ce, "FACET_SORT_INDEX", sizeof("FACET_SORT_INDEX")-1, 0L TSRMLS_CC); zend_declare_class_constant_long(ce, "FACET_SORT_COUNT", sizeof("FACET_SORT_COUNT")-1, 1L TSRMLS_CC); zend_declare_class_constant_long(ce, "TERMS_SORT_INDEX", sizeof("TERMS_SORT_INDEX")-1, 0L TSRMLS_CC); zend_declare_class_constant_long(ce, "TERMS_SORT_COUNT", sizeof("TERMS_SORT_COUNT")-1, 1L TSRMLS_CC); } /* }}} */ /** ************************************************************************ **/ /** FUNCTIONS FOR REFERENCE COUNT MANAGEMENT **/ /** ************************************************************************ **/ /** {{{ void solr_zval_add_ref(zval **p) */ PHP_SOLR_API void solr_zval_add_ref(zval **p) { Z_ADDREF_PP(p); } /* }}} */ /** {{{ void solr_zval_minus_ref(zval **p) */ PHP_SOLR_API void solr_zval_minus_ref(zval **p) { Z_DELREF_PP(p); } /* }}} */ /** ************************************************************************ **/ /** UTILITY FUNCTIONS **/ /** ************************************************************************ **/ /* {{{ int solr_hashtable_get_new_index(HashTable *ht TSRMLS_DC) Retrieves a unique index for this HashTable */ PHP_SOLR_API int solr_hashtable_get_new_index(HashTable *ht TSRMLS_DC) { int new_index = SOLR_GET_RANDOM_NUMBER(); /* If the key already exists in the HashTable, create another one. */ while(zend_hash_index_exists(ht, new_index)) { new_index = SOLR_GET_RANDOM_NUMBER(); } return new_index; } /* }}} */ /* {{{ static inline int solr_fetch_document_entry(zval *objptr, solr_document_t **doc_entry TSRMLS_DC) Retrieves a Document from the HashTable */ PHP_SOLR_API int solr_fetch_document_entry(zval *objptr, solr_document_t **doc_entry TSRMLS_DC) { zval *id = zend_read_property(Z_OBJCE_P(objptr), objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, 1 TSRMLS_CC); /* Retrieving the value of the document index from the zval */ long int document_index = Z_LVAL_P(id); *doc_entry = NULL; /* Retrieve the doc_entry from the HashTable */ if (zend_hash_index_find(SOLR_GLOBAL(documents), document_index, (void **) doc_entry) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Document Index %ld. HashTable index does not exist.", document_index); php_error_docref(NULL TSRMLS_CC, E_WARNING, SOLR_ERROR_1008_MSG, SOLR_FILE_LINE_FUNC); return FAILURE; } return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API int solr_fetch_client_entry(zval *objptr, solr_client_t **solr_client TSRMLS_DC) */ PHP_SOLR_API int solr_fetch_client_entry(zval *objptr, solr_client_t **solr_client TSRMLS_DC) { zval *id = zend_read_property(solr_ce_SolrClient, objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, 1 TSRMLS_CC); /* Retrieving the value of the client index from the zval */ long int client_index = Z_LVAL_P(id); *solr_client = NULL; /* Retrieve the doc_entry from the HashTable */ if (zend_hash_index_find(SOLR_GLOBAL(clients), client_index, (void **) solr_client) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid SolrClient Index %ld. HashTable index does not exist.", client_index); php_error_docref(NULL TSRMLS_CC, E_WARNING, SOLR_ERROR_1008_MSG, SOLR_FILE_LINE_FUNC); return FAILURE; } return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API int solr_fetch_params_entry(zval *objptr, solr_params_t **solr_params TSRMLS_DC) */ PHP_SOLR_API int solr_fetch_params_entry(zval *objptr, solr_params_t **solr_params TSRMLS_DC) { zval *id = zend_read_property(Z_OBJCE_P(objptr), objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, 1 TSRMLS_CC); long int params_index = Z_LVAL_P(id); *solr_params = NULL; if (zend_hash_index_find(SOLR_GLOBAL(params), params_index, (void **) solr_params) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid SolrParams Index %ld. HashTable index does not exist.", params_index); php_error_docref(NULL TSRMLS_CC, E_WARNING, SOLR_ERROR_1008_MSG, SOLR_FILE_LINE_FUNC); return FAILURE; } return SUCCESS; } /* }}} */ PHP_SOLR_API int solr_fetch_function_entry(zval *objptr, solr_function_t **solr_function TSRMLS_DC) { zval *id = zend_read_property(Z_OBJCE_P(objptr), objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, 1 TSRMLS_CC); long int params_index = Z_LVAL_P(id); *solr_function = NULL; if (zend_hash_index_find(SOLR_GLOBAL(functions), params_index, (void **) solr_function) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid solr_function Index %ld. HashTable index does not exist.", params_index); php_error_docref(NULL TSRMLS_CC, E_WARNING, SOLR_ERROR_1008_MSG, SOLR_FILE_LINE_FUNC); return FAILURE; } return SUCCESS; } /* {{{ PHP_SOLR_API void solr_destroy_function(void *solr_function) */ PHP_SOLR_API void solr_destroy_function(void *solr_function) { solr_function_t *function = (solr_function_t *) solr_function; zend_hash_destroy(function->params); pefree(function->params, SOLR_FUNCTIONS_PERSISTENT); } /* }}} */ /* {{{ PHP_SOLR_API xmlDocPtr solr_xml_create_xml_doc(const xmlChar *root_node_name, xmlNode **root_node_ptr) */ PHP_SOLR_API xmlDocPtr solr_xml_create_xml_doc(const xmlChar *root_node_name, xmlNode **root_node_ptr) { xmlNs *ns = NULL; xmlDoc *doc_ptr = xmlNewDoc((xmlChar *) "1.0"); xmlNode *root_node = xmlNewNode(ns, root_node_name); xmlDocSetRootElement(doc_ptr, root_node); if (root_node_ptr) { *root_node_ptr = root_node; } return doc_ptr; } /* }}} */ /** * escapes strings with characters that are part of the Lucene query syntax * * @sbuilder is a solr_string_t pointer used to store the escape char sequence * @unescaped is the unescaped string. It must be null terminated * @unescaped_length is the original length of the unescaped_string */ /* {{{ PHP_SOLR_API void solr_escape_query_chars(solr_string_t *sbuilder, solr_char_t *unescaped, long int unescaped_length) */ PHP_SOLR_API void solr_escape_query_chars(solr_string_t *sbuilder, solr_char_t *unescaped, long int unescaped_length) { register int i = 0; /** * Lucene supports escaping special characters that are part of the query syntax. * * The current list special characters are * + - && || ! ( ) { } [ ] ^ " ~ * ? : \ / * * These characters are part of the query syntax and must be escaped */ for (i = 0; i < unescaped_length; i++) { enter_switchboard : switch(unescaped[i]) { case '\\' : case '+' : case '-' : case '!' : case '(' : case ')' : case ':' : case '/' : case '^' : case '[' : case ']' : case '"' : case '{' : case '}' : case '~' : case '*' : case '?' : case ';' : { solr_string_appendc(sbuilder, '\\'); } break; case '|' : /* || */ { if ('|' == unescaped[i+1]) { solr_string_appendc(sbuilder, '\\'); solr_string_append_const(sbuilder, "||"); i += 2; goto enter_switchboard; } } break; case '&' : /* && */ { if ('&' == unescaped[i+1]) { solr_string_appendc(sbuilder, '\\'); solr_string_append_const(sbuilder, "&&"); i += 2; goto enter_switchboard; } } break; default : /* The current character is not a special character */ { /* Do nothing. Just append the character as is */ } } /* END switch(unescaped[i]) */ solr_string_appendc(sbuilder, unescaped[i]); } /* END for (i = 0; i < unescaped_length; i++) { */ } /* }}} */ /******************************************************************************/ /* SOLR XML RESPONSE DIGEST DATA TYPES AND FUNCTIONS */ /******************************************************************************/ /* {{{ solr_doc_encode_t, solr_php_encode_t, solr_encoding_type_t, solr_php_encode_func_t, solr_document_field_encode_func_t */ typedef enum { SOLR_DOC_ENCODE_START = 0, SOLR_DOC_ENCODE_FIELDS = 1, SOLR_DOC_ENCODE_FIELD = 2, SOLR_DOC_ENCODE_END } solr_doc_encode_t; typedef enum { SOLR_ENCODE_START = 0, SOLR_ENCODE_NULL = 1, SOLR_ENCODE_BOOL = 2, SOLR_ENCODE_INT = 3, SOLR_ENCODE_FLOAT = 4, SOLR_ENCODE_STRING = 5, SOLR_ENCODE_ARRAY = 6, SOLR_ENCODE_OBJECT = 7, SOLR_ENCODE_DOC = 8, SOLR_ENCODE_RESULT = 9, SOLR_ENCODE_END } solr_php_encode_t; typedef enum { SOLR_ENCODE_STANDALONE = 0, SOLR_ENCODE_OBJECT_PROPERTY = 1, SOLR_ENCODE_ARRAY_KEY = 2, SOLR_ENCODE_ARRAY_INDEX = 3 } solr_encoding_type_t; typedef void (*solr_php_encode_func_t)(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode); typedef void (*solr_document_field_encode_func_t)(const xmlNode *node, xmlNode *field); /* }}} */ /* {{{ Macros for XML transcoding */ /* Serializes the current XML node */ #define solr_encode_xml_node(__node, __buf, __enc_type, __arr_idx, __mode) solr_encoder_functions[solr_get_xml_type((__node))]((__node),(__buf), (__enc_type), (__arr_idx), (__mode)) #define solr_write_object_closer(__buf) solr_string_append_const((__buf), "}") #define solr_write_array_closer(__buf) solr_string_append_const((__buf), "}") #define solr_write_root_object_closer(__buf) solr_string_append_const((__buf), "}") /* }}} */ /* {{{ static void solr_encode_* prototypes */ static void solr_encode_null(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode); static void solr_encode_bool(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode); static void solr_encode_int(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode); static void solr_encode_float(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode); static void solr_encode_string(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode); static void solr_encode_array(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode); static void solr_encode_object(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode); static void solr_encode_document(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode); static void solr_encode_result(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode); static void solr_encode_document_field_simple(const xmlNode *fieldNode, xmlNode *field); static void solr_encode_document_field_complex(const xmlNode *fieldNode, xmlNode *field); /* }}} */ /* {{{ global variables solr_encoder_functions[], solr_document_field_encoders[] */ static solr_php_encode_func_t solr_encoder_functions[] = { solr_encode_string, solr_encode_null, solr_encode_bool, solr_encode_int, solr_encode_float, solr_encode_string, solr_encode_array, solr_encode_object, solr_encode_document, solr_encode_result, NULL }; static solr_document_field_encode_func_t solr_document_field_encoders[] = { solr_encode_document_field_simple, /* maps to SOLR_SIMPLE_FIELD */ solr_encode_document_field_complex, /* maps to SOLR_COMPLEX_FIELD */ NULL }; /* }}} */ /* {{{ Constants and Macros for handling node types */ #define SOLR_SIMPLE_FIELD 0 #define SOLR_COMPLEX_FIELD 1 #define solr_xml_field_node_type(node) (xmlStrEqual((node)->name, (xmlChar *)"arr")? SOLR_COMPLEX_FIELD : SOLR_SIMPLE_FIELD) #define solr_encode_document_field(field_in, field_out) solr_document_field_encoders[solr_xml_field_node_type((field_in))]((field_in), (field_out)) /* }}} */ /* Used to figure out now many properties or elements there are in an object or an array */ /* {{{ static inline int solr_get_node_size(const xmlNode *data_node) */ static inline int solr_get_node_size(const xmlNode *data_node) { register int size = 0; xmlNode *curr_node = data_node->children; while(curr_node != NULL) { if (XML_ELEMENT_NODE == curr_node->type) { size++; } curr_node = curr_node->next; } return size; } /* }}} */ /* {{{ static inline int solr_get_xml_type(xmlNode *node) */ static inline int solr_get_xml_type(xmlNode *node) { solr_char_t *node_name = (solr_char_t *) node->name; if (!node_name) { return SOLR_ENCODE_STRING; } if (!strcmp(node_name, "str")) { return SOLR_ENCODE_STRING; } else if (!strcmp(node_name, "int") || !strcmp(node_name, "long") || !strcmp(node_name, "short") || !strcmp(node_name, "byte")) { return SOLR_ENCODE_INT; } else if (!strcmp(node_name, "double") || !strcmp(node_name, "float")) { return SOLR_ENCODE_FLOAT; } else if (!strcmp(node_name, "lst")) { return SOLR_ENCODE_OBJECT; } else if (!strcmp(node_name, "arr")) { return SOLR_ENCODE_ARRAY; } else if (!strcmp(node_name, "bool")) { return SOLR_ENCODE_BOOL; } else if (!strcmp(node_name, "null")) { return SOLR_ENCODE_NULL; } else if (!strcmp(node_name, "result")) { return SOLR_ENCODE_RESULT; }else if (!strcmp(node_name, "doc")) { return SOLR_ENCODE_OBJECT; } else { return SOLR_ENCODE_STRING; } } /* }}} */ /* {{{ static inline void solr_write_variable_opener(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index) */ static inline void solr_write_variable_opener(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index) { switch(enc_type) { case SOLR_ENCODE_OBJECT_PROPERTY : /* fall through */ case SOLR_ENCODE_ARRAY_KEY : { solr_char_t *object_name = "_undefined_property_name"; xmlAttr *name_attr = node->properties; /* get the contents of the name attribute */ if (name_attr) { object_name = (solr_char_t *) solr_xml_get_node_contents(name_attr); } solr_string_append_const(buffer, "s:"); solr_string_append_long(buffer, strlen(object_name)); solr_string_append_const(buffer, ":\""); solr_string_appends(buffer, object_name, strlen(object_name)); solr_string_append_const(buffer, "\";"); } break; case SOLR_ENCODE_ARRAY_INDEX : { solr_string_append_const(buffer, "i:"); solr_string_append_long(buffer, array_index); solr_string_appendc(buffer, ';'); } break; default : { /* do nothing */ } break; } } /* }}} */ /* {{{ static void solr_write_object_opener(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index) */ static void solr_write_object_opener(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index) { int size = solr_get_node_size(node); solr_write_variable_opener(node, buffer, enc_type, array_index); solr_string_append_const(buffer, "O:10:\"SolrObject\":"); solr_string_append_long(buffer, size); solr_string_append_const(buffer, ":{"); } /* }}} */ /* {{{ static void solr_write_solr_document_opener(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, int size) */ static void solr_write_solr_document_opener(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, int size) { solr_write_variable_opener(node, buffer, enc_type, array_index); solr_string_append_const(buffer, "C:12:\"SolrDocument\":"); solr_string_append_long(buffer, size); solr_string_append_const(buffer, ":{"); } /* }}} */ /* {{{ static void solr_write_array_opener(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index) */ static void solr_write_array_opener(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index) { int size = solr_get_node_size(node); solr_write_variable_opener(node, buffer, enc_type, array_index); solr_string_append_const(buffer, "a:"); solr_string_append_long(buffer, size); solr_string_append_const(buffer, ":{"); } /* }}} */ static void solr_serialize_solr_document(const xmlNode *node, solr_string_t *dest); static void solr_encode_solr_document_children(const xmlNode *node, xmlNode* builder_node, int child_docs_found); static void solr_encode_solr_document(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode); static void solr_serialize_solr_document(const xmlNode *node, solr_string_t *dest) { xmlChar *doc_txt_buffer = NULL; int doc_txt_len = 0; xmlNode *solr_document_node = NULL; xmlDoc *doc_ptr = solr_xml_create_xml_doc((xmlChar *) "solr_document", &solr_document_node); xmlNode *fields_node = xmlNewChild(solr_document_node, NULL, (xmlChar *) "fields", NULL); xmlNode *curr_node = node->children; int format = 1; int child_docs_found = 0; while(curr_node != NULL) { if (XML_ELEMENT_NODE == curr_node->type) { if (strcmp((const char *)curr_node->name, "doc") == 0) { child_docs_found++; } else { xmlNode *field = xmlNewChild(fields_node, NULL, (xmlChar *)"field", NULL); solr_encode_document_field(curr_node, field); } } curr_node = curr_node->next; } if (child_docs_found > 0) { solr_encode_solr_document_children(node, solr_document_node, child_docs_found); } /* We have written all the fields to the document */ /* Dumping the document from memory to the buffer */ xmlDocDumpFormatMemoryEnc(doc_ptr, &doc_txt_buffer, &doc_txt_len, "UTF-8", format); solr_string_appends_ex(dest, (solr_char_t *)doc_txt_buffer, doc_txt_len); xmlFreeDoc(doc_ptr); xmlFree(doc_txt_buffer); } /* {{{ static void solr_encode_document_children(const xmlNode *node, solr_string_t* buffer, int child_docs_found, long int parse_mode) encodes the doc/doc child/nested documents */ static void solr_encode_solr_document_children(const xmlNode *node, xmlNode* builder_node, int child_docs_found) { int current_index = 0; xmlXPathContext *xpathctxt = NULL; const xmlChar *xpath_expression = (xmlChar *) "child::doc"; xmlXPathObject *xpathObj = NULL; xmlNodeSet *result = NULL; xmlNode *child_docs_node = NULL; xpathctxt = xmlXPathNewContext(node->doc); xpathctxt->node = (xmlNodePtr) node; xpathObj = xmlXPathEval(xpath_expression, xpathctxt); result = xpathObj->nodesetval; child_docs_found = result->nodeNr; child_docs_node = xmlNewChild(builder_node, NULL, (xmlChar *)"child_docs", NULL); for (current_index=0; current_index < child_docs_found; current_index++) { int encoded_len; char *encoded; solr_string_t tmp_buffer; solr_string_t tmp_s_buffer; memset(&tmp_buffer, 0, sizeof(solr_string_t)); memset(&tmp_s_buffer, 0, sizeof(solr_string_t)); solr_serialize_solr_document(result->nodeTab[current_index], &tmp_buffer); solr_string_append_const(&tmp_s_buffer, "C:12:\"SolrDocument\":"); solr_string_append_long(&tmp_s_buffer, tmp_buffer.len); solr_string_append_const(&tmp_s_buffer, ":{"); solr_string_appends_ex(&tmp_s_buffer, tmp_buffer.str, tmp_buffer.len); solr_write_object_closer(&tmp_s_buffer); encoded = (char *)php_base64_encode((unsigned char*)tmp_s_buffer.str, tmp_s_buffer.len, &encoded_len); xmlNewChild(child_docs_node, NULL, (const xmlChar *) "dochash", (xmlChar *)encoded); solr_string_free_ex(&tmp_buffer); solr_string_free_ex(&tmp_s_buffer); if (encoded) { efree(encoded); } } } /* }}} */ /** * * The @enc_type parameter must be SOLR_ENCODE_ARRAY_INDEX */ /* {{{ static void solr_encode_solr_document(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) */ static void solr_encode_solr_document(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) { solr_string_t doc_serialized_buffer; memset(&doc_serialized_buffer, 0, sizeof(solr_string_t)); solr_serialize_solr_document(node, &doc_serialized_buffer); solr_write_solr_document_opener(NULL, buffer, enc_type, array_index, doc_serialized_buffer.len); solr_string_appends(buffer, (char *) doc_serialized_buffer.str, doc_serialized_buffer.len); solr_write_object_closer(buffer); solr_string_free(&doc_serialized_buffer); } /* }}} */ /* {{{ static void solr_write_object_opener(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index) */ static void solr_write_object_opener_child_doc(const xmlNode *node, int num_child_docs ,solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index) { int size = solr_get_node_size(node) - num_child_docs + 1; solr_write_variable_opener(node, buffer, enc_type, array_index); solr_string_append_const(buffer, "O:10:\"SolrObject\":"); solr_string_append_long(buffer, size); solr_string_append_const(buffer, ":{"); } /* }}} */ /* {{{ static void solr_encode_document_children(const xmlNode *node, solr_string_t* buffer, int child_docs_found, long int parse_mode) encodes the doc/doc child/nested documents ONLY FOR SolrObject */ static void solr_encode_document_children(const xmlNode *node, solr_string_t* buffer, int child_docs_found, long int parse_mode) { int current_index = 0; xmlXPathContext *xpathctxt = NULL; const xmlChar *xpath_expression = (xmlChar *) "child::doc"; xmlXPathObject *xpathObj = NULL; xmlNodeSet *result = NULL; solr_php_encode_func_t document_encoder_functions[] = { solr_encode_document, solr_encode_solr_document, NULL }; solr_string_append_const(buffer, "s:"); solr_string_append_long(buffer, sizeof("_childDocuments_")-1); solr_string_append_const(buffer, ":\""); solr_string_appends(buffer, "_childDocuments_", sizeof("_childDocuments_")-1); solr_string_append_const(buffer, "\";"); solr_string_append_const(buffer, "a:"); solr_string_append_long(buffer, child_docs_found); solr_string_append_const(buffer, ":{"); xpathctxt = xmlXPathNewContext(node->doc); xpathctxt->node = (xmlNodePtr) node; xpathObj = xmlXPathEval(xpath_expression, xpathctxt); result = xpathObj->nodesetval; child_docs_found = result->nodeNr; for (current_index=0; current_index < child_docs_found; current_index++) { document_encoder_functions[parse_mode](result->nodeTab[current_index], buffer, SOLR_ENCODE_ARRAY_INDEX, current_index, parse_mode); } solr_write_array_closer(buffer); } /* }}} */ /* {{{ static void solr_encode_document(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) encodes/serializes the element result/doc */ static void solr_encode_document(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) { xmlNode *curr_node = NULL; int child_docs_found = 0; solr_string_t inner_buffer; memset(&inner_buffer, 0, sizeof(solr_string_t)); curr_node = node->children; while(curr_node != NULL) { if (XML_ELEMENT_NODE == curr_node->type) { if (strcmp((const char*) curr_node->name, "doc") == 0) { /* skip doc/doc elements to be processed later */ child_docs_found++; } else { solr_encode_xml_node(curr_node, &inner_buffer, SOLR_ENCODE_OBJECT_PROPERTY, 0L, parse_mode); } } curr_node = curr_node->next; } if (child_docs_found > 0){ solr_encode_document_children(node, &inner_buffer, child_docs_found, parse_mode); /** * write and calculate proper object opener * because the object number of properties depends on whether there are child documents involved */ solr_write_object_opener_child_doc(node, child_docs_found, buffer, enc_type, array_index); } else { solr_write_object_opener(node, buffer, enc_type, array_index); } solr_string_appends_ex(buffer, inner_buffer.str, inner_buffer.len); solr_write_object_closer(buffer); solr_string_free_ex(&inner_buffer); } /* }}} */ /** * Handles simple data types like strings, integers, booleans etc. */ /* {{{ static void solr_encode_document_field_simple(const xmlNode *fieldNode, xmlNode *field) */ static void solr_encode_document_field_simple(const xmlNode *fieldNode, xmlNode *field) { xmlChar *fieldname = NULL; xmlChar *field_value = NULL; fieldname = solr_xml_get_node_contents(fieldNode->properties); if (strcmp((const char *)fieldname, "") == 0) { /** todo throw an IllegalOperationException */ return; } field_value = xmlEncodeEntitiesReentrant(fieldNode->doc, solr_xml_get_node_contents(fieldNode)); xmlNewChild(field, NULL, (xmlChar *) "field_value", field_value); xmlNewProp(field, (xmlChar *) "name", fieldname); xmlFree(field_value); } /* }}} */ /* Handles complex data types like arrays */ /* {{{ static void solr_encode_document_field_complex(const xmlNode *fieldNode, xmlNode *field) */ static void solr_encode_document_field_complex(const xmlNode *fieldNode, xmlNode *field) { xmlChar *fieldname = solr_xml_get_node_contents(fieldNode->properties); xmlNode *current_value = fieldNode->children; while(current_value != NULL) { if (current_value->type == XML_ELEMENT_NODE) { xmlChar *field_value = xmlEncodeEntitiesReentrant(fieldNode->doc, solr_xml_get_node_contents(current_value)); xmlNewChild(field, NULL, (xmlChar *) "field_value", field_value); xmlFree(field_value); } current_value = current_value->next; } xmlNewProp(field, (xmlChar *) "name", fieldname); } /* }}} */ /* {{{ static void solr_encode_result(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) */ static void solr_encode_result(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) { xmlAttr *properties = node->properties; solr_char_t *object_name = (solr_char_t *) node->name; solr_char_t *num_found = NULL; solr_char_t *start = NULL; solr_char_t *max_score = NULL; solr_php_encode_func_t document_encoder_functions[] = { solr_encode_document, solr_encode_solr_document, NULL }; xmlAttr *curr_prop = properties; xmlXPathContext *xpathctxt = NULL; const xmlChar *xpath_expression = (xmlChar *) "child::doc"; xmlXPathObject *xpathObj = NULL; xmlNodeSet *result = NULL; long int document_count = 0; while(curr_prop != NULL) { if (solr_xml_match_node(curr_prop, "numFound")) { num_found = (solr_char_t *) solr_xml_get_node_contents(curr_prop); } if (solr_xml_match_node(curr_prop, "start")) { start = (solr_char_t *) solr_xml_get_node_contents(curr_prop); } if (solr_xml_match_node(curr_prop, "name")) { object_name = (solr_char_t *) solr_xml_get_node_contents(curr_prop); } if (solr_xml_match_node(curr_prop, "maxScore")) { max_score = (solr_char_t *) solr_xml_get_node_contents(curr_prop); } curr_prop = curr_prop->next; } xpathctxt = xmlXPathNewContext(node->doc); xpathctxt->node = (xmlNodePtr) node; xpathObj = xmlXPathEval(xpath_expression, xpathctxt); result = xpathObj->nodesetval; document_count = result->nodeNr; solr_string_append_const(buffer, "s:"); solr_string_append_long(buffer, strlen(object_name)); solr_string_append_const(buffer, ":\""); solr_string_appends(buffer, object_name, strlen(object_name)); solr_string_append_const(buffer, "\";"); solr_string_append_const(buffer, "O:10:\"SolrObject\":"); if (max_score) { solr_string_append_long(buffer, 4); /* numFound, start, docs, maxScore properties */ } else { solr_string_append_long(buffer, 3); /* numFound, start, docs properties */ } solr_string_append_const(buffer, ":{"); /* Object Opener for response */ /* Writing the numFound property */ solr_string_append_const(buffer, "s:"); solr_string_append_long(buffer, sizeof("numFound")-1); solr_string_append_const(buffer, ":\""); solr_string_appends(buffer, "numFound", sizeof("numFound")-1); solr_string_append_const(buffer, "\";"); solr_string_append_const(buffer, "i:"); solr_string_appends(buffer, num_found, solr_strlen(num_found)); solr_string_appendc(buffer, ';'); /* Writing the start property */ solr_string_append_const(buffer, "s:"); solr_string_append_long(buffer, sizeof("start")-1); solr_string_append_const(buffer, ":\""); solr_string_appends(buffer, "start", sizeof("start")-1); solr_string_append_const(buffer, "\";"); solr_string_append_const(buffer, "i:"); solr_string_appends(buffer, start, solr_strlen(start)); solr_string_appendc(buffer, ';'); /* writing max score property */ if (max_score) { solr_string_append_const(buffer, "s:"); solr_string_append_long(buffer, sizeof("maxScore")-1); solr_string_append_const(buffer, ":\""); solr_string_appends(buffer, "maxScore", sizeof("maxScore")-1); solr_string_append_const(buffer, "\";"); solr_string_append_const(buffer, "d:"); solr_string_appends(buffer, max_score, solr_strlen(max_score)); solr_string_appendc(buffer, ';'); } /* Writing the docs property */ solr_string_append_const(buffer, "s:"); solr_string_append_long(buffer, sizeof("docs")-1); solr_string_append_const(buffer, ":\""); solr_string_appends(buffer, "docs", sizeof("docs")-1); solr_string_append_const(buffer, "\";"); if (document_count) { /* Grab all the first /response/result/doc node */ xmlNode *curr_doc = node->children; long int curr_doc_index = 0L; /* Array opener */ solr_string_append_const(buffer, "a:"); solr_string_append_long(buffer, document_count); solr_string_append_const(buffer, ":{"); while(curr_doc != NULL) { /* Absolutely no assumptions. At least for now. */ if (XML_ELEMENT_NODE == curr_doc->type && solr_xml_match_node(curr_doc, "doc")) { /* This is where you decided whether to use SolrDocument or StdClass */ /* parse_mode value of 0 creates SolrObject; 1 creates SolrDocument */ document_encoder_functions[parse_mode](curr_doc, buffer, SOLR_ENCODE_ARRAY_INDEX, curr_doc_index, parse_mode); curr_doc_index++; } curr_doc = curr_doc->next; } solr_write_array_closer(buffer); /* Array closer */ } else { solr_string_append_const(buffer, "b:0;"); /* This means there are no docs */ } solr_write_object_closer(buffer); /* Object closer */ xmlXPathFreeContext(xpathctxt); xmlXPathFreeObject(xpathObj); } /* }}} */ /* {{{ static void solr_encode_null(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) */ static void solr_encode_null(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) { /* SolrObject should not contain nulls because of how magic functionality is implemented */ solr_write_variable_opener(node, buffer, enc_type, array_index); /* Setting nulls to boolean false */ solr_string_append_const(buffer, "b:0;"); } /* }}} */ /* {{{ static void solr_encode_bool(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) */ static void solr_encode_bool(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) { solr_char_t *data_value = (solr_char_t *) solr_xml_get_node_contents(node); long int boolean_value = (!strcmp("true", data_value))? 1 : 0; solr_write_variable_opener(node, buffer, enc_type, array_index); solr_string_append_const(buffer, "b:"); solr_string_append_long(buffer, boolean_value); solr_string_appendc(buffer, ';'); } /* }}} */ /* {{{ static void solr_encode_int(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) */ static void solr_encode_int(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) { solr_char_t *data_value = (solr_char_t *) solr_xml_get_node_contents(node); size_t data_value_len = solr_strlen(data_value); solr_write_variable_opener(node, buffer, enc_type, array_index); solr_string_append_const(buffer, "i:"); solr_string_appends(buffer, data_value, data_value_len); solr_string_appendc(buffer, ';'); } /* }}} */ /* {{{ static void solr_encode_float(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) */ static void solr_encode_float(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) { solr_char_t *data_value = (solr_char_t *) solr_xml_get_node_contents(node); size_t data_value_len = solr_strlen(data_value); solr_write_variable_opener(node, buffer, enc_type, array_index); solr_string_append_const(buffer, "d:"); if (strcmp(data_value, "NaN" ) == 0) { data_value = (solr_char_t *)"NAN"; } solr_string_appends(buffer, data_value, data_value_len); solr_string_appendc(buffer, ';'); } /* }}} */ /* {{{ static void solr_encode_string(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) */ static void solr_encode_string(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) { solr_char_t *data_value = (solr_char_t *) solr_xml_get_node_contents(node); size_t data_value_len = solr_strlen(data_value); solr_write_variable_opener(node, buffer, enc_type, array_index); solr_string_append_const(buffer, "s:"); solr_string_append_long(buffer, data_value_len); solr_string_append_const(buffer, ":\""); solr_string_appends(buffer, data_value, data_value_len); solr_string_append_const(buffer, "\";"); } /* }}} */ /* {{{ static void solr_encode_array(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) */ static void solr_encode_array(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) { xmlNode *curr_node = NULL; long int current_index = 0L; solr_write_array_opener(node, buffer, enc_type, array_index); curr_node = node->children; while(curr_node != NULL) { if (XML_ELEMENT_NODE == curr_node->type) { solr_encode_xml_node(curr_node, buffer, SOLR_ENCODE_ARRAY_INDEX, current_index, parse_mode); current_index++; } curr_node = curr_node->next; } solr_write_array_closer(buffer); } /* }}} */ /* {{{ static void solr_encode_object(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) */ static void solr_encode_object(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) { xmlNode *curr_node = NULL; solr_write_object_opener(node, buffer, enc_type, array_index); curr_node = node->children; while(curr_node != NULL) { if (XML_ELEMENT_NODE == curr_node->type) { solr_encode_xml_node(curr_node, buffer, SOLR_ENCODE_OBJECT_PROPERTY, 0L, parse_mode); } curr_node = curr_node->next; } solr_write_object_closer(buffer); } /* }}} */ /** * Used to digest Xml response messages from Solr * */ /* {{{ PHP_SOLR_API void solr_encode_generic_xml_response(solr_string_t *buffer, const solr_char_t *serialized, int size, long int parse_mode TSRMLS_DC) */ PHP_SOLR_API void solr_encode_generic_xml_response(solr_string_t *buffer, const solr_char_t *serialized, int size, long int parse_mode TSRMLS_DC) { xmlDoc *doc = xmlReadMemory(serialized, size, NULL, "UTF-8", XML_PARSE_RECOVER); xmlNode *root = NULL; if (!doc) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error loading XML document"); return; } root = xmlDocGetRootElement(doc); if (!root) { xmlFreeDoc(doc); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error loading root of XML document"); return; } parse_mode = ((parse_mode < 0L) ? 0L : ((parse_mode > 1L) ? 1L : parse_mode)); solr_encode_object(root, buffer, SOLR_ENCODE_STANDALONE, 0L, parse_mode); if (buffer->len == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error parsing XML document"); } xmlFreeDoc(doc); } /* }}} */ /* {{{ PHP_SOLR_API int solr_is_supported_response_writer(const solr_char_t * response_writer, int length) */ PHP_SOLR_API int solr_is_supported_response_writer(const solr_char_t * response_writer, int length) { if (length < 1) { return 0; } if (0 == strcmp(response_writer, SOLR_PHP_SERIALIZED_RESPONSE_WRITER)) { return 1; } if (0 == strcmp(response_writer, SOLR_XML_RESPONSE_WRITER)) { return 1; } if (0 == strcmp(response_writer, SOLR_JSON_RESPONSE_WRITER)) { return 1; } return 0; } /* }}} */ /* {{{ PHP_SOLR_API solr_char_t *solr_get_json_error_msg(solr_json_error_codes_t error_code) */ PHP_SOLR_API solr_char_t *solr_get_json_error_msg(solr_json_error_codes_t error_code) { switch(error_code) { case SOLR_JSON_ERROR_DEPTH: return "JSON maximum recursion depth was exceeded"; break; case SOLR_JSON_ERROR_STATE_MISMATCH: return "JSON error state mismatch"; break; case SOLR_JSON_ERROR_CTRL_CHAR: return "JSON control character was encountered"; break; case SOLR_JSON_ERROR_SYNTAX: return "JSON syntax error"; break; case SOLR_JSON_ERROR_UTF8: return "JSON UTF8 error"; break; default : return "JSON unknown error"; break; } } /* }}} */ /* {{{ PHP_SOLR_API int solr_json_to_php_native(solr_string_t *buffer, const solr_char_t *json_string, int json_string_length TSRMLS_DC) */ PHP_SOLR_API int solr_json_to_php_native(solr_string_t *buffer, const solr_char_t *json_string, int json_string_length TSRMLS_DC) { /* JSON recursion depth. default is 512 */ long recursion_depth = 1024L; long json_error = 0L; php_serialize_data_t var_hash; smart_str serialize_buffer = {0}; /* return value for the function */ zval json_decode_ret_val, *json_decode_ret_val_ptr; zend_uchar json_decode_ret_val_type = IS_NULL; json_decode_ret_val_ptr = &json_decode_ret_val; php_json_decode(&json_decode_ret_val, (char *) json_string, json_string_length, 1, recursion_depth TSRMLS_CC); json_error = solr_get_json_last_error(TSRMLS_C); /* Why ? todo investigate */ /* solr_string_set(buffer, "i:99;", sizeof("i:99;")); */ if (json_error > 0) { zval_dtor(&json_decode_ret_val); php_error_docref(NULL TSRMLS_CC, E_WARNING, "JSON error. JSON->PHP serialization error"); return (int) json_error; } memset(&var_hash, 0, sizeof(php_serialize_data_t)); PHP_VAR_SERIALIZE_INIT(var_hash); php_var_serialize(&serialize_buffer, &json_decode_ret_val_ptr, &var_hash TSRMLS_CC); json_decode_ret_val_type = Z_TYPE_P(json_decode_ret_val_ptr); zval_dtor(&json_decode_ret_val); solr_string_set(buffer, serialize_buffer.c, serialize_buffer.len); PHP_VAR_SERIALIZE_DESTROY(var_hash); smart_str_free(&serialize_buffer); /* return value should not be of NULL type. NULL means an error has occurred */ if (json_decode_ret_val_type == IS_NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "JSON error. Error occurred in php_json_decode(). Raw JSON string is \n %s \n", (char *) json_string); /* json_error always fails to detect an error. * todo investigate */ return (int) SOLR_JSON_ERROR_SERIALIZATION; } return (int) json_error; } /* }}} */ PHP_SOLR_API long solr_get_json_last_error(TSRMLS_D) { long json_error; zval json_last_error_ret_val, **object_pp; zval *json_last_error_params[] = {NULL}; zval json_last_error_function_name; ZVAL_STRINGL(&json_last_error_function_name, "json_last_error", sizeof("json_last_error"), 0); /* object instance to perform the method call */ object_pp = (zval **) NULL; call_user_function(EG(function_table), object_pp, &json_last_error_function_name, &json_last_error_ret_val, 0, json_last_error_params TSRMLS_CC); json_error = Z_LVAL(json_last_error_ret_val); zval_dtor(&json_last_error_ret_val); return json_error; } PHP_SOLR_API int solr_sarray_to_sobject(solr_string_t *buffer TSRMLS_DC) { char * regex = "/a\\:([0-9]+):{s/i", *result; int regex_len = sizeof(regex); zval * replace_val; int * result_len = (int *)emalloc(sizeof(int)); int limit = -1; int replace_count = -1; MAKE_STD_ZVAL(replace_val); ZVAL_STRING(replace_val,"O:10:\"SolrObject\":\\1:{s",1); result = php_pcre_replace( regex, regex_len, (*buffer).str, (*buffer).len, replace_val, 0, result_len, limit, &replace_count TSRMLS_CC ); solr_string_set_ex(buffer, (solr_char_t *)result, (size_t)*result_len); /* fprintf(stdout, "%s", buffer->str); */ efree(result_len); efree(result); zval_ptr_dtor(&replace_val); return SUCCESS; } PHP_SOLR_API int solr_sobject_to_sarray(solr_string_t *buffer TSRMLS_DC) { char * regex = "/O:10:\"SolrObject\":([0-9]+):{s/i", *result; int regex_len = sizeof(regex); zval * replace_val; int * result_len = (int *)emalloc(sizeof(int)); int limit = -1; int replace_count = -1; MAKE_STD_ZVAL(replace_val); ZVAL_STRING(replace_val,"a:\\1:{s",1); result = php_pcre_replace( regex, regex_len, (*buffer).str, (*buffer).len, replace_val, 0, result_len, limit, &replace_count TSRMLS_CC ); solr_string_set_ex(buffer, (solr_char_t *)result, (size_t)*result_len); efree(result_len); efree(result); zval_ptr_dtor(&replace_val); return SUCCESS; } /* }}} */ /* todo document and block this */ PHP_SOLR_API int solr_solrfunc_update_string(zval *obj, solr_char_t *key, int key_len, solr_char_t *value, int value_len TSRMLS_DC) { solr_function_t *function; solr_string_t string; memset(&string, 0, sizeof(solr_string_t)); if (solr_fetch_function_entry(obj, &function TSRMLS_CC) == FAILURE) { return FAILURE; } solr_string_set(&string, (solr_char_t *)value, value_len); if (zend_hash_update(function->params, key, key_len, (void **)&string, sizeof(solr_string_t), NULL) == FAILURE ) { solr_string_free(&string); return FAILURE; } return SUCCESS; } PHP_SOLR_API int solr_solrfunc_fetch_string(zval *obj, solr_char_t *key, int key_len, solr_string_t **string TSRMLS_DC) { solr_function_t *function; if (solr_fetch_function_entry(obj, &function TSRMLS_CC) == FAILURE) { return FAILURE; } if (zend_hash_find(function->params, key, key_len, (void **)string) == FAILURE ) { return FAILURE; } return SUCCESS; } PHP_SOLR_API int solr_solrfunc_display_string(zval *obj, solr_char_t *key, int key_len, zval **return_value TSRMLS_DC) { solr_string_t *field_string_ptr = NULL; memset(&field_string_ptr, 0, sizeof(solr_string_t *)); if (solr_solrfunc_fetch_string(obj, key, key_len, &field_string_ptr TSRMLS_CC) == SUCCESS) { ZVAL_STRINGL(*return_value, field_string_ptr->str, field_string_ptr->len, 1); return SUCCESS; } else { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to fetch string"); return FAILURE; } } PHP_SOLR_API void solr_solrfunc_to_string(solr_function_t *function, solr_string_t **dest) { zend_bool duplicate = 0; solr_string_t *buffer = *dest; solr_string_appends(buffer, (solr_char_t *)"{!", sizeof("{!")-1); solr_string_appends(buffer, function->name, function->name_length); solr_string_appendc(buffer, ' '); SOLR_HASHTABLE_FOR_LOOP(function->params) { solr_string_t *value; solr_char_t *key; uint key_len; ulong num_idx; zend_hash_get_current_key_ex(function->params, &key, &key_len, &num_idx, duplicate, (HashPosition *) 0); zend_hash_get_current_data_ex(function->params, (void **) &value, (HashPosition *) 0); /* key is always maintained internally */ solr_string_appends(buffer, key, key_len-1); solr_string_appendc(buffer, '='); if (strstr(value->str, " ") && !strstr(value->str,"'")) { solr_string_appendc(buffer, '\''); solr_string_append_solr_string (buffer, value); solr_string_appendc(buffer, '\''); } else { solr_string_append_solr_string (buffer, value); } solr_string_appendc(buffer, ' '); } solr_string_remove_last_char(buffer); solr_string_appendc(buffer, '}'); /* todo handle localParams argument */ } /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/solr_functions_params.c0000644000175000017500000013145012676753706017422 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* {{{ PHP_SOLR_API void solr_destroy_params(void *solr_params) */ PHP_SOLR_API void solr_destroy_params(void *solr_params) { solr_params_t *params = (solr_params_t *) solr_params; zend_hash_destroy(params->params); pefree(params->params, SOLR_PARAMS_PERSISTENT); } /* }}} */ /* {{{ PHP_SOLR_API void solr_destroy_param(solr_param_t **param) */ PHP_SOLR_API void solr_destroy_param(solr_param_t **param) { solr_param_value_t *temp_ptr = NULL; solr_param_value_t *current_ptr = (*param)->head; while(current_ptr != NULL) { temp_ptr = current_ptr->next; (*param)->value_free_func(current_ptr); current_ptr = temp_ptr; } (*param)->head = NULL; (*param)->last = NULL; pefree((*param)->param_name, SOLR_PARAMS_PERSISTENT); (*param)->param_name = NULL; pefree((*param), SOLR_PARAMS_PERSISTENT); (*param) = NULL; } /* }}} */ /* {{{ PHP_SOLR_API int solr_params_delete_param_value(solr_param_t *param, const solr_param_value_t *target_value TSRMLS_DC) */ PHP_SOLR_API int solr_params_delete_param_value(solr_param_t *param, const solr_param_value_t *target_value TSRMLS_DC) { solr_param_value_t *curr_value = param->head; int match_found = 0; if (!target_value) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Invalid pointer. Submitted target cannot be used for the delete search\n"); return FAILURE; } while(!match_found && curr_value != NULL) { match_found = param->value_equal_func(curr_value, target_value); /* If the target was found */ if (match_found) { /* If the target is not the head */ if (curr_value->prev) { curr_value->prev->next = curr_value->next; } else { param->head = curr_value->next; } /* If the target is not the tail */ if (curr_value->next) { curr_value->next->prev = curr_value->prev; } else { param->last = curr_value->prev; } /* Destroy target value */ param->value_free_func(curr_value); goto dpv_end; } curr_value = curr_value->next; } dpv_end : if (!match_found) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Target parameter value could not be found in '%s'. No value was deleted ", param->param_name); return FAILURE; } param->count--; /* Reduce the value count by one */ return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API int solr_params_insert_param_value(solr_param_t *param, solr_param_value_t *param_value) */ PHP_SOLR_API int solr_params_insert_param_value(solr_param_t *param, solr_param_value_t *param_value) { if (!param_value) { return FAILURE; } param_value->next = param_value->prev = NULL; if (!param->allow_multiple) { param->value_free_func(param->head); param->head = param_value; param->last = param_value; param->count = 1U; return SUCCESS; } if (param->head == NULL) { param->head = param_value; param->last = param_value; } else { param_value->prev = param->last; param->last->next = param_value; param->last = param_value; } param->count++; return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API solr_param_t *solr_create_new_param(const solr_char_t *param_name, size_t param_name_len, solr_param_type_t param_type, solr_bool allow_multiple, solr_param_value_equal_func_t value_equal_func, solr_param_fetch_func_t param_fetch_func, solr_param_value_free_func_t value_free_func, solr_char_t delimiter, solr_char_t arg_separator TSRMLS_DC) */ PHP_SOLR_API solr_param_t *solr_create_new_param(const solr_char_t *param_name, size_t param_name_len, solr_param_type_t param_type, solr_bool allow_multiple, solr_param_value_equal_func_t value_equal_func, solr_param_fetch_func_t param_fetch_func, solr_param_value_free_func_t value_free_func, solr_char_t delimiter, solr_char_t arg_separator TSRMLS_DC) { solr_param_t *query_param = (solr_param_t *) pemalloc(sizeof(solr_param_t), SOLR_PARAMS_PERSISTENT); /* Always initialize linked list containers to NULL. */ /* Member pointers may contain unallocated addresses */ /* This notice applies to all solr_param_t member pointers here */ memset(query_param, 0, sizeof(solr_param_t)); query_param->type = param_type; query_param->count = 0L; query_param->param_name = solr_strndup(param_name, param_name_len); query_param->param_name_length = param_name_len; query_param->allow_multiple = allow_multiple; query_param->head = query_param->last = NULL; query_param->value_equal_func = value_equal_func; query_param->fetch_func = param_fetch_func; query_param->value_free_func = value_free_func; query_param->delimiter = delimiter; query_param->arg_separator = arg_separator; return query_param; } /* }}} */ /* {{{ PHP_SOLR_API int solr_add_or_set_normal_param(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length, zend_bool allow_multiple TSRMLS_DC) parameter value addition functions */ PHP_SOLR_API int solr_add_or_set_normal_param(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length, zend_bool allow_multiple TSRMLS_DC) { solr_params_t *solr_params = NULL; solr_param_t **param_ptr = NULL; HashTable *params = NULL; solr_param_type_t param_type = SOLR_PARAM_TYPE_NORMAL; solr_param_t *param = NULL; solr_param_value_t *parameter_value = NULL; if (!pname_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter name"); /* php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameter name"); */ return FAILURE; } if (!pvalue_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter value"); /* php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameter value"); */ return FAILURE; } if (solr_fetch_params_entry(objptr, &solr_params TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "SolrParams instance could not be retrieved from HashTable"); return FAILURE; } params = solr_params->params; if (zend_hash_find(params, (char *) pname, pname_length, (void **) ¶m_ptr) == SUCCESS) { parameter_value = (solr_param_value_t *) pemalloc(sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); memset(parameter_value, 0, sizeof(solr_param_value_t)); solr_string_appends(&(parameter_value->contents.normal), pvalue, pvalue_length); solr_params_insert_param_value((*param_ptr), parameter_value); return SUCCESS; } param = solr_create_new_param(pname, pname_length, param_type, allow_multiple, solr_normal_param_value_equal, (solr_param_fetch_func_t) solr_normal_param_value_fetch, solr_normal_param_value_free, '&', 0 TSRMLS_CC); parameter_value = (solr_param_value_t *) pemalloc(sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); memset(parameter_value, 0, sizeof(solr_param_value_t)); solr_string_appends(&(parameter_value->contents.normal), pvalue, pvalue_length); solr_params_insert_param_value(param, parameter_value); if (zend_hash_add(params, pname, pname_length, (void *) ¶m, sizeof(solr_param_t *), (void **) NULL) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error from %s %s=%s", __func__, (char *) pname, pvalue); return FAILURE; } return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API int solr_add_simple_list_param(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC) */ PHP_SOLR_API int solr_add_simple_list_param(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC) { zend_bool allow_multiple = 1; /* This value type by definition allows multiple. add parameters can be added more than once */ solr_params_t *solr_params = NULL; solr_param_t **param_ptr = NULL; HashTable *params = NULL; solr_param_type_t param_type = SOLR_PARAM_TYPE_SIMPLE_LIST; solr_param_t *param = NULL; solr_param_value_t *parameter_value = NULL; if (!pname_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter name"); return FAILURE; } if (!pvalue_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter value"); return FAILURE; } if (solr_fetch_params_entry(objptr, &solr_params TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "SolrParams instance could not be retrieved from HashTable"); return FAILURE; } params = solr_params->params; if (zend_hash_find(params, pname, pname_length, (void **) ¶m_ptr) == SUCCESS) { parameter_value = (solr_param_value_t *) pemalloc(sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); memset(parameter_value, 0, sizeof(solr_param_value_t)); solr_string_appends(&(parameter_value->contents.simple_list), pvalue, pvalue_length); solr_params_insert_param_value((*param_ptr), parameter_value); return SUCCESS; } param = solr_create_new_param(pname, pname_length, param_type, allow_multiple, solr_simple_list_param_value_equal, (solr_param_fetch_func_t) solr_simple_list_param_value_fetch, solr_simple_list_param_value_free, ',', 0 TSRMLS_CC); parameter_value = (solr_param_value_t *) pemalloc(sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); memset(parameter_value, 0, sizeof(solr_param_value_t)); solr_string_appends(&(parameter_value->contents.simple_list), pvalue, pvalue_length); solr_params_insert_param_value(param, parameter_value); if (zend_hash_add(params, pname, pname_length, (void *) ¶m, sizeof(solr_param_t *), (void **) NULL) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error from %s %s=%s", __func__, (char *) pname, pvalue); return FAILURE; } return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API int solr_add_simple_list_param(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC) */ PHP_SOLR_API int solr_add_simple_list_param_ex(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length,solr_char_t *separator TSRMLS_DC) { zend_bool allow_multiple = 1; /* This value type by definition allows multiple. add parameters can be added more than once */ solr_params_t *solr_params = NULL; solr_param_t **param_ptr = NULL; HashTable *params = NULL; solr_param_type_t param_type = SOLR_PARAM_TYPE_SIMPLE_LIST; solr_param_t *param = NULL; solr_param_value_t *parameter_value = NULL; if (!pname_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter name"); return FAILURE; } if (!pvalue_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter value"); return FAILURE; } if (solr_fetch_params_entry(objptr, &solr_params TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "SolrParams instance could not be retrieved from HashTable"); return FAILURE; } params = solr_params->params; if (zend_hash_find(params, pname, pname_length, (void **) ¶m_ptr) == SUCCESS) { parameter_value = (solr_param_value_t *) pemalloc(sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); memset(parameter_value, 0, sizeof(solr_param_value_t)); solr_string_appends(&(parameter_value->contents.simple_list), pvalue, pvalue_length); solr_params_insert_param_value((*param_ptr), parameter_value); return SUCCESS; } param = solr_create_new_param(pname, pname_length, param_type, allow_multiple, solr_simple_list_param_value_equal, (solr_param_fetch_func_t) solr_simple_list_param_value_fetch, solr_simple_list_param_value_free, *separator, 0 TSRMLS_CC); parameter_value = (solr_param_value_t *) pemalloc(sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); memset(parameter_value, 0, sizeof(solr_param_value_t)); solr_string_appends(&(parameter_value->contents.simple_list), pvalue, pvalue_length); solr_params_insert_param_value(param, parameter_value); if (zend_hash_add(params, pname, pname_length, (void *) ¶m, sizeof(solr_param_t *), (void **) NULL) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error from %s %s=%s", __func__, (char *) pname, pvalue); return FAILURE; } return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API int solr_add_arg_list_param(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length, solr_char_t *avalue, int avalue_length, solr_char_t delimiter, solr_char_t arg_separator TSRMLS_DC) */ PHP_SOLR_API int solr_add_arg_list_param(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length, solr_char_t *avalue, int avalue_length, solr_char_t delimiter, solr_char_t arg_separator TSRMLS_DC) { zend_bool allow_multiple = 1; /* This value type by definition allows multiple */ solr_params_t *solr_params = NULL; solr_param_type_t param_type = SOLR_PARAM_TYPE_ARG_LIST; solr_param_t *param = NULL; solr_param_value_t *parameter_value = NULL; HashTable *params = NULL; solr_param_t **param_ptr = NULL; /* holds a pointer to the param structure e.g. sort */ if (!pname_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter name"); return FAILURE; } if (!pvalue_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter value"); return FAILURE; } /* if (!avalue_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid argument value"); return FAILURE; } */ if (solr_fetch_params_entry(objptr, &solr_params TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "SolrParams instance could not be retrieved from HashTable"); return FAILURE; } params = solr_params->params; /* if parameter exists add the new value argument(param_value) */ if (zend_hash_find(params, pname, pname_length, (void **) ¶m_ptr) == SUCCESS) { parameter_value = create_parameter_value_arg_list(pvalue, pvalue_length, avalue, avalue_length, "", 0 TSRMLS_CC); solr_params_insert_param_value((*param_ptr), parameter_value); return SUCCESS; } param = solr_create_new_param(pname, pname_length, param_type, allow_multiple, solr_arg_list_param_value_equal, (solr_param_fetch_func_t) solr_arg_list_param_value_fetch, solr_arg_list_param_value_free, delimiter, arg_separator TSRMLS_CC); parameter_value = create_parameter_value_arg_list(pvalue, pvalue_length, avalue, avalue_length, (solr_char_t*)"", 0 TSRMLS_CC); solr_params_insert_param_value(param, parameter_value); if (zend_hash_add(params, pname, pname_length, (void *) ¶m, sizeof(solr_param_t *), (void **) NULL) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error from %s %s=%s", __func__, (char *) pname, pvalue); return FAILURE; } return SUCCESS; } /* }}} */ PHP_SOLR_API solr_param_value_t* create_parameter_value_arg_list(solr_char_t *pvalue, int pvalue_length, solr_char_t *avalue, int avalue_length, solr_char_t *delimiter_override, solr_bool delimiter_overriden TSRMLS_DC) { solr_param_value_t *parameter_value = NULL; parameter_value = (solr_param_value_t *) pemalloc(sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); memset(parameter_value, 0, sizeof(solr_param_value_t)); solr_string_appends(&(parameter_value->contents.arg_list.value), pvalue, pvalue_length); solr_string_appends(&(parameter_value->contents.arg_list.arg), avalue, avalue_length); if(delimiter_overriden){ parameter_value->contents.arg_list.delimiter_override = solr_strndup(delimiter_override, sizeof(delimiter_override)); parameter_value->contents.arg_list.delimiter_overriden = delimiter_overriden; } return parameter_value; } PHP_SOLR_API int solr_add_arg_list_param_ex(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length, solr_char_t *avalue, int avalue_length, solr_char_t delimiter, solr_char_t arg_separator, solr_char_t delimiter_override TSRMLS_DC) { zend_bool allow_multiple = 1; /* This value type by definition allows multiple */ solr_params_t *solr_params = NULL; solr_param_type_t param_type = SOLR_PARAM_TYPE_ARG_LIST; solr_param_t *param = NULL; solr_param_value_t *parameter_value = NULL; HashTable *params = NULL; solr_param_t **param_ptr = NULL; /* holds a pointer to the param structure e.g. sort */ if (!pname_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter name"); return FAILURE; } if (!pvalue_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter value"); return FAILURE; } /* * commented for the favor of having empty value if (!avalue_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid argument value"); return FAILURE; } */ if (solr_fetch_params_entry(objptr, &solr_params TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "SolrParams instance could not be retrieved from HashTable"); return FAILURE; } params = solr_params->params; /* if parameter exists add the new value argument(param_value) */ if (zend_hash_find(params, pname, pname_length, (void **) ¶m_ptr) == SUCCESS) { parameter_value = create_parameter_value_arg_list(pvalue, pvalue_length, avalue, avalue_length, &delimiter_override, 1 TSRMLS_CC); solr_params_insert_param_value((*param_ptr), parameter_value); return SUCCESS; } param = solr_create_new_param(pname, pname_length, param_type, allow_multiple, solr_arg_list_param_value_equal, (solr_param_fetch_func_t) solr_arg_list_param_value_fetch, solr_arg_list_param_value_free, delimiter, arg_separator TSRMLS_CC); parameter_value = create_parameter_value_arg_list(pvalue, pvalue_length, avalue, avalue_length, &delimiter_override, 1 TSRMLS_CC); solr_params_insert_param_value(param, parameter_value); if (zend_hash_add(params, pname, pname_length, (void *) ¶m, sizeof(solr_param_t *), (void **) NULL) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error from %s %s=%s", __func__, (char *) pname, pvalue); return FAILURE; } return SUCCESS; } /* {{{ Parameter value EQUALITY FUNCTIONS */ /* {{{ PHP_SOLR_API int solr_normal_param_value_equal(const solr_param_value_t *a, const solr_param_value_t *b) */ PHP_SOLR_API int solr_normal_param_value_equal(const solr_param_value_t *a, const solr_param_value_t *b) { return solr_string_equal(&(a->contents.normal), &(b->contents.normal)); } /* }}} */ /* {{{ PHP_SOLR_API int solr_simple_list_param_value_equal(const solr_param_value_t *a, const solr_param_value_t *b) */ PHP_SOLR_API int solr_simple_list_param_value_equal(const solr_param_value_t *a, const solr_param_value_t *b) { return solr_string_equal(&(a->contents.simple_list), &(b->contents.simple_list)); } /* }}} */ /* {{{ PHP_SOLR_API int solr_arg_list_param_value_equal(const solr_param_value_t *a, const solr_param_value_t *b) */ PHP_SOLR_API int solr_arg_list_param_value_equal(const solr_param_value_t *a, const solr_param_value_t *b) { return solr_string_equal(&(a->contents.arg_list.value), &(b->contents.arg_list.value)); } /* }}} */ /* }}} */ /* {{{ Parameter values retrieval functions */ /* {{{ PHP_SOLR_API void solr_normal_param_value_fetch(solr_param_t *solr_param, solr_string_t *buffer) */ PHP_SOLR_API void solr_normal_param_value_fetch(solr_param_t *solr_param, solr_string_t *buffer) { solr_param_value_t *current_ptr = solr_param->head; solr_char_t glue = '&'; if (!solr_param->allow_multiple) { auto int new_pv_length = 0; solr_char_t *url_encoded_param_value = (solr_char_t *) php_raw_url_encode((char *) current_ptr->contents.normal.str, current_ptr->contents.normal.len, &new_pv_length); solr_string_appends(buffer, solr_param->param_name, solr_param->param_name_length); solr_string_appendc(buffer, '='); solr_string_appends(buffer, url_encoded_param_value, new_pv_length); efree(url_encoded_param_value); } else { ulong n_loops = solr_param->count - 1; auto int new_pv_length = 0; solr_char_t *url_encoded_param_value = NULL; while(n_loops) { new_pv_length = 0; url_encoded_param_value = php_raw_url_encode(current_ptr->contents.normal.str, current_ptr->contents.normal.len, &new_pv_length); solr_string_appends(buffer, solr_param->param_name, solr_param->param_name_length); solr_string_appendc(buffer, '='); solr_string_appends(buffer, url_encoded_param_value, new_pv_length); efree(url_encoded_param_value); url_encoded_param_value = NULL; solr_string_appendc(buffer, glue); n_loops--; current_ptr = current_ptr->next; } url_encoded_param_value = php_raw_url_encode(current_ptr->contents.normal.str, current_ptr->contents.normal.len, &new_pv_length); solr_string_appends(buffer, solr_param->param_name, solr_param->param_name_length); solr_string_appendc(buffer, '='); solr_string_appends(buffer, url_encoded_param_value, new_pv_length); efree(url_encoded_param_value); url_encoded_param_value = NULL; } } /* }}} */ /* {{{ PHP_SOLR_API void solr_simple_list_param_value_fetch(solr_param_t *solr_param, solr_string_t *buffer) */ PHP_SOLR_API void solr_simple_list_param_value_fetch(solr_param_t *solr_param, solr_string_t *buffer) { solr_param_value_t *current_ptr = solr_param->head; solr_char_t list_delimiter = ','; /* Comma 0x2C */ ulong n_loops = solr_param->count - 1; auto solr_string_t tmp_buffer; auto int new_pv_length = 0; solr_char_t *url_encoded_list = NULL; solr_string_appends(buffer, solr_param->param_name, solr_param->param_name_length); solr_string_appendc(buffer, '='); memset(&tmp_buffer, 0, sizeof(solr_string_t)); while(n_loops) { solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.simple_list)); solr_string_appendc(&tmp_buffer, list_delimiter); n_loops--; current_ptr = current_ptr->next; } solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.simple_list)); url_encoded_list = php_raw_url_encode(tmp_buffer.str, tmp_buffer.len, &new_pv_length); solr_string_appends(buffer, url_encoded_list, new_pv_length); efree(url_encoded_list); url_encoded_list = NULL; solr_string_free(&tmp_buffer); } /* }}} */ /* {{{ PHP_SOLR_API void solr_arg_list_param_value_fetch(solr_param_t *solr_param, solr_string_t *buffer) */ PHP_SOLR_API void solr_arg_list_param_value_fetch(solr_param_t *solr_param, solr_string_t *buffer) { solr_param_value_t *current_ptr = solr_param->head; solr_char_t list_delimiter = solr_param->delimiter; solr_char_t separator = solr_param->arg_separator; ulong n_loops = solr_param->count - 1; solr_string_t tmp_buffer; int new_pv_length = 0; solr_char_t *url_encoded_list = NULL; solr_string_appends(buffer, solr_param->param_name, solr_param->param_name_length); solr_string_appendc(buffer, '='); memset(&tmp_buffer, 0, sizeof(solr_string_t)); while(n_loops) { solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.arg_list.value)); solr_string_appendc(&tmp_buffer, separator); solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.arg_list.arg)); solr_string_appendc(&tmp_buffer, list_delimiter); n_loops--; current_ptr = current_ptr->next; } solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.arg_list.value)); solr_string_appendc(&tmp_buffer, separator); solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.arg_list.arg)); url_encoded_list = php_raw_url_encode(tmp_buffer.str, tmp_buffer.len, &new_pv_length); solr_string_appends(buffer, url_encoded_list, new_pv_length); efree(url_encoded_list); url_encoded_list = NULL; solr_string_free(&tmp_buffer); } /* }}} */ /* }}} */ /* {{{ Parameter retrieval functions. Only used for display. */ /* {{{ PHP_SOLR_API void solr_normal_param_value_display_string(solr_param_t *solr_param, zval *param_value) */ PHP_SOLR_API void solr_normal_param_value_display_string(solr_param_t *solr_param, zval *param_value) { solr_param_value_t *current_ptr = solr_param->head; ZVAL_STRINGL(param_value, current_ptr->contents.normal.str, current_ptr->contents.normal.len, 1); } /* }}} */ /* {{{ PHP_SOLR_API void solr_normal_param_value_display_integer(solr_param_t *solr_param, zval *param_value) */ PHP_SOLR_API void solr_normal_param_value_display_integer(solr_param_t *solr_param, zval *param_value) { solr_param_value_t *current_ptr = solr_param->head; long int return_value = atol(current_ptr->contents.normal.str); ZVAL_LONG(param_value, return_value); } /* }}} */ /* {{{ PHP_SOLR_API void solr_normal_param_value_display_double(solr_param_t *solr_param, zval *param_value) */ PHP_SOLR_API void solr_normal_param_value_display_double(solr_param_t *solr_param, zval *param_value) { solr_param_value_t *current_ptr = solr_param->head; double return_value = atof(current_ptr->contents.normal.str); ZVAL_DOUBLE(param_value, return_value); } /* }}} */ /* Checks if current_ptr->contents.normal.str matches str_const */ #define solr_npvdb_strcmp(str_const) (0 == strcmp(str_const, current_ptr->contents.normal.str)) /* {{{ PHP_SOLR_API void solr_normal_param_value_display_boolean(solr_param_t *solr_param, zval *param_value) */ PHP_SOLR_API void solr_normal_param_value_display_boolean(solr_param_t *solr_param, zval *param_value) { solr_param_value_t *current_ptr = solr_param->head; zend_bool return_value = (zend_bool) (solr_npvdb_strcmp("true") || solr_npvdb_strcmp("on") ); ZVAL_BOOL(param_value, return_value); } /* }}} */ /* {{{ PHP_SOLR_API void solr_normal_param_value_display_sort_type(solr_param_t *solr_param, zval *param_value) */ PHP_SOLR_API void solr_normal_param_value_display_sort_type(solr_param_t *solr_param, zval *param_value) { solr_param_value_t *current_ptr = solr_param->head; long int return_value = (long int) (solr_npvdb_strcmp("count")); ZVAL_LONG(param_value, return_value); } /* }}} */ /* {{{ PHP_SOLR_API void solr_normal_param_value_display(solr_param_t *solr_param, zval *param_value_array) */ PHP_SOLR_API void solr_normal_param_value_display(solr_param_t *solr_param, zval *param_value_array) { solr_param_value_t *current_ptr = solr_param->head; register int duplicate = 1; while (current_ptr != NULL) { add_next_index_stringl(param_value_array, current_ptr->contents.normal.str, current_ptr->contents.normal.len, duplicate); current_ptr = current_ptr->next; } } /* }}} */ /* {{{ PHP_SOLR_API void solr_simple_list_param_value_display(solr_param_t *solr_param, zval *param_value_array) */ PHP_SOLR_API void solr_simple_list_param_value_display(solr_param_t *solr_param, zval *param_value_array) { solr_param_value_t *current_ptr = solr_param->head; register int duplicate = 1; while (current_ptr != NULL) { add_next_index_stringl(param_value_array, current_ptr->contents.simple_list.str, current_ptr->contents.simple_list.len, duplicate); current_ptr = current_ptr->next; } } /* }}} */ /* {{{ PHP_SOLR_API void solr_arg_list_param_value_display(solr_param_t *solr_param, zval *param_value_array) */ PHP_SOLR_API void solr_arg_list_param_value_display(solr_param_t *solr_param, zval *param_value_array) { solr_param_value_t *current_ptr = solr_param->head; register int duplicate = 1; while (current_ptr != NULL) { solr_string_t tmp_buffer; memset(&tmp_buffer, 0, sizeof(solr_string_t)); solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.arg_list.value)); solr_string_appendc(&tmp_buffer, solr_param->arg_separator); solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.arg_list.arg)); add_next_index_stringl(param_value_array, tmp_buffer.str, tmp_buffer.len, duplicate); solr_string_free(&tmp_buffer); current_ptr = current_ptr->next; } } /* }}} */ /* }}} */ /* {{{ Parameter retrieval functions. Only used for toString() */ /* {{{ PHP_SOLR_API void solr_normal_param_value_tostring(solr_param_t *solr_param, solr_string_t *buffer, zend_bool url_encode) */ PHP_SOLR_API void solr_normal_param_value_tostring(solr_param_t *solr_param, solr_string_t *buffer, zend_bool url_encode) { solr_param_value_t *current_ptr = solr_param->head; solr_char_t glue = '&'; if (!solr_param->allow_multiple) { auto int new_pv_length = 0; solr_char_t *url_encoded_param_value = NULL; if (url_encode) { url_encoded_param_value = (solr_char_t *) php_raw_url_encode((char *) current_ptr->contents.normal.str, current_ptr->contents.normal.len, &new_pv_length); } else { new_pv_length = current_ptr->contents.normal.len; url_encoded_param_value = solr_strndup(current_ptr->contents.normal.str, current_ptr->contents.normal.len); } solr_string_appends(buffer, solr_param->param_name, solr_param->param_name_length); solr_string_appendc(buffer, '='); solr_string_appends(buffer, url_encoded_param_value, new_pv_length); efree(url_encoded_param_value); } else { ulong n_loops = solr_param->count - 1; auto int new_pv_length = 0; solr_char_t *url_encoded_param_value = NULL; while(n_loops) { new_pv_length = 0; if (url_encode) { url_encoded_param_value = php_raw_url_encode(current_ptr->contents.normal.str, current_ptr->contents.normal.len, &new_pv_length); } else { new_pv_length = current_ptr->contents.normal.len; url_encoded_param_value = solr_strndup(current_ptr->contents.normal.str, current_ptr->contents.normal.len); } solr_string_appends(buffer, solr_param->param_name, solr_param->param_name_length); solr_string_appendc(buffer, '='); solr_string_appends(buffer, url_encoded_param_value, new_pv_length); efree(url_encoded_param_value); url_encoded_param_value = NULL; solr_string_appendc(buffer, glue); n_loops--; current_ptr = current_ptr->next; } if (url_encode) { url_encoded_param_value = php_raw_url_encode(current_ptr->contents.normal.str, current_ptr->contents.normal.len, &new_pv_length); } else { new_pv_length = current_ptr->contents.normal.len; url_encoded_param_value = solr_strndup(current_ptr->contents.normal.str, current_ptr->contents.normal.len); } solr_string_appends(buffer, solr_param->param_name, solr_param->param_name_length); solr_string_appendc(buffer, '='); solr_string_appends(buffer, url_encoded_param_value, new_pv_length); efree(url_encoded_param_value); url_encoded_param_value = NULL; } } /* }}} */ /* {{{ PHP_SOLR_API void solr_simple_list_param_value_tostring(solr_param_t *solr_param, solr_string_t *buffer, zend_bool url_encode) */ PHP_SOLR_API void solr_simple_list_param_value_tostring(solr_param_t *solr_param, solr_string_t *buffer, zend_bool url_encode) { solr_param_value_t *current_ptr = solr_param->head; solr_char_t list_delimiter = solr_param->delimiter; /* Comma 0x2C */ ulong n_loops = solr_param->count - 1; auto solr_string_t tmp_buffer; auto int new_pv_length = 0; solr_char_t *url_encoded_list = NULL; solr_string_appends(buffer, solr_param->param_name, solr_param->param_name_length); solr_string_appendc(buffer, '='); memset(&tmp_buffer, 0, sizeof(solr_string_t)); while(n_loops) { solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.simple_list)); solr_string_appendc(&tmp_buffer, list_delimiter); n_loops--; current_ptr = current_ptr->next; } solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.simple_list)); if (url_encode) { url_encoded_list = php_raw_url_encode(tmp_buffer.str, tmp_buffer.len, &new_pv_length); } else { new_pv_length = tmp_buffer.len; url_encoded_list = solr_strndup(tmp_buffer.str, tmp_buffer.len); } solr_string_appends(buffer, url_encoded_list, new_pv_length); efree(url_encoded_list); url_encoded_list = NULL; solr_string_free(&tmp_buffer); } /* }}} */ /* {{{ PHP_SOLR_API void solr_arg_list_param_value_tostring(solr_param_t *solr_param, solr_string_t *buffer, zend_bool url_encode) */ PHP_SOLR_API void solr_arg_list_param_value_tostring(solr_param_t *solr_param, solr_string_t *buffer, zend_bool url_encode) { solr_param_value_t *current_ptr = solr_param->head; solr_char_t list_delimiter = solr_param->delimiter; solr_char_t separator = solr_param->arg_separator; ulong n_loops = solr_param->count - 1; solr_string_t tmp_buffer; int new_pv_length = 0; solr_char_t *url_encoded_list = NULL; solr_string_appends(buffer, solr_param->param_name, solr_param->param_name_length); solr_string_appendc(buffer, '='); memset(&tmp_buffer, 0, sizeof(solr_string_t)); while(n_loops) { solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.arg_list.value)); if(current_ptr->contents.arg_list.delimiter_overriden) { if(strlen(current_ptr->contents.arg_list.delimiter_override) > 0) { solr_string_appendc(&tmp_buffer, (*current_ptr->contents.arg_list.delimiter_override)); } }else{ solr_string_appendc(&tmp_buffer, separator); } solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.arg_list.arg)); solr_string_appendc(&tmp_buffer, list_delimiter); n_loops--; current_ptr = current_ptr->next; } /* process last parameter value */ solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.arg_list.value)); /* check for separator override */ if(current_ptr->contents.arg_list.delimiter_overriden) { if(strlen(current_ptr->contents.arg_list.delimiter_override) > 0) { solr_string_appendc(&tmp_buffer, (*current_ptr->contents.arg_list.delimiter_override)); } }else{ solr_string_appendc(&tmp_buffer, separator); } solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.arg_list.arg)); if (url_encode) { url_encoded_list = php_raw_url_encode(tmp_buffer.str, tmp_buffer.len, &new_pv_length); } else { new_pv_length = tmp_buffer.len; url_encoded_list = solr_strndup(tmp_buffer.str, tmp_buffer.len); } solr_string_appends(buffer, url_encoded_list, new_pv_length); efree(url_encoded_list); url_encoded_list = NULL; solr_string_free(&tmp_buffer); } /* }}} */ /* }}} */ /* {{{ Memory deallocation functions for parameter values */ /* {{{ PHP_SOLR_API void solr_normal_param_value_free(solr_param_value_t *param_value) */ PHP_SOLR_API void solr_normal_param_value_free(solr_param_value_t *param_value) { if (param_value) { solr_string_free(&(param_value->contents.normal)); pefree(param_value, SOLR_PARAMS_PERSISTENT); param_value = NULL; } } /* }}} */ /* {{{ PHP_SOLR_API void solr_simple_list_param_value_free(solr_param_value_t *param_value) */ PHP_SOLR_API void solr_simple_list_param_value_free(solr_param_value_t *param_value) { if (param_value) { solr_string_free(&(param_value->contents.simple_list)); pefree(param_value, SOLR_PARAMS_PERSISTENT); param_value = NULL; } } /* }}} */ /* {{{ PHP_SOLR_API void solr_arg_list_param_value_free(solr_param_value_t *param_value) */ PHP_SOLR_API void solr_arg_list_param_value_free(solr_param_value_t *param_value) { if (param_value) { solr_string_free(&(param_value->contents.arg_list.value)); solr_string_free(&(param_value->contents.arg_list.arg)); if(param_value->contents.arg_list.delimiter_override != NULL){ efree(param_value->contents.arg_list.delimiter_override); } pefree(param_value, SOLR_PARAMS_PERSISTENT); param_value = NULL; } } /* }}} */ /* {{{ PHP_SOLR_API void solr_set_return_solr_params_object(zval **return_value_ptr, zval *current_objptr TSRMLS_DC) */ PHP_SOLR_API void solr_set_return_solr_params_object(zval **return_value_ptr, zval *current_objptr TSRMLS_DC) { zval_ptr_dtor(return_value_ptr); Z_SET_ISREF_P(current_objptr); Z_ADDREF_P(current_objptr); *return_value_ptr = current_objptr; } /* }}} */ /* {{{ PHP_SOLR_API int solr_delete_solr_parameter(zval *objptr, solr_char_t *name, int name_length TSRMLS_DC) */ PHP_SOLR_API int solr_delete_solr_parameter(zval *objptr, solr_char_t *name, int name_length TSRMLS_DC) { solr_params_t *solr_params = NULL; HashTable *params_ht = NULL; if (solr_fetch_params_entry(objptr, &solr_params TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "SolrParams instance could not be retrieved from HashTable"); return FAILURE; } params_ht = solr_params->params; if (zend_hash_del(params_ht, name, name_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "parameter '%s' was not set. Attempting to remove an undefined parameter.", name); return FAILURE; } return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API int solr_delete_normal_param_value(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC) */ PHP_SOLR_API int solr_delete_normal_param_value(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC) { solr_params_t *solr_params = NULL; HashTable *params_ht = NULL; solr_param_t **param_ptr = NULL; solr_param_value_t *target_value = NULL; if (!pname_length) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameter name"); return FAILURE; } if (!pvalue_length) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameter value"); return FAILURE; } if (solr_fetch_params_entry(objptr, &solr_params TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "SolrParams instance could not be retrieved from HashTable"); return FAILURE; } params_ht = solr_params->params; if (zend_hash_find(params_ht, pname, pname_length, (void **) ¶m_ptr) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "parameter could not be retrieved from HashTable"); return FAILURE; } target_value = (solr_param_value_t *) pecalloc(1, sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); solr_string_appends(&(target_value->contents.normal), pvalue, pvalue_length); solr_params_delete_param_value((*param_ptr), target_value TSRMLS_CC); /* We are done with target_value. */ (*param_ptr)->value_free_func(target_value); if ((*param_ptr)->count < 1U) { zend_hash_del(params_ht, pname, pname_length); #if SOLR_DEBUG php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Deleted last value from parameter. Removing parameter '%s' from object instance.", pname); #endif } return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API int solr_delete_simple_list_param_value(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC) */ PHP_SOLR_API int solr_delete_simple_list_param_value(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC) { solr_params_t *solr_params = NULL; solr_param_t **param_ptr = NULL; HashTable *params_ht = NULL; solr_param_value_t *target_value = NULL; if (!pname_length) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameter name"); return FAILURE; } if (!pvalue_length) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameter value"); return FAILURE; } if (solr_fetch_params_entry(objptr, &solr_params TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "SolrParams instance could not be retrieved from HashTable"); return FAILURE; } params_ht = solr_params->params; if (zend_hash_find(params_ht, pname, pname_length, (void **) ¶m_ptr) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "parameter could not be retrieved from HashTable"); return FAILURE; } target_value = (solr_param_value_t *) pecalloc(1, sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); solr_string_appends(&(target_value->contents.simple_list), pvalue, pvalue_length); solr_params_delete_param_value((*param_ptr), target_value TSRMLS_CC); /* We are done with target_value. */ (*param_ptr)->value_free_func(target_value); if ((*param_ptr)->count < 1U) { zend_hash_del(params_ht, pname, pname_length); #if SOLR_DEBUG php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Deleted last value from parameter. Removing parameter '%s' from object instance.", pname); #endif } return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API int solr_delete_arg_list_param_value(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC) */ PHP_SOLR_API int solr_delete_arg_list_param_value(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC) { solr_params_t *solr_params = NULL; HashTable *params_ht = NULL; solr_param_t **param_ptr = NULL; solr_param_value_t *target_value = NULL; if (!pname_length) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameter name"); return FAILURE; } if (!pvalue_length) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameter value"); return FAILURE; } if (solr_fetch_params_entry(objptr, &solr_params TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "SolrParams instance could not be retrieved from HashTable"); return FAILURE; } params_ht = solr_params->params; if (zend_hash_find(params_ht, pname, pname_length, (void **) ¶m_ptr) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "parameter could not be retrieved from HashTable"); return FAILURE; } target_value = (solr_param_value_t *) pecalloc(1, sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); solr_string_appends(&(target_value->contents.arg_list.value), pvalue, pvalue_length); solr_params_delete_param_value((*param_ptr), target_value TSRMLS_CC); /* We are done with target_value. */ (*param_ptr)->value_free_func(target_value); if ((*param_ptr)->count < 1U) { zend_hash_del(params_ht, pname, pname_length); #if SOLR_DEBUG php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Deleted last value from parameter. Removing parameter '%s' from object instance.", pname); #endif } return SUCCESS; } /* }}} */ /* }}} */ /* {{{ PHP_SOLR_API int solr_param_find(zval *objptr, solr_char_t *pname, int pname_length, solr_param_t **solr_param TSRMLS_DC) */ PHP_SOLR_API int solr_param_find(zval *objptr, solr_char_t *pname, int pname_length, solr_param_t **solr_param TSRMLS_DC) { solr_params_t *solr_params = NULL; HashTable *params_ht = NULL; solr_param_t **solr_param_tmp = NULL; if (!pname_length) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameter name"); return FAILURE; } if (solr_fetch_params_entry(objptr, &solr_params TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "SolrParams instance could not be retrieved from HashTable"); return FAILURE; } params_ht = solr_params->params; if (zend_hash_find(params_ht, pname, pname_length, (void **) &solr_param_tmp) == FAILURE) { return FAILURE; } (*solr_param) = (*solr_param_tmp); return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API int solr_init_params(solr_params_t **solr_params, long int index TSRMLS_DC) Initialize solr_params_t structure */ PHP_SOLR_API int solr_init_params(solr_params_t **solr_params, long int index TSRMLS_DC) { uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE; solr_params_t solr_params_tmp; if (zend_hash_index_update(SOLR_GLOBAL(params), index, (void *) &solr_params_tmp, sizeof(solr_params_t), (void **) solr_params) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error while registering query parameters in HashTable"); return FAILURE; } (*solr_params)->params_index = index; (*solr_params)->params_count = 0U; /* Allocated memory for the parameters HashTable using fast cache for HashTables */ ALLOC_HASHTABLE((*solr_params)->params); zend_hash_init((*solr_params)->params, nSize, NULL, (dtor_func_t) solr_destroy_param, SOLR_PARAMS_PERSISTENT); return SUCCESS; } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/solr_functions_response.c0000644000175000017500000000730012676753706017771 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Israel Ekpo | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* Used to set the properties of the SolrResponse instance after a call to the server */ /* {{{ PHP_SOLR_API void solr_set_response_object_properties(zend_class_entry *scope, zval *response_object, const solr_client_t *client, const solr_string_t *request_url, zend_bool success TSRMLS_DC) */ PHP_SOLR_API void solr_set_response_object_properties(zend_class_entry *scope, zval *response_object, const solr_client_t *client, const solr_string_t *request_url, zend_bool success TSRMLS_DC) { const solr_curl_t *handle = &(client->handle); const solr_string_t *raw_request_headers = &(handle->request_header.buffer); const solr_string_t *raw_request = &(handle->request_body_debug.buffer); const solr_string_t *raw_response_headers = &(handle->response_header.buffer); const solr_string_t *raw_response = &(handle->response_body.buffer); const solr_string_t *response_writer = &(client->options.response_writer); long int http_status = handle->response_header.response_code; zend_update_property_long(scope, response_object, "http_status", sizeof("http_status")-1, http_status TSRMLS_CC); zend_update_property_bool(scope, response_object, "success", sizeof("success")-1, success TSRMLS_CC); if (response_writer->str) { zend_update_property_stringl(scope, response_object, "response_writer", sizeof("response_writer")-1, (char *)response_writer->str, response_writer->len TSRMLS_CC); } if (request_url->str) { zend_update_property_stringl(scope, response_object, "http_request_url", sizeof("http_request_url")-1, (char *)request_url->str, request_url->len TSRMLS_CC); } if (raw_request_headers->str) { zend_update_property_stringl(scope, response_object, "http_raw_request_headers", sizeof("http_raw_request_headers")-1, (char *)raw_request_headers->str, raw_request_headers->len TSRMLS_CC); } if (raw_request->str) { zend_update_property_stringl(scope, response_object, "http_raw_request", sizeof("http_raw_request")-1, (char *)raw_request->str, raw_request->len TSRMLS_CC); } if (raw_response_headers->str) { zend_update_property_stringl(scope, response_object, "http_raw_response_headers", sizeof("http_raw_response_headers")-1, (char *)raw_response_headers->str, raw_response_headers->len TSRMLS_CC); } if (raw_response->str) { zend_update_property_stringl(scope, response_object, "http_raw_response", sizeof("http_raw_response")-1, (char *)raw_response->str, raw_response->len TSRMLS_CC); } } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/solr_string.c0000644000175000017500000001604012676753706015352 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Israel Ekpo | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* {{{ static inline void solr_string_alloc(solr_string_t *dest, size_t length, size_t *new_length SOLR_MEM_DEBUG_DC) */ static inline void solr_string_alloc(solr_string_t *dest, size_t length, size_t *new_length SOLR_MEM_DEBUG_DC) { /* If buffer is empty */ if (!dest->str) { (*new_length) = length; dest->cap = ((*new_length) < SOLR_STRING_START_SIZE) ? SOLR_STRING_START_SIZE : (length + SOLR_STRING_INCREMENT_SIZE); dest->str = (solr_char_t *) perealloc(dest->str, dest->cap * sizeof(solr_char_t), SOLR_STRING_PERSISTENT); } else { (*new_length) = dest->len + length; /* If the buffer full, get more space */ if ((*new_length) >= dest->cap) { dest->cap = (*new_length) + SOLR_STRING_INCREMENT_SIZE; dest->str = (solr_char_t *) perealloc(dest->str, dest->cap * sizeof(solr_char_t), SOLR_STRING_PERSISTENT); } } #ifdef SOLR_MEM_DEBUG php_printf("solr_string_alloc() [Re]allocated %u bytes at %p in %s(), %s Line %d \n", dest->cap, dest->str SOLR_MEM_DEBUG_CC); #endif } /* }}} */ /* {{{ PHP_SOLR_API void solr_string_appends(solr_string_t *dest, const solr_char_t *src, size_t length SOLR_MEM_DEBUG_DC) */ PHP_SOLR_API void solr_string_appends_ex(solr_string_t *dest, const solr_char_t *src, size_t length SOLR_MEM_DEBUG_DC) { auto size_t __new_length = 0U; /* (Re)allocates memory and increases the capacity if necessary */ solr_string_alloc(dest, length, &__new_length SOLR_MEM_DEBUG_CC); /* Copy the data from the source to the destination */ memcpy(dest->str + dest->len, src, length); /* Reset the length of the solr_string to the new value */ dest->len = __new_length; /* Always make it a null-terminated string */ dest->str[__new_length] = (solr_char_t) 0x00; } /* }}} */ /* {{{ PHP_SOLR_API void solr_string_appendc(solr_string_t *dest, solr_char_t ch SOLR_MEM_DEBUG_DC) */ PHP_SOLR_API void solr_string_appendc_ex(solr_string_t *dest, solr_char_t ch SOLR_MEM_DEBUG_DC) { auto size_t __new_length = 0U; /* (Re)allocates memory and increases the capacity if necessary */ solr_string_alloc(dest, 1, &__new_length SOLR_MEM_DEBUG_CC); dest->str[dest->len] = ch; /* Reset the length of the solr_string to the new value (dest->len + 1) */ dest->len = __new_length; /* Always make it a null-terminated string */ dest->str[__new_length] = (solr_char_t) 0x00; } /* }}} */ /* {{{ PHP_SOLR_API void solr_string_remove_last_char(solr_string_t *dest) */ PHP_SOLR_API void solr_string_remove_last_char(solr_string_t *dest) { if (dest->str && dest->len) { dest->str[dest->len - 1] = (solr_char_t) 0x00; dest->len--; } } /* }}} */ /* {{{ PHP_SOLR_API void solr_string_append_long(solr_string_t *dest, long int long_val) */ PHP_SOLR_API void solr_string_append_long_ex(solr_string_t *dest, long int long_val SOLR_MEM_DEBUG_DC) { auto size_t __new_length = 0U; auto char tmp_buffer[SOLR_STRING_LONG_BUFFER_SIZE]; size_t length = 0; /* Write the formated long to the buffer */ php_sprintf(tmp_buffer, "%ld", long_val); length = strlen(tmp_buffer); /* (Re)allocates memory and increases the capacity if necessary */ solr_string_alloc(dest, length, &__new_length SOLR_MEM_DEBUG_CC); /* Copy the data from the source to the destination */ memcpy(dest->str + dest->len, tmp_buffer, length); /* Reset the length of the solr_string to the new value */ dest->len = __new_length; /* Always make it a null-terminated string */ dest->str[__new_length] = (solr_char_t) 0x00; } /* }}} */ /* {{{ PHP_SOLR_API void solr_string_append_unsigned_long(solr_string_t *dest, unsigned long int long_val) */ PHP_SOLR_API void solr_string_append_unsigned_long_ex(solr_string_t *dest, unsigned long int long_val SOLR_MEM_DEBUG_DC) { auto size_t __new_length = 0U; auto char tmp_buffer[SOLR_STRING_UNSIGNED_LONG_BUFFER_SIZE]; size_t length = 0; /* Write the formated unsigned long to the buffer */ php_sprintf(tmp_buffer, "%lu", long_val); length = strlen(tmp_buffer); /* (Re)allocates memory and increases the capacity if necessary */ solr_string_alloc(dest, length, &__new_length SOLR_MEM_DEBUG_CC); /* Copy the data from the source to the destination */ memcpy(dest->str + dest->len, tmp_buffer, length); /* Reset the length of the solr_string to the new value */ dest->len = __new_length; /* Always make it a null-terminated string */ dest->str[__new_length] = (solr_char_t) 0x00; } /* }}} */ /** * Checks if both strings are equal OR have same exact content. * * Returns 1 if they are equal, 0 if they are different. */ /* {{{ PHP_SOLR_API int solr_string_equal(const solr_string_t *a, const solr_string_t *b) */ PHP_SOLR_API int solr_string_equal(const solr_string_t *a, const solr_string_t *b) { const solr_char_t *str1 = a->str; const solr_char_t *str2 = b->str; if (str1 == str2) return 1; if (str1 == NULL) return 0; if (str2 == NULL) return 0; do { if (*str1++ != *str2) return(0); } while (*str2++); return 1; } /* }}} */ /* Deallocates memory for the buffer */ /* {{{ PHP_SOLR_API void solr_string_free(solr_string_t *dest SOLR_MEM_DEBUG_DC) */ PHP_SOLR_API void solr_string_free_ex(solr_string_t *dest SOLR_MEM_DEBUG_DC) { /* Only attempt this if the buffer is still valid */ if (dest->str) { #ifdef SOLR_MEM_DEBUG php_printf("solr_string_free_ex() Releasing %u bytes at %p in %s(), %s Line %d \n", dest->cap, dest->str SOLR_MEM_DEBUG_CC); #endif pefree(dest->str, SOLR_STRING_PERSISTENT); dest->str = (solr_char_t *) 0x00; dest->cap = dest->len = 0U; } } /* }}} */ /* Update the contents of the dest solr_string */ /* {{{ PHP_SOLR_API void solr_string_set(solr_string_t *dest, const solr_char_t *value, size_t length SOLR_MEM_DEBUG_DC) */ PHP_SOLR_API void solr_string_set_ex(solr_string_t *dest, const solr_char_t *value, size_t length SOLR_MEM_DEBUG_DC) { solr_string_free(dest); solr_string_appends(dest, value, length); } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php5/php_solr_dismax_query.c0000644000175000017500000010425312676753706017431 0ustar omaromar#include "php_solr.h" /* extern function_entry; */ zend_class_entry *solr_ce_SolrDixMaxQuery; ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_zero_arg_info, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_addQueryField_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(0, field) ZEND_ARG_INFO(0, boost) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery__construct_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 0) ZEND_ARG_INFO(0, q) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery__queryAlt_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(0, q) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_remove_field_arg, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(0, field) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_addPhraseField_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 2) ZEND_ARG_INFO(0, field) ZEND_ARG_INFO(0, boost) ZEND_ARG_INFO(0, slop) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_addBoostQuery_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 2) ZEND_ARG_INFO(0, field) ZEND_ARG_INFO(0, value) ZEND_ARG_INFO(0, boost) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_setPhraseSlop_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(0, slop) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_setBoostFunction_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(0, function) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_setMinimumMatch_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_setTieBreaker_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(0, tieBreaker) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_setFields_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(0, fields) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_uf_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(0, field) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_setufs_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(0, fields) ZEND_END_ARG_INFO() static zend_function_entry solr_dismax_query_methods[] = { PHP_ME(SolrDisMaxQuery, __construct, SolrDisMaxQuery__construct_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setQueryAlt, SolrDisMaxQuery__queryAlt_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, addQueryField, SolrDisMaxQuery_addQueryField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, removeQueryField, SolrDisMaxQuery_remove_field_arg, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, addPhraseField, SolrDisMaxQuery_addPhraseField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, removePhraseField, SolrDisMaxQuery_remove_field_arg, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setPhraseFields, SolrDisMaxQuery_setFields_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setPhraseSlop, SolrDisMaxQuery_setPhraseSlop_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setQueryPhraseSlop, SolrDisMaxQuery_setPhraseSlop_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setBoostQuery, SolrDisMaxQuery__queryAlt_args , ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, addBoostQuery, SolrDisMaxQuery_addBoostQuery_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, removeBoostQuery, SolrDisMaxQuery_remove_field_arg, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setBoostFunction, SolrDisMaxQuery_setBoostFunction_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setMinimumMatch, SolrDisMaxQuery_setMinimumMatch_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setTieBreaker, SolrDisMaxQuery_setTieBreaker_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, useDisMaxQueryParser, SolrDisMaxQuery_zero_arg_info, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, useEDisMaxQueryParser, SolrDisMaxQuery_zero_arg_info, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setBigramPhraseFields, SolrDisMaxQuery_setFields_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, addBigramPhraseField, SolrDisMaxQuery_addPhraseField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, removeBigramPhraseField, SolrDisMaxQuery_remove_field_arg, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setBigramPhraseSlop, SolrDisMaxQuery_setPhraseSlop_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setTrigramPhraseFields, SolrDisMaxQuery_setFields_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, addTrigramPhraseField, SolrDisMaxQuery_addPhraseField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, removeTrigramPhraseField, SolrDisMaxQuery_remove_field_arg, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setTrigramPhraseSlop, SolrDisMaxQuery_setPhraseSlop_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, addUserField, SolrDisMaxQuery_uf_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, removeUserField, SolrDisMaxQuery_uf_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setUserFields, SolrDisMaxQuery_setufs_args, ZEND_ACC_PUBLIC) PHP_FE_END }; void init_solr_dismax_query(TSRMLS_D){ zend_class_entry ce; INIT_CLASS_ENTRY(ce, "SolrDisMaxQuery", solr_dismax_query_methods); solr_ce_SolrDixMaxQuery = zend_register_internal_class_ex( &ce, solr_ce_SolrQuery, NULL TSRMLS_CC ); } /* {{{ proto SolrQuery::__construct([string q]) Constructor for SolrDisMaxQuery */ PHP_METHOD(SolrDisMaxQuery, __construct) { zval *param_value = NULL; solr_char_t *deftype_param_name = "defType", *deftype_param_value = SOLR_DISMAX_DEFAULT_PARSER; int deftype_param_name_len = strlen("defType"), deftype_param_value_len = strlen(SOLR_DISMAX_DEFAULT_PARSER); if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", ¶m_value) == FAILURE){ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters"); RETURN_NULL(); } if(param_value == NULL){ zend_call_method_with_0_params(&getThis(), solr_ce_SolrDixMaxQuery, &solr_ce_SolrDixMaxQuery->parent->constructor, "__construct", NULL); }else{ zend_call_method_with_1_params(&getThis(), solr_ce_SolrDixMaxQuery, &solr_ce_SolrDixMaxQuery->parent->constructor, "__construct", NULL, param_value); } solr_add_or_set_normal_param( getThis(), deftype_param_name, deftype_param_name_len, deftype_param_value, deftype_param_value_len, 0 TSRMLS_CC ); } /* }}} */ /* {{{ proto SolrQuery::useDisMaxQueryParser() Switch Query Parser to dismax */ PHP_METHOD(SolrDisMaxQuery, useDisMaxQueryParser) { solr_char_t *param_name = "defType", *param_value = "dismax"; int param_name_len = strlen("defType"), param_value_len = strlen("dismax"), result=1; result = solr_add_or_set_normal_param( getThis(), param_name, param_name_len, param_value, param_value_len, 0 TSRMLS_CC ); if(result != SUCCESS) { RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrQuery::useDisMaxQueryParser() Switch Query Parser to edismax */ PHP_METHOD(SolrDisMaxQuery, useEDisMaxQueryParser) { solr_char_t *pname = "defType", *param_value = "edismax"; int pname_len = strlen("defType"), param_value_len = strlen("edismax"), result=1; result = solr_add_or_set_normal_param( getThis(), pname, pname_len, param_value, param_value_len, 0 TSRMLS_CC ); if(result != SUCCESS) { RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrQuery::setQueryAlt(string q) SetQueryAlt uses q.alt if the q param is not defined */ PHP_METHOD(SolrDisMaxQuery, setQueryAlt) { solr_char_t *pname = "q.alt"; int pname_len = sizeof("q.alt")-1; solr_char_t *param_value = NULL; int param_value_len = 0; int set_param_return = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE){ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters"); RETURN_NULL(); } set_param_return = solr_add_or_set_normal_param(getThis(), pname, pname_len, param_value, param_value_len, 0 TSRMLS_CC); if(set_param_return == FAILURE) { RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrQuery::addQueryField(string field[, bool boost]) SetQueryAlt uses q.alt if the q param is not defined */ PHP_METHOD(SolrDisMaxQuery, addQueryField) { solr_char_t *pname = "qf"; int pname_len = sizeof("qf")-1; solr_char_t *boost_str = NULL; solr_char_t *field_name = NULL; int field_name_len = 0; int add_result = 0; solr_char_t *delimiter = " "; solr_char_t *separator = "^"; solr_char_t *separator_override=""; zval * boost = NULL; int boost_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &field_name, &field_name_len, &boost) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters"); RETURN_NULL(); } if(boost != NULL) { convert_to_string(boost); boost_str = Z_STRVAL_P(boost); boost_len = Z_STRLEN_P(boost); add_result = solr_add_arg_list_param( getThis(), pname, pname_len, field_name, field_name_len, boost_str, boost_len, *delimiter, *separator TSRMLS_CC ); }else{ boost_str = ""; add_result = solr_add_arg_list_param_ex( getThis(), pname, pname_len, field_name, field_name_len, boost_str, boost_len, *delimiter, *separator, *separator_override TSRMLS_CC ); } if(add_result == FAILURE) { RETURN_NULL(); } SOLR_RETURN_THIS(); } /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::removeQueryField(string field) Removes a sort field from the sort parameter. */ PHP_METHOD(SolrDisMaxQuery, removeQueryField) { solr_char_t *pname = (solr_char_t*) "qf"; int pname_len = sizeof("qf")-1; solr_char_t *field_name = NULL; int field_name_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_arg_list_param_value( getThis(), pname, pname_len, field_name, field_name_len TSRMLS_CC ); SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::addPhraseField(string field, float boost [, float slop]) * Adds a new phrase field */ PHP_METHOD(SolrDisMaxQuery, addPhraseField) { solr_char_t *pname = (solr_char_t*) "pf"; int pname_len = sizeof("pf")-1; solr_char_t *field_name = NULL; int field_name_len = 0; zval *boost = NULL; zval *slop = NULL; solr_char_t *boost_str = NULL; solr_char_t *slop_str = NULL; int add_result = 0; char * separator = "^"; solr_char_t * delimiter_override = ""; solr_string_t boost_slop_buffer; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|z", &field_name, &field_name_len, &boost, &slop) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if(boost != NULL) { convert_to_string(boost); boost_str = Z_STRVAL_P(boost); } if (slop != NULL) { convert_to_string(slop); slop_str = Z_STRVAL_P(slop); } if (slop != NULL && boost !=NULL) { delimiter_override = "~"; memset(&boost_slop_buffer, 0, sizeof(solr_string_t)); solr_string_appends(&boost_slop_buffer, (solr_char_t *)slop_str , Z_STRLEN_P(slop)); solr_string_appendc(&boost_slop_buffer, '^'); solr_string_appends(&boost_slop_buffer, boost_str , Z_STRLEN_P(boost)); add_result = solr_add_arg_list_param_ex( getThis(), pname, pname_len, field_name, field_name_len, boost_slop_buffer.str, boost_slop_buffer.len, ' ', *separator, *delimiter_override TSRMLS_CC ); solr_string_free(&boost_slop_buffer); } else { add_result = solr_add_arg_list_param( getThis(), pname, pname_len, field_name, field_name_len, boost_str, Z_STRLEN_P(boost),' ',*separator TSRMLS_CC ); } if(add_result == FAILURE) { RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::removeQueryField(string field) Removes a phrase field from pf. */ PHP_METHOD(SolrDisMaxQuery, removePhraseField) { solr_char_t *pname = (solr_char_t*) "pf"; int pname_len = sizeof("pf")-1; solr_char_t *field_name = NULL; int field_name_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_arg_list_param_value( getThis(), pname, pname_len, field_name, field_name_len TSRMLS_CC ); SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrQuery::setPhraseFields(string fields) setPhraseFields uses pf parameter */ PHP_METHOD(SolrDisMaxQuery, setPhraseFields) { solr_char_t *pname = "pf"; int pname_len = sizeof("pf")-1; int add_result = -1; solr_char_t *pvalue = NULL; int pvalue_len = 0; solr_param_t *param = NULL; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pvalue, &pvalue_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } /* if the parameter is registered with a different type, remove it first */ if(solr_param_find(getThis(), pname, pname_len, ¶m TSRMLS_CC) == SUCCESS && param->type != SOLR_PARAM_TYPE_NORMAL) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Parameter %s value(s) was overwritten by this call", pname); solr_delete_solr_parameter(getThis(), pname, pname_len TSRMLS_CC); } add_result = solr_add_or_set_normal_param(getThis(), pname, pname_len, pvalue, pvalue_len, 0 TSRMLS_CC); if(add_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add parameter %s", pname); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::setPhraseSlop(integer slop) sets Phrase Slop ps argument. */ PHP_METHOD(SolrDisMaxQuery, setPhraseSlop) { solr_char_t *pname = (solr_char_t*) "ps"; int pname_len = sizeof("ps")-1; int add_result = -1; solr_char_t *pvalue = NULL; int pvalue_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pvalue, &pvalue_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } add_result = solr_add_or_set_normal_param(getThis(), pname, pname_len, pvalue, pvalue_len, 0 TSRMLS_CC); if(add_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter value"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::setQueryPhraseSlop(integer slop) sets QueryPhrase Slop qs argument. */ PHP_METHOD(SolrDisMaxQuery, setQueryPhraseSlop) { solr_char_t *pname = (solr_char_t*) "qs"; int pname_len = sizeof("qs")-1; int add_result = -1; solr_char_t *pvalue = NULL; int pvalue_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pvalue, &pvalue_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } add_result = solr_add_or_set_normal_param(getThis(), pname, pname_len, pvalue, pvalue_len, 0 TSRMLS_CC); if(add_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter value"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::setBoostQuery(string q) sets Boost Query bq parameter. */ PHP_METHOD(SolrDisMaxQuery, setBoostQuery) { solr_char_t *pname = (solr_char_t*) "bq"; int pname_len = sizeof("bq")-1; int add_result = -1; solr_char_t *pvalue = NULL; int pvalue_len = 0; solr_param_t *param = NULL; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pvalue, &pvalue_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } /* if the parameter is registered with a different type, remove it first */ if(solr_param_find(getThis(), pname, pname_len, ¶m TSRMLS_CC) == SUCCESS && param->type != SOLR_PARAM_TYPE_NORMAL) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Parameter %s value(s) was overwritten by this call", pname); solr_delete_solr_parameter(getThis(), pname, pname_len TSRMLS_CC); } add_result = solr_add_or_set_normal_param(getThis(), pname, pname_len, pvalue, pvalue_len, 0 TSRMLS_CC); if(add_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add parameter %s", pname); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::addBoostQueryField(string field, string value [, float boost]) * Adds a new boost query field using the bq parameter */ PHP_METHOD(SolrDisMaxQuery, addBoostQuery) { solr_char_t *pname = (solr_char_t*) "bq"; int pname_len = sizeof("bq")-1; solr_char_t *field_name = NULL; int field_name_len = 0; zval *boost = NULL; solr_char_t *field_value = NULL; int field_value_len = 0; solr_char_t *boost_str = NULL; int add_result = 0; char * separator = ":"; solr_char_t *boost_separator = "^"; solr_string_t *value_boost_str = NULL; solr_param_t *param = NULL; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|z", &field_name, &field_name_len, &field_value, &field_value_len, &boost) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } /* if the parameter is registered with a different type, remove it first */ if(solr_param_find(getThis(), pname, pname_len, ¶m TSRMLS_CC) == SUCCESS && param->type != SOLR_PARAM_TYPE_ARG_LIST) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Parameter %s value(s) was overwritten by this call", pname); solr_delete_solr_parameter(getThis(), pname, pname_len TSRMLS_CC); } if(boost != NULL) { convert_to_string(boost); boost_str = Z_STRVAL_P(boost); } if(boost !=NULL) { value_boost_str = emalloc(sizeof(solr_string_t)); memset(value_boost_str, 0, sizeof(solr_string_t)); solr_string_appends(value_boost_str, field_value, field_value_len); solr_string_appendc(value_boost_str, *boost_separator); solr_string_appends(value_boost_str, boost_str, Z_STRLEN_P(boost)); add_result = solr_add_arg_list_param( getThis(),pname, pname_len, field_name, field_name_len, value_boost_str->str, value_boost_str->len,' ',*separator TSRMLS_CC ); solr_string_free(value_boost_str); efree(value_boost_str); }else{ add_result = solr_add_arg_list_param( getThis(),pname, pname_len, field_name, field_name_len, field_value, field_value_len,' ',*separator TSRMLS_CC ); } if(add_result == FAILURE) { RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::removeBoostQuery(string field) Removes a sort field from the sort parameter. */ PHP_METHOD(SolrDisMaxQuery, removeBoostQuery) { solr_char_t *pname = (solr_char_t*) "bq"; int pname_len = sizeof("bq")-1; solr_char_t *field_name = NULL; int field_name_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_arg_list_param_value( getThis(), pname, pname_len, field_name, field_name_len TSRMLS_CC ); SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::setBoostFunction(string function) sets Boost Query bf parameter. */ PHP_METHOD(SolrDisMaxQuery, setBoostFunction) { solr_char_t *pname = (solr_char_t*) "bf"; int pname_len = sizeof("bf")-1; int add_result = -1; solr_char_t *pvalue = NULL; int pvalue_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pvalue, &pvalue_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } add_result = solr_add_or_set_normal_param(getThis(), pname, pname_len, pvalue, pvalue_len, 0 TSRMLS_CC); if(add_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add parameter %s", pname); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::setMinimumMatch(string value) sets Minimum Match (mm) parameter. */ PHP_METHOD(SolrDisMaxQuery, setMinimumMatch) { solr_char_t *pname = (solr_char_t*) "mm"; int pname_len = sizeof("mm")-1; int add_result = -1; solr_char_t *pvalue = NULL; int pvalue_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pvalue, &pvalue_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } add_result = solr_add_or_set_normal_param(getThis(), pname, pname_len, pvalue, pvalue_len, 0 TSRMLS_CC); if(add_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add parameter %s", pname); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::setTieBreaker(float tieBreaker) sets Tie Breaker (tie) parameter. */ PHP_METHOD(SolrDisMaxQuery, setTieBreaker) { solr_char_t *pname = (solr_char_t*) "tie"; int pname_len = sizeof("tie")-1; int add_result = -1; solr_char_t *pvalue = NULL; int pvalue_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pvalue, &pvalue_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } add_result = solr_add_or_set_normal_param(getThis(), pname, pname_len, pvalue, pvalue_len, 0 TSRMLS_CC); if(add_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add parameter %s", pname); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::setBigramPhraseFields(string bigramFields) setBigramPhraseFields uses pf2 parameter */ PHP_METHOD(SolrDisMaxQuery, setBigramPhraseFields) { solr_char_t *pname = "pf2"; int pname_len = sizeof("pf2")-1; solr_char_t *param_value = NULL; int param_value_len = 0; int set_param_return = 0; solr_param_t *param = NULL; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE){ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters"); RETURN_NULL(); } /* if the parameter is registered with a different type, remove it first */ if(solr_param_find(getThis(), pname, pname_len, ¶m TSRMLS_CC) == SUCCESS && param->type != SOLR_PARAM_TYPE_NORMAL) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Parameter %s value(s) was overwritten by this call", pname); solr_delete_solr_parameter(getThis(), pname, pname_len TSRMLS_CC); } set_param_return = solr_add_or_set_normal_param(getThis(), pname, pname_len, param_value, param_value_len, 0 TSRMLS_CC); if(set_param_return == FAILURE) { RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::addBigramPhraseField(string field, float boost [, float slop]) * Adds a new bigram phrase field (pf2) to the list of fields */ PHP_METHOD(SolrDisMaxQuery, addBigramPhraseField) { solr_char_t *field_name = NULL; int field_name_len = 0; zval *boost = NULL; zval *slop = NULL; int add_result = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|z", &field_name, &field_name_len, &boost, &slop) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } add_result = add_phrase_field(getThis(), "pf2", boost, slop, field_name, field_name_len TSRMLS_CC); if(add_result == FAILURE) { RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::removeQueryField(string field) Removes a bigram phrase field. */ PHP_METHOD(SolrDisMaxQuery, removeBigramPhraseField) { solr_char_t *pname = (solr_char_t*) "pf2"; int pname_len = sizeof("pf2")-1; solr_char_t *field_name = NULL; int field_name_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_arg_list_param_value( getThis(), pname, pname_len, field_name, field_name_len TSRMLS_CC ); SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::setBigramPhraseSlop(integer slop) sets Bigram Phrase Slop ps argument. */ PHP_METHOD(SolrDisMaxQuery, setBigramPhraseSlop) { solr_char_t *pname = (solr_char_t*) "ps2"; int pname_len = sizeof("ps2")-1; int add_result = -1; solr_char_t *pvalue = NULL; int pvalue_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pvalue, &pvalue_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } add_result = solr_add_or_set_normal_param(getThis(), pname, pname_len, pvalue, pvalue_len, 0 TSRMLS_CC); if(add_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter value"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::setTrigramPhraseFields(string fields) setTrigramPhraseFields uses pf3 parameter */ PHP_METHOD(SolrDisMaxQuery, setTrigramPhraseFields) { solr_char_t *pname = "pf3"; int pname_len = sizeof("pf3")-1; solr_char_t *param_value = NULL; int param_value_len = 0; int set_param_return = 0; solr_param_t *param = NULL; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE){ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters"); RETURN_NULL(); } /* if the parameter is registered with a different type, remove it first */ if(solr_param_find(getThis(), pname, pname_len, ¶m TSRMLS_CC) == SUCCESS && param->type != SOLR_PARAM_TYPE_NORMAL) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Parameter %s value(s) was overwritten by this call", pname); solr_delete_solr_parameter(getThis(), pname, pname_len TSRMLS_CC); } set_param_return = solr_add_or_set_normal_param(getThis(), pname, pname_len, param_value, param_value_len, 0 TSRMLS_CC); if(set_param_return == FAILURE) { RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::addTrigramPhraseField(string field, float boost [, float slop]) * Adds a new trigram phrase field (pf3) to the list of fields */ PHP_METHOD(SolrDisMaxQuery, addTrigramPhraseField) { solr_char_t *field_name = NULL; int field_name_len = 0; zval *boost = NULL; zval *slop = NULL; int add_result = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|z", &field_name, &field_name_len, &boost, &slop) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } add_result = add_phrase_field(getThis(), "pf3", boost, slop, field_name, field_name_len TSRMLS_CC); if(add_result == FAILURE) { RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::removeQueryField(string field) Removes a trigram phrase field. */ PHP_METHOD(SolrDisMaxQuery, removeTrigramPhraseField) { solr_char_t *pname = (solr_char_t*) "pf3"; int pname_len = sizeof("pf3")-1; solr_char_t *field_name = NULL; int field_name_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_arg_list_param_value( getThis(), pname, pname_len, field_name, field_name_len TSRMLS_CC ); SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::setTrigramPhraseSlop(integer slop) sets Trigram Phrase Slop ps3 argument. */ PHP_METHOD(SolrDisMaxQuery, setTrigramPhraseSlop) { solr_char_t *pname = (solr_char_t*) "ps3"; int pname_len = sizeof("ps3")-1; int add_result = -1; solr_char_t *pvalue = NULL; int pvalue_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pvalue, &pvalue_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } add_result = solr_add_or_set_normal_param(getThis(), pname, pname_len, pvalue, pvalue_len, 0 TSRMLS_CC); if(add_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter value"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::addUserField(string field) Adds a userfield rule to uf parameter. */ PHP_METHOD(SolrDisMaxQuery, addUserField) { solr_char_t *pname = (solr_char_t*) "uf"; int pname_len = sizeof("uf")-1; int add_result = -1; solr_char_t *pvalue = NULL; int pvalue_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pvalue, &pvalue_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } add_result = solr_add_simple_list_param_ex(getThis(), pname, pname_len, pvalue, pvalue_len, " " TSRMLS_CC); if(add_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add user field: Invalid parameter value"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::removeUserField(string field) Removes a userfield rule from uf parameter. */ PHP_METHOD(SolrDisMaxQuery, removeUserField) { solr_char_t *pname = (solr_char_t*) "uf"; int pname_len = sizeof("uf")-1; solr_char_t *field_name = NULL; int field_name_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_simple_list_param_value(getThis(), pname, pname_len, field_name, field_name_len TSRMLS_CC); SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::setUserFields(string fields) Sets user fields (uf parameter) */ PHP_METHOD(SolrDisMaxQuery, setUserFields) { solr_char_t *pname = "uf"; int pname_len = sizeof("uf")-1; solr_char_t *param_value = NULL; int param_value_len = 0; int set_param_return = 0; solr_param_t *param = NULL; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE){ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters"); RETURN_NULL(); } /* if the parameter is registered with a different type, remove it first */ if(solr_param_find(getThis(), pname, pname_len, ¶m TSRMLS_CC) == SUCCESS && param->type != SOLR_PARAM_TYPE_NORMAL) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Parameter %s value(s) was overwritten by this call", pname); solr_delete_solr_parameter(getThis(), pname, pname_len TSRMLS_CC); } set_param_return = solr_add_or_set_normal_param(getThis(), pname, pname_len, param_value, param_value_len, 0 TSRMLS_CC); if(set_param_return == FAILURE) { RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ int add_phrase_field(zval *obj, solr_char_t *pname, zval *boost, zval *slop, solr_char_t *field_name, int field_name_len TSRMLS_DC) { int pname_len = strlen(pname); int add_result = 0; solr_char_t *boost_str = NULL; solr_char_t *slop_str = NULL; char * separator = "^"; solr_char_t * delimiter_override = ""; solr_string_t boost_slop_buffer; if(boost != NULL) { convert_to_string(boost); boost_str = Z_STRVAL_P(boost); } if (slop != NULL) { convert_to_string(slop); slop_str = Z_STRVAL_P(slop); } if (slop != NULL && boost !=NULL) { delimiter_override = "~"; memset(&boost_slop_buffer, 0, sizeof(solr_string_t)); solr_string_appends(&boost_slop_buffer, (solr_char_t *)slop_str , Z_STRLEN_P(slop)); solr_string_appendc(&boost_slop_buffer, '^'); solr_string_appends(&boost_slop_buffer, boost_str , Z_STRLEN_P(boost)); add_result = solr_add_arg_list_param_ex( obj, pname, pname_len, field_name, field_name_len, boost_slop_buffer.str, boost_slop_buffer.len, ' ', *separator, *delimiter_override TSRMLS_CC ); solr_string_free(&boost_slop_buffer); } else { add_result = solr_add_arg_list_param( obj, pname, pname_len, field_name, field_name_len, boost_str, Z_STRLEN_P(boost),' ',*separator TSRMLS_CC ); } return add_result; } solr-2.4.0/src/php5/php_solr_dismax_query.h0000644000175000017500000000507512676753706017440 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Omar Shaban | +----------------------------------------------------------------------+ */ #ifndef SOLR_DISMAX_QUERY_H_ #define SOLR_DISMAX_QUERY_H_ void init_solr_dismax_query(TSRMLS_D); PHP_METHOD(SolrDisMaxQuery, __construct); PHP_METHOD(SolrDisMaxQuery, setQueryAlt); PHP_METHOD(SolrDisMaxQuery, addQueryField); PHP_METHOD(SolrDisMaxQuery, removeQueryField); PHP_METHOD(SolrDisMaxQuery, addPhraseField); PHP_METHOD(SolrDisMaxQuery, removePhraseField); PHP_METHOD(SolrDisMaxQuery, setPhraseFields); PHP_METHOD(SolrDisMaxQuery, setPhraseSlop); PHP_METHOD(SolrDisMaxQuery, setQueryPhraseSlop); PHP_METHOD(SolrDisMaxQuery, setBoostQuery); PHP_METHOD(SolrDisMaxQuery, addBoostQuery); PHP_METHOD(SolrDisMaxQuery, removeBoostQuery); PHP_METHOD(SolrDisMaxQuery, setBoostFunction); PHP_METHOD(SolrDisMaxQuery, setMinimumMatch); PHP_METHOD(SolrDisMaxQuery, setTieBreaker); PHP_METHOD(SolrDisMaxQuery, useDisMaxQueryParser); PHP_METHOD(SolrDisMaxQuery, useEDisMaxQueryParser); PHP_METHOD(SolrDisMaxQuery, setBigramPhraseFields); PHP_METHOD(SolrDisMaxQuery, addBigramPhraseField); PHP_METHOD(SolrDisMaxQuery, removeBigramPhraseField); PHP_METHOD(SolrDisMaxQuery, setBigramPhraseSlop); PHP_METHOD(SolrDisMaxQuery, setTrigramPhraseFields); PHP_METHOD(SolrDisMaxQuery, addTrigramPhraseField); PHP_METHOD(SolrDisMaxQuery, removeTrigramPhraseField); PHP_METHOD(SolrDisMaxQuery, setTrigramPhraseSlop); PHP_METHOD(SolrDisMaxQuery, addUserField); PHP_METHOD(SolrDisMaxQuery, removeUserField); PHP_METHOD(SolrDisMaxQuery, setUserFields); #endif /* SOLR_DISMAX_QUERY_H_ */ solr-2.4.0/src/php5/php_solr_collapse_function.c0000644000175000017500000002564512676753706020435 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: | | Omar Shaban | +----------------------------------------------------------------------+ */ #include "php_solr.h" /* {{{ proto void SolrFunction::__construct([string field]) Constructor. */ PHP_METHOD(SolrCollapseFunction, __construct) { long int index = SOLR_UNIQUE_FUNCTION_INDEX(); uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE; solr_function_t *solr_function_dest = NULL; solr_function_t solr_function; zval *objptr = getThis(); solr_char_t *param_name = (solr_char_t *)"field"; int param_name_len = sizeof("field"); solr_string_t field_str; solr_char_t *field_name = NULL; int field_name_len = 0; memset(&solr_function, 0, sizeof(solr_function_t)); if (zend_hash_index_update(SOLR_GLOBAL(functions),index,(void *) &solr_function, sizeof(solr_function_t), (void **) &solr_function_dest) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error while registering query parameters in HashTable"); return ; } zend_update_property_long(solr_ce_SolrCollapseFunction, objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, index TSRMLS_CC); solr_function_dest->function_index = index; solr_function_dest->name_length = strlen("collapse"); solr_function_dest->name = (solr_char_t *)"collapse"; /* Allocated memory for the params HashTable using fast cache for HashTables */ ALLOC_HASHTABLE(solr_function_dest->params); zend_hash_init(solr_function_dest->params, nSize, NULL, (dtor_func_t) solr_string_free_ex, SOLR_FUNCTIONS_PERSISTENT); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error Parsing Parameters"); return; } if (field_name_len > 0 ){ memset(&field_str, 0, sizeof(solr_string_t)); solr_string_set(&field_str, (solr_char_t *)field_name, field_name_len); if(zend_hash_update(solr_function_dest->params, param_name, param_name_len, (void **)&field_str, sizeof(solr_string_t), NULL) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); } } Z_OBJ_HT_P(getThis()) = &solr_collapse_function_object_handlers; } /* }}} */ /* {{{ proto void SolrFunction::__destruct(void) Destructor. */ PHP_METHOD(SolrCollapseFunction, __destruct) { solr_function_t *function = NULL; /* Retrieve the document entry for this SolrDocument */ if (solr_fetch_function_entry(getThis(), &function TSRMLS_CC) == SUCCESS ) { zend_hash_index_del(SOLR_GLOBAL(functions), function->function_index); } return; } /* {{{ proto string SolrFunction::setField(string field) Set the field that is being collapsed on. The field must be a single valued String, Int or Float. */ PHP_METHOD(SolrCollapseFunction, setField) { solr_char_t *key = "field", *arg; int key_len = sizeof("field"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::getField(void) Get Collapse Field */ PHP_METHOD(SolrCollapseFunction, getField) { solr_char_t *key = "field"; int key_len = sizeof("field"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::setMin(string value) Selects the group heads by the min value of a numeric field or function query. */ PHP_METHOD(SolrCollapseFunction, setMin) { solr_char_t *key = "min", *arg; int key_len = sizeof("min"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::setMax(string value) Selects the group heads by the max value of a numeric field or function query. */ PHP_METHOD(SolrCollapseFunction, setMax) { solr_char_t *key = "max", *arg; int key_len = sizeof("max"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::getMin(void) Get min parameter */ PHP_METHOD(SolrCollapseFunction, getMin) { solr_char_t *key = "min"; int key_len = sizeof("min"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::getMax(void) Get max parameter */ PHP_METHOD(SolrCollapseFunction, getMax) { solr_char_t *key = "max"; int key_len = sizeof("max"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::setSize(void) Sets the initial size of the collapse data structures when collapsing on a numeric field only */ PHP_METHOD(SolrCollapseFunction, setSize) { solr_char_t *key = "size", *arg; int key_len = sizeof("size"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::getSize(void) Get size parameter */ PHP_METHOD(SolrCollapseFunction, getSize) { solr_char_t *key = "size"; int key_len = sizeof("size"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::setHint(void) Set collapse hint Currently there is only one hint available "top_fc", which stands for top level FieldCache */ PHP_METHOD(SolrCollapseFunction, setHint) { solr_char_t *key = "hint", *arg; int key_len = sizeof("hint"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::getHint(void) Get Hint */ PHP_METHOD(SolrCollapseFunction, getHint) { solr_char_t *key = "hint"; int key_len = sizeof("hint"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::setNullPolicy(void) Sets the NULL Policy. Accepts ignore, expand, or collapse */ PHP_METHOD(SolrCollapseFunction, setNullPolicy) { solr_char_t *key = "nullPolicy", *arg; int key_len = sizeof("nullPolicy"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::getNullPolicy(void) Get NullPolicy */ PHP_METHOD(SolrCollapseFunction, getNullPolicy) { solr_char_t *key = "nullPolicy"; int key_len = sizeof("nullPolicy"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::__toString(void) String value of the function object */ PHP_METHOD(SolrCollapseFunction, __toString) { solr_function_t *collapse_func; solr_string_t *buffer = NULL; if(solr_fetch_function_entry(getThis(), &collapse_func TSRMLS_CC) == FAILURE) { RETURN_NULL(); } buffer = (solr_string_t *)emalloc(sizeof(solr_string_t)); memset(buffer, 0, sizeof(solr_string_t)); solr_solrfunc_to_string(collapse_func, &buffer); ZVAL_STRINGL(return_value, buffer->str, buffer->len, 0); efree(buffer); } /* }}} */ /* {{{ proto SolrClient::__sleep(void) Should not be called directly. Serialization is not supported. */ PHP_METHOD(SolrCollapseFunction, __sleep) { solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1001 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Serialization of SolrCollapseFunction objects is currently not supported"); } /* }}} */ /* {{{ proto SolrClient::__wakeup(void) Should not be called directly. Serialization is not supported. */ PHP_METHOD(SolrCollapseFunction, __wakeup) { solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1001 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Unserialization of SolrCollapseFunction objects is currently not supported"); } /* }}} */ /* {{{ throw exception on cloning (clone handler) */ zend_object_value solr_collapse_function_handlers_clone_object(zval *object TSRMLS_DC) { zend_object_value retval; zend_object *fake; retval = zend_objects_new(&fake, zend_standard_class_def TSRMLS_CC); solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_4001 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Cloning of SolrCollapseFunction objects is currently not supported"); return retval; } /* }}} */ solr-2.4.0/src/php7/php_solr.h0000644000175000017500000011177512676753706014655 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #ifndef SOLRCLIENT_H #define SOLRCLIENT_H /* #define SOLR_MEM_DEBUG 1 */ #include
#ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef HAVE_SOLR #include #include #include
#include
#include
#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include extern zend_module_entry solr_module_entry; #define phpext_solr_ptr &solr_module_entry /* {{{ Startup, Shutdown, Activation, Deactivation and Info functions */ PHP_MINIT_FUNCTION(solr); /* Module Startup Function */ PHP_MSHUTDOWN_FUNCTION(solr); /* Module Shutdown Function */ PHP_RINIT_FUNCTION(solr); /* Request Activation Function */ PHP_RSHUTDOWN_FUNCTION(solr); /* Request Deactivation Function */ PHP_MINFO_FUNCTION(solr); /* Module Information Display Function */ /* }}} */ #ifdef ZTS #include #endif #if ((PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 2)) #define SOLR_ZEND_ENGINE_2_2 1 #endif /* List of constants */ #include "solr_constants.h" /* List of types */ #include "solr_types.h" #ifdef ZTS # define SOLR_GLOBAL(v) TSRMG(solr_globals_id, zend_solr_globals *, v) #else # define SOLR_GLOBAL(v) (solr_globals.v) #endif #include #include "php_solr_api.h" #include "php_solr_bc_macros.h" /* {{{ Variables declared elsewhere */ ZEND_EXTERN_MODULE_GLOBALS(solr) /* ZEND_EXTERN_MODULE_GLOBALS(json) */ extern zend_class_entry *solr_ce_SolrObject; extern zend_class_entry *solr_ce_SolrInputDocument; extern zend_class_entry *solr_ce_SolrDocument; extern zend_class_entry *solr_ce_SolrDocumentField; extern zend_class_entry *solr_ce_SolrClient; extern zend_class_entry *solr_ce_SolrParams; extern zend_class_entry *solr_ce_SolrModifiableParams; extern zend_class_entry *solr_ce_SolrCollapseFunction; extern zend_class_entry *solr_ce_SolrQuery; extern zend_class_entry *solr_ce_SolrResponse; extern zend_class_entry *solr_ce_SolrQueryResponse; extern zend_class_entry *solr_ce_SolrUpdateResponse; extern zend_class_entry *solr_ce_SolrPingResponse; extern zend_class_entry *solr_ce_SolrGenericResponse; extern zend_class_entry *solr_ce_SolrUtils; extern zend_class_entry *solr_ce_SolrException; extern zend_class_entry *solr_ce_SolrIllegalOperationException; extern zend_class_entry *solr_ce_SolrIllegalArgumentException; extern zend_class_entry *solr_ce_SolrClientException; extern zend_class_entry *solr_ce_SolrServerException; extern zend_class_entry *solr_ce_SolrMissingMandatoryParameterException; extern ZEND_API zend_class_entry *zend_ce_serializable; extern ZEND_API zend_class_entry *zend_ce_arrayaccess; extern ZEND_API zend_class_entry *zend_ce_iterator; /* {{{ Aliases for external class entries */ #define solr_ce_Serializable zend_ce_serializable #define solr_ce_ArrayAccess zend_ce_arrayaccess #define solr_ce_Iterator zend_ce_iterator #define solr_ce_Exception zend_exception_get_default(TSRMLS_C) /* }}} */ extern zend_object_handlers solr_object_handlers; extern zend_object_handlers solr_document_field_handlers; extern zend_object_handlers solr_input_document_object_handlers; extern zend_object_handlers solr_client_object_handlers; extern zend_object_handlers solr_response_object_handlers; extern zend_object_handlers solr_collapse_function_object_handlers; /* }}} */ /******************************************************************************/ /** DECLARATIONS FOR EXTENSION METHODS AND FUNCTIONS **/ /******************************************************************************/ /* {{{ Extension functions */ PHP_FUNCTION(solr_get_version); /* }}} */ /* {{{ SolrObject methods */ PHP_METHOD(SolrObject, __construct); PHP_METHOD(SolrObject, __destruct); PHP_METHOD(SolrObject, __set); PHP_METHOD(SolrObject, __get); PHP_METHOD(SolrObject, __isset); PHP_METHOD(SolrObject, __unset); PHP_METHOD(SolrObject, offsetSet); PHP_METHOD(SolrObject, offsetGet); PHP_METHOD(SolrObject, offsetExists); PHP_METHOD(SolrObject, offsetUnset); PHP_METHOD(SolrObject, getPropertyNames); /* }}} */ /* {{{ SolException object methods */ PHP_METHOD(SolrException, getInternalInfo); PHP_METHOD(SolrClientException, getInternalInfo); PHP_METHOD(SolrIllegalOperationException, getInternalInfo); PHP_METHOD(SolrIllegalArgumentException, getInternalInfo); PHP_METHOD(SolrServerException, getInternalInfo); /* }}} */ /* {{{ SolrDocument methods declarations */ PHP_METHOD(SolrDocument, __construct); PHP_METHOD(SolrDocument, __destruct); PHP_METHOD(SolrDocument, __clone); PHP_METHOD(SolrDocument, __get); PHP_METHOD(SolrDocument, __set); PHP_METHOD(SolrDocument, __isset); PHP_METHOD(SolrDocument, __unset); /* Methods from Serializable */ PHP_METHOD(SolrDocument, serialize); PHP_METHOD(SolrDocument, unserialize); /* Methods from ArrayAccess */ PHP_METHOD(SolrDocument, offsetExists); PHP_METHOD(SolrDocument, offsetGet); PHP_METHOD(SolrDocument, offsetSet); PHP_METHOD(SolrDocument, offsetUnset); /* Methods from Iterator */ PHP_METHOD(SolrDocument, current); PHP_METHOD(SolrDocument, key); PHP_METHOD(SolrDocument, next); PHP_METHOD(SolrDocument, rewind); PHP_METHOD(SolrDocument, valid); PHP_METHOD(SolrDocument, clear); PHP_METHOD(SolrDocument, addField); PHP_METHOD(SolrDocument, getFieldNames); PHP_METHOD(SolrDocument, getFieldCount); PHP_METHOD(SolrDocument, getField); PHP_METHOD(SolrDocument, toArray); PHP_METHOD(SolrDocument, fieldExists); PHP_METHOD(SolrDocument, deleteField); PHP_METHOD(SolrDocument, sort); PHP_METHOD(SolrDocument, merge); PHP_METHOD(SolrDocument, getInputDocument); PHP_METHOD(SolrDocument, hasChildDocuments); PHP_METHOD(SolrDocument, getChildDocuments); PHP_METHOD(SolrDocument, getChildDocumentsCount); /* }}} */ /* {{{ SolrDocumentField methods */ PHP_METHOD(SolrDocumentField, __construct); PHP_METHOD(SolrDocumentField, __destruct); /* }}} */ /* {{{ SolrInputDocument methods declarations */ PHP_METHOD(SolrInputDocument, __construct); PHP_METHOD(SolrInputDocument, __destruct); PHP_METHOD(SolrInputDocument, __clone); PHP_METHOD(SolrInputDocument, __sleep); PHP_METHOD(SolrInputDocument, __wakeup); PHP_METHOD(SolrInputDocument, setBoost); PHP_METHOD(SolrInputDocument, getBoost); PHP_METHOD(SolrInputDocument, clear); PHP_METHOD(SolrInputDocument, addField); PHP_METHOD(SolrInputDocument, setFieldBoost); PHP_METHOD(SolrInputDocument, getFieldBoost); PHP_METHOD(SolrInputDocument, getFieldNames); PHP_METHOD(SolrInputDocument, getFieldCount); PHP_METHOD(SolrInputDocument, getField); PHP_METHOD(SolrInputDocument, toArray); PHP_METHOD(SolrInputDocument, fieldExists); PHP_METHOD(SolrInputDocument, deleteField); PHP_METHOD(SolrInputDocument, sort); PHP_METHOD(SolrInputDocument, merge); PHP_METHOD(SolrInputDocument, addChildDocument); PHP_METHOD(SolrInputDocument, getChildDocuments); PHP_METHOD(SolrInputDocument, hasChildDocuments); PHP_METHOD(SolrInputDocument, getChildDocumentsCount); PHP_METHOD(SolrInputDocument, addChildDocuments); /* }}} */ /* {{{ SolrClient methods declarations */ PHP_METHOD(SolrClient, __construct); PHP_METHOD(SolrClient, __destruct); PHP_METHOD(SolrClient, __sleep); PHP_METHOD(SolrClient, __wakeup); PHP_METHOD(SolrClient, __clone); PHP_METHOD(SolrClient, query); PHP_METHOD(SolrClient, getOptions); PHP_METHOD(SolrClient, getDebug); PHP_METHOD(SolrClient, addDocument); PHP_METHOD(SolrClient, addDocuments); PHP_METHOD(SolrClient, setServlet); PHP_METHOD(SolrClient, setResponseWriter); PHP_METHOD(SolrClient, request); PHP_METHOD(SolrClient, ping); PHP_METHOD(SolrClient, system); PHP_METHOD(SolrClient, threads); PHP_METHOD(SolrClient, deleteById); PHP_METHOD(SolrClient, deleteByIds); PHP_METHOD(SolrClient, deleteByQuery); PHP_METHOD(SolrClient, deleteByQueries); PHP_METHOD(SolrClient, getById); PHP_METHOD(SolrClient, getByIds); PHP_METHOD(SolrClient, optimize); PHP_METHOD(SolrClient, commit); PHP_METHOD(SolrClient, rollback); /* }}} */ /* {{{ SolrParams methods declarations */ PHP_METHOD(SolrParams, setParam); /* Parameter can only accept one value */ PHP_METHOD(SolrParams, addParam); /* Parameter can accept more than one value */ PHP_METHOD(SolrParams, getParams); /* Retrieves the parameters and their values */ PHP_METHOD(SolrParams, getParam); /* Retrieves a parameter value */ PHP_METHOD(SolrParams, __toString); /* Returns a string representation of the object */ PHP_METHOD(SolrParams, toString); /* Returns a string representation of the object */ PHP_METHOD(SolrParams, getPreparedParams); /* Returns the prepared parameters */ PHP_METHOD(SolrParams, serialize); /* used by serialize() */ PHP_METHOD(SolrParams, unserialize); /* used by unserialize() */ PHP_METHOD(SolrParams, __clone); /* Used to enforce the cloning of SolrParams is currently unsupported */ /* }}} */ /* {{{ SolrModifiableParams methods declarations */ PHP_METHOD(SolrModifiableParams, __construct); PHP_METHOD(SolrModifiableParams, __destruct); /* }}} */ /* {{{ SolrQuery methods declarations */ /* Constructor and Destructor */ PHP_METHOD(SolrQuery, __construct); PHP_METHOD(SolrQuery, __destruct); /* CommonQueryParameters */ PHP_METHOD(SolrQuery, setQuery); PHP_METHOD(SolrQuery, getQuery); PHP_METHOD(SolrQuery, setStart); PHP_METHOD(SolrQuery, getStart); PHP_METHOD(SolrQuery, setRows); PHP_METHOD(SolrQuery, getRows); PHP_METHOD(SolrQuery, addField); PHP_METHOD(SolrQuery, removeField); PHP_METHOD(SolrQuery, getFields); PHP_METHOD(SolrQuery, addSortField); PHP_METHOD(SolrQuery, removeSortField); PHP_METHOD(SolrQuery, getSortFields); PHP_METHOD(SolrQuery, addFilterQuery); PHP_METHOD(SolrQuery, removeFilterQuery); PHP_METHOD(SolrQuery, getFilterQueries); PHP_METHOD(SolrQuery, setShowDebugInfo); PHP_METHOD(SolrQuery, setExplainOther); PHP_METHOD(SolrQuery, setTimeAllowed); PHP_METHOD(SolrQuery, getTimeAllowed); PHP_METHOD(SolrQuery, setOmitHeader); /* CoreQueryParameters */ PHP_METHOD(SolrQuery, setEchoHandler); PHP_METHOD(SolrQuery, setEchoParams); /* SimpleFacetParameters */ PHP_METHOD(SolrQuery, setFacet); PHP_METHOD(SolrQuery, getFacet); PHP_METHOD(SolrQuery, addFacetField); PHP_METHOD(SolrQuery, removeFacetField); PHP_METHOD(SolrQuery, getFacetFields); PHP_METHOD(SolrQuery, addFacetQuery); PHP_METHOD(SolrQuery, removeFacetQuery); PHP_METHOD(SolrQuery, getFacetQueries); PHP_METHOD(SolrQuery, setFacetPrefix); PHP_METHOD(SolrQuery, getFacetPrefix); PHP_METHOD(SolrQuery, setFacetSort); PHP_METHOD(SolrQuery, getFacetSort); PHP_METHOD(SolrQuery, setFacetLimit); PHP_METHOD(SolrQuery, getFacetLimit); PHP_METHOD(SolrQuery, setFacetOffset); PHP_METHOD(SolrQuery, getFacetOffset); PHP_METHOD(SolrQuery, setFacetMinCount); PHP_METHOD(SolrQuery, getFacetMinCount); PHP_METHOD(SolrQuery, setFacetMissing); PHP_METHOD(SolrQuery, getFacetMissing); PHP_METHOD(SolrQuery, setFacetMethod); PHP_METHOD(SolrQuery, getFacetMethod); PHP_METHOD(SolrQuery, setFacetEnumCacheMinDefaultFrequency); /* Date facet parameters */ PHP_METHOD(SolrQuery, addFacetDateField); PHP_METHOD(SolrQuery, removeFacetDateField); PHP_METHOD(SolrQuery, getFacetDateFields); PHP_METHOD(SolrQuery, setFacetDateStart); PHP_METHOD(SolrQuery, getFacetDateStart); PHP_METHOD(SolrQuery, setFacetDateEnd); PHP_METHOD(SolrQuery, getFacetDateEnd); PHP_METHOD(SolrQuery, setFacetDateGap); PHP_METHOD(SolrQuery, getFacetDateGap); PHP_METHOD(SolrQuery, setFacetDateHardEnd); PHP_METHOD(SolrQuery, getFacetDateHardEnd); PHP_METHOD(SolrQuery, addFacetDateOther); PHP_METHOD(SolrQuery, removeFacetDateOther); PHP_METHOD(SolrQuery, getFacetDateOther); /* GroupParameters */ PHP_METHOD(SolrQuery, setGroup); PHP_METHOD(SolrQuery, getGroup); PHP_METHOD(SolrQuery, addGroupField); PHP_METHOD(SolrQuery, getGroupFields); PHP_METHOD(SolrQuery, addGroupFunction); PHP_METHOD(SolrQuery, getGroupFunctions); PHP_METHOD(SolrQuery, addGroupQuery); PHP_METHOD(SolrQuery, getGroupQueries); PHP_METHOD(SolrQuery, setGroupLimit); PHP_METHOD(SolrQuery, getGroupLimit); PHP_METHOD(SolrQuery, setGroupOffset); PHP_METHOD(SolrQuery, getGroupOffset); PHP_METHOD(SolrQuery, addGroupSortField); PHP_METHOD(SolrQuery, getGroupSortFields); PHP_METHOD(SolrQuery, setGroupFormat); PHP_METHOD(SolrQuery, getGroupFormat); PHP_METHOD(SolrQuery, setGroupMain); PHP_METHOD(SolrQuery, getGroupMain); PHP_METHOD(SolrQuery, setGroupNGroups); PHP_METHOD(SolrQuery, getGroupNGroups); PHP_METHOD(SolrQuery, setGroupTruncate); PHP_METHOD(SolrQuery, getGroupTruncate); PHP_METHOD(SolrQuery, setGroupFacet); PHP_METHOD(SolrQuery, getGroupFacet); PHP_METHOD(SolrQuery, setGroupCachePercent); PHP_METHOD(SolrQuery, getGroupCachePercent); /* Collapse */ PHP_METHOD(SolrQuery, collapse); /* Expand Parameters */ PHP_METHOD(SolrQuery, setExpand); PHP_METHOD(SolrQuery, getExpand); PHP_METHOD(SolrQuery, addExpandSortField); PHP_METHOD(SolrQuery, removeExpandSortField); PHP_METHOD(SolrQuery, getExpandSortFields); PHP_METHOD(SolrQuery, setExpandRows); PHP_METHOD(SolrQuery, getExpandRows); PHP_METHOD(SolrQuery, setExpandQuery); PHP_METHOD(SolrQuery, getExpandQuery); PHP_METHOD(SolrQuery, addExpandFilterQuery); PHP_METHOD(SolrQuery, removeExpandFilterQuery); PHP_METHOD(SolrQuery, getExpandFilterQueries); /* HighlightingParameters */ PHP_METHOD(SolrQuery, setHighlight); PHP_METHOD(SolrQuery, getHighlight); PHP_METHOD(SolrQuery, addHighlightField); PHP_METHOD(SolrQuery, removeHighlightField); PHP_METHOD(SolrQuery, getHighlightFields); PHP_METHOD(SolrQuery, setHighlightSnippets); PHP_METHOD(SolrQuery, getHighlightSnippets); PHP_METHOD(SolrQuery, setHighlightFragsize); PHP_METHOD(SolrQuery, getHighlightFragsize); PHP_METHOD(SolrQuery, setHighlightMergeContiguous); PHP_METHOD(SolrQuery, getHighlightMergeContiguous); PHP_METHOD(SolrQuery, setHighlightRequireFieldMatch); PHP_METHOD(SolrQuery, getHighlightRequireFieldMatch); PHP_METHOD(SolrQuery, setHighlightMaxAnalyzedChars); PHP_METHOD(SolrQuery, getHighlightMaxAnalyzedChars); PHP_METHOD(SolrQuery, setHighlightAlternateField); PHP_METHOD(SolrQuery, getHighlightAlternateField); PHP_METHOD(SolrQuery, setHighlightMaxAlternateFieldLength); PHP_METHOD(SolrQuery, getHighlightMaxAlternateFieldLength); PHP_METHOD(SolrQuery, setHighlightFormatter); PHP_METHOD(SolrQuery, getHighlightFormatter); PHP_METHOD(SolrQuery, setHighlightSimplePre); PHP_METHOD(SolrQuery, getHighlightSimplePre); PHP_METHOD(SolrQuery, setHighlightSimplePost); PHP_METHOD(SolrQuery, getHighlightSimplePost); PHP_METHOD(SolrQuery, setHighlightFragmenter); PHP_METHOD(SolrQuery, getHighlightFragmenter); PHP_METHOD(SolrQuery, setHighlightUsePhraseHighlighter); PHP_METHOD(SolrQuery, getHighlightUsePhraseHighlighter); PHP_METHOD(SolrQuery, setHighlightHighlightMultiTerm); PHP_METHOD(SolrQuery, getHighlightHighlightMultiTerm); PHP_METHOD(SolrQuery, setHighlightRegexSlop); PHP_METHOD(SolrQuery, getHighlightRegexSlop); PHP_METHOD(SolrQuery, setHighlightRegexPattern); PHP_METHOD(SolrQuery, getHighlightRegexPattern); PHP_METHOD(SolrQuery, setHighlightRegexMaxAnalyzedChars); PHP_METHOD(SolrQuery, getHighlightRegexMaxAnalyzedChars); /* StatsComponent */ PHP_METHOD(SolrQuery, setStats); PHP_METHOD(SolrQuery, getStats); PHP_METHOD(SolrQuery, addStatsField); PHP_METHOD(SolrQuery, removeStatsField); PHP_METHOD(SolrQuery, getStatsFields); PHP_METHOD(SolrQuery, addStatsFacet); PHP_METHOD(SolrQuery, removeStatsFacet); PHP_METHOD(SolrQuery, getStatsFacets); /* MoreLikeThis */ PHP_METHOD(SolrQuery, setMlt); PHP_METHOD(SolrQuery, getMlt); PHP_METHOD(SolrQuery, setMltCount); PHP_METHOD(SolrQuery, getMltCount); PHP_METHOD(SolrQuery, addMltField); PHP_METHOD(SolrQuery, removeMltField); PHP_METHOD(SolrQuery, getMltFields); PHP_METHOD(SolrQuery, addMltQueryField); PHP_METHOD(SolrQuery, removeMltQueryField); PHP_METHOD(SolrQuery, getMltQueryFields); PHP_METHOD(SolrQuery, setMltMinTermFrequency); PHP_METHOD(SolrQuery, getMltMinTermFrequency); PHP_METHOD(SolrQuery, setMltMinDocFrequency); PHP_METHOD(SolrQuery, getMltMinDocFrequency); PHP_METHOD(SolrQuery, setMltMinWordLength); PHP_METHOD(SolrQuery, getMltMinWordLength); PHP_METHOD(SolrQuery, setMltMaxWordLength); PHP_METHOD(SolrQuery, getMltMaxWordLength); PHP_METHOD(SolrQuery, setMltMaxNumTokens); PHP_METHOD(SolrQuery, getMltMaxNumTokens); PHP_METHOD(SolrQuery, setMltMaxNumQueryTerms); PHP_METHOD(SolrQuery, getMltMaxNumQueryTerms); PHP_METHOD(SolrQuery, setMltBoost); PHP_METHOD(SolrQuery, getMltBoost); /* TermsComponent */ PHP_METHOD(SolrQuery, setTerms); PHP_METHOD(SolrQuery, getTerms); PHP_METHOD(SolrQuery, setTermsField); PHP_METHOD(SolrQuery, getTermsField); PHP_METHOD(SolrQuery, setTermsLowerBound); PHP_METHOD(SolrQuery, getTermsLowerBound); PHP_METHOD(SolrQuery, setTermsUpperBound); PHP_METHOD(SolrQuery, getTermsUpperBound); PHP_METHOD(SolrQuery, setTermsIncludeLowerBound); PHP_METHOD(SolrQuery, getTermsIncludeLowerBound); PHP_METHOD(SolrQuery, setTermsIncludeUpperBound); PHP_METHOD(SolrQuery, getTermsIncludeUpperBound); PHP_METHOD(SolrQuery, setTermsMinCount); PHP_METHOD(SolrQuery, getTermsMinCount); PHP_METHOD(SolrQuery, setTermsMaxCount); PHP_METHOD(SolrQuery, getTermsMaxCount); PHP_METHOD(SolrQuery, setTermsPrefix); PHP_METHOD(SolrQuery, getTermsPrefix); PHP_METHOD(SolrQuery, setTermsLimit); PHP_METHOD(SolrQuery, getTermsLimit); PHP_METHOD(SolrQuery, setTermsReturnRaw); PHP_METHOD(SolrQuery, getTermsReturnRaw); PHP_METHOD(SolrQuery, setTermsSort); PHP_METHOD(SolrQuery, getTermsSort); /* TODO : TermVectorComponent */ /* {{{ TermVectorComponent methods not yet defined */ PHP_METHOD(SolrQuery, setTermVector); PHP_METHOD(SolrQuery, setTermVectorTermFrequency); PHP_METHOD(SolrQuery, setTermVectorDocFrequency); PHP_METHOD(SolrQuery, setTermVectorPositions); PHP_METHOD(SolrQuery, setTermVectorOffsets); PHP_METHOD(SolrQuery, setTermVectorTfIdfProduct); PHP_METHOD(SolrQuery, setTermVectorAll); PHP_METHOD(SolrQuery, addTermVectorField); PHP_METHOD(SolrQuery, addTermVectorLuceneDocId); /* }}} */ /* }}} */ /* {{{ SolrResponse methods declarations */ PHP_METHOD(SolrResponse, getHttpStatus); PHP_METHOD(SolrResponse, getHttpStatusMessage); PHP_METHOD(SolrResponse, success); PHP_METHOD(SolrResponse, getRequestUrl); PHP_METHOD(SolrResponse, getRawRequestHeaders); PHP_METHOD(SolrResponse, getRawRequest); PHP_METHOD(SolrResponse, getRawResponseHeaders); PHP_METHOD(SolrResponse, getRawResponse); PHP_METHOD(SolrResponse, getDigestedResponse); PHP_METHOD(SolrResponse, setParseMode); PHP_METHOD(SolrResponse, getArrayResponse); PHP_METHOD(SolrResponse, getResponse); /* }}} */ /* {{{ SolrQueryResponse methods */ PHP_METHOD(SolrQueryResponse, __construct); PHP_METHOD(SolrQueryResponse, __destruct); /* }}} */ /* {{{ SolrUpdateResponse methods */ PHP_METHOD(SolrUpdateResponse, __construct); PHP_METHOD(SolrUpdateResponse, __destruct); /* }}} */ /* {{{ SolrPingResponse methods declarations */ PHP_METHOD(SolrPingResponse, __construct); PHP_METHOD(SolrPingResponse, __destruct); PHP_METHOD(SolrPingResponse, getResponse); /* }}} */ /* {{{ SolrGenericResponse methods */ PHP_METHOD(SolrGenericResponse, __construct); PHP_METHOD(SolrGenericResponse, __destruct); /* }}} */ /* {{{ SolrCollapseFunction methods */ PHP_METHOD(SolrCollapseFunction, __construct); PHP_METHOD(SolrCollapseFunction, __destruct); PHP_METHOD(SolrCollapseFunction, setField); PHP_METHOD(SolrCollapseFunction, getField); PHP_METHOD(SolrCollapseFunction, setMin); PHP_METHOD(SolrCollapseFunction, getMin); PHP_METHOD(SolrCollapseFunction, setMax); PHP_METHOD(SolrCollapseFunction, getMax); PHP_METHOD(SolrCollapseFunction, setNullPolicy); PHP_METHOD(SolrCollapseFunction, getNullPolicy); PHP_METHOD(SolrCollapseFunction, setHint); PHP_METHOD(SolrCollapseFunction, getHint); PHP_METHOD(SolrCollapseFunction, setSize); PHP_METHOD(SolrCollapseFunction, getSize); PHP_METHOD(SolrCollapseFunction, __toString); PHP_METHOD(SolrCollapseFunction, __sleep); PHP_METHOD(SolrCollapseFunction, __wakeup); /* }}} */ /* {{{ SolrUtils methods declarations */ PHP_METHOD(SolrUtils, escapeQueryChars); PHP_METHOD(SolrUtils, queryPhrase); PHP_METHOD(SolrUtils, digestXmlResponse); PHP_METHOD(SolrUtils, digestJsonResponse); PHP_METHOD(SolrUtils, getSolrVersion); PHP_METHOD(SolrUtils, getSolrStats); /* }}} */ /******************************************************************************/ /** DECLARATIONS FOR HELPERS AND EXTENSION-SPECIFIC FUNCTIONS **/ /******************************************************************************/ /* {{{ HTTP request function declarations */ size_t solr_curl_write(solr_char_t *data, size_t size, size_t nmemb, void *ctx); size_t solr_curl_write_header(solr_char_t *data, size_t size, size_t nmemb, void *ctx); int solr_curl_debug_callback(CURL *curl_handle, curl_infotype infotype, solr_char_t *debug_data, size_t size, void *ctx); PHP_SOLR_API int solr_init_options(solr_client_options_t *options TSRMLS_DC); PHP_SOLR_API int solr_init_handle(solr_curl_t *sch, solr_client_options_t *options TSRMLS_DC); PHP_SOLR_API int solr_make_request(solr_client_t *client, solr_request_type_t request_type TSRMLS_DC); PHP_SOLR_API void solr_free_handle(solr_curl_t *sch); PHP_SOLR_API void solr_free_option(solr_client_options_t *options); /* }}} */ PHP_SOLR_API void solr_extension_register_constants(int type, int module_number TSRMLS_DC); PHP_SOLR_API void solr_document_register_class_constants(zend_class_entry *ce TSRMLS_DC); PHP_SOLR_API void solr_client_register_class_constants(zend_class_entry *ce TSRMLS_DC); PHP_SOLR_API void solr_query_register_class_constants(zend_class_entry *ce TSRMLS_DC); PHP_SOLR_API void solr_collapse_function_register_class_constants(zend_class_entry *ce TSRMLS_DC); PHP_SOLR_API void solr_response_register_class_properties(zend_class_entry *ce TSRMLS_DC); PHP_SOLR_API void solr_response_register_class_constants(zend_class_entry *ce TSRMLS_DC); PHP_SOLR_API void solr_exception_register_class_properties(zend_class_entry *ce TSRMLS_DC); PHP_SOLR_API void solr_set_response_object_properties(zend_class_entry *scope, zval *response_object, const solr_client_t *client, const solr_string_t *request_url, zend_bool success TSRMLS_DC); PHP_SOLR_API void solr_throw_exception_ex(zend_class_entry *exception_ce, long code TSRMLS_DC, const char *filename, int file_line, const char *function_name, char *format, ...); PHP_SOLR_API void solr_throw_exception(zend_class_entry *exception_ce, char *message, long code TSRMLS_DC, const char *filename, int file_line, const char *function_name); PHP_SOLR_API void solr_throw_solr_server_exception(solr_client_t *client,const char *requestType TSRMLS_DC); /* {{{ init functions called in constructors - allocate/initialize params_t */ PHP_SOLR_API int solr_init_params(solr_params_t *solr_params, long int index); /* }}} */ /* {{{ solr_document_t based objects methods*/ PHP_SOLR_API solr_document_t *solr_init_document(long int document_index); PHP_SOLR_API solr_document_t *solr_input_doc_ctor(zval *objptr); PHP_SOLR_API zend_object *solr_document_object_handler_clone(zval *zobject TSRMLS_DC); /* }}} */ /* {{{ zend_hash_free functions */ PHP_SOLR_API void solr_destroy_field_list_ht_dtor(zval *zv_field_entry); PHP_SOLR_API void solr_destroy_field_list(solr_field_list_t *field_entry); PHP_SOLR_API void solr_destroy_client(zval *client); PHP_SOLR_API void solr_destroy_document_zv(zval *document); PHP_SOLR_API void solr_destroy_document_ex(solr_document_t *document); #ifdef PHP_7 #define solr_destroy_document solr_destroy_document_zv #else #define solr_destroy_document solr_destroy_document_ex #endif PHP_SOLR_API void solr_destroy_params(zval *solr_params); PHP_SOLR_API void solr_destroy_function(zval *solr_function); PHP_SOLR_API void solr_destory_param_ht_dtor(zval *param_zv); PHP_SOLR_API void solr_destroy_param(solr_param_t **param); /* dead */ PHP_SOLR_API void solr_destroy_param_value(solr_param_t *param, solr_param_value_t *param_value); /* }}} */ #ifdef PHP_7 #define field_copy_constructor field_copy_constructor_zv #else #define field_copy_constructor field_copy_constructor_ex #endif /* {{{ used for SolrDocument field manipulations */ PHP_SOLR_API int solr_document_insert_field_value(solr_field_list_t *queue, const solr_char_t *field_value, double field_boost); PHP_SOLR_API void field_copy_constructor_ex(solr_field_list_t **original_field_queue); PHP_SOLR_API void field_copy_constructor_zv(zval *field_queue_zv); /* }}} */ /* {{{ Used for comparison of document fields */ PHP_SOLR_API int solr_compare_field_name (const void *a, const void *b TSRMLS_DC); PHP_SOLR_API int solr_rcompare_field_name(const void *a, const void *b TSRMLS_DC); PHP_SOLR_API int solr_compare_field_value_count (const void *a, const void *b TSRMLS_DC); PHP_SOLR_API int solr_rcompare_field_value_count(const void *a, const void *b TSRMLS_DC); PHP_SOLR_API int solr_compare_field_boost_value (const void *a, const void *b TSRMLS_DC); PHP_SOLR_API int solr_rcompare_field_boost_value(const void *a, const void *b TSRMLS_DC); /* }}} */ /* {{{ Functions for SolrParams Parameters */ PHP_SOLR_API solr_param_t *solr_create_new_param(const solr_char_t *param_name, size_t param_name_len, solr_param_type_t param_type, solr_bool allow_multiple, solr_param_value_equal_func_t value_equal_func, solr_param_fetch_func_t param_fetch_func, solr_param_value_free_func_t value_free_func, solr_char_t delimiter, solr_char_t arg_separator TSRMLS_DC); PHP_SOLR_API int solr_params_insert_param_value(solr_param_t *param, solr_param_value_t *param_value); PHP_SOLR_API int solr_params_delete_param_value(solr_param_t *param, const solr_param_value_t *target_value TSRMLS_DC); PHP_SOLR_API int solr_delete_solr_parameter(zval *objptr, solr_char_t *name, int name_length TSRMLS_DC); PHP_SOLR_API int solr_add_or_set_normal_param(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length, solr_bool allow_multiple TSRMLS_DC); PHP_SOLR_API int solr_add_simple_list_param(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC); PHP_SOLR_API int solr_add_simple_list_param_ex(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length, solr_char_t *separator TSRMLS_DC); PHP_SOLR_API int solr_add_arg_list_param(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length, solr_char_t *avalue, int avalue_length, solr_char_t delimiter, solr_char_t arg_separator TSRMLS_DC); PHP_SOLR_API int solr_add_arg_list_param_ex(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length, solr_char_t *avalue, int avalue_length, solr_char_t delimiter, solr_char_t arg_separator, solr_char_t delimiter_override TSRMLS_DC); PHP_SOLR_API solr_param_value_t* create_parameter_value_arg_list(solr_char_t *pvalue, int pvalue_length, solr_char_t *avalue, int avalue_length, solr_char_t *delimiter_override, solr_bool delimiter_overriden TSRMLS_DC); #define solr_set_normal_param(objptr, pname, pname_length, pvalue, pvalue_length) solr_add_or_set_normal_param((objptr), (pname), (pname_length), (pvalue), (pvalue_length), 0 TSRMLS_CC) #define solr_add_normal_param(objptr, pname, pname_length, pvalue, pvalue_length) solr_add_or_set_normal_param((objptr), (pname), (pname_length), (pvalue), (pvalue_length), 1 TSRMLS_CC) PHP_SOLR_API int solr_normal_param_value_equal(const solr_param_value_t *a, const solr_param_value_t *b); PHP_SOLR_API int solr_simple_list_param_value_equal(const solr_param_value_t *a, const solr_param_value_t *b); PHP_SOLR_API int solr_arg_list_param_value_equal(const solr_param_value_t *a, const solr_param_value_t *b); PHP_SOLR_API void solr_normal_param_value_fetch(solr_param_t *solr_param, solr_string_t *buffer); PHP_SOLR_API void solr_simple_list_param_value_fetch(solr_param_t *solr_param, solr_string_t *buffer); PHP_SOLR_API void solr_arg_list_param_value_fetch(solr_param_t *solr_param, solr_string_t *buffer); PHP_SOLR_API void solr_normal_param_value_display(solr_param_t *solr_param, zval *param_value_array); PHP_SOLR_API void solr_simple_list_param_value_display(solr_param_t *solr_param, zval *param_value_array); PHP_SOLR_API void solr_arg_list_param_value_display(solr_param_t *solr_param, zval *param_value_array); /* Used to display values where allow_multiple is false */ PHP_SOLR_API void solr_normal_param_value_display_string(solr_param_t *solr_param, zval *param_value); PHP_SOLR_API void solr_normal_param_value_display_integer(solr_param_t *solr_param, zval *param_value); PHP_SOLR_API void solr_normal_param_value_display_double(solr_param_t *solr_param, zval *param_value); PHP_SOLR_API void solr_normal_param_value_display_boolean(solr_param_t *solr_param, zval *param_value); PHP_SOLR_API void solr_normal_param_value_display_sort_type(solr_param_t *solr_param, zval *param_value); PHP_SOLR_API int solr_param_find(zval *objptr, solr_char_t *pname, int pname_length, solr_param_t **solr_param TSRMLS_DC); PHP_SOLR_API void solr_normal_param_value_tostring(solr_param_t *solr_param, solr_string_t *buffer, zend_bool url_encode); PHP_SOLR_API void solr_simple_list_param_value_tostring(solr_param_t *solr_param, solr_string_t *buffer, zend_bool url_encode); PHP_SOLR_API void solr_arg_list_param_value_tostring(solr_param_t *solr_param, solr_string_t *buffer, zend_bool url_encode); PHP_SOLR_API void solr_normal_param_value_free(solr_param_value_t *param_value); PHP_SOLR_API void solr_simple_list_param_value_free(solr_param_value_t *param_value); PHP_SOLR_API void solr_arg_list_param_value_free(solr_param_value_t *param_value); /* Used for removing parameter values from the list of values for that param */ PHP_SOLR_API int solr_delete_normal_param_value(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC); PHP_SOLR_API int solr_delete_simple_list_param_value(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC); PHP_SOLR_API int solr_delete_arg_list_param_value(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC); /* }}} */ /* {{{ Debugging functions */ /* Debug function used to print field values in the field queue */ PHP_SOLR_API void solr_debug_print_fields(const solr_field_list_t *queue); /* Used when debugging is enabled to run in verbose mode */ PHP_SOLR_API void solr_debug_printf(const char *format, ...); /* }}} */ /* {{{ Document utility functions */ PHP_SOLR_API void solr_generate_document_xml_from_fields(xmlNode *solr_doc_node, HashTable *document_fields TSRMLS_DC); PHP_SOLR_API void solr_create_document_field_object(solr_field_list_t *field_values, zval **field_obj TSRMLS_DC); PHP_SOLR_API void solr_add_doc_node(xmlNode *root_node, solr_document_t *doc_entry TSRMLS_DC); PHP_SOLR_API xmlDocPtr solr_xml_create_xml_doc(const xmlChar *root_node_name, xmlNode **root_node_ptr); /* }}} */ /* {{{ identical functions used on both SolrDocument and SolrInputDocument */ PHP_SOLR_API void solr_document_get_field_names(INTERNAL_FUNCTION_PARAMETERS); /* }}} */ /* {{{ Utility functions */ PHP_SOLR_API long solr_get_json_last_error(TSRMLS_D); PHP_SOLR_API solr_char_t *solr_get_json_error_msg(solr_json_error_codes_t error_code); PHP_SOLR_API int solr_json_to_php_native(solr_string_t *buffer, const solr_char_t *json_string, int json_string_length TSRMLS_DC); PHP_SOLR_API int solr_is_supported_response_writer(const solr_char_t * response_writer, int length); PHP_SOLR_API int solr_hashtable_get_new_index(HashTable *ht TSRMLS_DC); PHP_SOLR_API int solr_fetch_document_entry(zval *objptr, solr_document_t **doc_entry TSRMLS_DC); PHP_SOLR_API int solr_fetch_client_entry(zval *objptr, solr_client_t **solr_client TSRMLS_DC); PHP_SOLR_API int solr_fetch_params_entry(zval *objptr, solr_params_t **solr_params TSRMLS_DC); PHP_SOLR_API int solr_fetch_function_entry(zval *objptr, solr_function_t **solr_params TSRMLS_DC); PHP_SOLR_API void solr_encode_generic_xml_response(solr_string_t *buffer, const solr_char_t *serialized, int size, long int parse_mode TSRMLS_DC); PHP_SOLR_API void solr_set_return_solr_params_object(zval *return_value_ptr, zval *current_objptr TSRMLS_DC); PHP_SOLR_API void solr_escape_query_chars(solr_string_t *sbuilder, solr_char_t *unescaped, long int unescaped_length); /* serialized array to serialized SolrObject */ PHP_SOLR_API int solr_sarray_to_sobject(solr_string_t *buffer TSRMLS_DC); PHP_SOLR_API int solr_sobject_to_sarray(solr_string_t *buffer TSRMLS_DC); PHP_SOLR_API void solr_response_get_response_impl(INTERNAL_FUNCTION_PARAMETERS, int return_array); /* }}} */ /* {{{ SolrFunction Helpers (solrfunc to avoid confusion with solr_function) */ PHP_SOLR_API int solr_solrfunc_update_string(zval *obj, solr_char_t *key, int key_len, solr_char_t *value, int value_len TSRMLS_DC); PHP_SOLR_API int solr_solrfunc_fetch_string(zval *obj, solr_char_t *key, int key_len, solr_string_t **string TSRMLS_DC); PHP_SOLR_API int solr_solrfunc_return_string(zval *obj, solr_char_t *key, int key_len, zval **return_value TSRMLS_DC); PHP_SOLR_API void solr_solrfunc_to_string(solr_function_t *function, solr_string_t **dest); PHP_SOLR_API int solr_solrfunc_display_string(zval *obj, solr_char_t *key, int key_len, zval **return_value TSRMLS_DC); zend_object *solr_collapse_function_object_handler_clone(zval *object TSRMLS_DC); /* }}} */ /* {{{ Solr Server Exception Handling */ PHP_SOLR_API int solr_get_xml_error(solr_string_t buffer, solr_exception_t *exceptionData TSRMLS_DC); PHP_SOLR_API int solr_get_json_error(solr_string_t buffer, solr_exception_t *exceptionData TSRMLS_DC); PHP_SOLR_API int solr_get_phpnative_error(solr_string_t buffer, solr_exception_t *exceptionData TSRMLS_DC); PHP_SOLR_API int hydrate_error_zval(zval *response, solr_exception_t *exceptionData TSRMLS_DC); /* }}} */ /* {{{ Solr Object Handlers */ #if PHP_VERSION_ID < 50399 PHP_SOLR_API void solr_object_write_property(zval *object, zval *member, zval *value TSRMLS_DC); PHP_SOLR_API zval *solr_object_read_property(zval *object, zval *member, int type TSRMLS_DC); PHP_SOLR_API void solr_object_unset_property(zval *object, zval *member TSRMLS_DC); #elif PHP_VERSION_ID < 70000 PHP_SOLR_API void solr_object_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC); PHP_SOLR_API zval *solr_object_read_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC); PHP_SOLR_API void solr_object_unset_property(zval *object, zval *member, const zend_literal *key TSRMLS_DC); #else PHP_SOLR_API void solr_object_write_property(zval *object, zval *member, zval *value, void **cache_slot); PHP_SOLR_API zval *solr_object_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv); PHP_SOLR_API void solr_object_unset_property(zval *object, zval *member, void **cache_slot); #endif PHP_SOLR_API void solr_object_write_dimension(zval *object, zval *offset, zval *value TSRMLS_DC); PHP_SOLR_API void solr_object_unset_dimension(zval *object, zval *offset TSRMLS_DC); #if PHP_VERSION_ID < 50399 PHP_SOLR_API void solr_document_field_write_property(zval *object, zval *member, zval *value TSRMLS_DC); PHP_SOLR_API void solr_document_field_unset_property(zval *object, zval *member TSRMLS_DC); #elif PHP_VERSION_ID < 70000 PHP_SOLR_API void solr_document_field_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC); PHP_SOLR_API void solr_document_field_unset_property(zval *object, zval *member, const zend_literal *key TSRMLS_DC); #else PHP_SOLR_API void solr_document_field_write_property(zval *object, zval *member, zval *value, void **cache_slot); PHP_SOLR_API void solr_document_field_unset_property(zval *object, zval *member, void **cache_slot); #endif /* }}} */ int add_phrase_field(zval *obj, solr_char_t *pname, zval *boost, zval *slop, solr_char_t *field_name, COMPAT_ARG_SIZE_T field_name_len TSRMLS_DC); #include "solr_macros.h" #include "php_solr_dismax_query.h" #endif /* HAVE_SOLR */ #endif /* SOLRCLIENT_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/php_solr_api.h0000644000175000017500000000357212676753706015501 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Israel Ekpo | +----------------------------------------------------------------------+ */ /* $Id$ */ /** * Declaring Macro for function attributes * * This is for functions on GNU systems and Win32 systems * * On Win32 systems __declspec(dllexport) adds the export directive to the * object file so you do not need to use a .def file * * Using __declspec(dllexport) in addition to using a .def file should * not cause build errors. */ #ifndef PHP_SOLR_API_H #define PHP_SOLR_API_H #ifdef PHP_WIN32 #define PHP_SOLR_API __declspec(dllexport) #elif defined(__GNUC__) && __GNUC__ >= 4 #define PHP_SOLR_API __attribute__ ((visibility("default"))) #else #define PHP_SOLR_API #endif #endif /* PHP_SOLR_API_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/php_solr_version.h0000644000175000017500000000507512676753706016415 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_version.h" #ifndef PHP_SOLR_VERSION_H #define PHP_SOLR_VERSION_H #define PHP_SOLR_MAJOR_VERSION 2 #define PHP_SOLR_MINOR_VERSION 4 #define PHP_SOLR_PATCH_VERSION 0 #define PHP_SOLR_RELEASE_VERSION PHP_SOLR_PATCH_VERSION #define PHP_SOLR_VERSION "2.4.0" #define PHP_SOLR_DOTTED_VERSION PHP_SOLR_VERSION /** * Extension version numbers using hexadecimal numbers * * This is the numeric version of the extension, meant for easier * parsing and comparisons by programs. The PHP_SOLR_VERSION_ID define will * always follow this syntax: * * 0xXXYYZZ * * Where XX, YY and ZZ are the main version, minor version and patch numbers in * hexadecimal (using 8 bits each). All three numbers are always represented * using two digits. 1.2 would appear as "0x010200" while version 9.11.7 * appears as "0x090b07". * * This 6-digit (24 bits) hexadecimal number does not show pre-release number, * and it is always a greater number in a more recent release. It makes * comparisons with greater than and less than work. */ #define PHP_SOLR_VERSION_ID 0x020400 #define SOLR_CLIENT_USER_AGENT "PHP Solr Client 2.4.0" #endif /* PHP_SOLR_VERSION_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/php_solr_bc_macros.h0000644000175000017500000000611112676753707016651 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Israel Ekpo | +----------------------------------------------------------------------+ */ /* $Id$ */ /** * PHP 5 backward compatibility macros * * With the arrival of ZE 2.3.0, some of the member structures of the zval struct * were renamed. These macros will allow us to still be able to use the * new macros introduced since php 5.3.0 to compile code in the PHP 5.2.x series. * * We should allow up to php version 5.2.11. The latest stable release as of the * time of the initial release of this extension. */ #ifndef PHP_SOLR_BC_MACROS_H #define PHP_SOLR_BC_MACROS_H /* Retrieves the refcount */ #ifndef Z_REFCOUNT_P #define Z_REFCOUNT_P(pz) (pz)->refcount; #define Z_REFCOUNT_PP(ppz) Z_REFCOUNT_P(*(ppz)) #endif /* Sets the refcount to the specified value. */ #ifndef Z_SET_REFCOUNT_P #define Z_SET_REFCOUNT_P(pz, rc) (pz)->refcount = rc; #define Z_SET_REFCOUNT_PP(ppz) Z_SET_REFCOUNT_P((*ppz), rc) #endif /* Increases the recount by 1 */ #ifndef Z_ADDREF_P #define Z_ADDREF_P(pz) (pz)->refcount++; #define Z_ADDREF_PP(ppz) Z_ADDREF_P(*(ppz)) #endif /* Reduces the refcount by 1 */ #ifndef Z_DELREF_P #define Z_DELREF_P(pz) (pz)->refcount--; #define Z_DELREF_PP(ppz) Z_DELREF_P(*(ppz)) #endif /* Sets the isref member on the zval */ #ifndef Z_SET_ISREF_P #define Z_SET_ISREF_P(pz) (pz)->is_ref = 1; #define Z_SET_ISREF_PP(ppz) Z_SET_ISREF_P(*(ppz)) #endif /* Unsets the isref member on the zval */ #ifndef Z_UNSET_ISREF_P #define Z_UNSET_ISREF_P(pz) (pz)->is_ref = 0; #define Z_UNSET_ISREF_PP(ppz ) Z_UNSET_ISREF_P(*(ppz)) #endif /* Checks if is_ref is set on the zval */ #ifndef Z_ISREF_P #define Z_ISREF_P(pz) ((pz)->is_ref) #define Z_ISREF_PP(ppz) Z_ISREF_P(*(ppz)) #endif /* Sets the is_ref member to the specified value */ #ifndef Z_SET_ISREF_TO_P #define Z_SET_ISREF_TO_P(pz, isref) (pz)->is_ref = is_ref; #define Z_SET_ISREF_TO_PP(ppz, isref) Z_SET_ISREF_TO_P(*(ppz), isref) #endif #endif /* PHP_SOLR_BC_MACROS_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/solr_constants.h0000644000175000017500000001757012676753707016101 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #ifndef SOLR_CONSTANTS_H #define SOLR_CONSTANTS_H #include "php_solr_version.h" #define SOLR_SPACE_STRING " " /* {{{ Constants for the SolrClient with*/ #define SOLR_DEFAULT_UPDATE_SERVLET "update" #define SOLR_DEFAULT_SEARCH_SERVLET "select" #define SOLR_DEFAULT_THREADS_SERVLET "admin/threads" #define SOLR_DEFAULT_PING_SERVLET "admin/ping" #define SOLR_DEFAULT_TERMS_SERVLET "terms" #define SOLR_DEFAULT_SYSTEM_SERVLET "admin/system" #define SOLR_DEFAULT_GET_SERVLET "get" #define SOLR_PHP_SERIALIZED_RESPONSE_WRITER "phps" #define SOLR_PHP_NATIVE_RESPONSE_WRITER "phpnative" #define SOLR_XML_RESPONSE_WRITER "xml" #define SOLR_JSON_RESPONSE_WRITER "json" #define SOLR_REQUEST_DEFAULT_HOST "localhost" #define SOLR_REQUEST_DEFAULT_PATH "solr" #define SOLR_REQUEST_DEFAULT_QS_DELIMITER "&" #define SOLR_REQUEST_DEFAULT_PORT 8983L #define SOLR_CURL_MAX_WRITE_SIZE CURL_MAX_WRITE_SIZE #define SOLR_CURL_OPTIONS_LENGTH 512 /* }}} */ /* {{{ Names of Objects */ #define PHP_SOLR_OBJECT_CLASSNAME "SolrObject" #define PHP_SOLR_DOCUMENT_CLASSNAME "SolrDocument" #define PHP_SOLR_DOCUMENT_FIELD_CLASSNAME "SolrDocumentField" #define PHP_SOLR_INPUT_DOCUMENT_CLASSNAME "SolrInputDocument" #define PHP_SOLR_CLIENT_CLASSNAME "SolrClient" #define PHP_SOLR_PARAMS_CLASSNAME "SolrParams" #define PHP_SOLR_QUERY_CLASSNAME "SolrQuery" #define PHP_SOLR_COLLAPSE_FUNCTION_CLASSNAME "SolrCollapseFunction" #define PHP_SOLR_MODIFIABLE_PARAMS_CLASSNAME "SolrModifiableParams" #define PHP_SOLR_RESPONSE_CLASSNAME "SolrResponse" #define PHP_SOLR_QUERY_RESPONSE_CLASSNAME "SolrQueryResponse" #define PHP_SOLR_UPDATE_RESPONSE_CLASSNAME "SolrUpdateResponse" #define PHP_SOLR_PING_RESPONSE_CLASSNAME "SolrPingResponse" #define PHP_SOLR_GENERIC_RESPONSE_CLASSNAME "SolrGenericResponse" #define PHP_SOLR_UTILS_CLASSNAME "SolrUtils" #define PHP_SOLR_EXCEPTION_CLASSNAME "SolrException" #define PHP_SOLR_ILLEGAL_OPERATION_EXCEPTION_CLASSNAME "SolrIllegalOperationException" #define PHP_SOLR_ILLEGAL_ARGUMENT_EXCEPTION_CLASSNAME "SolrIllegalArgumentException" #define PHP_SOLR_CLIENT_EXCEPTION_CLASSNAME "SolrClientException" #define PHP_SOLR_SERVER_EXCEPTION_CLASSNAME "SolrServerException" #define PHP_SOLR_MISSING_MANDATORY_PARAMETER_EXCEPTION_CLASSNAME "SolrMissingMandatoryParameterException" /* }}} */ /* {{{ Informational constants */ #define PHP_SOLR_EXTENSION_NAME "solr" #define PHP_CURL_EXTENSION_NAME "curl" #define PHP_LIBXML_EXTENSION_NAME "libxml" #define PHP_JSON_EXTENSION_NAME "json" /* }}} */ /* {{{ Property names */ #define SOLR_INDEX_PROPERTY_NAME "_hashtable_index" #define SOLR_FIELD_NAME_PROPERTY_NAME "name" #define SOLR_FIELD_BOOST_PROPERTY_NAME "boost" #define SOLR_FIELD_VALUES_PROPERTY_NAME "values" #define SOLR_SOURCELINE_NO_PROPERTY_NAME "sourceline" #define SOLR_SOURCEFILE_PROPERTY_NAME "sourcefile" #define SOLR_ZIFNAME_PROPERTY_NAME "zif_name" #define SOLR_DISMAX_DEFAULT_PARSER "edismax" #ifdef PHP_WIN32 #define __func__ __FUNCTION__ #endif #define SOLR_FILE_LINE_FUNC __FILE__, __LINE__, __func__ /* }}} */ /* {{{ Constants for Method/Function arguments and return styles */ #define SOLR_ARG_PASS_BY_REF_FALSE 0 #define SOLR_ARG_PASS_BY_REF_TRUE 1 #define SOLR_ARG_PASS_REMAINING_BY_REF_FALSE 0 #define SOLR_ARG_PASS_REMAINING_BY_REF_TRUE 1 #define SOLR_ARG_ALLOW_NULL_FALSE 0 #define SOLR_ARG_ALLOW_NULL_TRUE 1 #define SOLR_METHOD_RETURN_REFERENCE_FALSE 0 #define SOLR_METHOD_RETURN_REFERENCE_TRUE 1 /* }}} */ /* {{{ Constants for Sorting SolrDocument Fields */ #define SOLR_SORT_ASC 1 #define SOLR_SORT_DESC 2 #define SOLR_SORT_FIELD_NAME 1 #define SOLR_SORT_FIELD_VALUE_COUNT 2 #define SOLR_SORT_FIELD_BOOST_VALUE 4 /* }}} */ /* {{{ Constants for document encoding formats */ #define SOLR_XML_ENCODE_OBJ 0L #define SOLR_XML_ENCODE_DOC 1L /* }}} */ /** * Setting this to 8 gets rid of the extra while loops in _zend_hash_init() * * _zend_hash_init loops 3 times to increase the value of the size to 8 */ #define SOLR_INITIAL_HASH_TABLE_SIZE (1<<3) /* {{{ Memory Allocation Related Constants */ #define SOLR_HASHTABLE_PERSISTENT 0 #define SOLR_DOCUMENT_PERSISTENT 0 #define SOLR_DOCUMENT_FIELD_PERSISTENT 0 #define SOLR_CLIENT_PERSISTENT 0 #define SOLR_PARAMS_PERSISTENT 0 #define SOLR_FUNCTIONS_PERSISTENT 0 /* }}} */ /* {{{ SolrException Codes : Internal and UserSpace */ /* {{{ Error codes and messages */ #define SOLR_ERROR_1000 1000L #define SOLR_ERROR_1000_MSG "Error un-serializing response" #define SOLR_ERROR_1001 1001L #define SOLR_ERROR_1001_MSG "SolrClient objects cannot be serialized or unserialized" #define SOLR_ERROR_1002 1002L #define SOLR_ERROR_1002_MSG "The '%s' property cannot be removed or set to NULL. SolrObject properties cannot be unset or set to NULL." #define SOLR_ERROR_1003 1003L #define SOLR_ERROR_1003_MSG "Error building HTTP query from parameters" #define SOLR_ERROR_1004 1004L #define SOLR_ERROR_1004_MSG "Unsuccessful HTTP request" #define SOLR_ERROR_1005 1005L #define SOLR_ERROR_1005_MSG "SolrInputDocument objects cannot be serialized or unserialized" #define SOLR_ERROR_1006 1006L #define SOLR_ERROR_1006_MSG "SolrObject instances are read-only. Properties cannot be added, updated or removed." #define SOLR_ERROR_1007 1007L #define SOLR_ERROR_1007_MSG "SolrDocumentField instances are read-only. Properties cannot be updated or removed." #define SOLR_ERROR_1008 1008L #define SOLR_ERROR_1008_MSG "Internal Error 1008 generated from %s %d %s. The observed error is a possible side-effect of an illegal/unsupported operation in userspace. Please check the documentation and try again later." #define SOLR_ERROR_1009 1009L #define SOLR_ERROR_1009_MSG "The observed error is a possible side-effect of an illegal/unsupported operation in userspace. This object cannot be cloned. Cloning of this object type is not yet supported." #define SOLR_ERROR_1010 1010L #define SOLR_ERROR_1010_MSG "Unsuccessful %s request : Response Code %ld. %s" #define SOLR_ERROR_4000 4000L #define SOLR_ERROR_4000_MSG "Invalid argument" #define SOLR_ERROR_4001 4001L #define SOLR_ERROR_4001_MSG "Illegal Operation" #define SOLR_ERROR_4002 4002L #define SOLR_ERROR_4002_MSG "Return value requested without processing output" /* }}} */ /* {{{ UserSpace Errors */ #define SOLR_ERROR_4100 4100L #define SOLR_ERROR_4100_MSG "Mandatory parameter Missing: %s" /* }}} */ /* {{{ Compile time errors */ /* }}} */ /* }}} */ #endif /* SOLR_CONSTANTS_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/solr_macros.h0000644000175000017500000001555512676753707015352 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #ifndef SOLR_MACROS_H #define SOLR_MACROS_H #include /* Macros for Object constructors and destructors declaration */ #define SOLR_CTOR(class_name, func_name, arginfo) PHP_ME(class_name, func_name, arginfo, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) #define SOLR_DTOR(class_name, func_name, arginfo) PHP_ME(class_name, func_name, arginfo, ZEND_ACC_PUBLIC | ZEND_ACC_DTOR) /* Retrieve a unique hash index for this SolrDocument. Unique for this thread */ #define SOLR_UNIQUE_DOCUMENT_INDEX() solr_hashtable_get_new_index(SOLR_GLOBAL(documents) TSRMLS_CC) /* Retrieve a unique hash index for this SolrClient. Unique for this thread */ #define SOLR_UNIQUE_CLIENT_INDEX() solr_hashtable_get_new_index(SOLR_GLOBAL(clients) TSRMLS_CC) /* Retrieve a unique hash index for this SolrParams instance. Unique for this thread */ #define SOLR_UNIQUE_PARAMS_INDEX() solr_hashtable_get_new_index(SOLR_GLOBAL(params) TSRMLS_CC) /* Retrieve a unique hash index for this SolrFunction instance. Unique for this thread */ #define SOLR_UNIQUE_FUNCTION_INDEX() solr_hashtable_get_new_index(SOLR_GLOBAL(functions) TSRMLS_CC) /* Iterates through the HashTable pointer */ #define SOLR_HASHTABLE_FOR_LOOP(HashTablePtr) \ if (HashTablePtr) for ( zend_hash_internal_pointer_reset((HashTablePtr)); \ SUCCESS == zend_hash_has_more_elements((HashTablePtr)); \ zend_hash_move_forward((HashTablePtr)) ) #define SOLR_HASH_FOREACH_PTR(HashTablePtr, ptr) \ if (HashTablePtr) ZEND_HASH_FOREACH_PTR(HashTablePtr, ptr) #define SOLR_HASH_FOREACH_END() \ ZEND_HASH_FOREACH_END() /* Gets a random number between 1 and SHRT_MAX */ #define SOLR_GET_RANDOM_NUMBER() abs(rand() % SHRT_MAX + 1) /* {{{ Memory Allocation Macros */ /* Used only to release truly persistent allocations */ #define SOLR_FREE_PTR(ptr) { if (ptr != NULL) { pefree(ptr,SOLR_HASHTABLE_PERSISTENT); ptr = NULL; } else { printf("\nSOLR_FREE_PTR double free() from function %s() called in %s on line %d\n", __func__, __FILE__, __LINE__); } } /* }}} */ /** * Used to retrieve xmlAttr and xmlNode values * * At this time, I am not sure if the next and previous sibling links * are guaranteed to be document order 100% of the time. * This is why I am requiring matches for the attribute and element names before * copying values from the attributes or element nodes. * Since I am not 100%, I believe it is better to be safe than sorry. * There may be a slight performance hit but at least correctness is guaranteed. */ #define solr_xml_match_node(solrXmlNode, solrXmlNodeName) ( \ xmlStrEqual(solrXmlNode->name, (xmlChar *) solrXmlNodeName) && \ solrXmlNode->children && solrXmlNode->children->content ) /* Checks if children is a valid struct */ #define solr_xml_child_content_is_valid(solrXmlNode) (solrXmlNode && solrXmlNode->children) /* Checks to prevent segmentation fault. Ensures that children is a valid struct before attempting to get content */ #define solr_xml_get_node_contents(solrXmlNode) (solr_xml_child_content_is_valid(solrXmlNode)? (solrXmlNode->children->content) : ((xmlChar *) "")) #define solr_xml_get_node_contents_int(solrXmlNode) atoi((char *)solr_xml_get_node_contents(solrXmlNode)) #define solr_xml_get_node_contents_double(solrXmlNode) xmlXPathCastStringToNumber(solr_xml_get_node_contents(solrXmlNode)) /** * Used to manage SolrQuery parameters that allow overrides by field name. * * Many parameters may be overridden on a per-field basis with the following syntax * * f..= * f..= * * @buf pointer to a solr_string_t object * @fname field name * @fname_len length of the field name * @pname a string constant representing the name of the parameter. */ #define solr_query_field_override(buf, fname, fname_len, pname) { \ if ((fname_len)) { \ solr_string_append_const((buf), "f."); \ solr_string_appends((buf), (fname), (fname_len)); \ solr_string_appendc((buf), '.'); \ } \ solr_string_append_const((buf), (pname)); \ } /* Macro for returning SolrParams objects if requested */ #define solr_return_solr_params_object() { \ solr_set_return_solr_params_object(return_value, getThis() TSRMLS_DC); \ } /* client macros */ #define SOLR_RESPONSE_CODE_BODY (client->handle.response_header.response_code), (client->handle.response_body.buffer.str) #define SOLR_SHOW_CURL_WARNING { \ if (client->handle.err.str) \ { \ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ((solr_char_t *) client->handle.err.str)); \ } \ } /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception */ #define HANDLE_SOLR_SERVER_ERROR(clientPtr,requestType){ \ if(clientPtr->handle.result_code == CURLE_OK){ \ solr_throw_solr_server_exception(clientPtr, (const char *)requestType TSRMLS_CC);\ } \ } /* solr_throw_exception_ex(solr_ce_SolrClientException, SOLR_ERROR_1010 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1010_MSG, requestType, SOLR_RESPONSE_CODE_BODY); \ */ #define SOLR_RETURN_THIS() { \ RETURN_ZVAL(getThis(), 1, 0); \ } /* Used to release the (solr_document_t **) pointers */ #define SOLR_FREE_DOC_ENTRIES(ptr) { \ if ((ptr) != NULL)\ { \ pefree(ptr, SOLR_DOCUMENT_PERSISTENT); \ ptr = NULL; \ } \ } /* }}} */ /* Used to release the (solr_document_t **) pointers */ #define SOLR_FREE_DOC_ENTRIES(ptr) { \ if ((ptr) != NULL)\ { \ pefree(ptr, SOLR_DOCUMENT_PERSISTENT); \ ptr = NULL; \ } \ } /* }}} */ #endif /* SOLR_MACROS_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/solr_string.h0000644000175000017500000001227112676753707015364 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Israel Ekpo | +----------------------------------------------------------------------+ */ /* $Id$ */ #ifndef SOLR_STRING_H #define SOLR_STRING_H #include
#include #define SOLR_STRING_PERSISTENT 0 #define SOLR_STRING_START_SIZE 64 #define SOLR_STRING_INCREMENT_SIZE 128 #define SOLR_STRING_LONG_BUFFER_SIZE 16 #define SOLR_STRING_UNSIGNED_LONG_BUFFER_SIZE 32 #include "php_solr_api.h" #ifdef SOLR_DEBUG /* #define SOLR_MEM_DEBUG 1 Uncomment if you need memdebug enabled */ #endif #ifdef SOLR_MEM_DEBUG #define SOLR_MEM_DEBUG_DC , const char * mm_function, char * mm_filename, int mm_line #define SOLR_MEM_DEBUG_CC , mm_function, mm_filename, mm_line #define SOLR_MEM_DEBUG_RC , __func__, __FILE__, __LINE__ #else #define SOLR_MEM_DEBUG_DC #define SOLR_MEM_DEBUG_CC #define SOLR_MEM_DEBUG_RC #endif /** * solr_char_t * * iekpo 2009/08/28 * * Decided to create this type just in case there is a special need in the * future to use unsigned char instead of plain char to transport character * arrays within the library. * * Having this typedef will allow us to toggle easily between plain char and * unsigned char, without having to do a massive search and replace. * * There may be a few cases where casting may be needed to handle cases where * the sign of the variable is now the opposite. */ typedef char solr_char_t; /* Structure to store solr strings */ typedef struct _solr_string { solr_char_t *str; /* The buffer to store the character array. */ size_t len; /* The current length of the solr_string_t object */ size_t cap; /* The current capacity of the solr_string_t object */ } solr_string_t; #define SOLR_STRING_INITIALIZER {.str = ((solr_char_t *)0), .len = 0U, .cap = 0U} /* Appends a string constant to a solr_string_t */ #define solr_string_append_const(dest, str) solr_string_appends((dest), (solr_char_t *) str, sizeof(str)-1) /* Appends one solr_string_t to another */ #define solr_string_append_solr_string(dest, src) solr_string_appends((dest), (src)->str, (src)->len) /* Initializes the solr_string_t structure to empty values */ #define solr_string_init(dest) \ { \ (dest)->str = (solr_char_t *) 0x00; \ (dest)->len = 0U; \ (dest)->cap = 0U; \ } #define solr_strndup estrndup #define solr_strdup estrdup #define solr_strlen strlen #define solr_string_appends(dest, src, len) solr_string_appends_ex((dest), (src), (len) SOLR_MEM_DEBUG_RC) #define solr_string_appendc(dest, ch) solr_string_appendc_ex((dest), (ch) SOLR_MEM_DEBUG_RC) #define solr_string_append_long(dest, long_val) solr_string_append_long_ex((dest), (long_val) SOLR_MEM_DEBUG_RC) #define solr_string_append_unsigned_long(dest, long_val) solr_string_append_unsigned_long((dest), (long_val) SOLR_MEM_DEBUG_RC) #define solr_string_set(dest, value, length) solr_string_set_ex((dest), (value), (length) SOLR_MEM_DEBUG_RC) #define solr_string_free(dest) solr_string_free_ex((dest) SOLR_MEM_DEBUG_RC) PHP_SOLR_API void solr_string_appends_ex(solr_string_t *dest, const solr_char_t *src, size_t length SOLR_MEM_DEBUG_DC); PHP_SOLR_API void solr_string_appendc_ex(solr_string_t *dest, solr_char_t ch SOLR_MEM_DEBUG_DC); PHP_SOLR_API void solr_string_append_long_ex(solr_string_t *dest, long int long_val SOLR_MEM_DEBUG_DC); PHP_SOLR_API void solr_string_append_unsigned_long_ex(solr_string_t *dest, unsigned long int long_val SOLR_MEM_DEBUG_DC); PHP_SOLR_API void solr_string_remove_last_char(solr_string_t *dest); PHP_SOLR_API int solr_string_equal(const solr_string_t *a, const solr_string_t *b); PHP_SOLR_API void solr_destory_solr_string_zv(zval *solr_string_zv); PHP_SOLR_API void solr_string_free_ex(solr_string_t *dest SOLR_MEM_DEBUG_DC); PHP_SOLR_API void solr_string_set_ex(solr_string_t *dest, const solr_char_t *value, size_t length SOLR_MEM_DEBUG_DC); /* destroy data element of hashtable of solr_string_t */ #ifdef PHP_7 #define solr_destroy_solr_string solr_destory_solr_string_zv /* frees a solr_string_t within a zval */ #else #define solr_destroy_solr_string solr_string_free #endif #endif /* SOLR_STRING_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/solr_types.h0000644000175000017500000003147612676753707015232 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #ifndef SOLR_TYPES_H #define SOLR_TYPES_H #include
#include #include #include #include /* Declaring workarounds for SSL private key constants */ #if LIBCURL_VERSION_NUM >= 0x071700 /* Use CURLOPT_KEYPASSWD as is */ #elif LIBCURL_VERSION_NUM >= 0x070903 #define CURLOPT_KEYPASSWD CURLOPT_SSLKEYPASSWD #else #define CURLOPT_KEYPASSWD CURLOPT_SSLCERTPASSWD #endif #include #include #include #include #include #include typedef unsigned char solr_bool; #include "solr_string.h" /* {{{ types for the http client */ typedef enum { SOLR_REQUEST_BEGIN = 0, SOLR_REQUEST_SEARCH = 1, /** 1 **/ SOLR_REQUEST_UPDATE = 2, /** 2 **/ SOLR_REQUEST_THREADS = 3, /** 3 **/ SOLR_REQUEST_PING = 4, /** 4 **/ SOLR_REQUEST_TERMS = 5, /** 5 **/ SOLR_REQUEST_SYSTEM = 6, /** 6 **/ SOLR_REQUEST_GET = 7, SOLR_REQUEST_END } solr_request_type_t; typedef enum { SOLR_SERVLET_TYPE_BEGIN = 0, SOLR_SERVLET_TYPE_SEARCH = 1, SOLR_SERVLET_TYPE_UPDATE = 2, SOLR_SERVLET_TYPE_THREADS = 4, SOLR_SERVLET_TYPE_PING = 8, SOLR_SERVLET_TYPE_TERMS = 16, SOLR_SERVLET_TYPE_SYSTEM = 32, SOLR_SERVLET_TYPE_GET = 64, SOLR_SERVLET_TYPE_END } solr_servlet_type_t; typedef enum { SOLR_PARAM_TYPE_BEGIN = 0, SOLR_PARAM_TYPE_NORMAL = 1, SOLR_PARAM_TYPE_SIMPLE_LIST = 2, SOLR_PARAM_TYPE_ARG_LIST = 4, SOLR_PARAM_TYPE_END } solr_param_type_t; typedef enum { SOLR_SORT_DIR_ASC = 0, SOLR_SORT_DIR_DESC = 1 } solr_sort_dir_t; typedef enum { SOLR_JSON_ERROR_NONE = 0, SOLR_JSON_ERROR_DEPTH, SOLR_JSON_ERROR_STATE_MISMATCH, SOLR_JSON_ERROR_CTRL_CHAR, SOLR_JSON_ERROR_SYNTAX, SOLR_JSON_ERROR_UTF8, SOLR_JSON_ERROR_SERIALIZATION } solr_json_error_codes_t; typedef struct curl_slist solr_http_header_list_t; typedef struct { solr_string_t buffer; /* Stores the HTTP request headers */ } solr_curl_send_headers_t; typedef struct _solr_curl_send_data { solr_string_t buffer; /* Stores the HTTP request data */ } solr_curl_send_data_t; typedef struct { solr_string_t buffer; /* Stores the HTTP response headers */ long int response_code; /* Stores the HTTP response code */ } solr_curl_response_headers_t; typedef struct { solr_string_t buffer; /* Stores the HTTP response data */ } solr_curl_response_data_t; typedef struct { char str[CURL_ERROR_SIZE + 1]; /* Stores the error message */ uint number; /* Stores the error number */ } solr_curl_error_t; typedef struct { solr_curl_send_headers_t request_header; solr_curl_send_data_t request_body; solr_curl_send_data_t request_body_debug; solr_curl_response_headers_t response_header; solr_curl_response_data_t response_body; solr_curl_error_t err; solr_string_t debug_data_buffer; /* Stores all the debug data */ size_t handle_status; /* Whether or not the handle is still usable */ CURLcode result_code; CURL *curl_handle; } solr_curl_t; typedef struct { long int host_port; /* HTTP port for Solr server */ long int proxy_port; /* Proxy port for Solr server */ long int timeout; /* maximum time in seconds allowed for the http data transfer operation */ long int secure; /* Whether to connect to Solr Server using SSL/HTTPS */ long int ssl_verify_peer; /* Determines whether libcurl verifies the peer certificate */ long int ssl_verify_host; /* Determines how libcurl verifies the server certificate */ solr_string_t hostname; /* IP address or domain name */ solr_string_t path; /* Path to solr */ solr_string_t http_auth_credentials; /* HTTP Auth username:password */ solr_string_t proxy_hostname; /* IP address of domain name for the proxy server */ solr_string_t proxy_auth_credentials; /* Proxy Auth username:password */ solr_string_t ssl_cert; /* File name to a PEM-formatted private key + private certificate (concatenated in that order) */ solr_string_t ssl_key; /* File name to a PEM-formatted private key */ solr_string_t ssl_keypassword; /* The pass phrase/password for the private ssl_key */ solr_string_t ssl_cainfo; /* Name of file holding one or more certificates to verify peer with */ solr_string_t ssl_capath; /* Name of directory holding multiple CA certificates to verify peer with */ solr_string_t qs_delimiter; /* The query string delimiter */ solr_string_t response_writer; /* The response writer type (wt parameter) */ solr_string_t update_url; /* URL used for updates */ solr_string_t search_url; /* URL used for queries */ solr_string_t thread_url; /* URL used for thread monitoring */ solr_string_t ping_url; /* URL for sending ping requests */ solr_string_t terms_url; /* URL for sending terms requests */ solr_string_t system_url; /* URL for sending system requests */ solr_string_t get_url; /* URL for sending realtime get requests */ solr_string_t update_servlet; /* The update servlet */ solr_string_t search_servlet; /* The search servlet */ solr_string_t thread_servlet; /* The thread servlet */ solr_string_t ping_servlet; /* The ping servlet */ solr_string_t terms_servlet; /* The terms servlet */ solr_string_t system_servlet; /* The system info servlet */ solr_string_t get_servlet; /* The realtime get servlet */ } solr_client_options_t; typedef struct { ulong client_index; /* Unique for the SolrClient instance. Used as index in HashTables */ uint request_count; /* The number of requests made from this client */ solr_client_options_t options; /* The connection options for this client */ solr_curl_t handle; /* The Solr handle for this client */ } solr_client_t; /* }}} */ /* Types for documents and collections */ /* {{{ Types for documents and collections */ /* {{{ Types for SolrDocument fields */ typedef struct _solr_field_value_t { solr_char_t *field_value; /* The value for this field */ struct _solr_field_value_t *next; /* The next entry in the queue */ } solr_field_value_t; /** * List of Fields in a Solr Document * * @field_boost stores the boost value * @count stores how many fields there are in the list * @field_name stores the name of the field * @head the first entry in the list (if any) * @last the last entry in the list (if any) */ typedef struct { double field_boost; /* The boost value for this field */ uint count; /* The number of values in this field */ solr_char_t *field_name; /* The name of the field */ solr_field_value_t *head; /* The first value in the queue */ solr_field_value_t *last; /* The last value in the queue */ } solr_field_list_t; /* }}} */ /* {{{ Types for Documents and Document Collections */ typedef struct { ulong document_index; /* Unique for the SolrInputDocument instance. Used as index in HashTables */ uint field_count; /* Number of fields in this document */ double document_boost; /* The boost value for this document */ HashTable *fields; /* HashTable for storing all the solr_field_list_t fields */ HashTable *children; /* Hashtable for storing child documents(zval *) */ } solr_document_t; /* }}} */ /* {{{ Types for Solr Query Parameters */ typedef struct { solr_string_t value; /* The value for this parameter */ solr_string_t arg; /* The argument for this value*/ solr_char_t *delimiter_override; /* overrides the arg_list delimiter for this particular argument */ solr_bool delimiter_overriden; /* is delimiter overriden */ } solr_arg_list_value_t; typedef union { solr_string_t normal; /* Stores normal parameters */ solr_string_t simple_list; /* Stores delimited list parameters */ solr_arg_list_value_t arg_list; /* Stores parameters that have arguments */ } solr_pvc_t; typedef struct _solr_param_value_t { solr_pvc_t contents; /* A union for the contents of this value */ struct _solr_param_value_t *prev; /* The previous value in the list */ struct _solr_param_value_t *next; /* The next value in the list */ } solr_param_value_t; /* Checks if two parameter values are equal */ typedef int (*solr_param_value_equal_func_t)(const solr_param_value_t *a, const solr_param_value_t *b); /* Used to retrieve all the values for this parameter as a single solr string */ typedef void (*solr_param_fetch_func_t)(void *solr_param, solr_string_t *buffer); /* Frees the parameter value and its contents. */ typedef void (*solr_param_value_free_func_t)(solr_param_value_t *param_value); typedef struct { solr_param_type_t type; /* What type of query parameter this is */ uint count; /* The number of values for this parameter */ solr_char_t *param_name; /* The name of the parameter */ size_t param_name_length; /* The length of name of the parameter */ solr_bool allow_multiple; /* Whether this parameter should store more than one value */ solr_param_value_t *head; /* The first value in the list */ solr_param_value_t *last; /* The last value in the list */ solr_param_fetch_func_t fetch_func; /* Retrieves all the value contents as a single solr_string_t */ solr_param_value_free_func_t value_free_func; /* Frees the value and its contents */ solr_param_value_equal_func_t value_equal_func; /* Checks if two values are equal */ solr_char_t delimiter; /* Default is "," Used to separate list parameter values */ solr_char_t arg_separator; /* Used only be arg_lists to separate arguments from values */ } solr_param_t; /* Used to retrieve parameter values just for display purposes */ typedef void (*solr_param_display_func_t)(solr_param_t *solr_param, zval *param_value_array); /* Used to retrieve parameter values just for the toString() method */ /* The url_encode parameter will be ignored for now */ typedef void (*solr_param_tostring_func_t)(solr_param_t *solr_param, solr_string_t *buffer, zend_bool url_encode); typedef struct { ulong params_index; /* The index for this object in the HashTable */ uint params_count; /* The number of parameters for the query object */ HashTable *params; /* The HashTable for storing query parameters */ } solr_params_t; /* }}} */ /* {{{ solr function/localparams type */ typedef struct { ulong function_index; /* The index for this object in the HashTable */ solr_char_t *name; size_t name_length; solr_char_t *argument; size_t argument_length; HashTable *params; /* The HashTable for storing function key-val parameters */ } solr_function_t; /* }}} */ /* }}} */ /* {{{ Extension Global : This should be the last data type declared. More members may be added later. */ ZEND_BEGIN_MODULE_GLOBALS(solr) uint request_count; /* The number of times PHP_RINIT has been called */ uint document_count; /* The number of active SolrDocuments in this request */ uint client_count; /* The number of active SolrClients in this request */ uint functions_count; /* The number of active Functions in this request */ HashTable *documents; /* HashTable for storing solr_document_t documents */ HashTable *clients; /* HashTable for storing solr_client_t clients */ HashTable *params; /* HashTable for storing solr_params_t parameter containers */ HashTable *functions; /* HashTable for storing solr_function_t */ ZEND_END_MODULE_GLOBALS(solr) /* }}} */ typedef struct { int code; solr_char_t *message; } solr_exception_t; #endif /* SOLR_TYPES_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/php_solr.c0000664000175000017500000020016612676753707014644 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" #ifdef HAVE_SOLR /* PHP versions lower than 5.2.3 are not compatible or are causing tests to FAIL */ #if ((PHP_MAJOR_VERSION < 5) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 2) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 2 && PHP_RELEASE_VERSION < 3)) #error PHP 5.2.3 or newer is required. Please upgrade your php version. #endif #if LIBCURL_VERSION_NUM < 0x070F00 #error libcurl 7.15.0 or later is required. Please upgrade your libcurl version. #endif #if LIBXML_VERSION < 20616 #error libxml2 2.6.16 or later is required. Please upgrade your libxml2 version. #endif /******************************************************************************/ /** GLOBAL VARIABLE FOR THE EXTENSION **/ /******************************************************************************/ /* {{{ ZEND_DECLARE_MODULE_GLOBALS(solr) */ ZEND_DECLARE_MODULE_GLOBALS(solr) /* }}} */ /******************************************************************************/ /** OBJECT HANDLERS AND DECLARATIONS FOR CLASS ENTRIES **/ /******************************************************************************/ /* {{{ zend_class_entry declarations of the classes */ zend_class_entry *solr_ce_SolrObject; zend_class_entry *solr_ce_SolrInputDocument; zend_class_entry *solr_ce_SolrDocument; zend_class_entry *solr_ce_SolrDocumentField; zend_class_entry *solr_ce_SolrClient; zend_class_entry *solr_ce_SolrParams; zend_class_entry *solr_ce_SolrModifiableParams; zend_class_entry *solr_ce_SolrCollapseFunction; zend_class_entry *solr_ce_SolrQuery; zend_class_entry *solr_ce_SolrResponse; zend_class_entry *solr_ce_SolrQueryResponse; zend_class_entry *solr_ce_SolrUpdateResponse; zend_class_entry *solr_ce_SolrPingResponse; zend_class_entry *solr_ce_SolrGenericResponse; zend_class_entry *solr_ce_SolrUtils; zend_class_entry *solr_ce_SolrException; zend_class_entry *solr_ce_SolrIllegalOperationException; zend_class_entry *solr_ce_SolrIllegalArgumentException; zend_class_entry *solr_ce_SolrClientException; zend_class_entry *solr_ce_SolrServerException; zend_class_entry *solr_ce_SolrMissingMandatoryParameterException; /* }}} */ /* {{{ zend_object_handlers */ zend_object_handlers solr_object_handlers; zend_object_handlers solr_document_field_handlers; zend_object_handlers solr_input_document_object_handlers; zend_object_handlers solr_client_object_handlers; zend_object_handlers solr_response_object_handlers; zend_object_handlers solr_collapse_function_object_handlers; /* }}} */ /* {{{ static void php_solr_globals_ctor(zend_solr_globals *solr_globals_arg TSRMLS_DC) Global variable initializer. In ZTS mode, called once for each thread spawned. */ static void php_solr_globals_ctor(zend_solr_globals *solr_globals_arg TSRMLS_DC) { /* Initializing the counters to Zero */ solr_globals_arg->request_count = 0U; solr_globals_arg->document_count = 0U; solr_globals_arg->client_count = 0U; solr_globals_arg->functions_count = 0U; solr_globals_arg->documents = NULL; solr_globals_arg->clients = NULL; solr_globals_arg->params = NULL; solr_globals_arg->functions = NULL; } /* }}} */ /******************************************************************************/ /** DECLARING STRUCTURES FOR METHOD ARGUMENTS TYPE HINTING **/ /******************************************************************************/ /* {{{ arg_info vectors for functions and methods */ ZEND_BEGIN_ARG_INFO_EX(SolrObject__get_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, property_name) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrObject__set_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 2) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, property_name) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, property_value) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrObject_one_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, property_name) ZEND_END_ARG_INFO() /* {{{ SolrDocument arguments */ ZEND_BEGIN_ARG_INFO_EX(SolrDocument__construct_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDocument_addField_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 2) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldName) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldValue) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDocument_getField_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldName) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDocument_fieldExists_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldName) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDocument_deleteField_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldName) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDocument_sort_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, sortOrderBy) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, sortDirection) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDocument_merge_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_OBJ_INFO(SOLR_ARG_PASS_BY_REF_TRUE, sourceDoc, SolrDocument, SOLR_ARG_ALLOW_NULL_FALSE) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, overwrite) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDocument_current_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDocument_getInputDocument_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO(SolrDocument_unserialize_args, 0) ZEND_ARG_INFO(0, serialized) ZEND_END_ARG_INFO() /* }}} */ /* {{{ SolrInputDocument arguments */ ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument__construct_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument_setBoost_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, documentBoostValue) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument_addField_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 2) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldName) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldValue) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldBoostValue) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument_getFieldBoost_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldName) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument_getField_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldName) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument_setFieldBoost_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 2) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldName) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldBoostValue) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument_fieldExists_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldName) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument_deleteField_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldName) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument_sort_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, sortOrderBy) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, sortDirection) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument_merge_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_OBJ_INFO(SOLR_ARG_PASS_BY_REF_TRUE, sourceDoc, SolrInputDocument, SOLR_ARG_ALLOW_NULL_FALSE) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, overwrite) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument_addChildDocument_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_OBJ_INFO(SOLR_ARG_PASS_BY_REF_TRUE, child, SolrInputDocument, SOLR_ARG_ALLOW_NULL_FALSE) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrInputDocument_addChildDocuments_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_ARRAY_INFO(SOLR_ARG_PASS_BY_REF_TRUE, docs, SOLR_ARG_ALLOW_NULL_FALSE) ZEND_END_ARG_INFO() /* }}} */ /* {{{ SolrClient arguments */ ZEND_BEGIN_ARG_INFO_EX(SolrClient_constructor_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_ARRAY_INFO(SOLR_ARG_PASS_BY_REF_FALSE, clientOptions, SOLR_ARG_ALLOW_NULL_FALSE) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_query_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_OBJ_INFO(SOLR_ARG_PASS_BY_REF_TRUE, query, SolrParams, SOLR_ARG_ALLOW_NULL_FALSE) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_addDocument_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_OBJ_INFO(SOLR_ARG_PASS_BY_REF_TRUE, doc, SolrInputDocument, SOLR_ARG_ALLOW_NULL_FALSE) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, overwrite) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, commitWithin) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_addDocuments_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_ARRAY_INFO(SOLR_ARG_PASS_BY_REF_TRUE, docs, SOLR_ARG_ALLOW_NULL_FALSE) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, overwrite) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, commitWithin) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_request_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, raw_request) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_setResponseWriter_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, responseWriter) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_commit_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 0) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, softCommit) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, waitSearcher) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, expungeDeletes) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_optimize_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 0) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, maxSegments) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, softCommit) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, waitSearcher) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_rollback_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_deleteById_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, id) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_deleteByIds_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_ARRAY_INFO(SOLR_ARG_PASS_BY_REF_FALSE, ids, SOLR_ARG_ALLOW_NULL_FALSE) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_deleteByQuery_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, query) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_deleteByQueries_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_ARRAY_INFO(SOLR_ARG_PASS_BY_REF_FALSE, queries, SOLR_ARG_ALLOW_NULL_FALSE) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_ping_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_threads_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_info_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrClient_setServlet_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 2) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, type) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, value) ZEND_END_ARG_INFO() /* }}} */ /* {{{ SolrParams arguments */ ZEND_BEGIN_ARG_INFO_EX(SolrParams_setParam_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 2) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, name) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, value) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrParams_addParam_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 2) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, name) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, value) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrParams_toString_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 0) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, url_encode) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrParams_getParam_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, param_name) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO(SolrParams_unserialize_args, 0) ZEND_ARG_INFO(0, serialized) ZEND_END_ARG_INFO() /* }}} */ /* {{{ SolrQuery arguments */ ZEND_BEGIN_ARG_INFO_EX(SolrQuery_constructor_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 0) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, q) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_setQuery_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, q) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_setStart_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, start) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_setRows_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, rows) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_addField_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, field) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_addSortField_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, field) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, order) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_addFilterQuery_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fq) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_setShowDebugInfo_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, flag) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_setExplainOther_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, flag) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_setTimeAllowed_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, timeAllowed) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_setOmitHeader_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, flag) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_setEchoHandler_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, flag) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_setEchoParams_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, type) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_facet_get_1_0_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 0) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, field_override) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_facet_1_1_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, value) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_facet_2_1_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, value) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, field_override) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_group_1_1_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, value) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_hl_get_1_0_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 0) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, field_override) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_hl_1_1_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, value) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_hl_2_1_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, value) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, field_override) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_stats_1_1_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, value) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_mlt_1_1_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, value) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_mlt_2_2_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 2) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, field) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, boost) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_terms_1_1_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, value) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_setGroupCachePct_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, percent) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrQuery_collapse_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_TRUE, 1) ZEND_ARG_OBJ_INFO(SOLR_ARG_PASS_BY_REF_TRUE, collapseFunction, SolrCollapseFunction, SOLR_ARG_ALLOW_NULL_FALSE) ZEND_END_ARG_INFO() /* }}} */ /* {{{ Solr Generic arguments */ ZEND_BEGIN_ARG_INFO_EX(Solr_no_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 0) ZEND_END_ARG_INFO() /* }}} */ /* {{{ */ ZEND_BEGIN_ARG_INFO_EX(SolrResponse_setParseMode_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 0) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, parser_mode) ZEND_END_ARG_INFO() /* }}} */ /* {{{ SolrUtils */ ZEND_BEGIN_ARG_INFO_EX(SolrUtils_escapeQueryChars_arg, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, str) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrUtils_digestXML_arg, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, xmlresponse) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, parse_mode) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrUtils_digestJson_arg, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, jsonResponse) ZEND_END_ARG_INFO() /* }}} */ ZEND_BEGIN_ARG_INFO_EX(SolrCollapseFunction_construct_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 0) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, field) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrCollapseFunction_set_size_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, size) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrCollapseFunction_set_hint_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, hint) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrCollapseFunction_set_max_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, max) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrCollapseFunction_set_min_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, min) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrCollapseFunction_set_field_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, fieldName) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrCollapseFunction_set_null_policy_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(SOLR_ARG_PASS_BY_REF_FALSE, policy) ZEND_END_ARG_INFO() /* }}} */ /* {{{ solr_functions[] */ static zend_function_entry solr_functions[] = { PHP_FE(solr_get_version, Solr_no_args) PHP_FE_END }; /* }}} */ /* {{{ solr_object_methods */ static zend_function_entry solr_object_methods[] = { SOLR_CTOR(SolrObject, __construct, Solr_no_args) SOLR_DTOR(SolrObject, __destruct, Solr_no_args) /** Temporarily disconnected for now. May be brought back in the future. PHP_ME(SolrObject, __set, SolrObject__set_args, ZEND_ACC_PUBLIC) PHP_ME(SolrObject, __get, SolrObject__get_args, ZEND_ACC_PUBLIC) PHP_ME(SolrObject, __isset, SolrObject_one_args, ZEND_ACC_PUBLIC) PHP_ME(SolrObject, __unset, SolrObject_one_args, ZEND_ACC_PUBLIC) */ PHP_ME(SolrObject, offsetSet, SolrObject__set_args, ZEND_ACC_PUBLIC) PHP_ME(SolrObject, offsetGet, SolrObject__get_args, ZEND_ACC_PUBLIC) PHP_ME(SolrObject, offsetExists, SolrObject_one_args, ZEND_ACC_PUBLIC) PHP_ME(SolrObject, offsetUnset, SolrObject_one_args, ZEND_ACC_PUBLIC) PHP_ME(SolrObject, getPropertyNames, Solr_no_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_document_methods */ static zend_function_entry solr_document_field_methods[] = { SOLR_CTOR(SolrDocumentField, __construct, Solr_no_args) SOLR_DTOR(SolrDocumentField, __destruct, Solr_no_args) PHP_FE_END }; /* }}} */ /* {{{ solr_collapse_function_methods for the SolrCollapseFunction ce */ static zend_function_entry solr_collapse_function_methods[] = { SOLR_CTOR(SolrCollapseFunction, __construct, SolrCollapseFunction_construct_args) SOLR_DTOR(SolrCollapseFunction, __destruct, Solr_no_args) PHP_ME(SolrCollapseFunction, setField, SolrCollapseFunction_set_field_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, getField, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, setMax, SolrCollapseFunction_set_max_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, getMax, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, setMin, SolrCollapseFunction_set_min_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, getMin, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, setSize, SolrCollapseFunction_set_size_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, getSize, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, setHint, SolrCollapseFunction_set_hint_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, getHint, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, setNullPolicy, SolrCollapseFunction_set_null_policy_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, getNullPolicy, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, __toString, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, __sleep, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrCollapseFunction, __wakeup, Solr_no_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_document_methods */ static zend_function_entry solr_document_methods[] = { SOLR_CTOR(SolrDocument, __construct, SolrDocument__construct_args) SOLR_DTOR(SolrDocument, __destruct, Solr_no_args) PHP_ME(SolrDocument, __clone, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CLONE) PHP_ME(SolrDocument, __set, SolrDocument_addField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, __get, SolrDocument_getField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, __isset, SolrDocument_fieldExists_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, __unset, SolrDocument_deleteField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, offsetSet, SolrDocument_addField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, offsetGet, SolrDocument_getField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, offsetExists, SolrDocument_fieldExists_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, offsetUnset, SolrDocument_deleteField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, current, SolrDocument_current_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, key, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, next, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, rewind, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, valid, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, serialize, NULL, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, unserialize, SolrDocument_unserialize_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, clear, Solr_no_args, ZEND_ACC_PUBLIC) PHP_MALIAS(SolrDocument, reset, clear, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, addField, SolrDocument_addField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, getFieldNames, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, getFieldCount, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, getField, SolrDocument_getField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, toArray, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, fieldExists, SolrDocument_fieldExists_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, deleteField, SolrDocument_deleteField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, sort, SolrDocument_sort_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, merge, SolrDocument_merge_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, getInputDocument, SolrDocument_getInputDocument_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, getChildDocumentsCount, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, hasChildDocuments, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDocument, getChildDocuments, Solr_no_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_input_document_methods */ static zend_function_entry solr_input_document_methods[] = { SOLR_CTOR(SolrInputDocument, __construct, SolrInputDocument__construct_args) SOLR_DTOR(SolrInputDocument, __destruct, Solr_no_args) PHP_ME(SolrInputDocument, __clone, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CLONE) PHP_ME(SolrInputDocument, __sleep, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, __wakeup, NULL, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, setBoost, SolrInputDocument_setBoost_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, getBoost, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, clear, Solr_no_args, ZEND_ACC_PUBLIC) PHP_MALIAS(SolrInputDocument, reset, clear, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, addField, SolrInputDocument_addField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, getFieldBoost, SolrInputDocument_getFieldBoost_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, setFieldBoost, SolrInputDocument_setFieldBoost_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, getFieldNames, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, getFieldCount, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, getField, SolrInputDocument_getField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, toArray, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, fieldExists, SolrInputDocument_fieldExists_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, deleteField, SolrInputDocument_deleteField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, sort, SolrInputDocument_sort_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, merge, SolrInputDocument_merge_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, addChildDocument, SolrInputDocument_addChildDocument_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, getChildDocuments, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, hasChildDocuments, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, getChildDocumentsCount, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrInputDocument, addChildDocuments, SolrInputDocument_addChildDocuments_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_client_methods */ static zend_function_entry solr_client_methods[] = { SOLR_CTOR(SolrClient, __construct, SolrClient_constructor_args) SOLR_DTOR(SolrClient, __destruct, Solr_no_args) PHP_ME(SolrClient, __sleep, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, __wakeup, NULL, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, __clone, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CLONE) PHP_ME(SolrClient, getOptions, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, getDebug, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, setServlet, SolrClient_setServlet_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, query, SolrClient_query_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, addDocument, SolrClient_addDocument_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, addDocuments, SolrClient_addDocuments_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, request, SolrClient_request_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, setResponseWriter, SolrClient_setResponseWriter_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, deleteById, SolrClient_deleteById_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, deleteByIds, SolrClient_deleteByIds_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, deleteByQuery, SolrClient_deleteByQuery_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, deleteByQueries, SolrClient_deleteByQueries_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, getById, SolrClient_deleteById_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, getByIds, SolrClient_deleteByIds_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, commit, SolrClient_commit_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, optimize, SolrClient_optimize_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, rollback, SolrClient_rollback_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, ping, SolrClient_ping_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, system, SolrClient_info_args, ZEND_ACC_PUBLIC) PHP_ME(SolrClient, threads, SolrClient_threads_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_exception_methods. None. */ static zend_function_entry solr_exception_methods[] = { PHP_ME(SolrException, getInternalInfo, Solr_no_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_exception_methods. None. */ static zend_function_entry solr_client_exception_methods[] = { PHP_ME(SolrClientException, getInternalInfo, Solr_no_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_exception_methods. None. */ static zend_function_entry solr_server_exception_methods[] = { PHP_ME(SolrServerException, getInternalInfo, Solr_no_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_exception_methods. None. */ static zend_function_entry solr_illegal_operation_exception_methods[] = { PHP_ME(SolrIllegalOperationException, getInternalInfo, Solr_no_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_exception_methods. None. */ static zend_function_entry solr_illegal_argument_exception_methods[] = { PHP_ME(SolrIllegalArgumentException, getInternalInfo, Solr_no_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* PHP_MALIAS(SolrInputDocument, reset, clear, Solr_no_args, ZEND_ACC_PUBLIC) */ /* {{{ solr_params_methods. */ static zend_function_entry solr_params_methods[] = { PHP_ME(SolrParams, setParam, SolrParams_setParam_args, ZEND_ACC_PUBLIC) PHP_ME(SolrParams, addParam, SolrParams_addParam_args, ZEND_ACC_PUBLIC) PHP_ME(SolrParams, __toString, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrParams, toString, SolrParams_toString_args, ZEND_ACC_PUBLIC) PHP_ME(SolrParams, getParams, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrParams, getParam, SolrParams_getParam_args, ZEND_ACC_PUBLIC) PHP_ME(SolrParams, getPreparedParams, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrParams, __clone, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CLONE) PHP_ME(SolrParams, serialize, NULL, ZEND_ACC_PUBLIC) PHP_ME(SolrParams, unserialize, SolrParams_unserialize_args, ZEND_ACC_PUBLIC) PHP_MALIAS(SolrParams, add, addParam, SolrParams_addParam_args, ZEND_ACC_PUBLIC) PHP_MALIAS(SolrParams, set, setParam, SolrParams_setParam_args, ZEND_ACC_PUBLIC) PHP_MALIAS(SolrParams, get, getParam, SolrParams_getParam_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_modifiable_params_methods. */ static zend_function_entry solr_modifiable_params_methods[] = { SOLR_CTOR(SolrModifiableParams, __construct, Solr_no_args) SOLR_DTOR(SolrModifiableParams, __destruct, Solr_no_args) PHP_FE_END }; /* }}} */ /* {{{ solr_query_methods. */ static zend_function_entry solr_query_methods[] = { SOLR_CTOR(SolrQuery, __construct, SolrQuery_constructor_args) SOLR_DTOR(SolrQuery, __destruct, Solr_no_args) /* CommonQueryParameters */ PHP_ME(SolrQuery, setQuery, SolrQuery_setQuery_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getQuery, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setStart, SolrQuery_setStart_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getStart, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setRows, SolrQuery_setRows_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getRows, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addField, SolrQuery_addField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeField, SolrQuery_addField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFields, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addSortField, SolrQuery_addSortField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeSortField, SolrQuery_addField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getSortFields, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addFilterQuery, SolrQuery_addFilterQuery_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeFilterQuery, SolrQuery_addFilterQuery_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFilterQueries, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setShowDebugInfo, SolrQuery_setShowDebugInfo_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setExplainOther, SolrQuery_setExplainOther_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTimeAllowed, SolrQuery_setTimeAllowed_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTimeAllowed, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setOmitHeader, SolrQuery_setOmitHeader_args, ZEND_ACC_PUBLIC) /* CoreQueryParameters */ PHP_ME(SolrQuery, setEchoHandler, SolrQuery_setEchoHandler_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setEchoParams, SolrQuery_setEchoParams_args, ZEND_ACC_PUBLIC) /* SimpleFacetParameters */ PHP_ME(SolrQuery, setFacet, SolrQuery_facet_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacet, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addFacetField, SolrQuery_facet_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeFacetField, SolrQuery_facet_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetFields, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addFacetQuery, SolrQuery_facet_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeFacetQuery, SolrQuery_facet_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetQueries, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetPrefix, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetPrefix, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetSort, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetSort, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetLimit, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetLimit, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetOffset, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetOffset, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetMinCount, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetMinCount, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetMissing, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetMissing, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetMethod, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetMethod, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetEnumCacheMinDefaultFrequency, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) /* Date Faceting Parameters */ PHP_ME(SolrQuery, addFacetDateField, SolrQuery_facet_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeFacetDateField, SolrQuery_facet_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetDateFields, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetDateStart, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetDateStart, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetDateEnd, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetDateEnd, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetDateGap, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetDateGap, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setFacetDateHardEnd, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetDateHardEnd, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addFacetDateOther, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeFacetDateOther, SolrQuery_facet_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getFacetDateOther, SolrQuery_facet_get_1_0_args, ZEND_ACC_PUBLIC) /* SimpleGroupParameters */ PHP_ME(SolrQuery, setGroup, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroup, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addGroupField, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupFields, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addGroupFunction, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupFunctions, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addGroupQuery, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupQueries, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setGroupLimit, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupLimit, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setGroupOffset, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupOffset, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addGroupSortField, SolrQuery_addSortField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupSortFields, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setGroupFormat, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupFormat, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setGroupMain, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupMain, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setGroupNGroups, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupNGroups, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setGroupTruncate, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupTruncate, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setGroupFacet, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupFacet, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setGroupCachePercent, SolrQuery_setGroupCachePct_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getGroupCachePercent, Solr_no_args, ZEND_ACC_PUBLIC) /* Collapse Function */ PHP_ME(SolrQuery, collapse, SolrQuery_collapse_args, ZEND_ACC_PUBLIC) /* Expand Componenet */ PHP_ME(SolrQuery, setExpand, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getExpand, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addExpandSortField, SolrQuery_addSortField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeExpandSortField, SolrQuery_addField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getExpandSortFields, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setExpandRows, SolrQuery_group_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getExpandRows, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setExpandQuery, SolrQuery_setQuery_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getExpandQuery, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addExpandFilterQuery, SolrQuery_addFilterQuery_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeExpandFilterQuery, SolrQuery_addFilterQuery_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getExpandFilterQueries, Solr_no_args, ZEND_ACC_PUBLIC) /* HighlightingParameters */ PHP_ME(SolrQuery, setHighlight, SolrQuery_hl_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlight, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addHighlightField, SolrQuery_hl_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeHighlightField, SolrQuery_hl_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightFields, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightSnippets, SolrQuery_hl_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightSnippets, SolrQuery_hl_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightFragsize, SolrQuery_hl_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightFragsize, SolrQuery_hl_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightMergeContiguous, SolrQuery_hl_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightMergeContiguous, SolrQuery_hl_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightRequireFieldMatch, SolrQuery_hl_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightRequireFieldMatch, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightMaxAnalyzedChars, SolrQuery_hl_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightMaxAnalyzedChars, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightAlternateField, SolrQuery_hl_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightAlternateField, SolrQuery_hl_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightMaxAlternateFieldLength, SolrQuery_hl_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightMaxAlternateFieldLength, SolrQuery_hl_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightFormatter, SolrQuery_hl_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightFormatter, SolrQuery_hl_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightSimplePre, SolrQuery_hl_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightSimplePre, SolrQuery_hl_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightSimplePost, SolrQuery_hl_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightSimplePost, SolrQuery_hl_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightFragmenter, SolrQuery_hl_2_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightFragmenter, SolrQuery_hl_get_1_0_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightUsePhraseHighlighter, SolrQuery_hl_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightUsePhraseHighlighter, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightHighlightMultiTerm, SolrQuery_hl_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightHighlightMultiTerm, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightRegexSlop, SolrQuery_hl_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightRegexSlop, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightRegexPattern, SolrQuery_hl_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightRegexPattern, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setHighlightRegexMaxAnalyzedChars, SolrQuery_hl_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getHighlightRegexMaxAnalyzedChars, Solr_no_args, ZEND_ACC_PUBLIC) /* StatsComponent */ PHP_ME(SolrQuery, setStats, SolrQuery_stats_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getStats, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addStatsField, SolrQuery_stats_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeStatsField, SolrQuery_stats_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getStatsFields, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addStatsFacet, SolrQuery_stats_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeStatsFacet, SolrQuery_stats_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getStatsFacets, Solr_no_args, ZEND_ACC_PUBLIC) /* MoreLikeThis */ PHP_ME(SolrQuery, setMlt, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getMlt, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setMltCount, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getMltCount, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addMltField, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeMltField, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getMltFields, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, addMltQueryField, SolrQuery_mlt_2_2_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, removeMltQueryField, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getMltQueryFields, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setMltMinTermFrequency, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getMltMinTermFrequency, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setMltMinDocFrequency, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getMltMinDocFrequency, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setMltMinWordLength, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getMltMinWordLength, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setMltMaxWordLength, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getMltMaxWordLength, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setMltMaxNumTokens, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getMltMaxNumTokens, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setMltMaxNumQueryTerms, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getMltMaxNumQueryTerms, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setMltBoost, SolrQuery_mlt_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getMltBoost, Solr_no_args, ZEND_ACC_PUBLIC) /* TermsComponent */ PHP_ME(SolrQuery, setTerms, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTerms, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTermsField, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTermsField, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTermsLowerBound, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTermsLowerBound, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTermsUpperBound, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTermsUpperBound, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTermsIncludeLowerBound, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTermsIncludeLowerBound, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTermsIncludeUpperBound, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTermsIncludeUpperBound, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTermsMinCount, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTermsMinCount, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTermsMaxCount, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTermsMaxCount, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTermsPrefix, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTermsPrefix, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTermsLimit, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTermsLimit, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTermsReturnRaw, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTermsReturnRaw, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, setTermsSort, SolrQuery_terms_1_1_args, ZEND_ACC_PUBLIC) PHP_ME(SolrQuery, getTermsSort, Solr_no_args, ZEND_ACC_PUBLIC) /* TODO : TermVectorComponent */ PHP_FE_END }; /* }}} */ /* {{{ solr_response_methods. */ static zend_function_entry solr_response_methods[] = { PHP_ME(SolrResponse, getHttpStatus, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrResponse, getHttpStatusMessage, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrResponse, success, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrResponse, getRequestUrl, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrResponse, getRawRequestHeaders, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrResponse, getRawRequest, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrResponse, getRawResponseHeaders, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrResponse, getRawResponse, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrResponse, getDigestedResponse, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrResponse, setParseMode, SolrResponse_setParseMode_args, ZEND_ACC_PUBLIC) PHP_ME(SolrResponse, getResponse, Solr_no_args, ZEND_ACC_PUBLIC) PHP_ME(SolrResponse, getArrayResponse, Solr_no_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_query_response_methods. */ static zend_function_entry solr_query_response_methods[] = { SOLR_CTOR(SolrQueryResponse, __construct, Solr_no_args) SOLR_DTOR(SolrQueryResponse, __destruct, Solr_no_args) PHP_FE_END }; /* }}} */ /* {{{ solr_update_response_methods. */ static zend_function_entry solr_update_response_methods[] = { SOLR_CTOR(SolrUpdateResponse, __construct, Solr_no_args) SOLR_DTOR(SolrUpdateResponse, __destruct, Solr_no_args) PHP_FE_END }; /* }}} */ /* {{{ solr_ping_response_methods. */ static zend_function_entry solr_ping_response_methods[] = { SOLR_CTOR(SolrPingResponse, __construct, Solr_no_args) SOLR_DTOR(SolrPingResponse, __destruct, Solr_no_args) PHP_ME(SolrPingResponse, getResponse, Solr_no_args, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ /* {{{ solr_generic_response_methods. */ static zend_function_entry solr_generic_response_methods[] = { SOLR_CTOR(SolrGenericResponse, __construct, Solr_no_args) SOLR_DTOR(SolrGenericResponse, __destruct, Solr_no_args) PHP_FE_END }; /* }}} */ /* {{{ solr_utils_methods. */ static zend_function_entry solr_utils_methods[] = { PHP_ME(SolrUtils, escapeQueryChars, SolrUtils_escapeQueryChars_arg, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_ME(SolrUtils, queryPhrase, SolrUtils_escapeQueryChars_arg, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_ME(SolrUtils, digestXmlResponse, SolrUtils_digestXML_arg, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_ME(SolrUtils, digestJsonResponse, SolrUtils_digestJson_arg, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_ME(SolrUtils, getSolrVersion, Solr_no_args, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_ME(SolrUtils, getSolrStats, Solr_no_args, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) PHP_FE_END }; /* }}} */ /* {{{ solr_module_deps */ static zend_module_dep solr_module_deps[] = { ZEND_MOD_REQUIRED(PHP_LIBXML_EXTENSION_NAME) ZEND_MOD_REQUIRED(PHP_JSON_EXTENSION_NAME) ZEND_MOD_END }; /* }}} */ /* {{{ solr_module_entry */ zend_module_entry solr_module_entry = { STANDARD_MODULE_HEADER_EX, NULL, solr_module_deps, PHP_SOLR_EXTENSION_NAME, solr_functions, PHP_MINIT(solr), PHP_MSHUTDOWN(solr), PHP_RINIT(solr), PHP_RSHUTDOWN(solr), PHP_MINFO(solr), PHP_SOLR_DOTTED_VERSION, /* The current extension version number. */ STANDARD_MODULE_PROPERTIES }; /* }}} */ #ifdef COMPILE_DL_SOLR ZEND_GET_MODULE(solr) #endif /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(solr) { #ifdef ZTS /* As of ZE 2.2.0, this has to be NULL. */ /* It causes a segmentation fault, if it points to an actual function */ /* Probably a bug in the Zend Engine API */ ts_allocate_dtor php_solr_globals_dtor = NULL; #endif zend_class_entry ce; memcpy(&solr_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); memcpy(&solr_document_field_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); memcpy(&solr_input_document_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); memcpy(&solr_client_object_handlers, &solr_input_document_object_handlers, sizeof(zend_object_handlers)); memcpy(&solr_collapse_function_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); solr_collapse_function_object_handlers.clone_obj = solr_collapse_function_object_handler_clone; solr_input_document_object_handlers.clone_obj = solr_document_object_handler_clone; /* solr_object_handlers.read_property = solr_object_read_property; */ solr_object_handlers.write_property = solr_object_write_property; solr_object_handlers.write_dimension = solr_object_write_dimension; solr_object_handlers.unset_property = solr_object_unset_property; solr_object_handlers.unset_dimension = solr_object_unset_dimension; solr_document_field_handlers.write_property = solr_document_field_write_property; solr_document_field_handlers.unset_property = solr_document_field_unset_property; #ifdef ZTS ZEND_INIT_MODULE_GLOBALS(solr, php_solr_globals_ctor, php_solr_globals_dtor); #else php_solr_globals_ctor(&solr_globals TSRMLS_CC); #endif /* Register extension constants */ solr_extension_register_constants(type, module_number TSRMLS_CC); /* Register the SolrObject class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_OBJECT_CLASSNAME, solr_object_methods); solr_ce_SolrObject = zend_register_internal_class(&ce TSRMLS_CC); solr_ce_SolrObject->ce_flags |= ZEND_ACC_FINAL; /* SolrObject implements ArrayAccess */ zend_class_implements(solr_ce_SolrObject TSRMLS_CC, 1, solr_ce_ArrayAccess); /* Register the SolrDocument class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_DOCUMENT_CLASSNAME, solr_document_methods); solr_ce_SolrDocument = zend_register_internal_class(&ce TSRMLS_CC); solr_ce_SolrDocument->ce_flags |= ZEND_ACC_FINAL; /* This internal property will be used to map to this SolrDocument instance */ zend_declare_property_long(solr_ce_SolrDocument, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) -1, 0L, ZEND_ACC_PRIVATE TSRMLS_CC); /* Register SolrDocument class constants */ solr_document_register_class_constants(solr_ce_SolrDocument TSRMLS_CC); /* SolrDocument implements ArrayAccess, Iterator, Serializable */ zend_class_implements(solr_ce_SolrDocument TSRMLS_CC, 3, solr_ce_ArrayAccess, solr_ce_Iterator, solr_ce_Serializable); /* Register the SolrDocumentField class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_DOCUMENT_FIELD_CLASSNAME, solr_document_field_methods); solr_ce_SolrDocumentField = zend_register_internal_class(&ce TSRMLS_CC); solr_ce_SolrDocumentField->ce_flags |= ZEND_ACC_FINAL; /* Register the name, boost and values properties */ zend_declare_property_stringl(solr_ce_SolrDocumentField, SOLR_FIELD_NAME_PROPERTY_NAME, sizeof(SOLR_FIELD_NAME_PROPERTY_NAME)-1, SOLR_SPACE_STRING, sizeof(SOLR_SPACE_STRING)-1, ZEND_ACC_PUBLIC TSRMLS_CC); zend_declare_property_double(solr_ce_SolrDocumentField, SOLR_FIELD_BOOST_PROPERTY_NAME, sizeof(SOLR_FIELD_BOOST_PROPERTY_NAME)-1, 0.0f, ZEND_ACC_PUBLIC TSRMLS_CC); zend_declare_property_null(solr_ce_SolrDocumentField, SOLR_FIELD_VALUES_PROPERTY_NAME, sizeof(SOLR_FIELD_VALUES_PROPERTY_NAME)-1, ZEND_ACC_PUBLIC TSRMLS_CC); /* Register the SolrInputDocument class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_INPUT_DOCUMENT_CLASSNAME, solr_input_document_methods); solr_ce_SolrInputDocument = zend_register_internal_class(&ce TSRMLS_CC); solr_ce_SolrInputDocument->ce_flags |= ZEND_ACC_FINAL; /* This internal property will be used to map to this SolrDocument instance */ zend_declare_property_long(solr_ce_SolrInputDocument, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) -1, 0L, ZEND_ACC_PRIVATE TSRMLS_CC); /* Register SolrInputDocument class constants */ solr_document_register_class_constants(solr_ce_SolrInputDocument TSRMLS_CC); /* Register SolrClient Class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_CLIENT_CLASSNAME, solr_client_methods); solr_ce_SolrClient = zend_register_internal_class(&ce TSRMLS_CC); /* solr_ce_SolrClient->ce_flags |= ZEND_ACC_FINAL; */ /* This internal property will be used to map to this SolrClient instance */ zend_declare_property_long(solr_ce_SolrClient, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) -1, 0L, ZEND_ACC_PRIVATE TSRMLS_CC); /* Register SolrClient class constants */ solr_client_register_class_constants(solr_ce_SolrClient TSRMLS_CC); /* Register the SolrParams class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_PARAMS_CLASSNAME, solr_params_methods); solr_ce_SolrParams = zend_register_internal_class(&ce TSRMLS_CC); solr_ce_SolrParams->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; zend_class_implements(solr_ce_SolrParams TSRMLS_CC, 1, solr_ce_Serializable); /* This internal property will be used to map to this SolrParams instance */ zend_declare_property_long(solr_ce_SolrParams, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) -1, 0L, ZEND_ACC_PROTECTED TSRMLS_CC); /* Register the SolrModifiableParams class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_MODIFIABLE_PARAMS_CLASSNAME, solr_modifiable_params_methods); solr_ce_SolrModifiableParams = zend_register_internal_class_ex(&ce, solr_ce_SolrParams); /* Register the SolrQuery class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_QUERY_CLASSNAME, solr_query_methods); solr_ce_SolrQuery = zend_register_internal_class_ex(&ce, solr_ce_SolrModifiableParams); init_solr_dismax_query(TSRMLS_C); solr_query_register_class_constants(solr_ce_SolrQuery TSRMLS_CC); /* Register the SolrCollapseFunction class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_COLLAPSE_FUNCTION_CLASSNAME, solr_collapse_function_methods); solr_ce_SolrCollapseFunction = zend_register_internal_class_ex(&ce, solr_ce_SolrCollapseFunction); zend_declare_property_long(solr_ce_SolrCollapseFunction, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME)-1, 0l, ZEND_ACC_PROTECTED TSRMLS_CC); solr_collapse_function_register_class_constants(solr_ce_SolrCollapseFunction TSRMLS_CC); /* Register the SolrResponse base class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_RESPONSE_CLASSNAME, solr_response_methods); solr_ce_SolrResponse = zend_register_internal_class(&ce TSRMLS_CC); solr_ce_SolrResponse->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; /* Register all the properties for the SolrResponse object */ solr_response_register_class_properties(solr_ce_SolrResponse TSRMLS_CC); /* Register all the constants for the SolrResponse object */ solr_response_register_class_constants(solr_ce_SolrResponse TSRMLS_CC); /* Register the SolrQueryResponse class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_QUERY_RESPONSE_CLASSNAME, solr_query_response_methods); solr_ce_SolrQueryResponse = zend_register_internal_class_ex(&ce, solr_ce_SolrResponse); solr_ce_SolrQueryResponse->ce_flags |= ZEND_ACC_FINAL; /* Register the SolrUpdateResponse class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_UPDATE_RESPONSE_CLASSNAME, solr_update_response_methods); solr_ce_SolrUpdateResponse = zend_register_internal_class_ex(&ce, solr_ce_SolrResponse); solr_ce_SolrUpdateResponse->ce_flags |= ZEND_ACC_FINAL; /* Register the SolrPingResponse class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_PING_RESPONSE_CLASSNAME, solr_ping_response_methods); solr_ce_SolrPingResponse = zend_register_internal_class_ex(&ce, solr_ce_SolrResponse); solr_ce_SolrPingResponse->ce_flags |= ZEND_ACC_FINAL; /* Register the SolrGenericResponse class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_GENERIC_RESPONSE_CLASSNAME, solr_generic_response_methods); solr_ce_SolrGenericResponse = zend_register_internal_class_ex(&ce, solr_ce_SolrResponse); solr_ce_SolrGenericResponse->ce_flags |= ZEND_ACC_FINAL; /* Register the SolrUtils class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_UTILS_CLASSNAME, solr_utils_methods); solr_ce_SolrUtils = zend_register_internal_class(&ce TSRMLS_CC); solr_ce_SolrUtils->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; /* Register the SolrException class */ INIT_CLASS_ENTRY(ce, PHP_SOLR_EXCEPTION_CLASSNAME, solr_exception_methods); solr_ce_SolrException = zend_register_internal_class_ex(&ce, solr_ce_Exception); solr_exception_register_class_properties(solr_ce_SolrException TSRMLS_CC); INIT_CLASS_ENTRY(ce, PHP_SOLR_ILLEGAL_OPERATION_EXCEPTION_CLASSNAME, solr_illegal_operation_exception_methods); solr_ce_SolrIllegalOperationException = zend_register_internal_class_ex(&ce, solr_ce_SolrException); INIT_CLASS_ENTRY(ce, PHP_SOLR_ILLEGAL_ARGUMENT_EXCEPTION_CLASSNAME, solr_illegal_argument_exception_methods); solr_ce_SolrIllegalArgumentException = zend_register_internal_class_ex(&ce, solr_ce_SolrException); INIT_CLASS_ENTRY(ce, PHP_SOLR_CLIENT_EXCEPTION_CLASSNAME, solr_client_exception_methods); solr_ce_SolrClientException = zend_register_internal_class_ex(&ce, solr_ce_SolrException); INIT_CLASS_ENTRY(ce, PHP_SOLR_SERVER_EXCEPTION_CLASSNAME, solr_server_exception_methods); solr_ce_SolrServerException = zend_register_internal_class_ex(&ce, solr_ce_SolrException); INIT_CLASS_ENTRY(ce, PHP_SOLR_MISSING_MANDATORY_PARAMETER_EXCEPTION_CLASSNAME, NULL); solr_ce_SolrMissingMandatoryParameterException = zend_register_internal_class_ex(&ce, solr_ce_SolrException); return SUCCESS; } /* }}} */ /* {{{ PHP_RINIT_FUNCTION */ PHP_RINIT_FUNCTION(solr) { zend_bool persistent = SOLR_HASHTABLE_PERSISTENT; /* Initial size of the HashTable */ uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE; ALLOC_HASHTABLE(SOLR_GLOBAL(documents)); ALLOC_HASHTABLE(SOLR_GLOBAL(clients)); ALLOC_HASHTABLE(SOLR_GLOBAL(params)); ALLOC_HASHTABLE(SOLR_GLOBAL(functions)); /* Initialize the HashTable for directory for SolrInputDocuments */ zend_hash_init(SOLR_GLOBAL(documents), nSize, NULL, solr_destroy_document, persistent); zend_hash_init(SOLR_GLOBAL(clients), nSize, NULL, solr_destroy_client, persistent); /* Initialize the HashTable for directory of SolrParams */ zend_hash_init(SOLR_GLOBAL(params), nSize, NULL, solr_destroy_params, persistent); zend_hash_init(SOLR_GLOBAL(functions), nSize, NULL, solr_destroy_function, persistent); return SUCCESS; } /* }}} */ /* {{{ PHP_RSHUTDOWN_FUNCTION */ PHP_RSHUTDOWN_FUNCTION(solr) { zend_hash_destroy(SOLR_GLOBAL(documents)); zend_hash_destroy(SOLR_GLOBAL(clients)); zend_hash_destroy(SOLR_GLOBAL(params)); zend_hash_destroy(SOLR_GLOBAL(functions)); FREE_HASHTABLE(SOLR_GLOBAL(documents)); FREE_HASHTABLE(SOLR_GLOBAL(clients)); FREE_HASHTABLE(SOLR_GLOBAL(params)); FREE_HASHTABLE(SOLR_GLOBAL(functions)); return SUCCESS; } /* }}} */ /* {{{ PHP_MSHUTDOWN_FUNCTION */ PHP_MSHUTDOWN_FUNCTION(solr) { return SUCCESS; } /* }}} */ /* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(solr) { php_info_print_table_start(); php_info_print_table_header(2, "Solr Support", "enabled"); php_info_print_table_row(2, "Version", PHP_SOLR_DOTTED_VERSION); php_info_print_table_row(2, "Last Build Date", __DATE__); php_info_print_table_row(2, "Last Build Time", __TIME__); php_info_print_table_end(); } /* }}} */ #endif /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/php_solr_client.c0000644000175000017500000017033712676753707016206 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* {{{ Macros */ /* resets the key_str with key and tries to find the zv */ static inline int solr_opt_check(HashTable *options_ht, const char * key, zend_string * key_str, zval ** zv) { int result = 0; key_str = zend_string_init(key, strlen (key), 0); result = (*zv = zend_hash_find(options_ht, key_str)) != NULL; zend_string_release(key_str); return result; } /* {{{ static void solr_client_init_urls(solr_client_t *solr_client) */ static void solr_client_init_urls(solr_client_t *solr_client) { solr_string_t url_prefix; solr_client_options_t *options = &(solr_client->options); memset(&url_prefix, 0, sizeof(solr_string_t)); /* Release all previously allocated URL values, if any */ solr_string_free(&(options->update_url)); solr_string_free(&(options->search_url)); solr_string_free(&(options->thread_url)); solr_string_free(&(options->ping_url)); solr_string_free(&(options->terms_url)); solr_string_free(&(options->system_url)); solr_string_free(&(options->get_url)); /* Making http://hostname:host_port/path/ */ if (options->secure) { solr_string_append_const(&url_prefix, "https://"); } else { solr_string_append_const(&url_prefix, "http://"); } solr_string_append_solr_string(&url_prefix, &(options->hostname)); solr_string_appendc(&url_prefix, ':'); solr_string_append_long(&url_prefix, options->host_port); solr_string_appendc(&url_prefix, '/'); solr_string_append_solr_string(&url_prefix, &(options->path)); solr_string_appendc(&url_prefix, '/'); /* Copying over the prefixes */ solr_string_append_solr_string(&(options->update_url), &url_prefix); solr_string_append_solr_string(&(options->search_url), &url_prefix); solr_string_append_solr_string(&(options->thread_url), &url_prefix); solr_string_append_solr_string(&(options->ping_url), &url_prefix); solr_string_append_solr_string(&(options->terms_url), &url_prefix); solr_string_append_solr_string(&(options->system_url), &url_prefix); solr_string_append_solr_string(&(options->get_url), &url_prefix); /* Making http://hostname:host_port/path/servlet/ */ solr_string_append_solr_string(&(options->update_url), &(options->update_servlet)); solr_string_append_solr_string(&(options->search_url), &(options->search_servlet)); solr_string_append_solr_string(&(options->thread_url), &(options->thread_servlet)); solr_string_append_solr_string(&(options->ping_url), &(options->ping_servlet)); solr_string_append_solr_string(&(options->terms_url), &(options->terms_servlet)); solr_string_append_solr_string(&(options->system_url), &(options->system_servlet)); solr_string_append_solr_string(&(options->get_url), &(options->get_servlet)); solr_string_append_const(&(options->update_url), "/?version=2.2&indent=on&wt="); solr_string_append_const(&(options->search_url), "/?version=2.2&indent=on&wt="); solr_string_append_const(&(options->thread_url), "/?version=2.2&indent=on&wt="); solr_string_append_const(&(options->ping_url), "/?version=2.2&indent=on&wt="); solr_string_append_const(&(options->terms_url), "/?version=2.2&indent=on&wt="); solr_string_append_const(&(options->system_url), "/?version=2.2&indent=on&wt="); solr_string_append_const(&(options->get_url), "/?version=2.2&indent=on&wt="); solr_string_append_solr_string(&(options->update_url), &(options->response_writer)); solr_string_append_solr_string(&(options->search_url), &(options->response_writer)); solr_string_append_solr_string(&(options->thread_url), &(options->response_writer)); solr_string_append_solr_string(&(options->ping_url), &(options->response_writer)); solr_string_append_solr_string(&(options->terms_url), &(options->response_writer)); solr_string_append_solr_string(&(options->system_url), &(options->response_writer)); solr_string_append_solr_string(&(options->get_url), &(options->response_writer)); solr_string_free(&url_prefix); } /* }}} */ /* {{{ static int solr_http_build_query(solr_string_t *buffer, zval *params_objptr, const solr_char_t *delimiter, int delimiter_length TSRMLS_DC) */ static int solr_http_build_query(solr_string_t *buffer, zval *params_objptr, const solr_char_t *delimiter, int delimiter_length TSRMLS_DC) { solr_params_t *solr_params = NULL; HashTable *params = NULL; solr_param_t *solr_param = NULL; if (solr_fetch_params_entry(params_objptr, &solr_params TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve solr_params_t"); return FAILURE; } params = solr_params->params; ZEND_HASH_FOREACH_PTR(params, solr_param) { solr_string_t tmp_values_buffer; memset(&tmp_values_buffer, 0, sizeof(solr_string_t)); solr_param->fetch_func(solr_param, &tmp_values_buffer); solr_string_append_solr_string(buffer, &tmp_values_buffer); solr_string_appends(buffer, delimiter, delimiter_length); solr_string_free(&tmp_values_buffer); } ZEND_HASH_FOREACH_END(); solr_string_remove_last_char(buffer); return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API solr_client_t* solr_init_client(zval * objptr TSRMLS_DC) inititialize solr_client_t and update zval's index */ PHP_SOLR_API solr_client_t *solr_init_client(zval *objptr TSRMLS_DC) { long int client_index = SOLR_UNIQUE_CLIENT_INDEX(); solr_client_t *solr_client = NULL; zend_update_property_long(solr_ce_SolrClient, objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, client_index TSRMLS_CC); solr_client = (solr_client_t *) pemalloc(sizeof(solr_client_t), SOLR_CLIENT_PERSISTENT); memset(solr_client, 0, sizeof(solr_client_t)); solr_client->client_index = client_index; if ((solr_client = zend_hash_index_update_ptr(SOLR_GLOBAL(clients), client_index, (void *)solr_client)) == NULL) { pefree(solr_client, SOLR_CLIENT_PERSISTENT); php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error while registering client in HashTable"); return NULL; } return solr_client; } /* }}} */ /******************************************************************************/ /** DEFINITIONS FOR SOLR CLIENT METHODS **/ /******************************************************************************/ /* {{{ proto SolrClient::__construct(array options ) Constructor for SolrClient */ PHP_METHOD(SolrClient, __construct) { zval *options = NULL; zval *objptr = getThis(); HashTable *options_ht = NULL; zval *tmp1 = NULL, *tmp2 = NULL; solr_client_t *solr_client_dest = NULL; solr_client_options_t *client_options = NULL; solr_curl_t *handle = NULL; zend_string *key_str; /* tmp storage to use with zend_hash_find */ key_str = zend_string_init("", 0, 0); size_t num_options = 0; long int secure = 0L; long int verify_peer = 0L; long int verify_host = 2L; long int timeout = 30L; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &options) == FAILURE) { zend_string_release(key_str); solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter. The client options array is required for a SolrClient instance. It must also be passed as the only parameter"); return; } options_ht = Z_ARRVAL_P(options); num_options = zend_hash_num_elements(options_ht); if (!num_options) { zend_string_release(key_str); solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "The SolrClient options cannot be an empty array"); return; } solr_client_dest = solr_init_client(objptr TSRMLS_CC); if (!solr_client_dest) { zend_string_release(key_str); solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Unable to initialize solr_client_t "); return; } /* Release the original pointer */ client_options = &(solr_client_dest->options); handle = &(solr_client_dest->handle); solr_init_options(client_options TSRMLS_CC); solr_string_append_const(&(client_options->response_writer), SOLR_XML_RESPONSE_WRITER); solr_string_append_const(&(client_options->update_servlet), SOLR_DEFAULT_UPDATE_SERVLET); solr_string_append_const(&(client_options->search_servlet), SOLR_DEFAULT_SEARCH_SERVLET); solr_string_append_const(&(client_options->thread_servlet), SOLR_DEFAULT_THREADS_SERVLET); solr_string_append_const(&(client_options->ping_servlet), SOLR_DEFAULT_PING_SERVLET); solr_string_append_const(&(client_options->terms_servlet), SOLR_DEFAULT_TERMS_SERVLET); solr_string_append_const(&(client_options->system_servlet), SOLR_DEFAULT_SYSTEM_SERVLET); solr_string_append_const(&(client_options->get_servlet), SOLR_DEFAULT_GET_SERVLET); if ( solr_opt_check(options_ht, "wt", key_str, &tmp1) && Z_TYPE_P(tmp1) == IS_STRING && Z_STRLEN_P(tmp1)) { if (solr_is_supported_response_writer((solr_char_t *)Z_STRVAL_P(tmp1), Z_STRLEN_P(tmp1))) { solr_string_set(&(client_options->response_writer), (const solr_char_t *) Z_STRVAL_P(tmp1), Z_STRLEN_P(tmp1)); } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported response writer %s. This value will be ignored", Z_STRVAL_P(tmp1)); } } if (solr_opt_check(options_ht, "secure", key_str, &tmp1)) { if (Z_TYPE_P(tmp1) == IS_TRUE) { secure = (long int) 1L; } else if (Z_TYPE_P(tmp1) == IS_LONG) { secure = Z_LVAL_P(tmp1); } } client_options->secure = secure; /** * FOR NOW LET'S LEAVE IT AT 2 : This will force and require a match on the common name * if (secure && zend_hash_find(options_ht, "ssl_verifyhost", sizeof("ssl_verifyhost"), (void**) &tmp1) == SUCCESS && Z_TYPE_P(tmp1) == IS_LONG) { verify_host = ((Z_LVAL_P(tmp1) > 0L && Z_LVAL_P(tmp1) < 3L) ? Z_LVAL_P(tmp1) : verify_host); } */ client_options->ssl_verify_host = verify_host; if (secure && solr_opt_check(options_ht, "ssl_cert", key_str, &tmp1) && Z_TYPE_P(tmp1) == IS_STRING && Z_STRLEN_P(tmp1)) { verify_peer = 1L; solr_string_appends(&(client_options->ssl_cert), Z_STRVAL_P(tmp1), Z_STRLEN_P(tmp1)); } if (secure && solr_opt_check(options_ht, "ssl_key", key_str, &tmp1) && Z_TYPE_P(tmp1) == IS_STRING && Z_STRLEN_P(tmp1)) { verify_peer = 1L; solr_string_appends(&(client_options->ssl_key), (solr_char_t *) Z_STRVAL_P(tmp1), Z_STRLEN_P(tmp1)); } if (secure && solr_opt_check(options_ht, "ssl_keypassword", key_str, &tmp1) && Z_TYPE_P(tmp1) == IS_STRING && Z_STRLEN_P(tmp1)) { verify_peer = 1L; solr_string_appends(&(client_options->ssl_keypassword), (solr_char_t *) Z_STRVAL_P(tmp1), Z_STRLEN_P(tmp1)); } // ssl_cainfo if (secure && solr_opt_check(options_ht, "ssl_cainfo", key_str, &tmp1) && Z_TYPE_P(tmp1) == IS_STRING && Z_STRLEN_P(tmp1)) { verify_peer = 1L; solr_string_appends(&(client_options->ssl_cainfo), (solr_char_t *) Z_STRVAL_P(tmp1), Z_STRLEN_P(tmp1)); } // ssl_capath if (secure && solr_opt_check(options_ht, "ssl_capath", key_str, &tmp1) && Z_TYPE_P(tmp1) == IS_STRING && Z_STRLEN_P(tmp1)) { verify_peer = 1L; solr_string_appends(&(client_options->ssl_capath), (solr_char_t *) Z_STRVAL_P(tmp1), Z_STRLEN_P(tmp1)); } client_options->ssl_verify_peer = verify_peer; // hostname if (solr_opt_check(options_ht, "hostname", key_str, &tmp1) && Z_TYPE_P(tmp1) == IS_STRING && Z_STRLEN_P(tmp1)) { solr_string_appends(&(client_options->hostname), (solr_char_t *) Z_STRVAL_P(tmp1), Z_STRLEN_P(tmp1)); } else { solr_string_append_const(&(client_options->hostname), SOLR_REQUEST_DEFAULT_HOST); } // port if (solr_opt_check(options_ht, "port", key_str, &tmp1) && Z_TYPE_P(tmp1) == IS_LONG) { client_options->host_port = Z_LVAL_P(tmp1); } else if (solr_opt_check(options_ht, "port", key_str, &tmp1) && Z_TYPE_P(tmp1) == IS_STRING && Z_STRLEN_P(tmp1)) { long int host_port = atol(Z_STRVAL_P(tmp1)); if (host_port) { client_options->host_port = host_port; } else { client_options->host_port = SOLR_REQUEST_DEFAULT_PORT; } } else { client_options->host_port = SOLR_REQUEST_DEFAULT_PORT; } if (solr_opt_check(options_ht, "timeout", key_str, &tmp1)) { long int timeout_value = 30L; if (Z_TYPE_P(tmp1) == IS_LONG) { timeout_value = Z_LVAL_P(tmp1); } else if (Z_TYPE_P(tmp1) == IS_STRING && Z_STRLEN_P(tmp1)) { timeout_value = atol(Z_STRVAL_P(tmp1)); } timeout = ((timeout_value > 0L) ? timeout_value : timeout); } client_options->timeout = timeout; if (solr_opt_check(options_ht, "path", key_str, &tmp1) && Z_TYPE_P(tmp1) == IS_STRING && Z_STRLEN_P(tmp1)) { char *path_to_solr = Z_STRVAL_P(tmp1); size_t path_to_solr_start = 0; size_t length_adjustment = 0; if (path_to_solr[0] == '/') { path_to_solr_start = length_adjustment = 1; } if (path_to_solr[Z_STRLEN_P(tmp1)] == '/') { length_adjustment++; } solr_string_appends(&(client_options->path), Z_STRVAL_P(tmp1) + path_to_solr_start, Z_STRLEN_P(tmp1) - length_adjustment); } else { solr_string_append_const(&(client_options->path), SOLR_REQUEST_DEFAULT_PATH); } if ( solr_opt_check(options_ht, "query_string_delimiter", key_str, &tmp1) && Z_TYPE_P(tmp1) == IS_STRING) { solr_string_appends(&(client_options->qs_delimiter), Z_STRVAL_P(tmp1), Z_STRLEN_P(tmp1)); } else { solr_string_append_const(&(client_options->qs_delimiter), SOLR_REQUEST_DEFAULT_QS_DELIMITER); } if ( solr_opt_check(options_ht, "login", key_str, &tmp1) && Z_TYPE_P(tmp1) == IS_STRING && solr_opt_check(options_ht, "password", key_str, &tmp2) && Z_TYPE_P(tmp2) == IS_STRING) { solr_string_appends(&(client_options->http_auth_credentials), Z_STRVAL_P(tmp1), Z_STRLEN_P(tmp1)); solr_string_appendc(&(client_options->http_auth_credentials), ':'); solr_string_appends(&(client_options->http_auth_credentials), Z_STRVAL_P(tmp2), Z_STRLEN_P(tmp2)); } if (solr_opt_check(options_ht, "proxy_host", key_str, &tmp1) && Z_TYPE_P(tmp1) == IS_STRING) { solr_string_appends(&(client_options->proxy_hostname), Z_STRVAL_P(tmp1), Z_STRLEN_P(tmp1)); } if (solr_opt_check(options_ht, "proxy_port", key_str, &tmp1)) { long int proxy_port_value = 0L; if (Z_TYPE_P(tmp1) == IS_LONG) { proxy_port_value = Z_LVAL_P(tmp1); } else if (Z_TYPE_P(tmp1) == IS_STRING && Z_STRLEN_P(tmp1)) { proxy_port_value = atol(Z_STRVAL_P(tmp1)); } if (proxy_port_value > 0L) { client_options->proxy_port = proxy_port_value; } } if (solr_opt_check(options_ht, "proxy_login", key_str, &tmp1) && Z_TYPE_P(tmp1) == IS_STRING && solr_opt_check(options_ht, "proxy_password", key_str, &tmp2) && Z_TYPE_P(tmp2) == IS_STRING) { solr_string_appends(&(client_options->proxy_auth_credentials), Z_STRVAL_P(tmp1), Z_STRLEN_P(tmp1)); solr_string_appendc(&(client_options->proxy_auth_credentials), ':'); solr_string_appends(&(client_options->proxy_auth_credentials), Z_STRVAL_P(tmp2), Z_STRLEN_P(tmp2)); } solr_init_handle(handle, client_options TSRMLS_CC); zend_string_free(key_str); SOLR_GLOBAL(client_count)++; } /* }}} */ /* {{{ proto SolrClient::__destruct(void) Destructor for SolrClient */ PHP_METHOD(SolrClient, __destruct) { solr_client_t *solr_client = NULL; if (solr_fetch_client_entry(getThis(), &solr_client TSRMLS_CC) == SUCCESS) { zend_hash_index_del(SOLR_GLOBAL(clients), solr_client->client_index); /* Keep track of how many SolrClient instances we have. */ SOLR_GLOBAL(client_count)--; return ; } } /* }}} */ /* {{{ proto SolrClient::__sleep(void) Should not be called directly. Serialization is not supported. */ PHP_METHOD(SolrClient, __sleep) { solr_init_client(getThis() TSRMLS_CC); solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1001 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1001_MSG); } /* }}} */ /* {{{ proto SolrClient::__wakeup(void) Should not be called directly. Serialization is not supported. */ PHP_METHOD(SolrClient, __wakeup) { solr_init_client(getThis() TSRMLS_CC); solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1001 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1001_MSG); } /* }}} */ /* {{{ proto SolrClient::__clone(void) Should not be called directly. Cloning is not supported. */ PHP_METHOD(SolrClient, __clone) { solr_init_client(getThis() TSRMLS_CC); solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_4001 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Cloning of SolrClient objects is currently not supported"); } /* }}} */ /* {{{ proto bool SolrClient::setServelet(int servlet_type, string new_value) Changes the specified servlet type to a new value */ PHP_METHOD(SolrClient, setServlet) { long int servlet_type_value = 0L; solr_char_t *new_servlet_value = NULL; COMPAT_ARG_SIZE_T new_servlet_value_length = 0; solr_client_t *client = NULL; solr_servlet_type_t servlet_type = SOLR_SERVLET_TYPE_BEGIN; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &servlet_type_value, &new_servlet_value, &new_servlet_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter."); RETURN_FALSE; } if (!new_servlet_value_length) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid servlet value."); RETURN_FALSE; } /* Retrieve the client entry */ if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client"); RETURN_FALSE; } servlet_type = (solr_servlet_type_t) servlet_type_value; switch(servlet_type) { case SOLR_SERVLET_TYPE_SEARCH : { solr_string_set(&(client->options.search_servlet), new_servlet_value, new_servlet_value_length); } break; case SOLR_SERVLET_TYPE_TERMS : { solr_string_set(&(client->options.terms_servlet), new_servlet_value, new_servlet_value_length); } break; case SOLR_SERVLET_TYPE_UPDATE : { solr_string_set(&(client->options.update_servlet), new_servlet_value, new_servlet_value_length); } break; case SOLR_SERVLET_TYPE_THREADS : { solr_string_set(&(client->options.thread_servlet), new_servlet_value, new_servlet_value_length); } break; case SOLR_SERVLET_TYPE_PING : { solr_string_set(&(client->options.ping_servlet), new_servlet_value, new_servlet_value_length); } break; case SOLR_SERVLET_TYPE_SYSTEM : { solr_string_set(&(client->options.system_servlet), new_servlet_value, new_servlet_value_length); } break; default : { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid Servlet type %ld specified. Value discarded.", servlet_type_value); RETURN_FALSE; } } RETURN_TRUE; } /* }}} */ // client->handle.err.str client->handle.request_body_debug.buffer.str /* {{{ proto SolrQueryResponse SolrClient::query(SolrParams query) Sends a name-value pair request to the Solr server. */ PHP_METHOD(SolrClient, query) { zval *solr_params_obj = NULL; solr_client_t *client = NULL; solr_params_t *solr_params = NULL; solr_string_t *buffer = NULL; solr_char_t *delimiter = NULL; COMPAT_ARG_SIZE_T delimiter_length = 0; zend_bool success = 1; solr_request_type_t solr_request_type = SOLR_REQUEST_SEARCH; solr_string_t *request_url = NULL; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &solr_params_obj, solr_ce_SolrParams) == FAILURE) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_4000_MSG); return; } /* Retrieve the client entry */ if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client"); return; } /* Make sure the SolrParams object passed is a valid one */ if (solr_fetch_params_entry(solr_params_obj, &solr_params TSRMLS_CC) == FAILURE) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "SolrParams parameter passed is not a valid one."); return ; } /* The SolrParams instance must contain at least one parameter */ if (zend_hash_num_elements(solr_params->params) < 1) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "SolrParams parameter passed contains no parameters."); return ; } buffer = &(client->handle.request_body.buffer); /* Get rid of all the data from the previous request */ solr_string_free(buffer); delimiter = client->options.qs_delimiter.str; delimiter_length = client->options.qs_delimiter.len; /* Remove wt if any */ zend_hash_str_del(solr_params->params, "wt", sizeof("wt")-1); if (solr_http_build_query(buffer, solr_params_obj, delimiter, delimiter_length TSRMLS_CC) == FAILURE) { solr_throw_exception_ex(solr_ce_SolrException, SOLR_ERROR_1003 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Error building HTTP query from parameters"); return; } /* Always reset the URLs before making any request */ solr_client_init_urls(client); request_url = &(client->options.search_url); /* terms.fl is a required parameter for the TermsComponent */ if (zend_hash_str_exists(solr_params->params, "terms.fl", sizeof("terms.fl")-1)) { /* Change the request type to a TermsComponent request */ solr_request_type = SOLR_REQUEST_TERMS; request_url =&(client->options.terms_url); } /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, solr_request_type TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"query"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } object_init_ex(return_value, solr_ce_SolrQueryResponse); solr_set_response_object_properties(solr_ce_SolrQueryResponse, return_value, client, request_url, success TSRMLS_CC); } /* }}} */ /* {{{ proto SolrUpdateResponse SolrClient::addDocument(SolrInputDocument doc [, bool overwrite [, int commitWithin]]) Adds a document to the Solr server. */ PHP_METHOD(SolrClient, addDocument) { zval *solr_input_doc = NULL; zend_bool overwrite = 1; long int commitWithin = 0L; solr_document_t *doc_entry = NULL; solr_client_t *client = NULL; HashTable *document_fields; xmlNode *root_node = NULL; xmlDoc *doc_ptr = NULL; char *overwriteValue = NULL; int format = 1; int size = 0; xmlChar *request_string = NULL; zend_bool success = 1; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|bl", &solr_input_doc, solr_ce_SolrInputDocument, &overwrite, &commitWithin) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter."); return; } if (solr_fetch_document_entry(solr_input_doc, &doc_entry TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "SolrInputDocument is not valid. Object not present in HashTable"); return; } document_fields = doc_entry->fields; /* Document must contain at least one field */ if (0 == zend_hash_num_elements(document_fields)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "SolrInputDocument has no fields"); return; } /* Retrieve the client entry */ if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client"); return; } doc_ptr = solr_xml_create_xml_doc((xmlChar *) "add", &root_node); overwriteValue = (overwrite)? "true" : "false"; xmlNewProp(root_node, (xmlChar *) "overwrite", (xmlChar *) overwriteValue); if (commitWithin > 0L) { auto char commitWithinBuffer[32]; memset(commitWithinBuffer, 0, sizeof(commitWithinBuffer)); php_sprintf(commitWithinBuffer, "%ld", commitWithin); xmlNewProp(root_node, (xmlChar *) "commitWithin", (xmlChar *) commitWithinBuffer); } solr_add_doc_node(root_node, doc_entry TSRMLS_CC); xmlIndentTreeOutput = 1; xmlDocDumpFormatMemoryEnc(doc_ptr, &request_string, &size, "UTF-8", format); /* The XML request we are sending to Solr */ solr_string_set(&(client->handle.request_body.buffer), (solr_char_t *) request_string, size); xmlFree(request_string); xmlFreeDoc(doc_ptr); /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_UPDATE TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"update"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } object_init_ex(return_value, solr_ce_SolrUpdateResponse); solr_set_response_object_properties(solr_ce_SolrUpdateResponse, return_value, client, &(client->options.update_url), success TSRMLS_CC); } /* }}} */ /* {{{ proto SolrUpdateResponse SolrClient::addDocuments(array docs [, bool overwrite [, int commitWithin]]) Adds an array of SolrInputDocuments to the Solr server. */ PHP_METHOD(SolrClient, addDocuments) { zval *docs_array = NULL; zend_bool overwrite = 1; long int commitWithin = 0L; HashTable *solr_input_docs; size_t num_input_docs = 0; solr_client_t *client = NULL; solr_document_t **doc_entries = NULL; size_t curr_pos = 0U; xmlNode *root_node = NULL; xmlDoc *doc_ptr = NULL; xmlChar *overwriteValue = NULL; size_t pos = 0U; solr_document_t *current_doc_entry = NULL; int format = 1; int size = 0; zend_bool success = 1; xmlChar *request_string = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|bl", &docs_array, &overwrite, &commitWithin) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } solr_input_docs = Z_ARRVAL_P(docs_array); num_input_docs = zend_hash_num_elements(solr_input_docs); if(!num_input_docs) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "The array parameter passed is empty"); return; } /* This should be released if there is an error */ doc_entries = (solr_document_t **) pemalloc((sizeof(solr_document_t *) * (num_input_docs + 1)), SOLR_DOCUMENT_PERSISTENT); memset(doc_entries, 0, sizeof(solr_document_t *) * (num_input_docs + 1)); /* Please check all the SolrInputDocument instances passed via the array */ SOLR_HASHTABLE_FOR_LOOP(solr_input_docs) { zval *solr_input_doc = NULL; solr_document_t *doc_entry = NULL; HashTable *document_fields; solr_input_doc = zend_hash_get_current_data(solr_input_docs); if (Z_TYPE_P(solr_input_doc) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(solr_input_doc), solr_ce_SolrInputDocument TSRMLS_CC)) { SOLR_FREE_DOC_ENTRIES(doc_entries); solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "SolrInputDocument number %u is not a valid SolrInputDocument instance", (curr_pos + 1U)); return; } if (solr_fetch_document_entry((solr_input_doc), &doc_entry TSRMLS_CC) == FAILURE) { SOLR_FREE_DOC_ENTRIES(doc_entries); solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "SolrInputDocument number %u is not valid. Object not present in HashTable", (curr_pos + 1U)); return; } document_fields = doc_entry->fields; /* SolrInputDocument must contain at least one field */ if (0 == zend_hash_num_elements(document_fields)) { SOLR_FREE_DOC_ENTRIES(doc_entries); solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "SolrInputDocument number %u has no fields", (curr_pos + 1U)); return; } doc_entries[curr_pos] = doc_entry; curr_pos++; } /* Mark the end of the list */ doc_entries[curr_pos] = NULL; /* All the input documents have been validated. We can now retrieve the client entry */ if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { SOLR_FREE_DOC_ENTRIES(doc_entries); php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client from HashTable"); return; } doc_ptr = solr_xml_create_xml_doc((xmlChar *) "add", &root_node); overwriteValue = (overwrite) ? (xmlChar *) "true" : (xmlChar *) "false"; xmlNewProp(root_node, (xmlChar *) "overwrite", overwriteValue); if (commitWithin > 0L) { auto char commitWithinBuffer[32]; memset(commitWithinBuffer, 0, sizeof(commitWithinBuffer)); php_sprintf(commitWithinBuffer, "%ld", commitWithin); xmlNewProp(root_node, (xmlChar *) "commitWithin", (xmlChar *) commitWithinBuffer); } /* Grab the first (solr_document_t *) pointer */ current_doc_entry = doc_entries[pos]; while(current_doc_entry != NULL) { solr_add_doc_node(root_node, current_doc_entry TSRMLS_CC); pos++; /* Grab the next (solr_document_t *) pointer */ current_doc_entry = doc_entries[pos]; } /* We are done with the doc_entries pointer */ SOLR_FREE_DOC_ENTRIES(doc_entries); xmlIndentTreeOutput = 1; xmlDocDumpFormatMemoryEnc(doc_ptr, &request_string, &size, "UTF-8", format); /* The XML request we are sending to Solr */ solr_string_set(&(client->handle.request_body.buffer), (solr_char_t *) request_string, size); xmlFree(request_string); xmlFreeDoc(doc_ptr); /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_UPDATE TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"update"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } object_init_ex(return_value, solr_ce_SolrUpdateResponse); solr_set_response_object_properties(solr_ce_SolrUpdateResponse, return_value, client, &(client->options.update_url), success TSRMLS_CC); } /* }}} */ /* {{{ proto SolrUpdateResponse SolrClient::request(string request_string) Allows the user to send a manual XML update request */ PHP_METHOD(SolrClient, request) { solr_char_t *request_string = NULL; COMPAT_ARG_SIZE_T request_length = 0; solr_client_t *client = NULL; zend_bool success = 1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &request_string, &request_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } if (!request_length) { solr_throw_exception(solr_ce_SolrIllegalArgumentException, "Invalid request length. Request string is empty.", SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC); return; } if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client from HashTable"); return; } /* The update request we are sending to Solr */ solr_string_set(&(client->handle.request_body.buffer), request_string, request_length); /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_UPDATE TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"update"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } object_init_ex(return_value, solr_ce_SolrUpdateResponse); solr_set_response_object_properties(solr_ce_SolrUpdateResponse, return_value, client, &(client->options.update_url), success TSRMLS_CC); } /* }}} */ /* {{{ proto SolrUpdateResponse SolrClient::deleteById(string id) Allows the user to delete a document by id */ PHP_METHOD(SolrClient, deleteById) { solr_char_t *id = NULL; COMPAT_ARG_SIZE_T id_length = 0L; solr_client_t *client = NULL; xmlNode *root_node = NULL; xmlDoc *doc_ptr = NULL; xmlChar *escaped_id_value = NULL; int format = 1; int size = 0; xmlChar *request_string = NULL; zend_bool success = 1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &id, &id_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } if (!id_length) { solr_throw_exception(solr_ce_SolrIllegalArgumentException, "Invalid id parameter", SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC); return; } if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client from HashTable"); return; } doc_ptr = solr_xml_create_xml_doc((xmlChar *) "delete", &root_node); escaped_id_value = xmlEncodeEntitiesReentrant(doc_ptr, (xmlChar *) id); xmlNewChild(root_node, NULL, (xmlChar *) "id", escaped_id_value); xmlFree(escaped_id_value); xmlIndentTreeOutput = 1; xmlDocDumpFormatMemoryEnc(doc_ptr, &request_string, &size, "UTF-8", format); /* The XML request we are sending to Solr */ solr_string_set(&(client->handle.request_body.buffer), (solr_char_t *) request_string, size); xmlFree(request_string); xmlFreeDoc(doc_ptr); /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_UPDATE TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"update"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } object_init_ex(return_value, solr_ce_SolrUpdateResponse); solr_set_response_object_properties(solr_ce_SolrUpdateResponse, return_value, client, &(client->options.update_url), success TSRMLS_CC); } /* }}} */ /* {{{ proto SolrUpdateResponse SolrClient::request(array ids) Allows the user to delete a set of documents by ids. This should be an array of strings */ PHP_METHOD(SolrClient, deleteByIds) { zval *ids_array = NULL; HashTable *doc_ids = NULL; size_t num_ids = 0; xmlNode *root_node = NULL; xmlDoc *doc_ptr = NULL; zend_bool invalid_param = 0; size_t error_pos = 1, current_position = 1; solr_client_t *client = NULL; int format = 1; int size = 0; xmlChar *request_string = NULL; zend_bool success = 1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &ids_array) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } doc_ids = Z_ARRVAL_P(ids_array); num_ids = zend_hash_num_elements(doc_ids); if(!num_ids) { solr_throw_exception(solr_ce_SolrIllegalArgumentException, "The array parameter passed is empty", SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC); return; } doc_ptr = solr_xml_create_xml_doc((xmlChar *) "delete", &root_node); SOLR_HASHTABLE_FOR_LOOP(doc_ids) { zval *id_zval = NULL; id_zval = zend_hash_get_current_data(doc_ids); if (Z_TYPE_P(id_zval) == IS_STRING && Z_STRLEN_P(id_zval)) { xmlChar *escaped_id_value = xmlEncodeEntitiesReentrant(doc_ptr, (xmlChar *) Z_STRVAL_P(id_zval)); xmlNewChild(root_node, NULL, (xmlChar *) "id", escaped_id_value); xmlFree(escaped_id_value); } else { invalid_param = 1; /* This id is not a valid string */ error_pos = current_position; goto end_doc_ids_loop; } current_position++; } end_doc_ids_loop : if (invalid_param) { xmlFreeDoc(doc_ptr); solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Id number %u is not a valid string", error_pos); return; } if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client from HashTable"); return; } xmlIndentTreeOutput = 1; xmlDocDumpFormatMemoryEnc(doc_ptr, &request_string, &size, "UTF-8", format); /* The XML request we are sending to Solr */ solr_string_set(&(client->handle.request_body.buffer), (solr_char_t *) request_string, size); xmlFree(request_string); xmlFreeDoc(doc_ptr); /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_UPDATE TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"update"); } object_init_ex(return_value, solr_ce_SolrUpdateResponse); solr_set_response_object_properties(solr_ce_SolrUpdateResponse, return_value, client, &(client->options.update_url), success TSRMLS_CC); } /* }}} */ /* {{{ proto SolrUpdateResponse SolrClient::deleteByQuery(string query) Allows the user to delete a set of documents matching the query */ PHP_METHOD(SolrClient, deleteByQuery) { solr_char_t *query = NULL; COMPAT_ARG_SIZE_T query_length = 0L; solr_client_t *client = NULL; xmlNode *root_node = NULL; xmlDoc *doc_ptr = NULL; xmlChar *escaped_query_value = NULL; int format = 1; int size = 0; xmlChar *request_string = NULL; zend_bool success = 1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &query, &query_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } if (!query_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "The query parameter is not a valid id"); return; } if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client from HashTable"); return; } doc_ptr = solr_xml_create_xml_doc((xmlChar *) "delete", &root_node); escaped_query_value = xmlEncodeEntitiesReentrant(doc_ptr, (xmlChar *) query); xmlNewChild(root_node, NULL, (xmlChar *) "query", escaped_query_value); xmlFree(escaped_query_value); xmlIndentTreeOutput = 1; xmlDocDumpFormatMemoryEnc(doc_ptr, &request_string, &size, "UTF-8", format); /* The XML request we are sending to Solr */ solr_string_set(&(client->handle.request_body.buffer), (solr_char_t *) request_string, size); xmlFree(request_string); xmlFreeDoc(doc_ptr); /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_UPDATE TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"update"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } object_init_ex(return_value, solr_ce_SolrUpdateResponse); solr_set_response_object_properties(solr_ce_SolrUpdateResponse, return_value, client, &(client->options.update_url), success TSRMLS_CC); } /* }}} */ /* {{{ proto SolrQueryResponse SolrClient::getById(string id) Get Document By Id. Utilizes Solr Realtime Get (RTG) */ PHP_METHOD(SolrClient, getById) { solr_client_t *client; solr_char_t *id; COMPAT_ARG_SIZE_T id_len = 0; solr_string_t query_string; int success = 1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &id, &id_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } /* Always reset the URLs before making any request */ solr_client_init_urls(client); solr_string_init(&query_string); solr_string_appends(&query_string, "id=", sizeof("id=")-1); solr_string_appends(&query_string, id, id_len); solr_string_append_solr_string(&(client->handle.request_body.buffer), &query_string); if (solr_make_request(client, SOLR_REQUEST_GET TSRMLS_CC) == FAILURE) { /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"get"); success = 0; } object_init_ex(return_value, solr_ce_SolrQueryResponse); solr_set_response_object_properties(solr_ce_SolrQueryResponse, return_value, client, &(client->options.get_url), success TSRMLS_CC); solr_string_free(&query_string); } /* }}} */ /* {{{ proto SolrQueryResponse SolrClient::getByIds(array ids) Get Documents by their Ids. Utilizes Solr Realtime Get (RTG) */ PHP_METHOD(SolrClient, getByIds) { solr_client_t *client; HashTable *ids = NULL; zval *ids_z = NULL; zend_bool invalid_param = 0; solr_string_t query_string; size_t current_position = 0; int success = 1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &ids_z) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Internal Error: Cannot fetch client object"); return; } ids = Z_ARRVAL_P(ids_z); if (ids->nNumOfElements < 1) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, 4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter: at least 1 ID is required. Passed an empty array.", current_position); } /* Always reset the URLs before making any request */ solr_client_init_urls(client); solr_string_init(&query_string); solr_string_appends(&query_string, "ids=", sizeof("ids=")-1); SOLR_HASHTABLE_FOR_LOOP(ids) { zval *id_zv = NULL; id_zv = zend_hash_get_current_data(ids); if (Z_TYPE_P(id_zv) == IS_STRING && Z_STRLEN_P(id_zv)) { solr_string_appends(&query_string, Z_STRVAL_P(id_zv), Z_STRLEN_P(id_zv)); solr_string_appendc(&query_string, ','); } else { invalid_param = 1; goto solr_getbyids_exit; } current_position++; } solr_getbyids_exit: if (invalid_param) { solr_string_free(&query_string); solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, 4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid id at position %ld", current_position); return; } solr_string_remove_last_char(&query_string); solr_string_append_solr_string(&(client->handle.request_body.buffer), &query_string); if (solr_make_request(client, SOLR_REQUEST_GET TSRMLS_CC) == FAILURE) { /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"get"); success = 0; } object_init_ex(return_value, solr_ce_SolrQueryResponse); solr_set_response_object_properties(solr_ce_SolrQueryResponse, return_value, client, &(client->options.get_url), success TSRMLS_CC); solr_string_set_ex(&(client->handle.request_body.buffer),(solr_char_t *)0x00, 0); solr_string_free(&query_string); } /* }}} */ /* {{{ proto void SolrClient::setResponseWriter(string responseWriter) Allows the user to specify which response writer to use */ PHP_METHOD(SolrClient, setResponseWriter) { solr_char_t *wt = NULL; COMPAT_ARG_SIZE_T wt_length = 0L; solr_client_t *client = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &wt, &wt_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } if (!wt_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "The response writer is not a valid string"); return; } if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client from HashTable"); return; } if (solr_is_supported_response_writer((const solr_char_t *) wt, wt_length)) { /* The response writer used to present the response from Solr */ solr_string_set(&(client->options.response_writer), (solr_char_t *) wt, wt_length); } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported response writer %s. This value will be ignored", wt); } } /* }}} */ /* {{{ proto SolrUpdateResponse SolrClient::deleteByQueries(array queries) Allows the user to delete a set of documents matching the queries specified */ PHP_METHOD(SolrClient, deleteByQueries) { zval *queries_array = NULL; HashTable *doc_queries = NULL; size_t num_queries = 0; xmlNode *root_node = NULL; xmlDoc *doc_ptr = NULL; zend_bool invalid_param = 0; size_t error_pos, current_position = 1; solr_client_t *client = NULL; int format = 1; int size = 0; xmlChar *request_string = NULL; zend_bool success = 1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &queries_array) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } doc_queries = Z_ARRVAL_P(queries_array); num_queries = zend_hash_num_elements(doc_queries); if(!num_queries) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "The array parameter passed is empty"); return; } doc_ptr = solr_xml_create_xml_doc((xmlChar *) "delete", &root_node); SOLR_HASHTABLE_FOR_LOOP(doc_queries) { zval *query_zval = NULL; query_zval = zend_hash_get_current_data(doc_queries); if (Z_TYPE_P(query_zval) == IS_STRING && Z_STRLEN_P(query_zval)) { xmlChar *escaped_query_value = xmlEncodeEntitiesReentrant(doc_ptr, (xmlChar *) Z_STRVAL_P(query_zval)); xmlNewChild(root_node, NULL, (xmlChar *) "query", escaped_query_value); xmlFree(escaped_query_value); } else { invalid_param = 1; /* This query is not a valid string */ error_pos = current_position; goto end_doc_queries_loop; } current_position++; } end_doc_queries_loop : if (invalid_param) { xmlFreeDoc(doc_ptr); solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Query number %u is not a valid query string", error_pos); return; } if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client from HashTable"); return; } xmlIndentTreeOutput = 1; xmlDocDumpFormatMemoryEnc(doc_ptr, &request_string, &size, "UTF-8", format); /* The XML request we are sending to Solr */ solr_string_set(&(client->handle.request_body.buffer), (solr_char_t *) request_string, size); xmlFree(request_string); xmlFreeDoc(doc_ptr); /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_UPDATE TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"update"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } object_init_ex(return_value, solr_ce_SolrUpdateResponse); solr_set_response_object_properties(solr_ce_SolrUpdateResponse, return_value, client, &(client->options.update_url), success TSRMLS_CC); } /* }}} */ /* {{{ proto SolrUpdateResponse SolrClient::optimize([string maxSegments [, bool softCommit [, bool waitSearcher]]) Sends an optimize XML request to the server. */ PHP_METHOD(SolrClient, optimize) { zend_bool softCommit = 0, waitSearcher = 1; char *maxSegments = "1"; int maxSegmentsLen = sizeof("1")-1; char *softCommitValue, *waitSearcherValue; xmlNode *root_node = NULL; xmlDoc *doc_ptr = NULL; solr_client_t *client = NULL; int format = 1; int size = 0; xmlChar *request_string = NULL; zend_bool success = 1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sbb", &maxSegments, &maxSegmentsLen, &softCommit, &waitSearcher) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } softCommitValue = (softCommit)? "true" : "false"; waitSearcherValue = (waitSearcher)? "true" : "false"; doc_ptr = solr_xml_create_xml_doc((xmlChar *) "optimize", &root_node); xmlNewProp(root_node, (xmlChar *) "maxSegments", (xmlChar *) maxSegments); xmlNewProp(root_node, (xmlChar *) "softCommit", (xmlChar *) softCommitValue); xmlNewProp(root_node, (xmlChar *) "waitSearcher", (xmlChar *) waitSearcherValue); if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client from HashTable"); return; } xmlIndentTreeOutput = 1; xmlDocDumpFormatMemoryEnc(doc_ptr, &request_string, &size, "UTF-8", format); /* The XML request we are sending to Solr */ solr_string_set(&(client->handle.request_body.buffer), (solr_char_t *) request_string, size); xmlFree(request_string); xmlFreeDoc(doc_ptr); /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_UPDATE TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"update"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } object_init_ex(return_value, solr_ce_SolrUpdateResponse); solr_set_response_object_properties(solr_ce_SolrUpdateResponse, return_value, client, &(client->options.update_url), success TSRMLS_CC); } /* }}} */ /* {{{ proto SolrUpdateResponse SolrClient::commit( [bool softCommit [, bool waitSearcher [, bool expungeDeletes]]]) Sends a commit XML request to the server. */ PHP_METHOD(SolrClient, commit) { zend_bool softCommit = 0, waitSearcher = 1, expungeDeletes = 0; char *softCommitValue, *waitSearcherValue, *expungeDeletesValue; xmlNode *root_node = NULL; xmlDoc *doc_ptr = NULL; solr_client_t *client = NULL; int format = 1; int size = 0; xmlChar *request_string = NULL; zend_bool success = 1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|bbb", &softCommit, &waitSearcher, &expungeDeletes) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); return; } softCommitValue = (softCommit)? "true" : "false"; waitSearcherValue = (waitSearcher)? "true" : "false"; expungeDeletesValue = (expungeDeletes)? "true": "false"; doc_ptr = solr_xml_create_xml_doc((xmlChar *) "commit", &root_node); xmlNewProp(root_node, (xmlChar *) "softCommit", (xmlChar *) softCommitValue); xmlNewProp(root_node, (xmlChar *) "waitSearcher", (xmlChar *) waitSearcherValue); xmlNewProp(root_node, (xmlChar *) "expungeDeletes", (xmlChar *) expungeDeletesValue); if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client from HashTable"); return; } xmlIndentTreeOutput = 1; xmlDocDumpFormatMemoryEnc(doc_ptr, &request_string, &size, "UTF-8", format); /* The XML request we are sending to Solr */ solr_string_set(&(client->handle.request_body.buffer), (solr_char_t *) request_string, size); xmlFree(request_string); xmlFreeDoc(doc_ptr); /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_UPDATE TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"update"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } object_init_ex(return_value, solr_ce_SolrUpdateResponse); solr_set_response_object_properties(solr_ce_SolrUpdateResponse, return_value, client, &(client->options.update_url), success TSRMLS_CC); } /* }}} */ /* {{{ proto SolrUpdateResponse SolrClient::rollback(void) Sends a rollback XML request to the server. */ PHP_METHOD(SolrClient, rollback) { xmlNode *root_node = NULL; zend_bool success = 1; xmlDoc *doc_ptr = NULL; solr_client_t *client = NULL; int format = 1; int size = 0; xmlChar *request_string = NULL; doc_ptr = solr_xml_create_xml_doc((xmlChar *) "rollback", &root_node); if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client from HashTable"); return; } xmlIndentTreeOutput = 1; xmlDocDumpFormatMemoryEnc(doc_ptr, &request_string, &size, "UTF-8", format); /* The XML request we are sending to Solr */ solr_string_set(&(client->handle.request_body.buffer), (solr_char_t *) request_string, size); xmlFree(request_string); xmlFreeDoc(doc_ptr); /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_UPDATE TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"update"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } object_init_ex(return_value, solr_ce_SolrUpdateResponse); solr_set_response_object_properties(solr_ce_SolrUpdateResponse, return_value, client, &(client->options.update_url), success TSRMLS_CC); } /* }}} */ /* {{{ proto SolrPingResponse SolrClient::ping() Sends a HEAD request to check if the server is still up and running. */ PHP_METHOD(SolrClient, ping) { solr_client_t *client = NULL; zend_bool success = 1; /* Retrieve the client entry */ if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client"); return; } /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_PING TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"ping"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } object_init_ex(return_value, solr_ce_SolrPingResponse); solr_set_response_object_properties(solr_ce_SolrPingResponse, return_value, client, &(client->options.ping_url), success TSRMLS_CC); } /* }}} */ /* {{{ proto SolrGenericResponse SolrClient::threads() Sends a request to get info about threads. */ PHP_METHOD(SolrClient, threads) { zend_bool success = 1; solr_client_t *client = NULL; /* Retrieve the client entry */ if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client"); return; } /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_THREADS TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"threads"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } object_init_ex(return_value, solr_ce_SolrGenericResponse); solr_set_response_object_properties(solr_ce_SolrGenericResponse, return_value, client, &(client->options.thread_url), success TSRMLS_CC); } /* }}} */ /* {{{ proto SolrGenericResponse SolrClient::info() Sends a request to get system info. */ PHP_METHOD(SolrClient, system) { zend_bool success = 1; solr_client_t *client = NULL; /* Retrieve the client entry */ if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client"); return; } /* Always reset the URLs before making any request */ solr_client_init_urls(client); /* Make the HTTP request to the Solr instance */ if (solr_make_request(client, SOLR_REQUEST_SYSTEM TSRMLS_CC) == FAILURE) { success = 0; /* if there was an error with the http request solr_make_request throws an exception by itself * if it wasn't a curl connection error, throw exception (omars) */ HANDLE_SOLR_SERVER_ERROR(client,"system"); /* SOLR_SHOW_CURL_WARNING; commented by: omars */ } object_init_ex(return_value, solr_ce_SolrGenericResponse); solr_set_response_object_properties(solr_ce_SolrGenericResponse, return_value, client, &(client->options.system_url), success TSRMLS_CC); } /* }}} */ /* {{{ proto array SolrClient::getOptions() Returns all the options for this client. */ PHP_METHOD(SolrClient, getOptions) { solr_client_t *client = NULL; solr_client_options_t *options = NULL; /* Retrieve the client entry */ if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client"); return; } options = &(client->options); array_init(return_value); add_assoc_long(return_value, "timeout", options->timeout); add_assoc_bool(return_value, "secure", (int) options->secure); add_assoc_stringl(return_value, "hostname", options->hostname.str, options->hostname.len); add_assoc_stringl(return_value, "wt", options->response_writer.str, options->response_writer.len); add_assoc_long(return_value, "port", options->host_port); add_assoc_stringl(return_value, "proxy_host", options->proxy_hostname.str, options->proxy_hostname.len); add_assoc_long(return_value, "proxy_port", options->proxy_port); add_assoc_stringl(return_value, "path", options->path.str, options->path.len); add_assoc_stringl(return_value, "http_auth", options->http_auth_credentials.str, options->http_auth_credentials.len); add_assoc_stringl(return_value, "proxy_auth", options->proxy_auth_credentials.str, options->proxy_auth_credentials.len); add_assoc_bool(return_value, "ssl_verify_peer", (int) options->ssl_verify_peer); add_assoc_long(return_value, "ssl_verify_host", options->ssl_verify_host); add_assoc_stringl(return_value, "ssl_cert", options->ssl_cert.str, options->ssl_cert.len); add_assoc_stringl(return_value, "ssl_key", options->ssl_key.str, options->ssl_key.len); add_assoc_stringl(return_value, "ssl_keypassword", options->ssl_keypassword.str, options->ssl_keypassword.len); add_assoc_stringl(return_value, "ssl_cainfo", options->ssl_cainfo.str, options->ssl_cainfo.len); add_assoc_stringl(return_value, "ssl_capath", options->ssl_capath.str, options->ssl_capath.len); } /* }}} */ /* {{{ proto string SolrClient::getDebug() Returns all debug data captured in the process of making the request. */ PHP_METHOD(SolrClient, getDebug) { solr_client_t *client = NULL; solr_curl_t *handle = NULL; /* Retrieve the client entry */ if (solr_fetch_client_entry(getThis(), &client TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to retrieve client"); return; } handle = &(client->handle); if (!handle->debug_data_buffer.len) { RETURN_NULL(); } RETVAL_STRINGL(handle->debug_data_buffer.str, handle->debug_data_buffer.len); } /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/php_solr_collapse_function.c0000644000175000017500000002543512676753707020435 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: | | Omar Shaban | +----------------------------------------------------------------------+ */ #include "php_solr.h" /* {{{ proto void SolrFunction::__construct([string field]) Constructor. */ PHP_METHOD(SolrCollapseFunction, __construct) { long int index = SOLR_UNIQUE_FUNCTION_INDEX(); uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE; solr_function_t *solr_function_dest = NULL; zval *objptr = getThis(); #ifdef PHP_7 solr_function_dest = pemalloc(sizeof(solr_function_t), SOLR_FUNCTIONS_PERSISTENT); #endif solr_char_t *param_name = (solr_char_t *)"field"; COMPAT_ARG_SIZE_T param_name_len = sizeof("field"); solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; if ((solr_function_dest = zend_hash_index_update_ptr(SOLR_GLOBAL(functions),index,(void *) solr_function_dest)) == NULL) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error while registering query parameters in HashTable"); return ; } zend_update_property_long(solr_ce_SolrCollapseFunction, objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, index TSRMLS_CC); solr_function_dest->function_index = index; solr_function_dest->name_length = strlen("collapse"); solr_function_dest->name = (solr_char_t *)"collapse"; /* Allocated memory for the params HashTable using fast cache for HashTables */ ALLOC_HASHTABLE(solr_function_dest->params); zend_hash_init(solr_function_dest->params, nSize, NULL, (dtor_func_t) solr_destroy_solr_string, SOLR_FUNCTIONS_PERSISTENT); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error Parsing Parameters"); return; } if (field_name_len > 0 ) { solr_solrfunc_update_string(getThis(), param_name, param_name_len, field_name, field_name_len); } Z_OBJ_HT_P(getThis()) = &solr_collapse_function_object_handlers; } /* }}} */ /* {{{ proto void SolrFunction::__destruct(void) Destructor. */ PHP_METHOD(SolrCollapseFunction, __destruct) { solr_function_t *function = NULL; /* Retrieve the document entry for this SolrDocument */ if (solr_fetch_function_entry(getThis(), &function TSRMLS_CC) == SUCCESS ) { zend_hash_index_del(SOLR_GLOBAL(functions), function->function_index); } return; } /* {{{ proto string SolrFunction::setField(string field) Set the field that is being collapsed on. The field must be a single valued String, Int or Float. */ PHP_METHOD(SolrCollapseFunction, setField) { solr_char_t *key = "field", *arg; COMPAT_ARG_SIZE_T key_len = sizeof("field"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::getField(void) Get Collapse Field */ PHP_METHOD(SolrCollapseFunction, getField) { solr_char_t *key = "field"; COMPAT_ARG_SIZE_T key_len = sizeof("field"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::setMin(string value) Selects the group heads by the min value of a numeric field or function query. */ PHP_METHOD(SolrCollapseFunction, setMin) { solr_char_t *key = "min", *arg; COMPAT_ARG_SIZE_T key_len = sizeof("min"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::setMax(string value) Selects the group heads by the max value of a numeric field or function query. */ PHP_METHOD(SolrCollapseFunction, setMax) { solr_char_t *key = "max", *arg; COMPAT_ARG_SIZE_T key_len = sizeof("max"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::getMin(void) Get min parameter */ PHP_METHOD(SolrCollapseFunction, getMin) { solr_char_t *key = "min"; COMPAT_ARG_SIZE_T key_len = sizeof("min"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::getMax(void) Get max parameter */ PHP_METHOD(SolrCollapseFunction, getMax) { solr_char_t *key = "max"; COMPAT_ARG_SIZE_T key_len = sizeof("max"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::setSize(void) Sets the initial size of the collapse data structures when collapsing on a numeric field only */ PHP_METHOD(SolrCollapseFunction, setSize) { solr_char_t *key = "size", *arg; COMPAT_ARG_SIZE_T key_len = sizeof("size"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::getSize(void) Get size parameter */ PHP_METHOD(SolrCollapseFunction, getSize) { solr_char_t *key = "size"; COMPAT_ARG_SIZE_T key_len = sizeof("size"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::setHint(void) Set collapse hint Currently there is only one hint available "top_fc", which stands for top level FieldCache */ PHP_METHOD(SolrCollapseFunction, setHint) { solr_char_t *key = "hint", *arg; COMPAT_ARG_SIZE_T key_len = sizeof("hint"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::getHint(void) Get Hint */ PHP_METHOD(SolrCollapseFunction, getHint) { solr_char_t *key = "hint"; COMPAT_ARG_SIZE_T key_len = sizeof("hint"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::setNullPolicy(void) Sets the NULL Policy. Accepts ignore, expand, or collapse */ PHP_METHOD(SolrCollapseFunction, setNullPolicy) { solr_char_t *key = "nullPolicy", *arg; COMPAT_ARG_SIZE_T key_len = sizeof("nullPolicy"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::getNullPolicy(void) Get NullPolicy */ PHP_METHOD(SolrCollapseFunction, getNullPolicy) { solr_char_t *key = "nullPolicy"; COMPAT_ARG_SIZE_T key_len = sizeof("nullPolicy"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::__toString(void) String value of the function object */ PHP_METHOD(SolrCollapseFunction, __toString) { solr_function_t *collapse_func; solr_string_t *buffer = NULL; if(solr_fetch_function_entry(getThis(), &collapse_func TSRMLS_CC) == FAILURE) { RETURN_NULL(); } buffer = (solr_string_t *)emalloc(sizeof(solr_string_t)); memset(buffer, 0, sizeof(solr_string_t)); solr_solrfunc_to_string(collapse_func, &buffer); ZVAL_STRINGL(return_value, buffer->str, buffer->len); solr_string_free(buffer); efree(buffer); } /* }}} */ /* {{{ proto SolrClient::__sleep(void) Should not be called directly. Serialization is not supported. */ PHP_METHOD(SolrCollapseFunction, __sleep) { solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1001 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Serialization of SolrCollapseFunction objects is currently not supported"); } /* }}} */ /* {{{ proto SolrClient::__wakeup(void) Should not be called directly. Serialization is not supported. */ PHP_METHOD(SolrCollapseFunction, __wakeup) { solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1001 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Unserialization of SolrCollapseFunction objects is currently not supported"); } /* }}} */ /* {{{ throw exception on cloning (clone handler) */ zend_object* solr_collapse_function_object_handler_clone(zval *object TSRMLS_DC) { zend_object *fake; fake = zend_objects_new(zend_standard_class_def); solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_4001 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Cloning of SolrCollapseFunction objects is currently not supported"); return fake; } /* }}} */ solr-2.4.0/src/php7/php_solr_document.c0000644000175000017500000011511212676753707016534 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /** ************************************************************************ **/ /** DEFINITIONS FOR SOLR DOCUMENT METHODS **/ /** ************************************************************************ **/ /* {{{ static int solr_document_set_field(zval *objptr, solr_char_t *field_name, COMPAT_ARG_SIZE_T field_name_length, solr_char_t *field_value, COMPAT_ARG_SIZE_T field_value_length TSRMLS_DC) */ static int solr_document_set_field(zval *objptr, solr_char_t *field_name, COMPAT_ARG_SIZE_T field_name_length, solr_char_t *field_value, COMPAT_ARG_SIZE_T field_value_length TSRMLS_DC) { double field_boost = 0.0f; solr_document_t *doc_entry = NULL; if (!field_name_length) { return FAILURE; } if (!field_value_length) { return FAILURE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(objptr, &doc_entry TSRMLS_CC) == SUCCESS) { solr_field_list_t *field_values = NULL; zval *tmp; /* If the field already exists in the SolrDocument instance append the value to the field list queue */ if ((field_values = zend_hash_str_find_ptr(doc_entry->fields, field_name, field_name_length)) != NULL) { if (solr_document_insert_field_value(field_values, field_value, field_boost) == FAILURE) { return FAILURE; } } else { /* Otherwise, create a new one and add it to the hash table */ field_values = (solr_field_list_t *) pemalloc(sizeof(solr_field_list_t), SOLR_DOCUMENT_FIELD_PERSISTENT); memset(field_values, 0, sizeof(solr_field_list_t)); field_values->count = 0L; field_values->field_boost = 0.0; field_values->field_name = (solr_char_t *) pestrdup(field_name,SOLR_DOCUMENT_FIELD_PERSISTENT); field_values->head = NULL; field_values->last = NULL; if (solr_document_insert_field_value(field_values, field_value, field_boost) == FAILURE) { solr_destroy_field_list(field_values); return FAILURE; } if ((tmp = zend_hash_str_add_ptr(doc_entry->fields, field_name, field_name_length, field_values)) == NULL) { solr_destroy_field_list(field_values); return FAILURE; } /* Increment field count only when HEAD is added */ doc_entry->field_count++; } return SUCCESS; } return FAILURE; } /* }}} */ /* {{{ static int solr_document_get_field(zval *objptr, zval *return_value, solr_char_t *field_name, COMPAT_ARG_SIZE_T field_name_length TSRMLS_DC) */ static int solr_document_get_field(zval *objptr, zval *return_value, solr_char_t *field_name, COMPAT_ARG_SIZE_T field_name_length TSRMLS_DC) { solr_document_t *doc_entry = NULL; if (!field_name_length) { return FAILURE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(objptr, &doc_entry TSRMLS_CC) == SUCCESS) { solr_field_list_t *field_values = NULL; if ((field_values = zend_hash_str_find_ptr(doc_entry->fields, (char *)field_name, field_name_length)) != NULL) { solr_create_document_field_object(field_values, &return_value TSRMLS_CC); /* The field was retrieved, so we're done here */ return SUCCESS; } return FAILURE; } return FAILURE; } /* }}} */ /* {{{ static int solr_document_remove_field(zval *objptr, solr_char_t *field_name, COMPAT_ARG_SIZE_T field_name_length TSRMLS_DC) */ static int solr_document_remove_field(zval *objptr, solr_char_t *field_name, COMPAT_ARG_SIZE_T field_name_length TSRMLS_DC) { solr_document_t *doc_entry = NULL; if (!field_name_length) { return FAILURE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(objptr, &doc_entry TSRMLS_CC) == SUCCESS) { if (zend_hash_str_del(doc_entry->fields, field_name, field_name_length) == SUCCESS) { doc_entry->field_count--; return SUCCESS; } return FAILURE; } return FAILURE; } /* }}} */ /* {{{ static int solr_document_field_exists(zval *objptr, solr_char_t *field_name, COMPAT_ARG_SIZE_T field_name_length TSRMLS_DC) */ static int solr_document_field_exists(zval *objptr, solr_char_t *field_name, COMPAT_ARG_SIZE_T field_name_length TSRMLS_DC) { solr_document_t *doc_entry = NULL; if (!field_name_length) { return FAILURE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(objptr, &doc_entry TSRMLS_CC) == SUCCESS) { if (zend_hash_str_exists(doc_entry->fields, field_name, field_name_length)) { return SUCCESS; } else { return FAILURE; } } return FAILURE; } /* }}} */ /* {{{ static void solr_serialize_document_object(HashTable *document_fields, xmlChar **buffer, int *size TSRMLS_DC) */ static void solr_serialize_document_object(HashTable *document_fields, xmlChar **buffer, int *size TSRMLS_DC) { xmlNode *root_node = NULL, *fields_node = NULL; xmlDoc *doc_ptr = NULL; int format = 1; if(!buffer) { return; } doc_ptr = solr_xml_create_xml_doc((xmlChar *) "solr_document", &root_node); fields_node = xmlNewChild(root_node, NULL, (xmlChar *) "fields", NULL); SOLR_HASHTABLE_FOR_LOOP(document_fields) { solr_field_list_t *field = NULL; solr_char_t *doc_field_name = NULL; solr_field_value_t *doc_field_value = NULL; xmlNode *field_node = NULL; field = zend_hash_get_current_data_ptr(document_fields); doc_field_name = field->field_name; doc_field_value = field->head; field_node = xmlNewChild(fields_node, NULL, (xmlChar *) "field", NULL); xmlNewProp(field_node, (xmlChar *) "name", (xmlChar *) doc_field_name); /* Loop through all the values for this field */ while(doc_field_value != NULL) { xmlChar *escaped_field_value = xmlEncodeEntitiesReentrant(doc_ptr, (xmlChar *) doc_field_value->field_value); xmlNewChild(field_node, NULL, (xmlChar *) "field_value", escaped_field_value); /* Release the memory allocated by xmlEncodeEntitiesReentrant */ xmlFree(escaped_field_value); /* Grab the next value for this field if any */ doc_field_value = doc_field_value->next; } /* while(doc_field_value != NULL) */ } /* SOLR_HASHTABLE_FOR_LOOP(document_fields) */ xmlIndentTreeOutput = 1; xmlDocDumpFormatMemoryEnc(doc_ptr, buffer, size, "UTF-8", format); xmlFreeDoc(doc_ptr); } /* }}} */ /* {{{ static void solr_unserialize_document_field(HashTable *document_fields, xmlNode *field_node TSRMLS_DC) */ static void solr_unserialize_document_field(HashTable *document_fields, xmlNode *field_node TSRMLS_DC) { solr_char_t *field_name = NULL; xmlNode *xml_curr_value = NULL; solr_field_list_t *field_values = (solr_field_list_t *) pemalloc(sizeof(solr_field_list_t), SOLR_DOCUMENT_FIELD_PERSISTENT); zend_string *field_str; memset(field_values, 0, sizeof(solr_field_list_t)); field_name = (solr_char_t *) solr_xml_get_node_contents(field_node->properties); field_values->count = 0L; field_values->field_boost = 0.0f; field_values->field_name = (solr_char_t *) pestrdup(field_name, SOLR_DOCUMENT_FIELD_PERSISTENT); field_values->head = NULL; field_values->last = NULL; /* Grab the first field node */ xml_curr_value = field_node->children; /* Looping through all the field_value nodes */ while(xml_curr_value != NULL) { /* No assumptions. It must be the field value nodes */ if (xml_curr_value->type == XML_ELEMENT_NODE && solr_xml_match_node(xml_curr_value, "field_value")) { solr_char_t *field_value = (solr_char_t *) solr_xml_get_node_contents(xml_curr_value); /* Add this value to the list of values */ if (solr_document_insert_field_value(field_values, field_value, 0.0f) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error adding field value during SolrDocument unserialization"); } } /* Move to the next field_value */ xml_curr_value = xml_curr_value->next; } field_str = zend_string_init(field_name, strlen(field_name), SOLR_DOCUMENT_FIELD_PERSISTENT); /* All the values have been retrieved for this field. Now let's drop the field in the HashTable */ if ((field_values = zend_hash_add_new_ptr(document_fields, field_str, (void *) field_values)) == NULL) { zend_string_release(field_str); solr_destroy_field_list(field_values); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error adding field values to HashTable during SolrDocument unserialization"); return; } zend_string_release(field_str); } /* }}} */ /* {{{ static int solr_unserialize_child_documents(xmlDoc *doc, solr_document_t *doc_entry TSRMLS_DC) * 1. retrieve doc hashes * 2. base64_decode * 3. unserialize (call php method) * 4. add child to solr_doc_t.children */ static int solr_unserialize_child_documents(xmlDoc *doc, solr_document_t *doc_entry TSRMLS_DC) { xmlXPathContext *xp_ctx = NULL; xmlXPathObject *xp_obj = NULL; xmlNodeSet *result = NULL; xmlChar *hash, *xp_expression; int num_nodes = 0, idx = 0; /* unserialize vars */ php_unserialize_data_t var_hash; zval solr_doc_zv; xp_expression = (xmlChar *)"/solr_document/child_docs/dochash"; xp_ctx = xmlXPathNewContext(doc); xp_obj = xmlXPathEvalExpression(xp_expression, xp_ctx); result = xp_obj->nodesetval; num_nodes = result->nodeNr; if (num_nodes > 0) { for (;idx < num_nodes; idx++) { zend_string *sdoc_str; /* serialized document string */ unsigned char *sdoc_copy, *str_end; hash = result->nodeTab[idx]->children->content; sdoc_str = (zend_string *)php_base64_decode((const unsigned char*)hash, strlen((char *)hash)); memset(&var_hash, 0, sizeof(php_unserialize_data_t)); PHP_VAR_UNSERIALIZE_INIT(var_hash); sdoc_copy = (unsigned char *)sdoc_str->val; str_end = (unsigned char *) (sdoc_copy + strlen((const char *)sdoc_copy)); if (!php_var_unserialize(&solr_doc_zv, (const unsigned char **)&sdoc_copy, str_end, &var_hash TSRMLS_CC)){ PHP_VAR_UNSERIALIZE_DESTROY(var_hash); php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to unserialize child document"); xmlXPathFreeContext(xp_ctx); xmlXPathFreeObject(xp_obj); zend_string_release(sdoc_str); return FAILURE; } zend_string_release(sdoc_str); if (zend_hash_next_index_insert(doc_entry->children, &solr_doc_zv) == NULL) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to add child document to parent document post-unserialize"); } PHP_VAR_UNSERIALIZE_DESTROY(var_hash); } } xmlXPathFreeContext(xp_ctx); xmlXPathFreeObject(xp_obj); return SUCCESS; } /* }}} */ static int solr_unserialize_document_fields(xmlDoc *doc, HashTable *document_fields TSRMLS_DC) { xmlXPathContext *xpathctxt = NULL; xmlChar *xpath_expression = NULL; xmlXPathObject *xpathObj = NULL; xmlNodeSet *result = NULL; register size_t num_nodes = 0U; register size_t i = 0U; xpathctxt = xmlXPathNewContext(doc); if (!xpathctxt) { xmlFreeDoc(doc); php_error_docref(NULL TSRMLS_CC, E_WARNING, "A valid XML xpath context could not be created"); return FAILURE; } xpath_expression = (xmlChar *) "/solr_document/fields/field/@name"; xpathObj = xmlXPathEval(xpath_expression, xpathctxt); if (!xpathObj) { xmlXPathFreeContext(xpathctxt); xmlFreeDoc(doc); php_error_docref(NULL TSRMLS_CC, E_WARNING, "A valid XML xpath object could not be created from the expression"); return FAILURE; } result = xpathObj->nodesetval; if (!result) { xmlXPathFreeContext(xpathctxt); xmlXPathFreeObject(xpathObj); xmlFreeDoc(doc); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Document has no fields"); return FAILURE; } num_nodes = result->nodeNr; i = 0U; if (!num_nodes) { xmlXPathFreeContext(xpathctxt); xmlXPathFreeObject(xpathObj); xmlFreeDoc(doc); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Document has no fields"); return FAILURE; } for (i = 0U; i < num_nodes; i++) { xmlNode *currNode = result->nodeTab[i]; /* Absolutely No assumptions. I have to make sure that this is the name attribute */ if (currNode->type == XML_ATTRIBUTE_NODE && solr_xml_match_node(currNode, "name")) { /* Get the field node */ xmlNode *field_xml_node = currNode->parent; /* Retrieve all the values for this field and put them in the HashTable */ solr_unserialize_document_field(document_fields, field_xml_node TSRMLS_CC); } } xmlXPathFreeContext(xpathctxt); xmlXPathFreeObject(xpathObj); return SUCCESS; } /* {{{ static int solr_unserialize_document_object(HashTable *document_fields, char *serialized, int size TSRMLS_DC) */ static int solr_unserialize_document_object(solr_document_t *doc_entry, char *serialized, int size TSRMLS_DC) { xmlDoc *doc = NULL; doc = xmlReadMemory(serialized, size, NULL, "UTF-8", 0); if (!doc) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "The serialized document string is invalid"); return FAILURE; } if (solr_unserialize_document_fields(doc, doc_entry->fields TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to unserialize document fields"); return FAILURE; } if (solr_unserialize_child_documents(doc, doc_entry TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to unserialize document fields"); return FAILURE; } xmlFreeDoc(doc); return SUCCESS; } /* }}} */ /* {{{ proto void SolrDocument::__construct(void) SolrDocument constructor */ PHP_METHOD(SolrDocument, __construct) { zval *objptr = getThis(); ulong document_index = SOLR_UNIQUE_DOCUMENT_INDEX(); if (solr_init_document(document_index) == NULL) { return; } /* Set the value of the internal id property */ zend_update_property_long(solr_ce_SolrDocument, objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, document_index TSRMLS_CC); /* Overriding the default object handlers */ Z_OBJ_HT_P(objptr) = &solr_input_document_object_handlers; } /* }}} */ /* {{{ proto void SolrDocument::__destruct(void) Destructor for SolrDocument */ PHP_METHOD(SolrDocument, __destruct) { solr_document_t *doc_entry = NULL; /* Retrieve the document entry for this SolrDocument */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { zend_hash_index_del(SOLR_GLOBAL(documents), doc_entry->document_index); /* Keep track of how many SolrDocument instances we currently have */ SOLR_GLOBAL(document_count)--; return ; } } /* }}} */ /* {{{ proto SolrDocument::__clone(void) Clone method for SolrDocument */ PHP_METHOD(SolrDocument, __clone) { RETURN_NULL(); } /* }}} */ /* {{{ proto SolrDocument::__set(string fieldname, string field_value) Magic method for setting field names. */ PHP_METHOD(SolrDocument, __set) { solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_length = 0; solr_char_t *field_value = NULL; COMPAT_ARG_SIZE_T field_value_length = 0; /* Process the parameters passed to the method */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &field_name, &field_name_length, &field_value, &field_value_length) == FAILURE) { RETURN_FALSE; } if (solr_document_set_field(getThis(), field_name, field_name_length, field_value, field_value_length TSRMLS_CC) == SUCCESS) { RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto SolrDocumentField SolrDocument::__get(string fieldname) Magic method for getting a field. */ PHP_METHOD(SolrDocument, __get) { solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (solr_document_get_field(getThis(), return_value, field_name, field_name_length TSRMLS_CC) == FAILURE) { RETURN_NULL(); } } /* }}} */ /* {{{ proto bool SolrDocument::__isset(string field_name) Checks if a field exists */ PHP_METHOD(SolrDocument, __isset) { solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_length = 0; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (solr_document_field_exists(getThis(), field_name, field_name_length TSRMLS_CC) == SUCCESS) { RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto bool SolrDocument::__unset(string fieldname) Removes a field from the document. */ PHP_METHOD(SolrDocument, __unset) { solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_length = 0; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (solr_document_remove_field(getThis(), field_name, field_name_length TSRMLS_CC) == SUCCESS) { RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto void SolrDocument::offsetSet(string field_name, string field_value) Sets the specified field in the document */ PHP_METHOD(SolrDocument, offsetSet) { solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_length = 0; solr_char_t *field_value = NULL; COMPAT_ARG_SIZE_T field_value_length = 0; /* Process the parameters passed to the method */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &field_name, &field_name_length, &field_value, &field_value_length) == FAILURE) { return; } if (solr_document_set_field(getThis(), field_name, field_name_length, field_value, field_value_length TSRMLS_CC) == SUCCESS) { return; } } /* }}} */ /* {{{ proto SolrDocumentField SolrDocument::offsetGet(string field_name) Returns the request field. */ PHP_METHOD(SolrDocument, offsetGet) { solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (solr_document_get_field(getThis(), return_value, field_name, field_name_length TSRMLS_CC) == FAILURE) { RETURN_NULL(); } } /* }}} */ /* {{{ proto bool SolrDocument::offsetExists(string fieldname) Checks if the request field exists in the document */ PHP_METHOD(SolrDocument, offsetExists) { solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_length = 0; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (solr_document_field_exists(getThis(), field_name, field_name_length TSRMLS_CC) == SUCCESS) { RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto void SolrDocument::offsetUnset(string fieldname) Removes the specified field from the document */ PHP_METHOD(SolrDocument, offsetUnset) { solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_length = 0; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { return; } if (solr_document_remove_field(getThis(), field_name, field_name_length TSRMLS_CC) == SUCCESS) { return; } } /* }}} */ /* {{{ proto void SolrDocument::rewind(void) Resets the internal pointer. */ PHP_METHOD(SolrDocument, rewind) { solr_document_t *doc_entry = NULL; HashTable *doc_fields = NULL; if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == FAILURE) { return; } doc_fields = doc_entry->fields; zend_hash_internal_pointer_reset(doc_fields); } /* }}} */ /* {{{ proto SolrDocumentField SolrDocument::current(void) Retrieves the current field. */ PHP_METHOD(SolrDocument, current) { solr_document_t *doc_entry = NULL; HashTable *doc_fields = NULL; solr_field_list_t *field_values = NULL; if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == FAILURE) { return; } doc_fields = doc_entry->fields; field_values = zend_hash_get_current_data_ptr(doc_fields); if(field_values && field_values ) { solr_create_document_field_object(field_values, &return_value TSRMLS_CC); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrDocument::key(void) Retrieves the current key. */ PHP_METHOD(SolrDocument, key) { solr_document_t *doc_entry = NULL; ulong num_index = 0L; HashTable *doc_fields = NULL; zend_string *field_name_str; if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == FAILURE) { return; } doc_fields = doc_entry->fields; if (zend_hash_get_current_key(doc_fields, &field_name_str, &num_index)) { RETURN_STR_COPY(field_name_str); } } /* }}} */ /* {{{ proto void SolrDocument::next(void) Moves the internal pointer to the next field. */ PHP_METHOD(SolrDocument, next) { solr_document_t *doc_entry = NULL; HashTable *doc_fields = NULL; if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == FAILURE) { return; } doc_fields = doc_entry->fields; zend_hash_move_forward(doc_fields); } /* }}} */ /* {{{ proto bool SolrDocument::valid(void) Checks if the current internal pointer position is still valid. */ PHP_METHOD(SolrDocument, valid) { solr_document_t *doc_entry = NULL; HashTable *doc_fields = NULL; zend_bool is_valid = 0; if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == FAILURE) { return; } doc_fields = doc_entry->fields; is_valid = (zend_bool) ( SUCCESS == zend_hash_has_more_elements(doc_fields) ); RETURN_BOOL(is_valid); } /* }}} */ /* {{{ proto string SolrDocument::serialize(void) Custom SolrDocument serializer. Returns an XML document string representing the object. */ PHP_METHOD(SolrDocument, serialize) { solr_document_t *doc_entry = NULL; HashTable *doc_fields = NULL; char *serialized = NULL; int size = 0; /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == FAILURE) { /* todo error here */ RETURN_NULL(); } doc_fields = doc_entry->fields; solr_serialize_document_object(doc_fields, (xmlChar **) &serialized, &size TSRMLS_CC); if (size) { RETVAL_STRINGL(serialized, size); xmlFree(serialized); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto void SolrDocument::unserialize(string serialized_xml) Custom SolrDocument unserializer. Brings the object back to life. */ PHP_METHOD(SolrDocument, unserialize) { solr_char_t *serialized = NULL; COMPAT_ARG_SIZE_T serialized_length = 0; zval *objptr = getThis(); ulong document_index = SOLR_UNIQUE_DOCUMENT_INDEX(); solr_document_t *doc_entry = NULL; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &serialized, &serialized_length) == FAILURE) { RETURN_FALSE; } doc_entry = solr_init_document(document_index); /* Set the value of the internal id property */ zend_update_property_long(solr_ce_SolrDocument, objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, document_index TSRMLS_CC); /* Overriding the default object handlers */ Z_OBJ_HT_P(objptr) = &solr_input_document_object_handlers; if (solr_unserialize_document_object(doc_entry, serialized, serialized_length TSRMLS_CC) == FAILURE) { return; } doc_entry->field_count = zend_hash_num_elements(doc_entry->fields); } /* }}} */ /* {{{ proto bool SolrDocument::clear(void) Resets the current object. Discards all the fields and resets the document boost to zero. */ PHP_METHOD(SolrDocument, clear) { solr_document_t *doc_entry = NULL; if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { doc_entry->document_boost = 0.0; doc_entry->field_count = 0L; zend_hash_clean(doc_entry->fields); RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto bool SolrDocument::addField(string fieldname, string value) Adds a field to the document */ PHP_METHOD(SolrDocument, addField) { solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_length = 0; solr_char_t *field_value = NULL; COMPAT_ARG_SIZE_T field_value_length = 0; /* Process the parameters passed to the method */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &field_name, &field_name_length, &field_value, &field_value_length) == FAILURE) { RETURN_FALSE; } if (solr_document_set_field(getThis(), field_name, field_name_length, field_value, field_value_length TSRMLS_CC) == SUCCESS) { RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto array SolrDocument::getFieldNames(void) Returns an array of fields names in the document. */ PHP_METHOD(SolrDocument, getFieldNames) { solr_document_get_field_names(INTERNAL_FUNCTION_PARAM_PASSTHRU); } /* }}} */ /* {{{ proto int SolrDocument::getFieldCount(void) Returns the number of fields in this document. Multi-value fields are only counted once. */ PHP_METHOD(SolrDocument, getFieldCount) { solr_document_t *doc_entry = NULL; /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { RETURN_LONG(zend_hash_num_elements(doc_entry->fields)); } RETURN_FALSE; } /* }}} */ /* {{{ proto SolrDocumentField SolrDocument::getField(string fieldname) Retrieves the requested field */ PHP_METHOD(SolrDocument, getField) { solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_length = 0; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (solr_document_get_field(getThis(), return_value, field_name, field_name_length TSRMLS_CC) == FAILURE) { RETURN_FALSE; } } /* }}} */ /* {{{ proto array SolrDocument::toArray(void) Returns an array representation of the SolrDocument object. */ PHP_METHOD(SolrDocument, toArray) { solr_document_t *doc_entry = NULL; zval arr_tmp; zval *fields_array = &arr_tmp; /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { HashTable *fields_ht; #ifndef PHP_7 MAKE_STD_ZVAL(fields_array); #endif array_init(return_value); array_init(fields_array); add_assoc_double(return_value, "document_boost", doc_entry->document_boost); add_assoc_long(return_value, "field_count", doc_entry->field_count); add_assoc_zval(return_value, "fields", fields_array); fields_ht = doc_entry->fields; SOLR_HASHTABLE_FOR_LOOP(fields_ht) { solr_field_list_t *field = NULL; zval current_field_tmp; zval *current_field = ¤t_field_tmp; #ifndef PHP_7 MAKE_STD_ZVAL(current_field); #endif field = zend_hash_get_current_data_ptr(fields_ht); solr_create_document_field_object(field, ¤t_field TSRMLS_CC); add_next_index_zval(fields_array, current_field); } /* We are done */ return; } RETURN_FALSE; } /* }}} */ /* {{{ proto bool SolrDocument::fieldExists(string fieldname) Checks if the field exists. */ PHP_METHOD(SolrDocument, fieldExists) { solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_length = 0; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (solr_document_field_exists(getThis(), field_name, field_name_length TSRMLS_CC) == SUCCESS) { RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto bool SolrDocument::deleteField(string field_name) Removes the requested field. */ PHP_METHOD(SolrDocument, deleteField) { solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_length = 0; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (solr_document_remove_field(getThis(), field_name, field_name_length TSRMLS_CC) == SUCCESS) { RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto bool SolrDocument::sort(int sort_criterion [, int sort_direction]) Sorts the fields in the document */ PHP_METHOD(SolrDocument, sort) { long int order_by = 0L; long int sort_direction = SOLR_SORT_ASC; solr_document_t *doc_entry = NULL; int renumber = 0; /* The pointer to the comparison function used by zend_qsort */ compare_func_t comparison_function = (compare_func_t) NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &order_by, &sort_direction) == FAILURE) { RETURN_FALSE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == FAILURE) { RETURN_FALSE; } /* {{{ Select the appropriate comparison function */ switch(order_by) { case SOLR_SORT_FIELD_NAME : /* Sorting by field name */ { switch(sort_direction) { case SOLR_SORT_ASC : comparison_function = solr_compare_field_name; break; case SOLR_SORT_DESC : comparison_function = solr_rcompare_field_name; break; } } break; /* case SOLR_SORT_FIELD_NAME */ case SOLR_SORT_FIELD_VALUE_COUNT : /* Sorting by number of values per field */ { switch(sort_direction) { case SOLR_SORT_ASC : comparison_function = solr_compare_field_value_count; break; case SOLR_SORT_DESC : comparison_function = solr_rcompare_field_value_count; break; } } break; /* case SOLR_SORT_FIELD_VALUE_COUNT */ case SOLR_SORT_FIELD_BOOST_VALUE : /* Sorting by field boost values */ { switch(sort_direction) { case SOLR_SORT_ASC : comparison_function = solr_compare_field_boost_value; break; case SOLR_SORT_DESC : comparison_function = solr_rcompare_field_boost_value; break; } } break; /* case SOLR_SORT_FIELD_BOOST_VALUE */ default : /* Undefined sort criteria */ RETURN_FALSE; break; } /* }}} switch(order_by) */ /* Undefined sort direction. It was not ASC or DESC */ if (!comparison_function) { RETURN_FALSE; } if (zend_hash_sort_ex(doc_entry->fields, zend_qsort, comparison_function, renumber TSRMLS_CC) == FAILURE) { RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* {{{ proto bool SolrDocument::merge(SolrDocument source [, bool override]) Merges source to the current SolrDocument. */ PHP_METHOD(SolrDocument, merge) { solr_document_t *destination_document = NULL; solr_document_t *source_document = NULL; copy_ctor_func_t p_copy_ctor = (copy_ctor_func_t) field_copy_constructor; /* The destination SolrDocument instance */ zval *destination_document_zval = getThis(); /* The source SolrDocument instance */ zval *source_document_zval = NULL; /* Should we skip fields that already exist in destination */ zend_bool overwrite = (zend_bool) 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|b", &source_document_zval, solr_ce_SolrDocument, &overwrite) == FAILURE) { RETURN_FALSE; } if (solr_fetch_document_entry(source_document_zval, &source_document TSRMLS_CC) == FAILURE) { RETURN_FALSE; } if (solr_fetch_document_entry(destination_document_zval, &destination_document TSRMLS_CC) == FAILURE) { RETURN_FALSE; } if (zend_hash_num_elements(source_document->fields) == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Source SolrDocument has no fields. Source"); RETURN_FALSE; } /* TODO child documents */ /* Copy the fields in the source HashTable to the destination HashTable */ zend_hash_merge(destination_document->fields, source_document->fields, p_copy_ctor, (int) overwrite); /* Update the field count */ destination_document->field_count = (uint) zend_hash_num_elements(destination_document->fields); RETURN_TRUE; } /* }}} */ static void solr_add_child_input_documents_from_documents(HashTable * children, solr_document_t *new_doc_entry TSRMLS_DC) { SOLR_HASHTABLE_FOR_LOOP(children) { zval solr_input_doc; zval *solr_doc = zend_hash_get_current_data(children); zend_call_method_with_0_params(solr_doc, Z_OBJCE_P(solr_doc), NULL, "getinputdocument", &solr_input_doc); if (zend_hash_next_index_insert(new_doc_entry->children, &solr_input_doc) == NULL) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to convert child SolrDocument to SolrInputDocument"); } } } /* {{{ proto SolrInputDocument SolrDocument::getInputDocument(void) Returns a SolrInputDocument equivalent of the object. */ PHP_METHOD(SolrDocument, getInputDocument) { zval *objptr = getThis(); solr_document_t new_solr_doc; solr_document_t *new_doc_entry = NULL, *old_doc_entry = NULL; memset(&new_solr_doc, 0, sizeof(solr_document_t)); new_doc_entry = &new_solr_doc; /* Retrieve the document entry for the original SolrDocument */ if (solr_fetch_document_entry(objptr, &old_doc_entry TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "SolrDocument could not be fetched."); return; } object_init_ex(return_value, solr_ce_SolrInputDocument); if ((new_doc_entry = solr_input_doc_ctor(return_value))== NULL) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "SolrInputDocument could not be created."); } /* Duplicate the doc_entry contents */ new_doc_entry->field_count = old_doc_entry->field_count; new_doc_entry->document_boost = old_doc_entry->document_boost; /* Initializing the hash table used for storing fields in this SolrDocument */ /* Copy the contents of the old fields HashTable to the new SolrDocument */ zend_hash_copy(new_doc_entry->fields, old_doc_entry->fields, (copy_ctor_func_t) field_copy_constructor); /* call getInputDocument on each child SolrDocument and store children */ if (zend_hash_num_elements(old_doc_entry->children) > 0) { solr_add_child_input_documents_from_documents(old_doc_entry->children, new_doc_entry TSRMLS_CC); } } /* }}} */ /* {{{ proto array SolrInputDocument::getChildDocuments( void ) Returns child documents or null if none */ PHP_METHOD(SolrDocument, getChildDocuments) { solr_document_t *solr_doc = NULL; if (solr_fetch_document_entry(getThis(), &solr_doc TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to fetch document entry for current object"); return; } if (zend_hash_num_elements(solr_doc->children) > 0) { array_init(return_value); zend_hash_init(Z_ARRVAL_P(return_value), zend_hash_num_elements(solr_doc->children), NULL, ZVAL_PTR_DTOR, 0); zend_hash_copy(Z_ARRVAL_P(return_value), solr_doc->children, (copy_ctor_func_t)zval_add_ref); } } /* }}} */ /* {{{ proto bool SolrInputDocument::hasChildDocuments( void ) Checks whether this document has child documents */ PHP_METHOD(SolrDocument, hasChildDocuments) { solr_document_t *solr_doc = NULL; if (solr_fetch_document_entry(getThis(), &solr_doc TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to fetch document entry for current object"); return; } if (zend_hash_num_elements(solr_doc->children) > 0) { RETURN_TRUE; } else { RETURN_FALSE; } } /* }}} */ /* {{{ proto int SolrInputDocument::getChildDocumentsCount( void ) Returns the number of child documents */ PHP_METHOD(SolrDocument, getChildDocumentsCount) { solr_document_t *solr_doc = NULL; if (solr_fetch_document_entry(getThis(), &solr_doc TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to fetch document entry for current object"); return; } ZVAL_LONG(return_value, zend_hash_num_elements(solr_doc->children)); } /* }}} */ /* {{{ proto SolrDocumentField::__construct(void) Constructor */ PHP_METHOD(SolrDocumentField, __construct) { Z_OBJ_HT_P(getThis()) = &solr_document_field_handlers; } /* }}} */ /* {{{ proto SolrDocumentField::__destruct(void) Destructor */ PHP_METHOD(SolrDocumentField, __destruct) { } /* }}} */ /* {{{ PHP_SOLR_API void solr_document_field_write_property(zval *object, zval *member, zval *value TSRMLS_DC) */ #if PHP_VERSION_ID < 50399 PHP_SOLR_API void solr_document_field_write_property(zval *object, zval *member, zval *value TSRMLS_DC) #elif PHP_VERSION_ID < 70000 PHP_SOLR_API void solr_document_field_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC) #else PHP_SOLR_API void solr_document_field_write_property(zval *object, zval *member, zval *value, void **cache_slot) #endif { solr_throw_exception(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1007_MSG, SOLR_ERROR_1007 TSRMLS_CC, SOLR_FILE_LINE_FUNC); /* if (Z_TYPE_P(member) == IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempting to set value for [%s] property in a SolrDocumentField instance", Z_STRVAL_P(member)); } */ } /* }}} */ /* {{{ PHP_SOLR_API void solr_document_field_unset_property(zval *object, zval *member TSRMLS_DC) */ #if PHP_VERSION_ID < 50399 PHP_SOLR_API void solr_document_field_unset_property(zval *object, zval *member TSRMLS_DC) #elif PHP_VERSION_ID < 70000 PHP_SOLR_API void solr_document_field_unset_property(zval *object, zval *member, const zend_literal *key TSRMLS_DC) #else PHP_SOLR_API void solr_document_field_unset_property(zval *object, zval *member, void ** cache_slot) #endif { solr_throw_exception(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1007_MSG, SOLR_ERROR_1007 TSRMLS_CC, SOLR_FILE_LINE_FUNC); /* if (Z_TYPE_P(member) == IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempting to remove [%s] property in a SolrDocumentField instance", Z_STRVAL_P(member)); } */ } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/php_solr_exception.c0000644000175000017500000001475012676753707016722 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* {{{ static void solr_prepare_internal_info(zval *object, zval *return_value TSRMLS_DC) */ static void solr_prepare_internal_info(zval *object, zval *return_value TSRMLS_DC) { zval *rv = NULL; zval *line_no = zend_read_property(Z_OBJCE_P(object), object, SOLR_SOURCELINE_NO_PROPERTY_NAME, sizeof(SOLR_SOURCELINE_NO_PROPERTY_NAME)-1, 0, rv); zval *solr_file = zend_read_property(Z_OBJCE_P(object), object, SOLR_SOURCEFILE_PROPERTY_NAME, sizeof(SOLR_SOURCEFILE_PROPERTY_NAME)-1, 0, rv); zval *solr_zif_name = zend_read_property(Z_OBJCE_P(object), object, SOLR_ZIFNAME_PROPERTY_NAME, sizeof(SOLR_ZIFNAME_PROPERTY_NAME)-1, 0, rv); long int source_line = Z_LVAL_P(line_no); char *solr_source_file = Z_STRVAL_P(solr_file); char *solr_zifname = Z_STRVAL_P(solr_zif_name); array_init(return_value); add_assoc_long(return_value, SOLR_SOURCELINE_NO_PROPERTY_NAME, source_line); add_assoc_string(return_value, SOLR_SOURCEFILE_PROPERTY_NAME, solr_source_file); add_assoc_string(return_value, SOLR_ZIFNAME_PROPERTY_NAME, solr_zifname); } /* }}} */ /* {{{ void solr_throw_exception_ex(zend_class_entry *exception_ce, long code TSRMLS_DC, const char *filename, int file_line, const char *function_name, char *format, ...) */ PHP_SOLR_API void solr_throw_exception_ex(zend_class_entry *exception_ce, long code TSRMLS_DC, const char *filename, int file_line, const char *function_name, char *format, ...) { char *message = NULL; zval object; zend_object *object_val = NULL; va_list args; va_start(args,format); /* Preparing the message string from the format and variable argument list, if any. */ ap_php_vasprintf(&message, format, args); va_end(args); /* Retrieves the thrown object and updates the properties */ object_val = zend_throw_exception(exception_ce, message, code TSRMLS_CC); ZVAL_OBJ(&object, object_val); /* This is the line number in the source file where it was thrown */ zend_update_property_long(exception_ce, &object, SOLR_SOURCELINE_NO_PROPERTY_NAME, sizeof(SOLR_SOURCELINE_NO_PROPERTY_NAME)-1, file_line TSRMLS_CC); /* This is the line source file where it was thrown */ zend_update_property_string(exception_ce, &object, SOLR_SOURCEFILE_PROPERTY_NAME, sizeof(SOLR_SOURCEFILE_PROPERTY_NAME)-1, (char *) filename TSRMLS_CC); /* This is the C function where it was thrown */ zend_update_property_string(exception_ce, &object, SOLR_ZIFNAME_PROPERTY_NAME, sizeof(SOLR_ZIFNAME_PROPERTY_NAME)-1, (char *) function_name TSRMLS_CC); /* message must be freed */ if (message != NULL) { free(message); } } /* }}} */ /* {{{ void solr_throw_exception(zend_class_entry *exception_ce, char *message, long code TSRMLS_DC, const char *filename, int file_line, const char *function_name) */ PHP_SOLR_API void solr_throw_exception(zend_class_entry *exception_ce, char *message, long code TSRMLS_DC, const char *filename, int file_line, const char *function_name) { /* Retrieves the thrown object and updates the properties */ zend_object *object_val = NULL; zval object; object_val = zend_throw_exception(exception_ce, message, code); ZVAL_OBJ(&object, object_val); /* This is the line number in the source file where it was thrown */ zend_update_property_long(exception_ce, &object, SOLR_SOURCELINE_NO_PROPERTY_NAME, sizeof(SOLR_SOURCELINE_NO_PROPERTY_NAME)-1, file_line); /* This is the line source file where it was thrown */ zend_update_property_string(exception_ce, &object, SOLR_SOURCEFILE_PROPERTY_NAME, sizeof(SOLR_SOURCEFILE_PROPERTY_NAME)-1, (char *) filename); /* This is the C function where it was thrown */ zend_update_property_string(exception_ce, &object, SOLR_ZIFNAME_PROPERTY_NAME, sizeof(SOLR_ZIFNAME_PROPERTY_NAME)-1, (char *) function_name); } /* }}} */ /* Macro for preparing the return value array */ #define solr_exception_return_internal_info() { \ solr_prepare_internal_info(getThis(), return_value TSRMLS_CC); \ } /* {{{ proto array SolrException::getInternalInfo(void) Returns the internal API information where the exception was generated */ PHP_METHOD(SolrException, getInternalInfo) { solr_exception_return_internal_info() } /* }}} */ /* {{{ proto array SolrClientException::getInternalInfo(void) Returns the internal API information where the exception was generated */ PHP_METHOD(SolrClientException, getInternalInfo) { solr_exception_return_internal_info() } /* }}} */ /* {{{ proto array SolrIllegalOperationException::getInternalInfo(void) Returns the internal API information where the exception was generated */ PHP_METHOD(SolrIllegalOperationException, getInternalInfo) { solr_exception_return_internal_info() } /* }}} */ /* {{{ proto array SolrIllegalArgumentException::getInternalInfo(void) Returns the internal API information where the exception was generated */ PHP_METHOD(SolrIllegalArgumentException, getInternalInfo) { solr_exception_return_internal_info() } /* }}} */ /* {{{ proto array SolrServerException::getInternalInfo(void) Returns the internal API information where the exception was generated */ PHP_METHOD(SolrServerException, getInternalInfo) { solr_exception_return_internal_info() } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/php_solr_input_document.c0000644000175000017500000005754012676753707017765 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /** ************************************************************************ **/ /** DEFINITIONS FOR SOLR INPUT DOCUMENT METHODS **/ /** ************************************************************************ **/ /* {{{ proto void SolrInputDocument::__construct() SolrInputDocument constructor */ PHP_METHOD(SolrInputDocument, __construct) { zval *objptr = getThis(); if (solr_input_doc_ctor(objptr) == NULL) { return; } } /* }}} */ /* {{{ proto void SolrInputDocument::__destruct(void) Destructor for SolrInputDocument */ PHP_METHOD(SolrInputDocument, __destruct) { solr_document_t *doc_entry = NULL; /* Retrieve the document entry for this SolrDocument */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { zend_hash_index_del(SOLR_GLOBAL(documents), doc_entry->document_index); /* Keep track of how many SolrDocument instances we currently have */ SOLR_GLOBAL(document_count)--; return ; } } /* }}} */ /* {{{ proto void SolrInputDocument::__clone(void) Clones the current object. Not to be called directly. */ PHP_METHOD(SolrInputDocument, __clone) { RETURN_NULL(); } /* }}} */ /* {{{ proto void SolrInputDocument::__sleep(void) Should not be called directly. Serialization is not supported. */ PHP_METHOD(SolrInputDocument, __sleep) { solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1005 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1005_MSG); } /* }}} */ /* {{{ proto void SolrInputDocument::__wakeup(void) Should not be called directly. Serialization is not supported. */ PHP_METHOD(SolrInputDocument, __wakeup) { solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1005 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1005_MSG); } /* }}} */ /* {{{ proto bool SolrInputDocument::setBoost(float document_boost) Sets the boost for the document. */ PHP_METHOD(SolrInputDocument, setBoost) { double boost_value = 0.0f; solr_document_t *doc_entry = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &boost_value) == FAILURE) { RETURN_FALSE; } /* If the submitted boost_value is negative. */ if (boost_value < 0.0) { RETURN_FALSE; } /* Retrieve the document entry for this SolrDocument */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { doc_entry->document_boost = boost_value; RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto float SolrInputDocument::getBoost(void) Retrieves the boost for the document. */ PHP_METHOD(SolrInputDocument, getBoost) { solr_document_t *doc_entry = NULL; if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { RETURN_DOUBLE(doc_entry->document_boost); } RETURN_FALSE; } /* }}} */ /* {{{ proto bool SolrInputDocument::clear(void) Discards all the fields and resets the document boost to zero. */ PHP_METHOD(SolrInputDocument, clear) { solr_document_t *doc_entry = NULL; if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { doc_entry->document_boost = 0.0; doc_entry->field_count = 0L; zend_hash_clean(doc_entry->fields); RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto bool SolrInputDocument::addField(string field_name, field_value [, float field_boost]) Adds a field to the document. Can be called multiple times. */ PHP_METHOD(SolrInputDocument, addField) { solr_char_t *field_name = NULL, *field_value = NULL; COMPAT_ARG_SIZE_T field_name_length = 0, field_value_length = 0; solr_document_t *doc_entry = NULL; double field_boost = 0.0; /* Process the parameters passed to the method */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|d", &field_name, &field_name_length, &field_value, &field_value_length, &field_boost) == FAILURE) { RETURN_FALSE; } if (!field_name_length) { RETURN_FALSE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { solr_field_list_t *field_values = NULL; /* If the field already exists in the SolrDocument instance append the value to the field list queue */ if ((field_values = (solr_field_list_t *)zend_hash_str_find_ptr(doc_entry->fields, field_name, field_name_length)) != NULL) { if (solr_document_insert_field_value(field_values, (solr_char_t *)field_value, field_boost) == FAILURE) { RETURN_FALSE; } } else { /* Otherwise, create a new one and add it to the hash table */ field_values = (solr_field_list_t *) pemalloc(sizeof(solr_field_list_t), SOLR_DOCUMENT_FIELD_PERSISTENT); memset(field_values, 0, sizeof(solr_field_list_t)); field_values->count = 0L; field_values->field_boost = 0.0; field_values->field_name = (solr_char_t *) pestrdup((char *)field_name, SOLR_DOCUMENT_FIELD_PERSISTENT); field_values->head = NULL; field_values->last = NULL; if (solr_document_insert_field_value(field_values, field_value, field_boost) == FAILURE) { solr_destroy_field_list(field_values); RETURN_FALSE; } if (zend_hash_str_add_ptr(doc_entry->fields, field_name, field_name_length,(void *) field_values) == NULL) { solr_destroy_field_list(field_values); RETURN_FALSE; } /* Increment field count only when HEAD is added */ doc_entry->field_count++; } RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto bool SolrInputDocument::setFieldBoost(string fieldname, float boost_value) Sets the boost for the specified field. */ PHP_METHOD(SolrInputDocument, setFieldBoost) { solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_length = 0; double field_boost = 0.0; solr_document_t *doc_entry = NULL; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sd", &field_name, &field_name_length, &field_boost) == FAILURE) { RETURN_FALSE; } if (!field_name_length) { RETURN_FALSE; } if (field_boost < 0.0) { RETURN_FALSE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { solr_field_list_t *field_values = NULL; /* If the field already exists in the SolrDocument instance append the value to the field list queue */ if ((field_values = zend_hash_str_find_ptr(doc_entry->fields, field_name, field_name_length)) != NULL) { field_values->field_boost = field_boost; RETURN_TRUE; } RETURN_FALSE; } RETURN_FALSE; } /* }}} */ /* {{{ proto float SolrInputDocument::getFieldBoost(string fieldname) Returns the boost value for the specified field. */ PHP_METHOD(SolrInputDocument, getFieldBoost) { solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_length = 0; solr_document_t *doc_entry = NULL; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (!field_name_length) { RETURN_FALSE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { solr_field_list_t *field_values = NULL; if ((field_values = zend_hash_str_find_ptr(doc_entry->fields, field_name, field_name_length)) != NULL) { RETURN_DOUBLE(field_values->field_boost); } RETURN_FALSE; } RETURN_FALSE; } /* }}} */ /* {{{ proto array SolrInputDocument::getFieldNames(void) Returns an array of all the field names in the document. */ PHP_METHOD(SolrInputDocument, getFieldNames) { solr_document_get_field_names(INTERNAL_FUNCTION_PARAM_PASSTHRU); } /* }}} */ /* {{{ proto int SolrInputDocument::getFieldCount(void) Returns the number of fields in document. Multivalued fields are only counted once. */ PHP_METHOD(SolrInputDocument, getFieldCount) { solr_document_t *doc_entry = NULL; /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { RETURN_LONG(zend_hash_num_elements(doc_entry->fields)); } RETURN_FALSE; } /* }}} */ /* {{{ proto SolrDocumentField SolrInputDocument::getField(string fieldname) Returns the requested field. */ PHP_METHOD(SolrInputDocument, getField) { solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_length = 0; solr_document_t *doc_entry = NULL; zend_string *field_str = NULL; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (!field_name_length) { RETURN_FALSE; } field_str = zend_string_init(field_name, field_name_length, SOLR_DOCUMENT_FIELD_PERSISTENT); /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { solr_field_list_t *field_values = NULL; if ((field_values = zend_hash_find_ptr(doc_entry->fields, field_str)) != NULL) { solr_create_document_field_object(field_values, &return_value TSRMLS_CC); /* The field was retrieved, so we're done here */ zend_string_release(field_str); return ; } goto return_false; } return_false: zend_string_release(field_str); RETURN_FALSE; } /* }}} */ /* {{{ proto array SolrInputDocument::toArray(void) Returns an array representation of the object. */ PHP_METHOD(SolrInputDocument, toArray) { solr_document_t *doc_entry = NULL; zval fields_array; /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { HashTable *fields_ht; array_init(return_value); array_init(&fields_array); zend_hash_init(Z_ARRVAL(fields_array), zend_hash_num_elements(doc_entry->fields), NULL, ZVAL_PTR_DTOR, 0); add_assoc_double(return_value, "document_boost", doc_entry->document_boost); add_assoc_long(return_value, "field_count", doc_entry->field_count); add_assoc_zval(return_value, "fields", &fields_array); fields_ht = doc_entry->fields; SOLR_HASHTABLE_FOR_LOOP(fields_ht) { solr_field_list_t *field = NULL; zval current_field; zval *current_field_ptr = ¤t_field; field = zend_hash_get_current_data_ptr(fields_ht); /* create SolrDocumentField */ solr_create_document_field_object(field, ¤t_field_ptr TSRMLS_CC); /* create SolrDocumentField to the fields HT */ add_next_index_zval(&fields_array, current_field_ptr); } /* We are done */ return; } RETURN_FALSE; } /* }}} */ /* {{{ proto bool SolrInputDocument::fieldExists(string field_name) Checks if the field name exists in the document. */ PHP_METHOD(SolrInputDocument, fieldExists) { solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_length = 0; solr_document_t *doc_entry = NULL; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_length) == FAILURE) { RETURN_FALSE; } if (!field_name_length) { RETURN_FALSE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { if (zend_hash_str_exists(doc_entry->fields, field_name, field_name_length)) { RETURN_TRUE; } else { RETURN_FALSE; } } RETURN_FALSE; } /* }}} */ /* {{{ proto bool SolrInputDocument::deleteField(string field_name) Removes the request field from the document. */ PHP_METHOD(SolrInputDocument, deleteField) { solr_document_t *doc_entry = NULL; char *field_name; COMPAT_ARG_SIZE_T field_name_len = 0; /* Process the parameters passed to the default constructor */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_len) == FAILURE) { RETURN_FALSE; } if (!field_name_len) { RETURN_FALSE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { if (zend_hash_str_del(doc_entry->fields, field_name, field_name_len) == SUCCESS) { doc_entry->field_count--; RETURN_TRUE; } RETURN_FALSE; } RETURN_FALSE; } /* }}} */ /* {{{ proto bool SolrInputDocument::sort(int sort_criterion [, int sort_direction]) Sorts the document fields by the specified criterion. */ PHP_METHOD(SolrInputDocument, sort) { long int order_by = 0L; long int sort_direction = SOLR_SORT_ASC; solr_document_t *doc_entry = NULL; int renumber = 0; /* The pointer to the comparison function used by zend_qsort */ compare_func_t comparison_function = (compare_func_t) NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &order_by, &sort_direction) == FAILURE) { RETURN_FALSE; } /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == FAILURE) { RETURN_FALSE; } /* {{{ Select the appropriate comparison function */ switch(order_by) { case SOLR_SORT_FIELD_NAME : /* Sorting by field name */ { switch(sort_direction) { case SOLR_SORT_ASC : comparison_function = solr_compare_field_name; break; case SOLR_SORT_DESC : comparison_function = solr_rcompare_field_name; break; } } break; /* case SOLR_SORT_FIELD_NAME */ case SOLR_SORT_FIELD_VALUE_COUNT : /* Sorting by number of values per field */ { switch(sort_direction) { case SOLR_SORT_ASC : comparison_function = solr_compare_field_value_count; break; case SOLR_SORT_DESC : comparison_function = solr_rcompare_field_value_count; break; } } break; /* case SOLR_SORT_FIELD_VALUE_COUNT */ case SOLR_SORT_FIELD_BOOST_VALUE : /* Sorting by field boost values */ { switch(sort_direction) { case SOLR_SORT_ASC : comparison_function = solr_compare_field_boost_value; break; case SOLR_SORT_DESC : comparison_function = solr_rcompare_field_boost_value; break; } } break; /* case SOLR_SORT_FIELD_BOOST_VALUE */ default : /* Undefined sort criteria */ RETURN_FALSE; break; } /* }}} switch(order_by) */ /* Undefined sort direction. It was not ASC or DESC */ if (!comparison_function) { RETURN_FALSE; } if (zend_hash_sort_ex(doc_entry->fields, zend_qsort, comparison_function, renumber TSRMLS_CC) == FAILURE) { RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* {{{ proto bool SolrInputDocument::merge(SolrInputDocument source [, bool override]) Merges the source document to the current object. */ PHP_METHOD(SolrInputDocument, merge) { solr_document_t *destination_document = NULL; solr_document_t *source_document = NULL; /* The destination SolrDocument instance */ zval * destination_document_zval = getThis(); /* The source SolrDocument instance */ zval *source_document_zval = NULL; /* Should we skip fields that already exist in destination */ zend_bool overwrite = (zend_bool) 0; copy_ctor_func_t p_copy_ctor = (copy_ctor_func_t) field_copy_constructor; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|b", &source_document_zval, solr_ce_SolrInputDocument, &overwrite) == FAILURE) { RETURN_FALSE; } if (solr_fetch_document_entry(source_document_zval, &source_document TSRMLS_CC) == FAILURE) { RETURN_FALSE; } if (solr_fetch_document_entry(destination_document_zval, &destination_document TSRMLS_CC) == FAILURE) { RETURN_FALSE; } if (zend_hash_num_elements(source_document->fields) == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Source SolrInputDocument has no fields. Source documentId"); RETURN_FALSE; } /* Copy the fields in the source HashTable to the destination HashTable */ zend_hash_merge(destination_document->fields, source_document->fields, p_copy_ctor, overwrite); /* Update the field count */ destination_document->field_count = (uint) zend_hash_num_elements(destination_document->fields); RETURN_TRUE; } /* }}} */ /* {{{ proto void SolrInputDocument::addChildDocument(SolrInputDocument child) Adds a child document */ PHP_METHOD(SolrInputDocument, addChildDocument) { zval *child_obj = NULL; solr_document_t *solr_doc = NULL, *child_doc_entry = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &child_obj, solr_ce_SolrInputDocument) == FAILURE) { RETURN_FALSE; } if (solr_fetch_document_entry(getThis(), &solr_doc TSRMLS_CC) == FAILURE) { solr_throw_exception_ex(solr_ce_SolrException, SOLR_ERROR_1008 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Internal Error: Unable to fetch document_entry."); return; } if (solr_fetch_document_entry(child_obj, &child_doc_entry TSRMLS_CC) == FAILURE) { solr_throw_exception_ex(solr_ce_SolrException, SOLR_ERROR_1008 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Internal Error: Unable to fetch document_entry for child document."); return; } /* SolrInputDocument must contain at least one field */ if (0 == zend_hash_num_elements(child_doc_entry->fields)) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Child document has no fields"); return; } if (zend_hash_next_index_insert(solr_doc->children, child_obj) == NULL) { solr_throw_exception_ex(solr_ce_SolrException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Internal Error: Unable to add child to the hashtable."); } else { Z_ADDREF_P(child_obj); } } /* }}} */ /* {{{ proto void SolrInputDocument::addChildDocuments(array) Adds a child documents */ PHP_METHOD(SolrInputDocument, addChildDocuments) { HashTable *solr_input_docs; solr_document_t *solr_doc = NULL; zval *docs_array = NULL; int num_input_docs = 0, curr_pos = 0; size_t pos = 0U; zval **input_docs = NULL, *current_input_doc = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &docs_array) == FAILURE) { return; } if (solr_fetch_document_entry(getThis(), &solr_doc TSRMLS_CC) == FAILURE) { solr_throw_exception_ex(solr_ce_SolrException, SOLR_ERROR_1008 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Internal Error: Unable to fetch document_entry."); } solr_input_docs = Z_ARRVAL_P(docs_array); num_input_docs = zend_hash_num_elements(solr_input_docs); if(!num_input_docs) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "The array parameter passed is empty"); return; } /* This should be released if there is an error */ input_docs = (zval **) pemalloc((sizeof(zval *) * (num_input_docs + 1)), SOLR_DOCUMENT_PERSISTENT); memset(input_docs, 0, sizeof(zval *) * (num_input_docs + 1)); /* Please check all the SolrInputDocument instances passed via the array */ SOLR_HASHTABLE_FOR_LOOP(solr_input_docs) { zval *solr_input_doc = NULL; solr_document_t *doc_entry = NULL; HashTable *document_fields; solr_input_doc = zend_hash_get_current_data(solr_input_docs); if (Z_TYPE_P(solr_input_doc) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(solr_input_doc), solr_ce_SolrInputDocument TSRMLS_CC)) { SOLR_FREE_DOC_ENTRIES(input_docs); solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "SolrInputDocument number %u is not a valid SolrInputDocument instance", (curr_pos + 1U)); return; } if (solr_fetch_document_entry(solr_input_doc, &doc_entry TSRMLS_CC) == FAILURE) { SOLR_FREE_DOC_ENTRIES(input_docs); solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "SolrInputDocument number %u is not valid. Object not present in HashTable", (curr_pos + 1U)); return; } document_fields = doc_entry->fields; /* SolrInputDocument must contain at least one field */ if (0 == zend_hash_num_elements(document_fields)) { SOLR_FREE_DOC_ENTRIES(input_docs); solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "SolrInputDocument number %u has no fields", (curr_pos + 1U)); return; } input_docs[curr_pos] = solr_input_doc; curr_pos++; } /* Grab the first (solr_document_t *) pointer */ current_input_doc = input_docs[pos]; while(current_input_doc != NULL) { if (zend_hash_next_index_insert(solr_doc->children, current_input_doc) == NULL) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "SolrInputDocument number %u has no fields", (pos + 1U)); SOLR_FREE_DOC_ENTRIES(input_docs); return; } /* todo possible leak */ Z_ADDREF_P(current_input_doc); pos++; current_input_doc = input_docs[pos]; } SOLR_FREE_DOC_ENTRIES(input_docs); } /* }}} */ /* {{{ proto array SolrInputDocument::getChildDocuments( void ) Returns child documents or null if none */ PHP_METHOD(SolrInputDocument, getChildDocuments) { solr_document_t *solr_doc = NULL; if (solr_fetch_document_entry(getThis(), &solr_doc TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to fetch document entry for current object"); } if (zend_hash_num_elements(solr_doc->children) > 0) { array_init(return_value); zend_hash_init(Z_ARRVAL_P(return_value), zend_hash_num_elements(solr_doc->children), NULL, ZVAL_PTR_DTOR, 0); zend_hash_copy(Z_ARRVAL_P(return_value), solr_doc->children, (copy_ctor_func_t)zval_add_ref); } } /* }}} */ /* {{{ proto bool SolrInputDocument::hasChildDocuments (void) Checks whether this document has got child documents */ PHP_METHOD(SolrInputDocument, hasChildDocuments) { solr_document_t *solr_doc = NULL; if (solr_fetch_document_entry(getThis(), &solr_doc TSRMLS_CC)) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to fetch document entry for current object"); } if (zend_hash_num_elements(solr_doc->children) > 0) { RETURN_TRUE; } else { RETURN_FALSE; } } /* }}} */ /* {{{ proto int SolrInputDocument::getChildDocumentsCount (void) Returns the number of child documents */ PHP_METHOD(SolrInputDocument, getChildDocumentsCount) { solr_document_t *solr_doc = NULL; if (solr_fetch_document_entry(getThis(), &solr_doc TSRMLS_CC)) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to fetch document entry for current object"); } ZVAL_LONG(return_value, zend_hash_num_elements(solr_doc->children)); } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/php_solr_object.c0000664000175000017500000002523312676753707016172 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* {{{ PHP_SOLR_API void solr_object_write_property(zval *object, zval *member, zval *value TSRMLS_DC) */ #if PHP_VERSION_ID < 50399 PHP_SOLR_API void solr_object_write_property(zval *object, zval *member, zval *value TSRMLS_DC) #elif PHP_VERSION_ID < 70000 PHP_SOLR_API void solr_object_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC) #else PHP_SOLR_API void solr_object_write_property(zval *object, zval *member, zval *value, void **cache_slot) #endif { solr_throw_exception(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1006_MSG, SOLR_ERROR_1006 TSRMLS_CC, SOLR_FILE_LINE_FUNC); if (Z_TYPE_P(member) == IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempting to set value for [%s] property in a SolrObject instance", Z_STRVAL_P(member)); } } /* }}} */ /* {{{ PHP_SOLR_API void solr_object_write_dimension(zval *object, zval *offset, zval *value TSRMLS_DC) */ PHP_SOLR_API void solr_object_write_dimension(zval *object, zval *offset, zval *value TSRMLS_DC) { solr_throw_exception(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1006_MSG, SOLR_ERROR_1006 TSRMLS_CC, SOLR_FILE_LINE_FUNC); if (Z_TYPE_P(offset) == IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempting to set value for [%s] property in a SolrObject instance", Z_STRVAL_P(offset)); } } /* }}} */ /* {{{ PHP_SOLR_API void solr_object_unset_property(zval *object, zval *member TSRMLS_DC) */ #if PHP_VERSION_ID < 50399 PHP_SOLR_API void solr_object_unset_property(zval *object, zval *member TSRMLS_DC) #elif PHP_VERSION_ID < 70000 PHP_SOLR_API void solr_object_unset_property(zval *object, zval *member, const zend_literal *key TSRMLS_DC) #else PHP_SOLR_API void solr_object_unset_property(zval *object, zval *member, void **cache_slot) #endif { solr_throw_exception(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1006_MSG, SOLR_ERROR_1006 TSRMLS_CC, SOLR_FILE_LINE_FUNC); if (Z_TYPE_P(member) == IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempting to remove [%s] property in a SolrObject instance", Z_STRVAL_P(member)); } } /* }}} */ /* {{{ PHP_SOLR_API void solr_object_unset_dimension(zval *object, zval *offset TSRMLS_DC) */ PHP_SOLR_API void solr_object_unset_dimension(zval *object, zval *offset TSRMLS_DC) { solr_throw_exception(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1006_MSG, SOLR_ERROR_1006 TSRMLS_CC, SOLR_FILE_LINE_FUNC); if (Z_TYPE_P(offset) == IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempting to remove [%s] property in a SolrObject instance", Z_STRVAL_P(offset)); } } /* }}} */ /* {{{ PHP_SOLR_API zval *solr_object_read_property(zval *object, zval *member, int type TSRMLS_DC) */ #if PHP_VERSION_ID < 50399 PHP_SOLR_API zval *solr_object_read_property(zval *object, zval *member, int type TSRMLS_DC) #elif PHP_VERSION_ID < 70000 PHP_SOLR_API zval *solr_object_read_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC) #else PHP_SOLR_API zval *solr_object_read_property(zval *object, zval *member, int type, void **cache_slot, zval* rv) #endif { zval *value = &EG(uninitialized_zval); char *name = NULL; HashTable *properties = NULL; if (Z_TYPE_P(member) != IS_STRING) { return value; } SOLR_HASHTABLE_FOR_LOOP(properties) { char *property_name = NULL; /* If the property name is in the HashTable */ if (property_name && !strcmp(property_name, name)) { value = zend_hash_get_current_data(properties); } } return value; } /* }}} */ /* {{{ proto SolrObject::__construct(void) Constructor for SolrObject */ PHP_METHOD(SolrObject, __construct) { Z_OBJ_HT_P(getThis()) = &solr_object_handlers; } /* }}} */ /* {{{ proto SolrObject::__destruct(void) Destructor for SolrObject. */ PHP_METHOD(SolrObject, __destruct) { } /* }}} */ /* {{{ proto void SolrObject::__set(string property_name, mixed value) Magic method for setting/updating property values. */ PHP_METHOD(SolrObject, __set) { } /* }}} */ /* {{{ proto mixed SolrObject::__get(string property_name) Magic method for retrieving properties. */ PHP_METHOD(SolrObject, __get) { solr_char_t *name = NULL; COMPAT_ARG_SIZE_T name_len = 0; zval *property = NULL, rv; zend_bool copy_value = 1; void *dtor = NULL; /* Process the parameters passed to the method */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { RETURN_FALSE; } property = zend_read_property(solr_ce_SolrObject, getThis(), name, name_len, 0, &rv); if (property) { RETURN_ZVAL(property, copy_value, dtor); } } /* }}} */ /* {{{ proto bool SolrObject::__isset(string property_name) Magic method for checking if a property exists in the object. */ PHP_METHOD(SolrObject, __isset) { solr_char_t *name = NULL; COMPAT_ARG_SIZE_T name_len = 0; zend_object *zobject = NULL; zval *value = NULL; /* Process the parameters passed to the method */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { RETURN_FALSE; } zobject = Z_OBJ_P(getThis()); value = zend_hash_str_find(zobject->properties, name, name_len); if (value) { RETURN_TRUE; } RETURN_FALSE; } /* }}} */ /* {{{ proto void SolrObject::__unset(string property_name) Magic method for removing the specified property. */ PHP_METHOD(SolrObject, __unset) { solr_char_t *name = NULL; COMPAT_ARG_SIZE_T name_len = 0; /* Process the parameters passed to the method */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { return; } solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1002 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1002_MSG, name); RETURN_FALSE; } /* }}} */ /* {{{ proto void SolrObject::offsetSet(string key, mixed value) Sets the specified key to value. */ PHP_METHOD(SolrObject, offsetSet) { solr_char_t *name = NULL; COMPAT_ARG_SIZE_T name_len = 0; zval *prop = NULL; /* Process the parameters passed to the method */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", &name, &name_len, &prop) == FAILURE) { RETURN_FALSE; } if (prop && Z_TYPE_P(prop) == IS_NULL) { solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1002 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1002_MSG, name); return ; } zend_update_property(Z_OBJCE_P(getThis()), getThis(), name, name_len, prop TSRMLS_CC); } /* }}} */ /* {{{ proto mixed SolrObject::offsetGet(string key) Retrieves the requested key. */ PHP_METHOD(SolrObject, offsetGet) { solr_char_t *name = NULL; COMPAT_ARG_SIZE_T name_len = 0; zend_object *zobject = Z_OBJ_P(getThis()); HashTable *properties = zobject->properties; zval *property_value = NULL; zend_bool copy_value = 1; void *dtor = NULL; /* Process the parameters passed to the method */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { RETURN_FALSE; } if ((property_value = zend_hash_str_find(properties, name, name_len)) != NULL) { goto job_complete; } else { RETURN_NULL(); } job_complete : if (property_value && (property_value)) { RETURN_ZVAL((property_value), copy_value, dtor); } } /* }}} */ /* {{{ proto bool SolrObject::offsetExists(string key) Checks if the key exists. */ PHP_METHOD(SolrObject, offsetExists) { solr_char_t *name = NULL; COMPAT_ARG_SIZE_T name_len = 0; zend_object *zobject = Z_OBJ_P(getThis()); HashTable *properties = zobject->properties; zend_bool property_exists = 0; /* Process the parameters passed to the method */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { RETURN_FALSE; } if (!properties) { RETURN_FALSE; } property_exists = zend_hash_str_exists(properties, name, name_len); zend_hash_internal_pointer_reset(properties); RETURN_BOOL(property_exists); } /* }}} */ /* {{{ proto void SolrObject::offsetUnset(string key) Removes the specified key. */ PHP_METHOD(SolrObject, offsetUnset) { solr_char_t *name = NULL; COMPAT_ARG_SIZE_T name_len = 0; /* Process the parameters passed to the method */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { return; } solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1002 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1002_MSG, name); RETURN_FALSE; } /* }}} */ /* {{{ proto array SolrObject::getPropertyNames(void) Returns an array of all the properties/keys in the object. */ PHP_METHOD(SolrObject, getPropertyNames) { zend_object *zobject = Z_OBJ_P(getThis()); zval new_val; zend_ulong num_idx; zend_string *str_idx; HashTable *properties = zobject->properties; if (! properties || !zend_hash_num_elements(properties)) { array_init_size(return_value, 0); zend_hash_real_init(Z_ARRVAL_P(return_value), 1); return; } array_init_size(return_value, zend_hash_num_elements(properties)); zend_hash_real_init(Z_ARRVAL_P(return_value), 1); ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) { /* Go through input array and add keys to the return array */ ZEND_HASH_FOREACH_KEY(properties, num_idx, str_idx) { if (str_idx) { ZVAL_STR_COPY(&new_val, str_idx); } else { ZVAL_LONG(&new_val, num_idx); } ZEND_HASH_FILL_ADD(&new_val); } ZEND_HASH_FOREACH_END(); } ZEND_HASH_FILL_END(); } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/php_solr_params.c0000644000175000017500000007314512676753707016212 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* {{{ static void solr_serialize_xml_set_param_props(xmlNode *xml_param_node, solr_param_t *param) */ static void solr_serialize_xml_set_param_props(xmlNode *xml_param_node, solr_param_t *param) { char tmp_buffer[32]; /* This should be enough to hold any value */ memset(tmp_buffer, 0, sizeof(tmp_buffer)); /* Set the name attribute on the param node */ xmlNewProp(xml_param_node, (xmlChar *) "name", (xmlChar *) param->param_name); php_sprintf(tmp_buffer, "%d", param->type); /* Set the type attribute on the param node */ xmlNewProp(xml_param_node, (xmlChar *) "type", (xmlChar *) tmp_buffer); php_sprintf(tmp_buffer, "%d", param->allow_multiple); /* Set the allow_multiple attribute on the param node */ xmlNewProp(xml_param_node, (xmlChar *) "allow_multiple", (xmlChar *) tmp_buffer); php_sprintf(tmp_buffer, "%u", param->count); /* Set the count attribute on the param node */ xmlNewProp(xml_param_node, (xmlChar *) "count", (xmlChar *) tmp_buffer); php_sprintf(tmp_buffer, "%d", param->delimiter); /* Set the delimiter attribute on the param node */ xmlNewProp(xml_param_node, (xmlChar *) "delimiter", (xmlChar *) tmp_buffer); php_sprintf(tmp_buffer, "%d", param->arg_separator); /* Set the arg_separator attribute on the param node */ xmlNewProp(xml_param_node, (xmlChar *) "arg_separator", (xmlChar *) tmp_buffer); } /* }}} */ /* {{{ static void solr_serialize_normal_param_value(xmlNode *xml_params_node, solr_param_t *param) */ static void solr_serialize_normal_param_value(xmlNode *xml_params_node, solr_param_t *param) { xmlNode *xml_param_node = xmlNewChild(xml_params_node, NULL, (xmlChar *) "param", NULL); solr_param_value_t *curr_value = param->head; solr_serialize_xml_set_param_props(xml_param_node, param); while(curr_value != NULL) { xmlChar *param_value_txt = xmlEncodeEntitiesReentrant(xml_params_node->doc, (xmlChar *) curr_value->contents.normal.str); xmlNewChild(xml_param_node, NULL, (xmlChar *) "param_value", param_value_txt); xmlFree(param_value_txt); curr_value = curr_value->next; /* Go to the next value in the list */ } } /* }}} */ /* {{{ static void solr_serialize_simple_list_param_value(xmlNode *xml_params_node, solr_param_t *param) */ static void solr_serialize_simple_list_param_value(xmlNode *xml_params_node, solr_param_t *param) { xmlNode *xml_param_node = xmlNewChild(xml_params_node, NULL, (xmlChar *) "param", NULL); solr_param_value_t *curr_value = param->head; solr_serialize_xml_set_param_props(xml_param_node, param); while(curr_value != NULL) { xmlChar *param_value_txt = xmlEncodeEntitiesReentrant(xml_params_node->doc, (xmlChar *) curr_value->contents.simple_list.str); xmlNewChild(xml_param_node, NULL, (xmlChar *) "param_value", param_value_txt); xmlFree(param_value_txt); curr_value = curr_value->next; /* Go to the next value in the list */ } } /* }}} */ /* {{{ static void solr_serialize_arg_list_param_value(xmlNode *xml_params_node, solr_param_t *param) */ static void solr_serialize_arg_list_param_value(xmlNode *xml_params_node, solr_param_t *param) { xmlNode *xml_param_node = xmlNewChild(xml_params_node, NULL, (xmlChar *) "param", NULL); solr_param_value_t *curr_value = param->head; solr_serialize_xml_set_param_props(xml_param_node, param); while(curr_value != NULL) { xmlChar *param_value_txt = xmlEncodeEntitiesReentrant(xml_params_node->doc, (xmlChar *) curr_value->contents.arg_list.value.str); xmlChar *arg_value_txt = xmlEncodeEntitiesReentrant(xml_params_node->doc, (xmlChar *) curr_value->contents.arg_list.arg.str); xmlNode *xml_param_value = xmlNewChild(xml_param_node, NULL, (xmlChar *) "param_value", param_value_txt); xmlNewProp(xml_param_value, (xmlChar *) "argument", arg_value_txt); xmlFree(param_value_txt); xmlFree(arg_value_txt); curr_value = curr_value->next; /* Go to the next value in the list */ } } /* }}} */ /* {{{ static int solr_serialize_solr_params_object(xmlChar **serialized, int *size, zval *objptr TSRMLS_DC) */ static int solr_serialize_solr_params_object(xmlChar **serialized, int *size, zval *objptr TSRMLS_DC) { solr_params_t *solr_params = NULL; xmlNode *xml_solr_params = NULL, *xml_params = NULL; xmlDoc *doc_ptr = NULL; HashTable *params = NULL; int format = 1; if (solr_fetch_params_entry(objptr, &solr_params TSRMLS_CC) == FAILURE) { return FAILURE; } if (!serialized || !size || !objptr) { return FAILURE; } doc_ptr = solr_xml_create_xml_doc((xmlChar *) "solr_params", &xml_solr_params); xml_params = xmlNewChild(xml_solr_params, NULL, (xmlChar *) "params", NULL); params = solr_params->params; SOLR_HASHTABLE_FOR_LOOP(params) { solr_param_t *solr_param_ptr = NULL; solr_param_ptr = zend_hash_get_current_data_ptr(params); switch(solr_param_ptr->type) { case SOLR_PARAM_TYPE_NORMAL : { solr_serialize_normal_param_value(xml_params, solr_param_ptr); } break; case SOLR_PARAM_TYPE_SIMPLE_LIST : { solr_serialize_simple_list_param_value(xml_params, solr_param_ptr); } break; case SOLR_PARAM_TYPE_ARG_LIST : { solr_serialize_arg_list_param_value(xml_params, solr_param_ptr); } break; default : { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Solr Param Type %d", solr_param_ptr->type); } } } xmlIndentTreeOutput = 1; xmlDocDumpFormatMemoryEnc(doc_ptr, serialized, size, "UTF-8", format); xmlFreeDoc(doc_ptr); return SUCCESS; } /* }}} */ /* {{{ static void solr_unserialize_get_param_normal(xmlNode *normal_param, HashTable *params_ht TSRMLS_DC) */ static void solr_unserialize_get_param_normal(xmlNode *normal_param, HashTable *params_ht TSRMLS_DC) { solr_char_t *param_name = NULL; size_t param_name_len = 0U; solr_bool allow_multiple = 0; solr_param_type_t param_type = SOLR_PARAM_TYPE_NORMAL; xmlAttr *currAttr = normal_param->properties; solr_param_t *param = NULL; xmlNode *currNode = normal_param->children; solr_param_value_equal_func_t equal_func = solr_normal_param_value_equal; solr_param_fetch_func_t fetch_func = (solr_param_fetch_func_t) solr_normal_param_value_fetch; solr_param_value_free_func_t free_func = solr_normal_param_value_free; /* Grab the name and setting for this parameter */ while(currAttr != NULL) { if (solr_xml_match_node(currAttr, "name")) { param_name = (solr_char_t *) solr_xml_get_node_contents(currAttr); param_name_len = solr_strlen(param_name); } if (solr_xml_match_node(currAttr, "allow_multiple")) { allow_multiple = solr_xml_get_node_contents_int(currAttr); } currAttr = currAttr->next; } param = solr_create_new_param(param_name, param_name_len, param_type, allow_multiple, equal_func, fetch_func, free_func, '&', 0 TSRMLS_CC); /* Retrieve all the values for this parameter */ while(currNode != NULL) { if (solr_xml_match_node(currNode, "param_value")) { xmlChar *pvalue = solr_xml_get_node_contents(currNode); size_t pvalue_length = solr_strlen((char *)pvalue); solr_param_value_t *parameter_value = (solr_param_value_t *) pemalloc(sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); memset(parameter_value, 0, sizeof(solr_param_value_t)); solr_string_appends(&(parameter_value->contents.normal), (solr_char_t *) pvalue, pvalue_length); solr_params_insert_param_value(param, parameter_value); } currNode = currNode->next; } /* Add this parameter to the hash table */ if (zend_hash_str_add_ptr(params_ht, (char *) param_name, param_name_len, (void *) param) == NULL) { /* Release all the memory allocated to this paramter */ solr_destroy_param(¶m); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error from %s %s", __func__, (char *) param_name); return; } } /* }}} */ /* {{{ static void solr_unserialize_get_param_simple_list(xmlNode *list_param, HashTable *params_ht TSRMLS_DC) */ static void solr_unserialize_get_param_simple_list(xmlNode *list_param, HashTable *params_ht TSRMLS_DC) { solr_char_t *param_name = NULL; size_t param_name_len = 0U; solr_bool allow_multiple = 0; solr_param_type_t param_type = SOLR_PARAM_TYPE_SIMPLE_LIST; solr_param_t *param = NULL; xmlNode *currNode = list_param->children; xmlAttr *currAttr = list_param->properties; solr_param_value_equal_func_t equal_func = solr_simple_list_param_value_equal; solr_param_fetch_func_t fetch_func = (solr_param_fetch_func_t) solr_simple_list_param_value_fetch; solr_param_value_free_func_t free_func = solr_simple_list_param_value_free; /* Grab the name and setting for this parameter */ while(currAttr != NULL) { if (solr_xml_match_node(currAttr, "name")) { param_name = (solr_char_t *) solr_xml_get_node_contents(currAttr); param_name_len = solr_strlen(param_name); } if (solr_xml_match_node(currAttr, "allow_multiple")) { allow_multiple = solr_xml_get_node_contents_int(currAttr); } currAttr = currAttr->next; } param = solr_create_new_param(param_name, param_name_len, param_type, allow_multiple, equal_func, fetch_func, free_func, ',', 0 TSRMLS_CC); /* Retrieve all the values for this parameter */ while(currNode != NULL) { if (solr_xml_match_node(currNode, "param_value")) { solr_char_t *pvalue = (solr_char_t *) solr_xml_get_node_contents(currNode); size_t pvalue_length = solr_strlen(pvalue); solr_param_value_t *parameter_value = (solr_param_value_t *) pemalloc(sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); memset(parameter_value, 0, sizeof(solr_param_value_t)); solr_string_appends(&(parameter_value->contents.simple_list), pvalue, pvalue_length); solr_params_insert_param_value(param, parameter_value); } currNode = currNode->next; } /* Add this parameter to the hash table */ if (zend_hash_str_add_ptr(params_ht, (char *) param_name, param_name_len, (void *) param) == NULL) { /* Release all the memory allocated to this paramter */ solr_destroy_param(¶m); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error from %s %s", __func__, (char *) param_name); return; } } /* }}} */ /* {{{ static void solr_unserialize_get_param_arg_list(xmlNode *sort_param, HashTable *params_ht TSRMLS_DC) */ static void solr_unserialize_get_param_arg_list(xmlNode *sort_param, HashTable *params_ht TSRMLS_DC) { solr_char_t *param_name = NULL; size_t param_name_len = 0U; solr_bool allow_multiple = 0; solr_char_t delimiter = 0; solr_char_t separator = 0; xmlAttr *currAttr = sort_param->properties; solr_param_type_t param_type = SOLR_PARAM_TYPE_ARG_LIST; solr_param_t *param = NULL; xmlNode *currNode = sort_param->children; solr_param_value_equal_func_t equal_func = solr_arg_list_param_value_equal; solr_param_fetch_func_t fetch_func = (solr_param_fetch_func_t) solr_arg_list_param_value_fetch; solr_param_value_free_func_t free_func = solr_arg_list_param_value_free; /* Grab the name and setting for this parameter */ while(currAttr != NULL) { if (solr_xml_match_node(currAttr, "name")) { param_name = (solr_char_t *) solr_xml_get_node_contents(currAttr); param_name_len = solr_strlen(param_name); } if (solr_xml_match_node(currAttr, "allow_multiple")) { allow_multiple = solr_xml_get_node_contents_int(currAttr); } if (solr_xml_match_node(currAttr, "delimiter")) { delimiter = solr_xml_get_node_contents_int(currAttr); } if (solr_xml_match_node(currAttr, "arg_separator")) { separator = solr_xml_get_node_contents_int(currAttr); } currAttr = currAttr->next; } param = solr_create_new_param(param_name, param_name_len, param_type, allow_multiple, equal_func, fetch_func, free_func, delimiter, separator TSRMLS_CC); /* Retrieve all the values for this parameter */ while(currNode != NULL) { if (solr_xml_match_node(currNode, "param_value")) { solr_char_t *pvalue = (solr_char_t *) solr_xml_get_node_contents(currNode); xmlAttr *argument = currNode->properties; /* the argument is the only property */ solr_char_t *avalue = (solr_char_t *) solr_xml_get_node_contents(argument); size_t pvalue_length = solr_strlen(pvalue); size_t avalue_length = solr_strlen(avalue); solr_param_value_t *parameter_value = (solr_param_value_t *) pemalloc(sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); memset(parameter_value, 0, sizeof(solr_param_value_t)); solr_string_appends(&(parameter_value->contents.arg_list.value), pvalue, pvalue_length); solr_string_appends(&(parameter_value->contents.arg_list.arg), avalue, avalue_length); solr_params_insert_param_value(param, parameter_value); } currNode = currNode->next; } /* Add this parameter to the hash table */ if (zend_hash_str_add_ptr(params_ht, (char *) param_name, param_name_len, (void *) param) == NULL) { /* Release all the memory allocated to this paramter */ solr_destroy_param(¶m); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error from %s %s", __func__, (char *) param_name); return; } } /* }}} */ /* {{{ static int solr_unserialize_solr_params_object(const char *serialized, int size, zval *objptr TSRMLS_DC) */ static int solr_unserialize_solr_params_object(const char *serialized, int size, zval *objptr TSRMLS_DC) { solr_params_t *solr_params = NULL; long int params_index = SOLR_UNIQUE_PARAMS_INDEX(); solr_params_t tmp_solr_params; uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE; HashTable *params_ht = NULL; xmlDoc *doc = NULL; xmlXPathContext *xpathctxt; const xmlChar *xpath_expression = (xmlChar *) "/solr_params/params/param/@type"; xmlXPathObject *xpathObj; xmlNodeSet *result = NULL; register size_t num_nodes; register size_t i = 0U; int return_status = SUCCESS; #ifdef PHP_7 solr_params = pemalloc(sizeof(solr_params_t), SOLR_PARAMS_PERSISTENT); #endif zend_update_property_long(Z_OBJCE_P(objptr), objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, params_index TSRMLS_CC); memset(&tmp_solr_params, 0, sizeof(solr_params_t)); if ((solr_params = zend_hash_index_update_ptr(SOLR_GLOBAL(params), params_index, (void *) solr_params)) == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while registering SolrParam object in HashTable"); return FAILURE; } solr_params->params_index = params_index; /* Allocate memory for the parameters HashTable using fast cache for HashTables */ ALLOC_HASHTABLE(solr_params->params); zend_hash_init(solr_params->params, nSize, NULL, (dtor_func_t) solr_destory_param_ht_dtor, SOLR_PARAMS_PERSISTENT); params_ht = solr_params->params; doc = xmlReadMemory(serialized, size, NULL, "UTF-8", 0); if (doc == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while parsing serialized XML string"); return FAILURE; } xpathctxt = xmlXPathNewContext(doc); if (xpathctxt == NULL) { xmlFreeDoc(doc); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while creating XML Xpath context"); return FAILURE; } xpathObj = xmlXPathEval(xpath_expression, xpathctxt); if (xpathObj == NULL) { xmlXPathFreeContext(xpathctxt); xmlFreeDoc(doc); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while evaluation XML Xpath expression"); return FAILURE; } result = xpathObj->nodesetval; if (result == NULL) { xmlXPathFreeObject(xpathObj); xmlXPathFreeContext(xpathctxt); xmlFreeDoc(doc); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while extracting result from XML xpath object during unserialization"); return FAILURE; } num_nodes = result->nodeNr; /* Number of parameter nodes matches in the xmlDocument */ /* Loop through all the parameter nodes and create an entry in the HashTable for each one */ for (i = 0U; i < num_nodes; i++) { xmlNode *currNode = result->nodeTab[i]; /* Absolutely No assumptions. I have to make sure that this is an attribute node */ if (currNode->type == XML_ATTRIBUTE_NODE) { /* Find out what type of parameter this is */ const solr_param_type_t param_type = solr_xml_get_node_contents_int(currNode); /* Get the /solr_params/params/param node */ xmlNode *param_xml_node = currNode->parent; /* Handle each parameter type separately */ switch(param_type) { case SOLR_PARAM_TYPE_NORMAL : { solr_unserialize_get_param_normal(param_xml_node, params_ht TSRMLS_CC); } break; case SOLR_PARAM_TYPE_SIMPLE_LIST : { solr_unserialize_get_param_simple_list(param_xml_node, params_ht TSRMLS_CC); } break; case SOLR_PARAM_TYPE_ARG_LIST : { solr_unserialize_get_param_arg_list(param_xml_node, params_ht TSRMLS_CC); } break; default : { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter type"); return_status = FAILURE; goto loop_complete; } } /* End switch */ } /* End if (currNode->type == XML_ATTRIBUTE_NODE) */ } /* End for */ loop_complete: xmlXPathFreeObject(xpathObj); xmlXPathFreeContext(xpathctxt); xmlFreeDoc(doc); return return_status; } /* }}} */ /* {{{ proto SolrParams::__clone(void) Should never be called directly. Throws exceptions whenever there is an attempt to clone a SolrParams instance */ PHP_METHOD(SolrParams, __clone) { long int params_index = SOLR_UNIQUE_PARAMS_INDEX(); solr_params_t solr_params; if (solr_init_params(&solr_params, params_index) == FAILURE) { return; } zend_update_property_long(solr_ce_SolrQuery, getThis(), SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, params_index TSRMLS_CC); solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_4001 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Cloning of SolrParams object instances is currently not supported"); } /* }}} */ /* {{{ proto SolrParams::setParam(string param_name, string param_value) Sets the parameter to the specified value */ PHP_METHOD(SolrParams, setParam) { solr_char_t *param_name = NULL; COMPAT_ARG_SIZE_T param_name_length = 0; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", ¶m_name, ¶m_name_length, ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrParams::addParam(string param_name, string param_value) Adds another param_name to the object. */ PHP_METHOD(SolrParams, addParam) { solr_char_t *param_name = NULL; COMPAT_ARG_SIZE_T param_name_length = 0; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", ¶m_name, ¶m_name_length, ¶m_value, ¶m_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_length, param_value, param_value_length) == FAILURE) { RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrParams::getParam(string param_name) Retrieves a parameter value */ PHP_METHOD(SolrParams, getParam) { solr_char_t *param_name = NULL; COMPAT_ARG_SIZE_T param_name_length = 0; solr_param_t *solr_param = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", ¶m_name, ¶m_name_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_FALSE; } if (!param_name_length) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter name"); RETURN_NULL(); } if (solr_param_find(getThis(), param_name, param_name_length, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } if (!solr_param) { /* This should never happen unless there is a logic error in solr_param_find() */ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Very severe internal error while fetching (solr_param_t **) from solr_param_find() %s", __func__); return; } switch(solr_param->type) { case SOLR_PARAM_TYPE_NORMAL : { if (solr_param->allow_multiple) { array_init(return_value); solr_normal_param_value_display(solr_param, return_value); return; } else { solr_normal_param_value_display_string(solr_param, return_value); return; } } break; case SOLR_PARAM_TYPE_SIMPLE_LIST : { array_init(return_value); solr_simple_list_param_value_display(solr_param, return_value); return; } break; case SOLR_PARAM_TYPE_ARG_LIST : { array_init(return_value); solr_arg_list_param_value_display(solr_param, return_value); return; } break; default : { /* This should never happen. However, never say never! */ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameter type in switch case %s", __func__); } } /* END switch(solr_param->type) */ } /* }}} */ /* {{{ proto array SolrParams::getPreparedParams(void) Returns an array of all the parameters (url-encoded) as they will be sent in the name-value pair POST request. */ PHP_METHOD(SolrParams, getPreparedParams) { solr_params_t *solr_params = NULL; array_init(return_value); /* Retrieve the document entry for this SolrDocument */ if (solr_fetch_params_entry(getThis(), &solr_params TSRMLS_CC) == SUCCESS) { HashTable *params = solr_params->params; SOLR_HASHTABLE_FOR_LOOP(params) { solr_param_t *solr_param = NULL; solr_string_t tmp_buffer; solr_param = zend_hash_get_current_data_ptr(params); memset(&tmp_buffer, 0, sizeof(solr_string_t)); solr_param->fetch_func(solr_param, &tmp_buffer); add_assoc_stringl(return_value, solr_param->param_name, tmp_buffer.str, tmp_buffer.len); solr_string_free(&tmp_buffer); } return; } php_error_docref(NULL TSRMLS_CC, E_WARNING, "SolrParams instance could not be retrieved from HashTable"); RETURN_NULL(); } /* }}} */ /* {{{ proto array SolrParams::getParams(void) Returns an array of the parameters in the object. The values are not url-encoded. */ PHP_METHOD(SolrParams, getParams) { solr_params_t *solr_params = NULL; array_init(return_value); /* Retrieve the document entry for this SolrDocument */ if (solr_fetch_params_entry(getThis(), &solr_params TSRMLS_CC) == SUCCESS) { HashTable *params = solr_params->params; SOLR_HASHTABLE_FOR_LOOP(params) { solr_param_t *solr_param_ptr = NULL; solr_param_display_func_t display_func = NULL; zval *current_param = NULL; solr_param_ptr = zend_hash_get_current_data_ptr(params); switch(solr_param_ptr->type) { case SOLR_PARAM_TYPE_NORMAL : { display_func = solr_normal_param_value_display; } break; case SOLR_PARAM_TYPE_SIMPLE_LIST : { display_func = solr_simple_list_param_value_display; } break; case SOLR_PARAM_TYPE_ARG_LIST : { display_func = solr_arg_list_param_value_display; } break; default : { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter type"); } } MAKE_STD_ZVAL(current_param); array_init(current_param); add_assoc_zval(return_value, solr_param_ptr->param_name, current_param); display_func(solr_param_ptr, current_param); #ifdef PHP_7 efree(current_param); #endif } return; } php_error_docref(NULL TSRMLS_CC, E_WARNING, "SolrParams instance could not be retrieved from HashTable"); RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrParams::__toString(void) Returns a string representation of the object */ PHP_METHOD(SolrParams, __toString) { solr_params_t *solr_params = NULL; register zend_bool url_encode = 0; /* Retrieve the document entry for this SolrDocument */ if (solr_fetch_params_entry(getThis(), &solr_params TSRMLS_CC) == SUCCESS) { HashTable *params = solr_params->params; solr_string_t tmp_buffer; memset(&tmp_buffer, 0, sizeof(solr_string_t)); SOLR_HASHTABLE_FOR_LOOP(params) { solr_param_t *solr_param_ptr = NULL; solr_param_tostring_func_t tostring_func = NULL; solr_param_ptr = zend_hash_get_current_data_ptr(params); switch(solr_param_ptr->type) { case SOLR_PARAM_TYPE_NORMAL : { tostring_func = solr_normal_param_value_tostring; } break; case SOLR_PARAM_TYPE_SIMPLE_LIST : { tostring_func = solr_simple_list_param_value_tostring; } break; case SOLR_PARAM_TYPE_ARG_LIST : { tostring_func = solr_arg_list_param_value_tostring; } break; default : { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter type"); } } tostring_func(solr_param_ptr, &(tmp_buffer), url_encode); solr_string_appendc(&(tmp_buffer), '&'); } if (tmp_buffer.str && tmp_buffer.len) { solr_string_remove_last_char(&(tmp_buffer)); RETVAL_STRINGL((char *) tmp_buffer.str, tmp_buffer.len); solr_string_free(&(tmp_buffer)); return; } } RETVAL_STRINGL(SOLR_SPACE_STRING, sizeof(SOLR_SPACE_STRING)-1); } /* }}} */ /* {{{ proto string SolrParams::toString(void) Returns a string representation of the object */ PHP_METHOD(SolrParams, toString) { solr_params_t *solr_params = NULL; zend_bool url_encode = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &url_encode) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); return; } /* Retrieve the document entry for this SolrDocument */ if (solr_fetch_params_entry(getThis(), &solr_params TSRMLS_CC) == SUCCESS) { HashTable *params = solr_params->params; solr_string_t tmp_buffer; memset(&tmp_buffer, 0, sizeof(solr_string_t)); SOLR_HASHTABLE_FOR_LOOP(params) { solr_param_t *solr_param_ptr = NULL; solr_param_tostring_func_t tostring_func = NULL; solr_param_ptr = zend_hash_get_current_data_ptr(params); switch(solr_param_ptr->type) { case SOLR_PARAM_TYPE_NORMAL : { tostring_func = solr_normal_param_value_tostring; } break; case SOLR_PARAM_TYPE_SIMPLE_LIST : { tostring_func = solr_simple_list_param_value_tostring; } break; case SOLR_PARAM_TYPE_ARG_LIST : { tostring_func = solr_arg_list_param_value_tostring; } break; default : { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter type"); } } tostring_func(solr_param_ptr, &(tmp_buffer), url_encode); solr_string_appendc(&(tmp_buffer), '&'); } if (tmp_buffer.str && tmp_buffer.len) { solr_string_remove_last_char(&(tmp_buffer)); RETVAL_STRINGL((char *) tmp_buffer.str, tmp_buffer.len); solr_string_free(&(tmp_buffer)); return; } } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrParams::serialize(void) Returns a string representation of the object. Used for custom serialization. */ PHP_METHOD(SolrParams, serialize) { xmlChar *serialized = NULL; int size = 0; if (solr_serialize_solr_params_object(&serialized, &size, getThis() TSRMLS_CC) == FAILURE || !serialized || !size) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to serialize object"); RETURN_NULL(); } RETVAL_STRINGL((char *) serialized, size); xmlFree(serialized); } /* }}} */ /* {{{ proto void SolrParams::unserialize(string serialized) Brings the serialized object back to life. */ PHP_METHOD(SolrParams, unserialize) { char *serialized_object = NULL; COMPAT_ARG_SIZE_T serialized_object_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &serialized_object, &serialized_object_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if(serialized_object_len == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_unserialize_solr_params_object(serialized_object, serialized_object_len, getThis() TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error during unserialization"); } } /* }}} */ /* {{{ proto void SolrModifiableParams::__construct(void) Constructor. */ PHP_METHOD(SolrModifiableParams, __construct) { long int params_index = SOLR_UNIQUE_PARAMS_INDEX(); solr_params_t solr_params; if (solr_init_params(&solr_params, params_index) == FAILURE) { return; } zend_update_property_long(solr_ce_SolrModifiableParams, getThis(), SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, params_index TSRMLS_CC); } /* }}} */ /* {{{ proto void SolrModifiableParams::__destruct(void) Destructor. */ PHP_METHOD(SolrModifiableParams, __destruct) { solr_params_t *solr_params = NULL; /* Retrieve the document entry for this SolrDocument */ if (solr_fetch_params_entry(getThis(), &solr_params TSRMLS_CC) == SUCCESS) { zend_hash_index_del(SOLR_GLOBAL(params), solr_params->params_index); return ; } } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/php_solr_query.c0000644000175000017500000047343012676753707016075 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* Outstanding Work/Changes */ /* TODO: Change SolrQuery::getTermsSort() to return integer */ /* TODO: Change SolrQuery::getFacetSort() to return integer */ /** * Note about methods implementation: * * One reason why each SolrQuery has custom code is because each method * could require separate tweaking. * * At this point in time, even though most of the SolrQuery methods share * basic features, I still believe that is a better idea to write separate code * for each method implementation. * * This will make the methods easier to maintain because * * from time to time, Solr modifies the way some of the request parameters are * submitted or processed. * * Hence, it is currently more logical to make each method an independent entity. */ /* {{{ proto SolrQuery::__construct([string q]) Constructor for SolrQuery */ PHP_METHOD(SolrQuery, __construct) { long int params_index = SOLR_UNIQUE_PARAMS_INDEX(); solr_char_t *q = NULL; COMPAT_ARG_SIZE_T query_length = 0; solr_params_t solr_params; zend_error_handling error_handling; zend_replace_error_handling(EH_THROW, solr_ce_SolrIllegalArgumentException, &error_handling TSRMLS_CC); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &q, &query_length) == FAILURE) { zend_restore_error_handling(&error_handling TSRMLS_CC); return; } zend_restore_error_handling(&error_handling TSRMLS_CC); if (solr_init_params(&solr_params, params_index) == FAILURE) { return; } zend_update_property_long(solr_ce_SolrQuery, getThis(), SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, params_index TSRMLS_CC); if (query_length) { if (solr_set_normal_param(getThis(), (solr_char_t *) "q", sizeof("q")-1, q, query_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error while setting query parameter"); return; } } } /* }}} */ /* {{{ proto SolrQuery::__destruct() Destructor for SolrQuery */ PHP_METHOD(SolrQuery, __destruct) { solr_params_t *solr_params = NULL; /* Retrieve the entry for this SolrParams instance */ if (solr_fetch_params_entry(getThis(), &solr_params TSRMLS_CC) == SUCCESS) { zend_hash_index_del(SOLR_GLOBAL(params), solr_params->params_index); return ; } /* This would only happen if user attempted an illegal operation */ php_error_docref(NULL TSRMLS_CC, E_ERROR, SOLR_ERROR_1008_MSG, SOLR_FILE_LINE_FUNC); } /* }}} */ /* {{{ CommonQueryParameters */ /* {{{ proto SolrQuery SolrQuery::setQuery(string q) Sets the q parameter */ PHP_METHOD(SolrQuery, setQuery) { solr_char_t *param_name = (solr_char_t *) "q"; COMPAT_ARG_SIZE_T param_name_len = sizeof("q")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setStart(int start) Sets the start parameter */ PHP_METHOD(SolrQuery, setStart) { solr_char_t *param_name = (solr_char_t *) "start"; COMPAT_ARG_SIZE_T param_name_len = sizeof("start")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setRows(int rows) Sets the rows parameter */ PHP_METHOD(SolrQuery, setRows) { solr_char_t *param_name = (solr_char_t *) "rows"; COMPAT_ARG_SIZE_T param_name_len = sizeof("rows")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addField(string fl) Adds another fl parameter */ PHP_METHOD(SolrQuery, addField) { solr_char_t *param_name = (solr_char_t *) "fl"; size_t param_name_len = sizeof("fl")-1; solr_char_t *param_value = NULL; size_t param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_simple_list_param(getThis(), param_name, param_name_len, param_value, param_value_len TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addSortField(string fl [, int sort_direction]) Adds another sort parameter */ PHP_METHOD(SolrQuery, addSortField) { solr_char_t *param_name = (solr_char_t *) "sort"; COMPAT_ARG_SIZE_T param_name_len = sizeof("sort")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; long int sort_direction = 1L; solr_sort_dir_t sort_order = SOLR_SORT_DIR_DESC; solr_char_t *avalue = NULL; COMPAT_ARG_SIZE_T avalue_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", ¶m_value, ¶m_value_len, &sort_direction) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } sort_order = (sort_direction < 0L || sort_direction > 1L) ? SOLR_SORT_DIR_DESC : (solr_sort_dir_t) sort_direction; avalue = (sort_order) ? "desc" : "asc"; avalue_length = solr_strlen(avalue); if (solr_add_arg_list_param(getThis(), param_name, param_name_len, param_value, param_value_len, avalue, avalue_length, ',', ' ' TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addFiterQuery(string fq) Adds another fq parameter */ PHP_METHOD(SolrQuery, addFilterQuery) { solr_char_t *param_name = (solr_char_t *) "fq"; COMPAT_ARG_SIZE_T param_name_len = sizeof("fq")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setShowDebugInfo(bool flag) Sets the debugQuery parameter */ PHP_METHOD(SolrQuery, setShowDebugInfo) { solr_char_t *param_name = (solr_char_t *) "debugQuery"; COMPAT_ARG_SIZE_T param_name_len = sizeof("debugQuery")-1; zend_bool show_debug_info = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &show_debug_info) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (!show_debug_info) { solr_delete_solr_parameter(getThis(), param_name, param_name_len TSRMLS_CC); solr_return_solr_params_object(); return; } if (solr_set_normal_param(getThis(), param_name, param_name_len, "true", sizeof("true")-1) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error adding debugging info "); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setExplainOther(string explainOther) Sets the explainOther parameter */ PHP_METHOD(SolrQuery, setExplainOther) { solr_char_t *param_name = (solr_char_t *) "explainOther"; COMPAT_ARG_SIZE_T param_name_len = sizeof("explainOther")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTimeAllowed(int milliseconds) Sets the maximum time in milliseconds allowed for the query */ PHP_METHOD(SolrQuery, setTimeAllowed) { solr_char_t *param_name = (solr_char_t *) "timeAllowed"; COMPAT_ARG_SIZE_T param_name_len = sizeof("timeAllowed")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setOmitHeader(bool flag) Sets the omitHeader parameter */ PHP_METHOD(SolrQuery, setOmitHeader) { solr_char_t *param_name = (solr_char_t *) "omitHeader"; COMPAT_ARG_SIZE_T param_name_len = sizeof("omitHeader")-1; COMPAT_ARG_SIZE_T param_value_len = 0; zend_bool omit_header = 0; solr_char_t *omit_header_str = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &omit_header) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } omit_header_str = (omit_header)? "true" : "false"; param_value_len = solr_strlen(omit_header_str); if (solr_set_normal_param(getThis(), param_name, param_name_len, omit_header_str, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, omit_header_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* }}} END OF CommonQueryParameters */ /* {{{ CoreQueryParameters */ /* {{{ proto SolrQuery SolrQuery::setEchoHandler(bool flag) Sets the echoHandler parameter */ PHP_METHOD(SolrQuery, setEchoHandler) { solr_char_t *param_name = (solr_char_t *) "echoHandler"; COMPAT_ARG_SIZE_T param_name_len = sizeof("echoHandler")-1; COMPAT_ARG_SIZE_T param_value_len = 0; zend_bool echo_handler = 0; solr_char_t *echo_handler_str = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &echo_handler) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } echo_handler_str = (echo_handler)? "true" : "false"; param_value_len = solr_strlen(echo_handler_str); if (solr_set_normal_param(getThis(), param_name, param_name_len, echo_handler_str, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, echo_handler_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setEchoParams(string value) Sets the echoParams parameter */ PHP_METHOD(SolrQuery, setEchoParams) { solr_char_t *param_name = (solr_char_t *) "echoParams"; COMPAT_ARG_SIZE_T param_name_len = sizeof("echoParams")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* }}} END OF CoreQueryParameters */ /* {{{ SimpleFacetParameters */ /* {{{ proto SolrQuery SolrQuery::setFacet(bool value) Sets the facet parameter */ PHP_METHOD(SolrQuery, setFacet) { solr_char_t *param_name = (solr_char_t *) "facet"; COMPAT_ARG_SIZE_T param_name_len = sizeof("facet")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_len, bool_flag_str, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addFacetField(string value) Sets the facet.field parameter */ PHP_METHOD(SolrQuery, addFacetField) { solr_char_t *param_name = (solr_char_t *) "facet.field"; COMPAT_ARG_SIZE_T param_name_len = sizeof("facet.field")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add param value %s to %s ", param_value, param_name); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addFacetQuery(string value) Adds another facet.query parameter */ PHP_METHOD(SolrQuery, addFacetQuery) { solr_char_t *param_name = (solr_char_t *) "facet.query"; COMPAT_ARG_SIZE_T param_name_len = sizeof("facet.query")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetPrefix(string value [, string field_override]) Sets the facet.prefix parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetPrefix) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.prefix"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetSort(int value [, string field_override]) Sets the facet.sort parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetSort) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Parameter value */ solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; long int sort_type = 0L; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|s", &sort_type, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.sort"); param_value = ((sort_type)? "count" : "index"); param_value_len = solr_strlen(param_value); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetLimit(string value [, string field_override]) Sets the facet.limit parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetLimit) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.limit"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetOffset(string value [, string field_override]) Sets the facet.offset parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetOffset) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.offset"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetMinCount(string value [, string field_override]) Sets the facet.mincount parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetMinCount) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.mincount"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetMissing(bool value [, string field_override]) Sets the facet.missing parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetMissing) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Parameter value */ solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; zend_bool bool_flag = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b|s", &bool_flag, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.missing"); param_value = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(param_value); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetMethod(string value [, string field_override]) Sets the facet.method parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetMethod) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.method"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetEnumCacheMinDefaultFrequency(string value [, string field_override]) Sets the facet.enum.cache.minDf parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetEnumCacheMinDefaultFrequency) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.enum.cache.minDf"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ Date facet parameters */ /* {{{ proto SolrQuery SolrQuery::addFacetDateField(string value) Adds another facet.date parameter. */ PHP_METHOD(SolrQuery, addFacetDateField) { solr_char_t *param_name = (solr_char_t *) "facet.date"; COMPAT_ARG_SIZE_T param_name_len = sizeof("facet.date")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetDateStart(string value [, string field_override]) Sets the facet.date.start parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetDateStart) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.date.start"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetDateEnd(string value [, string field_override]) Sets the facet.date.end parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetDateEnd) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.date.end"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetDateGap(string value [, string field_override]) Sets the facet.date.gap parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetDateGap) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.date.gap"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setFacetDateHardEnd(bool value [, string field_override]) Sets the facet.date.hardend parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setFacetDateHardEnd) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Parameter value */ solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; zend_bool bool_flag = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b|s", &bool_flag, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.date.hardend"); param_value = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(param_value); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addFacetDateOther(string value [, string field_override]) Sets the facet.date.other parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, addFacetDateOther) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.date.other"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* }}} End of date facet parameters */ /* }}} End of SimpleFacetParameters */ /* {{{ SimpleGroupParameters */ /* {{{ proto SolrQuery SolrQuery::setGroup(bool value) Enable result grouping (group parameter) */ PHP_METHOD(SolrQuery, setGroup) { solr_char_t *param_name = (solr_char_t *) "group"; COMPAT_ARG_SIZE_T param_name_len = sizeof("group")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_len, bool_flag_str, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto bool SolrQuery::getGroup() Returns true if grouping is enabled */ PHP_METHOD(SolrQuery, getGroup) { solr_char_t *param_name = (solr_char_t *) "group"; COMPAT_ARG_SIZE_T param_name_len = sizeof("group")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addGroupField(string value) Adds a group.field parameter */ PHP_METHOD(SolrQuery, addGroupField) { solr_char_t *param_name = (solr_char_t *) "group.field"; int param_name_len = sizeof("group.field")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add param value %s to %s ", param_value, param_name); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto string SolrQuery::getGroupFields() Returns all the group fields (group.field parameter values) */ PHP_METHOD(SolrQuery, getGroupFields) { solr_char_t *param_name = (solr_char_t *) "group.field"; COMPAT_ARG_SIZE_T param_name_len = sizeof("group.field")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_normal_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addGroupFunction(string value) Adds a group function (group.func parameter) */ PHP_METHOD(SolrQuery, addGroupFunction) { solr_char_t *param_name = (solr_char_t *) "group.func"; int param_name_len = sizeof("group.func")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add param value %s to %s ", param_value, param_name); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto string SolrQuery::getGroupFunctions() Returns all the group functions (group.func parameters) */ PHP_METHOD(SolrQuery, getGroupFunctions) { solr_char_t *param_name = (solr_char_t *) "group.func"; COMPAT_ARG_SIZE_T param_name_len = sizeof("group.func")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_normal_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addGroupQuery(string value) Sets the group.query parameter */ PHP_METHOD(SolrQuery, addGroupQuery) { solr_char_t *param_name = (solr_char_t *) "group.query"; int param_name_len = sizeof("group.query")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add param value %s to %s ", param_value, param_name); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto string SolrQuery::getGroupQueries() Returns all the group.query parameter values */ PHP_METHOD(SolrQuery, getGroupQueries) { solr_char_t *param_name = (solr_char_t *) "group.query"; COMPAT_ARG_SIZE_T param_name_len = sizeof("group.query")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_normal_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setGroupLimit(string value) Sets the group.limit parameter. */ PHP_METHOD(SolrQuery, setGroupLimit) { solr_char_t *param_name = (solr_char_t *) "group.limit"; int param_name_len = sizeof("group.limit")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add param value %s to %s ", param_value, param_name); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto int SolrQuery::getGroupLimit() Returns the group.limit value */ PHP_METHOD(SolrQuery, getGroupLimit) { solr_char_t *param_name = (solr_char_t *) "group.limit"; COMPAT_ARG_SIZE_T param_name_len = sizeof("group.limit")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setGroupOffset(int offset) Sets the group.offset parameter. */ PHP_METHOD(SolrQuery, setGroupOffset) { solr_char_t *param_name = (solr_char_t *) "group.offset"; int param_name_len = sizeof("group.offset")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add param value %s to %s ", param_value, param_name); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto int SolrQuery::getGroupOffset() Returns the group.offset value */ PHP_METHOD(SolrQuery, getGroupOffset) { solr_char_t *param_name = (solr_char_t *) "group.offset"; COMPAT_ARG_SIZE_T param_name_len = sizeof("group.offset")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addGroupSortField(string sort[, integer direction]) Add a group sort field (group.sort parameter). */ PHP_METHOD(SolrQuery, addGroupSortField) { solr_char_t *param_name = (solr_char_t *) "group.sort"; COMPAT_ARG_SIZE_T param_name_len = sizeof("group.sort")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; long int sort_direction = 1L; solr_sort_dir_t sort_order = SOLR_SORT_DIR_DESC; solr_char_t *avalue = NULL; COMPAT_ARG_SIZE_T avalue_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", ¶m_value, ¶m_value_len, &sort_direction) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } sort_order = (sort_direction < 0L || sort_direction > 1L) ? SOLR_SORT_DIR_DESC : (solr_sort_dir_t) sort_direction; avalue = (sort_order) ? "desc" : "asc"; avalue_length = solr_strlen(avalue); if (solr_add_arg_list_param(getThis(), param_name, param_name_len, param_value, param_value_len, avalue, avalue_length, ',', ' ' TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto array SolrQuery::getGroupSortFields() Returns the group.sort value */ PHP_METHOD(SolrQuery, getGroupSortFields) { solr_char_t *param_name = (solr_char_t *) "group.sort"; COMPAT_ARG_SIZE_T param_name_len = sizeof("group.sort")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_arg_list_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setGroupFormat(string value) Sets the group.format parameter. */ PHP_METHOD(SolrQuery, setGroupFormat) { solr_char_t *param_name = (solr_char_t *) "group.format"; int param_name_len = sizeof("group.format")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add param value %s to %s ", param_value, param_name); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto string SolrQuery::getGroupFormat() Returns the group.format value */ PHP_METHOD(SolrQuery, getGroupFormat) { solr_char_t *param_name = (solr_char_t *) "group.format"; COMPAT_ARG_SIZE_T param_name_len = sizeof("group.format")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_string(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setGroupMain(bool value) Sets the group.main parameter */ PHP_METHOD(SolrQuery, setGroupMain) { solr_char_t *param_name = (solr_char_t *) "group.main"; COMPAT_ARG_SIZE_T param_name_len = sizeof("group.main")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_len, bool_flag_str, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto bool SolrQuery::getGroupMain() Returns the group.main value */ PHP_METHOD(SolrQuery, getGroupMain) { solr_char_t *param_name = (solr_char_t *) "group.main"; COMPAT_ARG_SIZE_T param_name_len = sizeof("group.main")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setGroupNGroups(bool value) Sets the group.ngroups parameter */ PHP_METHOD(SolrQuery, setGroupNGroups) { solr_char_t *param_name = (solr_char_t *) "group.ngroups"; COMPAT_ARG_SIZE_T param_name_len = sizeof("group.ngroups")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_len, bool_flag_str, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto bool SolrQuery::getGroupNGroups() Returns the group.ngroups value */ PHP_METHOD(SolrQuery, getGroupNGroups) { solr_char_t *param_name = (solr_char_t *) "group.ngroups"; COMPAT_ARG_SIZE_T param_name_len = sizeof("group.ngroups")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setGroupTruncate(bool value) Sets the group.truncate parameter */ PHP_METHOD(SolrQuery, setGroupTruncate) { solr_char_t *param_name = (solr_char_t *) "group.truncate"; COMPAT_ARG_SIZE_T param_name_len = sizeof("group.truncate")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_len, bool_flag_str, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto bool SolrQuery::getGroupTruncate() Returns the group.truncate value */ PHP_METHOD(SolrQuery, getGroupTruncate) { solr_char_t *param_name = (solr_char_t *) "group.truncate"; COMPAT_ARG_SIZE_T param_name_len = sizeof("group.truncate")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setGroupFacet(bool value) Sets the group.facet parameter */ PHP_METHOD(SolrQuery, setGroupFacet) { solr_char_t *param_name = (solr_char_t *) "group.facet"; COMPAT_ARG_SIZE_T param_name_len = sizeof("group.facet")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_len, bool_flag_str, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto bool SolrQuery::getGroupFacet() Returns the group.facet value */ PHP_METHOD(SolrQuery, getGroupFacet) { solr_char_t *param_name = (solr_char_t *) "group.facet"; COMPAT_ARG_SIZE_T param_name_len = sizeof("group.facet")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setGroupCachePercent(int value) sets the group cache percent group.cache.percent value */ PHP_METHOD(SolrQuery, setGroupCachePercent) { solr_char_t *param_name = (solr_char_t *) "group.cache.percent"; COMPAT_ARG_SIZE_T param_name_len = sizeof ("group.cache.percent")-1; long cache_pct = 0; solr_char_t pval[4]; int pval_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &cache_pct)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } if (cache_pct < 0 || cache_pct > 100) { solr_throw_exception(solr_ce_SolrIllegalArgumentException, "Group cache percent must be between 0 and 100", SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC); RETURN_NULL(); } snprintf (pval, sizeof(pval), "%ld", cache_pct); pval_len = strlen(pval); if (solr_add_or_set_normal_param(getThis(), param_name, param_name_len, pval, pval_len, 0 TSRMLS_CC)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, pval); efree(pval); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto int SolrQuery::getGroupCachePercent() Gets the group cache percent group.cache.percent value */ PHP_METHOD(SolrQuery, getGroupCachePercent) { solr_char_t *param_name = (solr_char_t *) "group.cache.percent"; COMPAT_ARG_SIZE_T param_name_len = sizeof("group.cache.percent")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* }}} End of SimpleGroupParameters */ /* {{{ proto SolrQuery SolrQuery::collapse(SolrCollapseFunction collapseFunction) Collapse a Solr Query */ PHP_METHOD(SolrQuery, collapse) { solr_char_t *param_name = (solr_char_t *) "fq"; COMPAT_ARG_SIZE_T param_name_len = sizeof("fq")-1; zval *collapse_func_obj, *obj_ref; solr_function_t *collapse_func; solr_string_t *buffer = NULL; zend_string *field_str = zend_string_init("field", sizeof("field"), SOLR_FUNCTIONS_PERSISTENT); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &obj_ref) == FAILURE) { RETURN_NULL(); } if (Z_TYPE_P(obj_ref) == IS_REFERENCE) { collapse_func_obj = Z_REFVAL_P(obj_ref); } else { collapse_func_obj = obj_ref; } if(solr_fetch_function_entry(collapse_func_obj, &collapse_func TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal Error Unable to fetch function from functions global"); RETURN_NULL(); } /* validate */ if (!zend_hash_exists(collapse_func->params, field_str)) { solr_throw_exception_ex(solr_ce_SolrMissingMandatoryParameterException,SOLR_ERROR_4100 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_4100_MSG, "field"); } buffer = (solr_string_t *)pemalloc(sizeof(solr_string_t), SOLR_STRING_PERSISTENT); memset(buffer, 0, sizeof(solr_string_t)); solr_solrfunc_to_string(collapse_func, &buffer); if (solr_add_or_set_normal_param(getThis(), param_name, param_name_len, buffer->str, buffer->len, 1 TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, buffer->str); } solr_string_free(buffer); pefree(buffer, SOLR_STRING_PERSISTENT); zend_string_release(field_str); solr_return_solr_params_object(); } /* }}} */ /* {{{ Expand Parameters */ /* {{{ proto SolrQuery SolrQuery::setExpand(bool value) Sets the expand parameter. This enables or disables group expanding. */ PHP_METHOD(SolrQuery, setExpand) { solr_char_t *param_name = (solr_char_t *) "expand"; COMPAT_ARG_SIZE_T param_name_len = sizeof("expand")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_len, bool_flag_str, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto bool SolrQuery::getExpand() Returns true if group expanding is enabled */ PHP_METHOD(SolrQuery, getExpand) { solr_char_t *param_name = (solr_char_t *) "expand"; COMPAT_ARG_SIZE_T param_name_len = sizeof("expand")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addExpandSortField(string sort[, integer direction]) Orders the documents within the expanded groups (expand.sort parameter). */ PHP_METHOD(SolrQuery, addExpandSortField) { solr_char_t *param_name = (solr_char_t *) "expand.sort"; COMPAT_ARG_SIZE_T param_name_len = sizeof("expand.sort")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; long int sort_direction = 1L; solr_sort_dir_t sort_order = SOLR_SORT_DIR_DESC; solr_char_t *avalue = NULL; COMPAT_ARG_SIZE_T avalue_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", ¶m_value, ¶m_value_len, &sort_direction) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } sort_order = (sort_direction < 0L || sort_direction > 1L) ? SOLR_SORT_DIR_DESC : (solr_sort_dir_t) sort_direction; avalue = (sort_order) ? "desc" : "asc"; avalue_length = solr_strlen(avalue); if (solr_add_arg_list_param(getThis(), param_name, param_name_len, param_value, param_value_len, avalue, avalue_length, ',', ' ' TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeExpandSortField(string field) Removes an expand sort field from the expand.sort parameter. */ PHP_METHOD(SolrQuery, removeExpandSortField) { solr_char_t *pname = (solr_char_t *) "expand.sort"; int pname_length = sizeof("expand.sort")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_arg_list_param_value(getThis(), pname, pname_length, param_value, param_value_len TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto string SolrQuery::getExpandSortFields() returns an array of fields */ PHP_METHOD(SolrQuery, getExpandSortFields) { solr_char_t *param_name = (solr_char_t *) "expand.sort"; COMPAT_ARG_SIZE_T param_name_len = sizeof("expand.sort")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_normal_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setExpandRows(int rows) Sets the number of rows to display in each group (expand.rows). Server Default 5 */ PHP_METHOD(SolrQuery, setExpandRows) { solr_char_t *param_name = (solr_char_t *) "expand.rows"; COMPAT_ARG_SIZE_T param_name_len = sizeof("expand.rows")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto int SolrQuery::getExpandRows() Returns The number of rows to display in each group (expand.rows) */ PHP_METHOD(SolrQuery, getExpandRows) { solr_char_t *param_name = (solr_char_t *) "expand.rows"; COMPAT_ARG_SIZE_T param_name_len = sizeof("expand.rows")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setExpandQuery(string q) Sets the expand.q parameter. Overrides the main q parameter, determines which documents to include in the main group. */ PHP_METHOD(SolrQuery, setExpandQuery) { solr_char_t *param_name = (solr_char_t *) "expand.q"; COMPAT_ARG_SIZE_T param_name_len = sizeof("expand.q")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto string SolrQuery::getExpandQuery() Returns the expand query expand.q parameter */ PHP_METHOD(SolrQuery, getExpandQuery) { solr_char_t *param_name = (solr_char_t *) "expand.q"; COMPAT_ARG_SIZE_T param_name_len = sizeof("expand.q")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_string(solr_param, return_value); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addExpandFilterQuery(string fq) Overrides main fq's, determines which documents to include in the main group. */ PHP_METHOD(SolrQuery, addExpandFilterQuery) { solr_char_t *param_name = (solr_char_t *) "expand.fq"; COMPAT_ARG_SIZE_T param_name_len = sizeof("expand.fq")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeExpandFilterQuery(string fq) Removes an expand filter query. */ PHP_METHOD(SolrQuery, removeExpandFilterQuery) { solr_char_t *pname = (solr_char_t *) "expand.fq"; int pname_length = sizeof("expand.fq")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_normal_param_value(getThis(), pname, pname_length, param_value, param_value_len TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto array SolrQuery::getExpandFilterQueries() Returns the expand filter queries */ PHP_METHOD(SolrQuery, getExpandFilterQueries) { solr_char_t *param_name = (solr_char_t *) "expand.fq"; COMPAT_ARG_SIZE_T param_name_len = sizeof("expand.fq")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_normal_param_value_display(solr_param, return_value); } /* }}} */ /* }}} */ /* {{{ HighlightingParameters */ /* {{{ proto SolrQuery SolrQuery::setHighlight(bool value) Sets the hl parameter. This enables or disables highlighting. */ PHP_METHOD(SolrQuery, setHighlight) { solr_char_t *param_name = (solr_char_t *) "hl"; COMPAT_ARG_SIZE_T param_name_len = sizeof("hl")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_len, bool_flag_str, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addHighlightField(string value) Adds another hl.fl parameter. */ PHP_METHOD(SolrQuery, addHighlightField) { solr_char_t *list_param_name = (solr_char_t *) "hl.fl"; COMPAT_ARG_SIZE_T list_param_name_len = sizeof("hl.fl")-1; solr_char_t *list_param_value = NULL; COMPAT_ARG_SIZE_T list_param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &list_param_value, &list_param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_simple_list_param(getThis(), list_param_name, list_param_name_len, list_param_value, list_param_value_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add param value %s to %s list ", list_param_value, list_param_name); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightSnippets(string value [, string field_override]) Sets the hl.snippets parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setHighlightSnippets) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "hl.snippets"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightFragsize(string value [, string field_override]) Sets the hl.fragsize parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setHighlightFragsize) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "hl.fragsize"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightMergeContiguous(bool flag [, string field_override]) Sets the hl.mergeContiguous parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setHighlightMergeContiguous) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Parameter value */ solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; zend_bool bool_flag = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b|s", &bool_flag, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "hl.mergeContiguous"); param_value = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(param_value); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightRequireFieldMatch(bool flag) Sets the hl.requireFieldMatch. */ PHP_METHOD(SolrQuery, setHighlightRequireFieldMatch) { solr_char_t *param_name = (solr_char_t *) "hl.requireFieldMatch"; COMPAT_ARG_SIZE_T param_name_len = sizeof("hl.requireFieldMatch")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_len, bool_flag_str, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightMaxAnalyzedChars(string value) Sets the hl.maxAnalyzedChars parameter */ PHP_METHOD(SolrQuery, setHighlightMaxAnalyzedChars) { solr_char_t *param_name = (solr_char_t *) "hl.maxAnalyzedChars"; COMPAT_ARG_SIZE_T param_name_len = sizeof("hl.maxAnalyzedChars")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightAlternateField(string value [, string field_override]) Sets the hl.alternateField parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setHighlightAlternateField) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "hl.alternateField"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightMaxAlternateFieldLength(string value [, string field_override]) Sets the hl.maxAlternateFieldLength parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setHighlightMaxAlternateFieldLength) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "hl.maxAlternateFieldLength"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightFormatter(string value [, string field_override]) Sets the hl.formatter parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setHighlightFormatter) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = "simple"; COMPAT_ARG_SIZE_T param_value_len = sizeof("simple")-1; /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "hl.formatter"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightSimplePre(string value [, string field_override]) Sets the hl.simple.pre parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setHighlightSimplePre) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = ""; COMPAT_ARG_SIZE_T param_value_len = sizeof("")-1; /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "hl.simple.pre"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightSimplePost(string value [, string field_override]) Sets the hl.simple.post parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setHighlightSimplePost) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = ""; COMPAT_ARG_SIZE_T param_value_len = sizeof("")-1; /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "hl.simple.post"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightFragmenter(string value [, string field_override]) Sets the hl.fragmenter parameter. Accepts an optional field override. */ PHP_METHOD(SolrQuery, setHighlightFragmenter) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "hl.fragmenter"); if (solr_set_normal_param(getThis(), fbuf.str, fbuf.len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", fbuf.str, param_value); solr_string_free(&fbuf); RETURN_NULL(); } solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightUsePhraseHighlighter(bool flag) Sets the hl.usePhraseHighlighter parameter. */ PHP_METHOD(SolrQuery, setHighlightUsePhraseHighlighter) { solr_char_t *param_name = (solr_char_t *) "hl.usePhraseHighlighter"; COMPAT_ARG_SIZE_T param_name_len = sizeof("hl.usePhraseHighlighter")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_len, bool_flag_str, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightHighlightMultiTerm(bool flag) Sets the hl.highlightMultiTerm parameter. */ PHP_METHOD(SolrQuery, setHighlightHighlightMultiTerm) { solr_char_t *param_name = (solr_char_t *) "hl.highlightMultiTerm"; COMPAT_ARG_SIZE_T param_name_len = sizeof("hl.highlightMultiTerm")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_len, bool_flag_str, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightRegexSlop(string value) Sets the hl.regex.slop parameter. */ PHP_METHOD(SolrQuery, setHighlightRegexSlop) { solr_char_t *param_name = (solr_char_t *) "hl.regex.slop"; COMPAT_ARG_SIZE_T param_name_len = sizeof("hl.regex.slop")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightRegexPattern(string value) Sets the hl.regex.pattern parameter. */ PHP_METHOD(SolrQuery, setHighlightRegexPattern) { solr_char_t *param_name = (solr_char_t *) "hl.regex.pattern"; COMPAT_ARG_SIZE_T param_name_len = sizeof("hl.regex.pattern")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setHighlightRegexMaxAnalyzedChars(string value) Sets the hl.regex.maxAnalyzedChars parameter. */ PHP_METHOD(SolrQuery, setHighlightRegexMaxAnalyzedChars) { solr_char_t *param_name = (solr_char_t *) "hl.regex.maxAnalyzedChars"; COMPAT_ARG_SIZE_T param_name_len = sizeof("hl.regex.maxAnalyzedChars")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* }}} End of HighlightingParameters */ /* {{{ StatsComponent */ /* {{{ proto SolrQuery SolrQuery::setStats(bool flag) Sets the stats parameter. Enables or disables stats */ PHP_METHOD(SolrQuery, setStats) { solr_char_t *param_name = (solr_char_t *) "stats"; COMPAT_ARG_SIZE_T param_name_len = sizeof("stats")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_len, bool_flag_str, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addStatsField(string value) Adds another stats.field parameter. */ PHP_METHOD(SolrQuery, addStatsField) { solr_char_t *param_name = (solr_char_t *) "stats.field"; COMPAT_ARG_SIZE_T param_name_len = sizeof("stats.field")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error adding parameter %s=%s ", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addStatsFacet(string value) Adds another stats.facet parameter. */ PHP_METHOD(SolrQuery, addStatsFacet) { solr_char_t *param_name = (solr_char_t *) "stats.facet"; COMPAT_ARG_SIZE_T param_name_len = sizeof("stats.facet")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error adding parameter %s=%s ", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* }}} End of StatsComponent */ /* {{{ MoreLikeThis */ /* {{{ proto SolrQuery SolrQuery::setMlt(bool flag) Sets the mlt parameter. Enables or disables the moreLikeThis component */ PHP_METHOD(SolrQuery, setMlt) { solr_char_t *param_name = (solr_char_t *) "mlt"; COMPAT_ARG_SIZE_T param_name_len = sizeof("mlt")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_len, bool_flag_str, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setMltCount(string value) Sets the mlt.count parameter. */ PHP_METHOD(SolrQuery, setMltCount) { solr_char_t *param_name = (solr_char_t *) "mlt.count"; COMPAT_ARG_SIZE_T param_name_len = sizeof("mlt.count")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addMltField(string field) Adds another field name to the mlt.fl parameter. */ PHP_METHOD(SolrQuery, addMltField) { solr_char_t *list_param_name = (solr_char_t *) "mlt.fl"; COMPAT_ARG_SIZE_T list_param_name_len = sizeof("mlt.fl")-1; solr_char_t *list_param_value = NULL; COMPAT_ARG_SIZE_T list_param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &list_param_value, &list_param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_simple_list_param(getThis(), list_param_name, list_param_name_len, list_param_value, list_param_value_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add param value %s to %s list ", list_param_value, list_param_name); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::addMltQueryField(string value, string boost) Adds another query field and boost value to the mlt.qf parameter. */ PHP_METHOD(SolrQuery, addMltQueryField) { solr_char_t *param_name = (solr_char_t *) "mlt.qf"; COMPAT_ARG_SIZE_T param_name_len = sizeof("mlt.qf")-1; solr_char_t *query_field = NULL; COMPAT_ARG_SIZE_T query_field_length = 0; solr_char_t *boost_value = "1.0"; COMPAT_ARG_SIZE_T boost_value_length = sizeof("1.0"); /* TODO: make boost optional parameter. */ /* If boost is not sent, then the index time boost is used */ /* This will involve re-doing all the arg_list functions to allow optional args. */ /* Temporary solution is to use SolrQuery::add("mlt.qf", "value"). This should be documented. */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &query_field, &query_field_length, &boost_value, &boost_value_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_add_arg_list_param(getThis(), param_name, param_name_len, query_field, query_field_length, boost_value, boost_value_length, ' ', '^' TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setMltMinTermFrequency(string value) Sets the mlt.mintf parameter. */ PHP_METHOD(SolrQuery, setMltMinTermFrequency) { solr_char_t *param_name = (solr_char_t *) "mlt.mintf"; COMPAT_ARG_SIZE_T param_name_len = sizeof("mlt.mintf")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setMltMinDocFrequency(string value) Sets the mlt.mindf parameter. */ PHP_METHOD(SolrQuery, setMltMinDocFrequency) { solr_char_t *param_name = (solr_char_t *) "mlt.mindf"; COMPAT_ARG_SIZE_T param_name_len = sizeof("mlt.mindf")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setMltMinWordLength(string value) Sets the mlt.minwl parameter. */ PHP_METHOD(SolrQuery, setMltMinWordLength) { solr_char_t *param_name = (solr_char_t *) "mlt.minwl"; COMPAT_ARG_SIZE_T param_name_len = sizeof("mlt.minwl")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setMltMaxWordLength(string value) Sets the mlt.maxwl parameter. */ PHP_METHOD(SolrQuery, setMltMaxWordLength) { solr_char_t *param_name = (solr_char_t *) "mlt.maxwl"; COMPAT_ARG_SIZE_T param_name_len = sizeof("mlt.maxwl")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setMltMaxNumTokens(string value) Sets the mlt.maxntp parameter. */ PHP_METHOD(SolrQuery, setMltMaxNumTokens) { solr_char_t *param_name = (solr_char_t *) "mlt.maxntp"; COMPAT_ARG_SIZE_T param_name_len = sizeof("mlt.maxntp")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setMltMaxNumQueryTerms(string value) Sets the mlt.maxqt parameter. */ PHP_METHOD(SolrQuery, setMltMaxNumQueryTerms) { solr_char_t *param_name = (solr_char_t *) "mlt.maxqt"; COMPAT_ARG_SIZE_T param_name_len = sizeof("mlt.maxqt")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setMltBoost(bool flag) Sets the mlt.boost parameter. */ PHP_METHOD(SolrQuery, setMltBoost) { solr_char_t *param_name = (solr_char_t *) "mlt.boost"; COMPAT_ARG_SIZE_T param_name_len = sizeof("mlt.boost")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_len, bool_flag_str, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* }}} End of MoreLikeThis */ /* {{{ TermsComponent */ /* {{{ proto SolrQuery SolrQuery::setTerms(bool flag) Sets the terms parameter. This flag enables or disables the TermsComponent */ PHP_METHOD(SolrQuery, setTerms) { solr_char_t *param_name = (solr_char_t *) "terms"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_len, bool_flag_str, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTermsField(string field) Sets the terms.fl parameter. */ PHP_METHOD(SolrQuery, setTermsField) { solr_char_t *param_name = (solr_char_t *) "terms.fl"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms.fl")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTermsLowerBound(string value) Sets the terms.lower parameter. */ PHP_METHOD(SolrQuery, setTermsLowerBound) { solr_char_t *param_name = (solr_char_t *) "terms.lower"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms.lower")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTermsUpperBound(string value) Sets the terms.upper parameter. */ PHP_METHOD(SolrQuery, setTermsUpperBound) { solr_char_t *param_name = (solr_char_t *) "terms.upper"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms.upper")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTermsIncludeLowerBound(string value) Sets the terms.lower.incl parameter. */ PHP_METHOD(SolrQuery, setTermsIncludeLowerBound) { solr_char_t *param_name = (solr_char_t *) "terms.lower.incl"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms.lower.incl")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_len, bool_flag_str, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTermsIncludeUpperBound(string value) Sets the terms.upper.incl parameter. */ PHP_METHOD(SolrQuery, setTermsIncludeUpperBound) { solr_char_t *param_name = (solr_char_t *) "terms.upper.incl"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms.upper.incl")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_len, bool_flag_str, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTermsMinCount(string value) Sets the terms.mincount parameter. */ PHP_METHOD(SolrQuery, setTermsMinCount) { solr_char_t *param_name = (solr_char_t *) "terms.mincount"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms.mincount")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTermsMaxCount(string value) Sets the terms.maxcount parameter. */ PHP_METHOD(SolrQuery, setTermsMaxCount) { solr_char_t *param_name = (solr_char_t *) "terms.maxcount"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms.maxcount")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTermsPrefix(string value) Sets the terms.prefix parameter. */ PHP_METHOD(SolrQuery, setTermsPrefix) { solr_char_t *param_name = (solr_char_t *) "terms.prefix"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms.prefix")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTermsLimit(string value) Sets the terms.limit parameter. */ PHP_METHOD(SolrQuery, setTermsLimit) { solr_char_t *param_name = (solr_char_t *) "terms.limit"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms.limit")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if (solr_set_normal_param(getThis(), param_name, param_name_len, param_value, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s", param_name, param_value); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTermsReturnRaw(bool flag) Sets the terms.raw parameter. */ PHP_METHOD(SolrQuery, setTermsReturnRaw) { solr_char_t *param_name = (solr_char_t *) "terms.raw"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms.raw")-1; zend_bool bool_flag = 0; solr_char_t *bool_flag_str = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bool_flag) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } bool_flag_str = ((bool_flag)? "true" : "false"); param_value_len = solr_strlen(bool_flag_str); if (solr_set_normal_param(getThis(), param_name, param_name_len, bool_flag_str, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, bool_flag_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::setTermsSort(int sort) Sets the terms.sort parameter. */ PHP_METHOD(SolrQuery, setTermsSort) { solr_char_t *param_name = (solr_char_t *) "terms.sort"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms.sort")-1; long int sort_type = 0L; solr_char_t *sort_type_str = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &sort_type) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter"); RETURN_NULL(); } sort_type_str = ((sort_type)? "count" : "index"); param_value_len = solr_strlen(sort_type_str); if (solr_set_normal_param(getThis(), param_name, param_name_len, sort_type_str, param_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error setting parameter %s=%s ", param_name, sort_type_str); RETURN_NULL(); } solr_return_solr_params_object(); } /* }}} */ /* }}} End of TermsComponent */ /* {{{ Value removal methods */ /* {{{ proto SolrQuery SolrQuery::removeField(string fl) Removes a field from the fl parameter */ PHP_METHOD(SolrQuery, removeField) { solr_char_t *pname = (solr_char_t *) "fl"; int pname_length = sizeof("fl")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_simple_list_param_value(getThis(), pname, pname_length, param_value, param_value_len TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeSortField(string fl) Removes a sort field from the sort parameter. */ PHP_METHOD(SolrQuery, removeSortField) { solr_char_t *pname = (solr_char_t *) "sort"; int pname_length = sizeof("sort")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_arg_list_param_value(getThis(), pname, pname_length, param_value, param_value_len TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeFilterQuery(string fq) Removes one of the fq parameter. */ PHP_METHOD(SolrQuery, removeFilterQuery) { solr_char_t *pname = (solr_char_t *) "fq"; int pname_length = sizeof("fq")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_normal_param_value(getThis(), pname, pname_length, param_value, param_value_len TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeFacetField(string field) Removes one of fields from the facet.field parameter. */ PHP_METHOD(SolrQuery, removeFacetField) { solr_char_t *pname = (solr_char_t *) "facet.field"; int pname_length = sizeof("facet.field")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_normal_param_value(getThis(), pname, pname_length, param_value, param_value_len TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeFacetQuery(string facet_query) Removes one of the facet.query parameters. */ PHP_METHOD(SolrQuery, removeFacetQuery) { solr_char_t *pname = (solr_char_t *) "facet.query"; int pname_length = sizeof("facet.query")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_normal_param_value(getThis(), pname, pname_length, param_value, param_value_len TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeFacetDateField(string date_field) Removes one of the facet.date parameters. */ PHP_METHOD(SolrQuery, removeFacetDateField) { solr_char_t *pname = (solr_char_t *) "facet.date"; int pname_length = sizeof("facet.date")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_normal_param_value(getThis(), pname, pname_length, param_value, param_value_len TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeFacetDateOther(string value [, string field_override]) Removes one of the facet.date.other parameters. Also accepts an optional field override. */ PHP_METHOD(SolrQuery, removeFacetDateOther) { solr_string_t fbuf; /* Field name buffer to prepare field override */ /* Parameter value */ solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; /* Field name override,f if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; memset(&fbuf, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¶m_value, ¶m_value_len, &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&fbuf, field_name, field_name_len, "facet.date.other"); solr_delete_normal_param_value(getThis(), fbuf.str, fbuf.len, param_value, param_value_len TSRMLS_CC); solr_string_free(&fbuf); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeHighlightField(string field) Removes one of the fields from the hl.fl parameter. */ PHP_METHOD(SolrQuery, removeHighlightField) { solr_char_t *pname = (solr_char_t *) "hl.fl"; int pname_length = sizeof("hl.fl")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_simple_list_param_value(getThis(), pname, pname_length, param_value, param_value_len TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeStatsField(string field) Removes one of the stats.field parameters. */ PHP_METHOD(SolrQuery, removeStatsField) { solr_char_t *pname = (solr_char_t *) "stats.field"; int pname_length = sizeof("stats.field")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_normal_param_value(getThis(), pname, pname_length, param_value, param_value_len TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeStatsFacet(string value) Removes one of the stats.facet parameters. */ PHP_METHOD(SolrQuery, removeStatsFacet) { solr_char_t *pname = (solr_char_t *) "stats.facet"; int pname_length = sizeof("stats.facet")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_normal_param_value(getThis(), pname, pname_length, param_value, param_value_len TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeMltField(string field) Removes one of the fields from the mlt.fl parameter. */ PHP_METHOD(SolrQuery, removeMltField) { solr_char_t *pname = (solr_char_t *) "mlt.fl"; int pname_length = sizeof("mlt.fl")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_simple_list_param_value(getThis(), pname, pname_length, param_value, param_value_len TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* {{{ proto SolrQuery SolrQuery::removeMltQueryField(string field) Removes one of the values from the mlt.qf parameter. */ PHP_METHOD(SolrQuery, removeMltQueryField) { solr_char_t *pname = (solr_char_t *) "mlt.qf"; int pname_length = sizeof("mlt.qf")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_arg_list_param_value(getThis(), pname, pname_length, param_value, param_value_len TSRMLS_CC); solr_return_solr_params_object(); } /* }}} */ /* }}} End of Value removal methods */ /* {{{ Begin getter methods */ /* {{{ proto string SolrQuery::getQuery() Returns the query */ PHP_METHOD(SolrQuery, getQuery) { solr_char_t *param_name = (solr_char_t *) "q"; COMPAT_ARG_SIZE_T param_name_len = sizeof("q")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_string(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getStart() Returns the start parameter */ PHP_METHOD(SolrQuery, getStart) { solr_char_t *param_name = (solr_char_t *) "start"; COMPAT_ARG_SIZE_T param_name_len = sizeof("start")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getRows() Returns the rows parameter */ PHP_METHOD(SolrQuery, getRows) { solr_char_t *param_name = (solr_char_t *) "rows"; COMPAT_ARG_SIZE_T param_name_len = sizeof("rows")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto array SolrQuery::getFields() Returns the fields */ PHP_METHOD(SolrQuery, getFields) { solr_char_t *param_name = (solr_char_t *) "fl"; COMPAT_ARG_SIZE_T param_name_len = sizeof("fl")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_simple_list_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto array SolrQuery::getSortFields() Returns all the sort fields */ PHP_METHOD(SolrQuery, getSortFields) { solr_char_t *param_name = (solr_char_t *) "sort"; COMPAT_ARG_SIZE_T param_name_len = sizeof("sort")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_arg_list_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getFilterQueries() Returns all the filter queries */ PHP_METHOD(SolrQuery, getFilterQueries) { solr_char_t *param_name = (solr_char_t *) "fq"; COMPAT_ARG_SIZE_T param_name_len = sizeof("fq")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_normal_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getTimeAllowed() Returns the maximum time in milliseconds allowed for the search query */ PHP_METHOD(SolrQuery, getTimeAllowed) { solr_char_t *param_name = (solr_char_t *) "timeAllowed"; COMPAT_ARG_SIZE_T param_name_len = sizeof("timeAllowed")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto bool SolrQuery::getFacet() Returns true is faceting is enabled */ PHP_METHOD(SolrQuery, getFacet) { solr_char_t *param_name = (solr_char_t *) "facet"; COMPAT_ARG_SIZE_T param_name_len = sizeof("facet")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getFacetFields() Returns all the facet fields */ PHP_METHOD(SolrQuery, getFacetFields) { solr_char_t *param_name = (solr_char_t *) "facet.field"; COMPAT_ARG_SIZE_T param_name_len = sizeof("facet.field")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_normal_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getFacetQueries() Returns all the facet queries */ PHP_METHOD(SolrQuery, getFacetQueries) { solr_char_t *param_name = (solr_char_t *) "facet.query"; COMPAT_ARG_SIZE_T param_name_len = sizeof("facet.query")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_normal_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getFacetPrefix([string field_override]) Returns the prefix for the facet */ PHP_METHOD(SolrQuery, getFacetPrefix) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.prefix"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_string(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto int SolrQuery::getFacetSort([string field_override]) Returns the facet sort state (for the field, if it was overridden) */ PHP_METHOD(SolrQuery, getFacetSort) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.sort"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_sort_type(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto int SolrQuery::getFacetLimit([string field_override]) Returns the maximum number of items for the facet */ PHP_METHOD(SolrQuery, getFacetLimit) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.limit"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_integer(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto int SolrQuery::getFacetOffset([string field_override]) Returns the offset into the list of constraints */ PHP_METHOD(SolrQuery, getFacetOffset) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.offset"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_integer(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto int SolrQuery::getFacetMinCount([string field_override]) Returns the minimum count for the facet */ PHP_METHOD(SolrQuery, getFacetMinCount) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.mincount"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_integer(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto bool SolrQuery::getFacetMissing([string field_override]) Returns the facet.missing parameter */ PHP_METHOD(SolrQuery, getFacetMissing) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.missing"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_boolean(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrQuery::getFacetMethod([string field_override]) Returns the facet.method parameter */ PHP_METHOD(SolrQuery, getFacetMethod) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.method"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_string(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto array SolrQuery::getFacetDateFields() Returns all the facet.date fields */ PHP_METHOD(SolrQuery, getFacetDateFields) { solr_char_t *param_name = (solr_char_t *) "facet.date"; COMPAT_ARG_SIZE_T param_name_len = sizeof("facet.date")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_normal_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getFacetDateStart([string field_override]) Returns the facet.date.start parameter */ PHP_METHOD(SolrQuery, getFacetDateStart) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.date.start"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_string(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrQuery::getFacetDateEnd([string field_override]) Returns the facet.date.end parameter */ PHP_METHOD(SolrQuery, getFacetDateEnd) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.date.end"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_string(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrQuery::getFacetDateGap([string field_override]) Returns the facet.date.gap */ PHP_METHOD(SolrQuery, getFacetDateGap) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.date.gap"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_string(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto bool SolrQuery::getFacetDateHardEnd([string field_override]) Returns the facet.date.hardend parameter */ PHP_METHOD(SolrQuery, getFacetDateHardEnd) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.date.hardend"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_boolean(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrQuery::getFacetDateOther([string field_override]) Returns the facet.date.other parameter */ PHP_METHOD(SolrQuery, getFacetDateOther) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "facet.date.other"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { array_init(return_value); solr_normal_param_value_display(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto bool SolrQuery::getHighlight() Returns the state of the hl parameter */ PHP_METHOD(SolrQuery, getHighlight) { solr_char_t *param_name = (solr_char_t *) "hl"; COMPAT_ARG_SIZE_T param_name_len = sizeof("hl")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto array SolrQuery::getHighlightFields() Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightFields) { solr_char_t *param_name = (solr_char_t *) "hl.fl"; COMPAT_ARG_SIZE_T param_name_len = sizeof("hl.fl")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_simple_list_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getHighlightSnippets([string field_override]) Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightSnippets) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "hl.snippets"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_integer(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto int SolrQuery::getHighlightFragsize([string field_override]) Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightFragsize) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "hl.fragsize"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_integer(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto bool SolrQuery::getHighlightMergeContiguous([string field_override]) Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightMergeContiguous) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "hl.mergeContiguous"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_boolean(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto bool SolrQuery::getHighlightRequireFieldMatch() Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightRequireFieldMatch) { solr_char_t *param_name = (solr_char_t *) "hl.requireFieldMatch"; COMPAT_ARG_SIZE_T param_name_len = sizeof("hl.requireFieldMatch")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getHighlightMaxAnalyzedChars() Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightMaxAnalyzedChars) { solr_char_t *param_name = (solr_char_t *) "hl.maxAnalyzedChars"; COMPAT_ARG_SIZE_T param_name_len = sizeof("hl.maxAnalyzedChars")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getHighlightAlternateField([string field_override]) Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightAlternateField) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "hl.alternateField"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_string(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto int SolrQuery::getHighlightMaxAlternateFieldLength([string field_override]) Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightMaxAlternateFieldLength) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "hl.maxAlternateFieldLength"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_integer(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrQuery::getHighlightFormatter([string field_override]) Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightFormatter) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "hl.formatter"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_string(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrQuery::getHighlightSimplePre([string field_override]) Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightSimplePre) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "hl.simple.pre"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_string(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrQuery::getHighlightSimplePost([string field_override]) Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightSimplePost) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "hl.simple.post"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_string(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrQuery::getHighlightFragmenter([string field_override]) Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightFragmenter) { solr_param_t *solr_param = NULL; solr_string_t field_override_buffer; /* Field name buffer to prepare field override */ /* Field name override, if any */ solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; /* Set if the parameter was found in the HashTable and off otherwise */ zend_bool param_is_set = 1; memset(&field_override_buffer, 0, sizeof(solr_string_t)); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_query_field_override(&field_override_buffer, field_name, field_name_len, "hl.fragmenter"); if (solr_param_find(getThis(), field_override_buffer.str, field_override_buffer.len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { param_is_set = 0; } solr_string_free(&field_override_buffer); if (param_is_set) { solr_normal_param_value_display_string(solr_param, return_value); return; } RETURN_NULL(); } /* }}} */ /* {{{ proto bool SolrQuery::getHighlightUsePhraseHighlighter() Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightUsePhraseHighlighter) { solr_char_t *param_name = (solr_char_t *) "hl.usePhraseHighlighter"; COMPAT_ARG_SIZE_T param_name_len = sizeof("hl.usePhraseHighlighter")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto bool SolrQuery::getHighlightHighlightMultiTerm() Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightHighlightMultiTerm) { solr_char_t *param_name = (solr_char_t *) "hl.highlightMultiTerm"; COMPAT_ARG_SIZE_T param_name_len = sizeof("hl.highlightMultiTerm")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto float SolrQuery::getHighlightRegexSlop() Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightRegexSlop) { solr_char_t *param_name = (solr_char_t *) "hl.regex.slop"; COMPAT_ARG_SIZE_T param_name_len = sizeof("hl.regex.slop")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_double(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getHighlightRegexPattern() Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightRegexPattern) { solr_char_t *param_name = (solr_char_t *) "hl.regex.pattern"; COMPAT_ARG_SIZE_T param_name_len = sizeof("hl.regex.pattern")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_string(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getHighlightRegexMaxAnalyzedChars() Returns the parameter */ PHP_METHOD(SolrQuery, getHighlightRegexMaxAnalyzedChars) { solr_char_t *param_name = (solr_char_t *) "hl.regex.maxAnalyzedChars"; COMPAT_ARG_SIZE_T param_name_len = sizeof("hl.regex.maxAnalyzedChars")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto bool SolrQuery::getStats() Returns the status of the stats parameter */ PHP_METHOD(SolrQuery, getStats) { solr_char_t *param_name = (solr_char_t *) "stats"; COMPAT_ARG_SIZE_T param_name_len = sizeof("stats")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto array SolrQuery::getStatsFields() Returns the stats.field parameters */ PHP_METHOD(SolrQuery, getStatsFields) { solr_char_t *param_name = (solr_char_t *) "stats.field"; COMPAT_ARG_SIZE_T param_name_len = sizeof("stats.field")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_normal_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getStatsFacets() Returns all the stats facets */ PHP_METHOD(SolrQuery, getStatsFacets) { solr_char_t *param_name = (solr_char_t *) "stats.facet"; COMPAT_ARG_SIZE_T param_name_len = sizeof("stats.facet")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_normal_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto bool SolrQuery::getMlt() Returns the parameter */ PHP_METHOD(SolrQuery, getMlt) { solr_char_t *param_name = (solr_char_t *) "mlt"; COMPAT_ARG_SIZE_T param_name_len = sizeof("mlt")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getMltCount() Returns the parameter */ PHP_METHOD(SolrQuery, getMltCount) { solr_char_t *param_name = (solr_char_t *) "mlt.count"; COMPAT_ARG_SIZE_T param_name_len = sizeof("mlt.count")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto array SolrQuery::getMltFields() Returns the parameter */ PHP_METHOD(SolrQuery, getMltFields) { solr_char_t *param_name = (solr_char_t *) "mlt.fl"; COMPAT_ARG_SIZE_T param_name_len = sizeof("mlt.fl")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_simple_list_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto array SolrQuery::getMltQueryFields() Returns the parameter */ PHP_METHOD(SolrQuery, getMltQueryFields) { solr_char_t *param_name = (solr_char_t *) "mlt.qf"; COMPAT_ARG_SIZE_T param_name_len = sizeof("mlt.qf")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } array_init(return_value); solr_arg_list_param_value_display(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getMltMinTermFrequency() Returns the parameter */ PHP_METHOD(SolrQuery, getMltMinTermFrequency) { solr_char_t *param_name = (solr_char_t *) "mlt.mintf"; COMPAT_ARG_SIZE_T param_name_len = sizeof("mlt.mintf")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getMltMinDocFrequency() Returns the parameter */ PHP_METHOD(SolrQuery, getMltMinDocFrequency) { solr_char_t *param_name = (solr_char_t *) "mlt.mindf"; COMPAT_ARG_SIZE_T param_name_len = sizeof("mlt.mindf")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getMltMinWordLength() Returns the parameter */ PHP_METHOD(SolrQuery, getMltMinWordLength) { solr_char_t *param_name = (solr_char_t *) "mlt.minwl"; COMPAT_ARG_SIZE_T param_name_len = sizeof("mlt.minwl")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getMltMaxWordLength() Returns the parameter */ PHP_METHOD(SolrQuery, getMltMaxWordLength) { solr_char_t *param_name = (solr_char_t *) "mlt.maxwl"; COMPAT_ARG_SIZE_T param_name_len = sizeof("mlt.maxwl")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getMltMaxNumTokens() Returns the parameter */ PHP_METHOD(SolrQuery, getMltMaxNumTokens) { solr_char_t *param_name = (solr_char_t *) "mlt.maxntp"; COMPAT_ARG_SIZE_T param_name_len = sizeof("mlt.maxntp")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getMltMaxNumQueryTerms() Returns the parameter */ PHP_METHOD(SolrQuery, getMltMaxNumQueryTerms) { solr_char_t *param_name = (solr_char_t *) "mlt.maxqt"; COMPAT_ARG_SIZE_T param_name_len = sizeof("mlt.maxqt")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto bool SolrQuery::getMltBoost() Returns the parameter */ PHP_METHOD(SolrQuery, getMltBoost) { solr_char_t *param_name = (solr_char_t *) "mlt.boost"; COMPAT_ARG_SIZE_T param_name_len = sizeof("mlt.boost")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto bool SolrQuery::getTerms() Returns the parameter */ PHP_METHOD(SolrQuery, getTerms) { solr_char_t *param_name = (solr_char_t *) "terms"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getTermsField() Returns the parameter */ PHP_METHOD(SolrQuery, getTermsField) { solr_char_t *param_name = (solr_char_t *) "terms.fl"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms.fl")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_string(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getTermsLowerBound() Returns the parameter */ PHP_METHOD(SolrQuery, getTermsLowerBound) { solr_char_t *param_name = (solr_char_t *) "terms.lower"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms.lower")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_string(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getTermsUpperBound() Returns the parameter */ PHP_METHOD(SolrQuery, getTermsUpperBound) { solr_char_t *param_name = (solr_char_t *) "terms.upper"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms.upper")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_string(solr_param, return_value); } /* }}} */ /* {{{ proto bool SolrQuery::getTermsIncludeLowerBound() Returns the parameter */ PHP_METHOD(SolrQuery, getTermsIncludeLowerBound) { solr_char_t *param_name = (solr_char_t *) "terms.lower.incl"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms.lower.incl")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto bool SolrQuery::getTermsIncludeUpperBound() Returns the parameter */ PHP_METHOD(SolrQuery, getTermsIncludeUpperBound) { solr_char_t *param_name = (solr_char_t *) "terms.upper.incl"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms.upper.incl")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getTermsMinCount() Returns the parameter */ PHP_METHOD(SolrQuery, getTermsMinCount) { solr_char_t *param_name = (solr_char_t *) "terms.mincount"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms.mincount")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getTermsMaxCount() Returns the parameter */ PHP_METHOD(SolrQuery, getTermsMaxCount) { solr_char_t *param_name = (solr_char_t *) "terms.maxcount"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms.maxcount")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto string SolrQuery::getTermsPrefix() Returns the parameter */ PHP_METHOD(SolrQuery, getTermsPrefix) { solr_char_t *param_name = (solr_char_t *) "terms.prefix"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms.prefix")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_string(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getTermsLimit() Returns the parameter */ PHP_METHOD(SolrQuery, getTermsLimit) { solr_char_t *param_name = (solr_char_t *) "terms.limit"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms.limit")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_integer(solr_param, return_value); } /* }}} */ /* {{{ proto bool SolrQuery::getTermsReturnRaw() Returns the parameter */ PHP_METHOD(SolrQuery, getTermsReturnRaw) { solr_char_t *param_name = (solr_char_t *) "terms.raw"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms.raw")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_boolean(solr_param, return_value); } /* }}} */ /* {{{ proto int SolrQuery::getTermsSort() Returns the parameter */ PHP_METHOD(SolrQuery, getTermsSort) { solr_char_t *param_name = (solr_char_t *) "terms.sort"; COMPAT_ARG_SIZE_T param_name_len = sizeof("terms.sort")-1; solr_param_t *solr_param = NULL; if (solr_param_find(getThis(), param_name, param_name_len, (solr_param_t **) &solr_param TSRMLS_CC) == FAILURE) { RETURN_NULL(); } solr_normal_param_value_display_sort_type(solr_param, return_value); } /* }}} */ /* }}} End of getter methods */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/php_solr_response.c0000644000175000017500000002706412676753707016564 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* {{{ Macro for extracting property values using string constants */ #define solr_read_response_object_property(objptr, name, silent, rv) zend_read_property(Z_OBJCE_P(objptr), objptr, name, sizeof(name)-1, silent, rv) /* }}} */ /* {{{ proto int SolrResponse::getHttpStatus(void) Returns the value of the http_status property. */ PHP_METHOD(SolrResponse, getHttpStatus) { zend_bool silent = 1; zval rv; zval *objptr = getThis(); zval *http_status = NULL; http_status = solr_read_response_object_property(objptr, "http_status", silent, &rv); RETURN_LONG(Z_LVAL_P(http_status)); } /* }}} */ /* {{{ proto string SolrResponse::getHttpStatusMessage(void) Returns the http_status_message property. */ PHP_METHOD(SolrResponse, getHttpStatusMessage) { zend_bool silent = 1; zval rv; zval *objptr = getThis(); zval *http_status_message = NULL; http_status_message = solr_read_response_object_property(objptr, "http_status_message", silent, &rv); RETURN_STRINGL(Z_STRVAL_P(http_status_message), Z_STRLEN_P(http_status_message)); } /* }}} */ /* {{{ proto bool SolrResponse::success(void) Returns whether the request was successful or not. */ PHP_METHOD(SolrResponse, success) { zend_bool silent = 1; zval rv; zval *objptr = getThis(); zval *success = NULL; success = solr_read_response_object_property(objptr, "success", silent, &rv); RETURN_ZVAL(success, 0, 0); } /* }}} */ /* {{{ proto string SolrResponse::getRequestUrl(void) Returns the URL used for the request. */ PHP_METHOD(SolrResponse, getRequestUrl) { zend_bool silent = 1; zval rv; zval *objptr = getThis(); zval *prop = NULL; prop = solr_read_response_object_property(objptr, "http_request_url", silent, &rv); RETURN_STRINGL(Z_STRVAL_P(prop), Z_STRLEN_P(prop)); } /* }}} */ /* {{{ proto string SolrResponse::getRawRequestHeaders(void) Returns the raw http request headers sent to the server. */ PHP_METHOD(SolrResponse, getRawRequestHeaders) { zend_bool silent = 1; zval rv; zval *objptr = getThis(); zval *prop = NULL; prop = solr_read_response_object_property(objptr, "http_raw_request_headers", silent, &rv); RETURN_STRINGL(Z_STRVAL_P(prop), Z_STRLEN_P(prop)); } /* }}} */ /* {{{ proto string SolrResponse::getRawRequest(void) Returns the raw http request sent to the server. */ PHP_METHOD(SolrResponse, getRawRequest) { zend_bool silent = 1; zval rv; zval *objptr = getThis(); zval *prop = NULL; prop = solr_read_response_object_property(objptr, "http_raw_request", silent, &rv); RETURN_STRINGL(Z_STRVAL_P(prop), Z_STRLEN_P(prop)); } /* }}} */ /* {{{ proto string SolrResponse::getRawResponseHeaders(void) Returns the raw http response headers from the server. */ PHP_METHOD(SolrResponse, getRawResponseHeaders) { zend_bool silent = 1; zval rv; zval *objptr = getThis(); zval *prop = NULL; prop = solr_read_response_object_property(objptr, "http_raw_response_headers", silent, &rv); RETURN_STRINGL(Z_STRVAL_P(prop), Z_STRLEN_P(prop)); } /* }}} */ /* {{{ proto string SolrResponse::getRawResponse(void) Returns the raw http response from the server. */ PHP_METHOD(SolrResponse, getRawResponse) { zend_bool silent = 1; zval rv; zval *objptr = getThis(); zval *prop = NULL; prop = solr_read_response_object_property(objptr, "http_raw_response", silent, &rv); if (Z_STRLEN_P(prop)) { RETURN_STRINGL(Z_STRVAL_P(prop), Z_STRLEN_P(prop)); } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrResponse::getDigestedResponse(void) Returns the serialized object string derived from the XML response. */ PHP_METHOD(SolrResponse, getDigestedResponse) { zend_bool silent = 0; zval rv; zval *objptr = getThis(); zval *prop = NULL; prop = solr_read_response_object_property(objptr, "http_digested_response", silent, &rv); if (Z_STRLEN_P(prop)) { RETURN_STRINGL(Z_STRVAL_P(prop), Z_STRLEN_P(prop)); } RETURN_NULL(); } /* }}} */ /* {{{ proto string SolrReponse::setParseMode([bool parse_mode]) Sets the parsing mode. This determines whether documents will be parsed as SolrObjects or SolrDocuments. */ PHP_METHOD(SolrResponse, setParseMode) { long int parse_mode = 0L; zval *objptr = getThis(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &parse_mode) == FAILURE) { RETURN_FALSE; } parse_mode = ((parse_mode < 0L) ? 0L : ((parse_mode > 1L) ? 1L : parse_mode)); zend_update_property_long(Z_OBJCE_P(objptr), objptr, "parser_mode", sizeof("parser_mode")-1, parse_mode TSRMLS_CC); RETURN_TRUE; } /* }}} */ /* {{{ proto SolrObject SolrResponse::getResponse(void) Returns the response object from the server. */ PHP_METHOD(SolrResponse, getResponse) { solr_response_get_response_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU,0); } /* }}} */ /* {{{ proto array SolrResponse::getArrayResponse(void) Returns the response array from the server. */ PHP_METHOD(SolrResponse, getArrayResponse) { solr_response_get_response_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU,1); } /* }}} */ /** * Digest solr server raw response * and return SolrObject or array */ PHP_SOLR_API void solr_response_get_response_impl( INTERNAL_FUNCTION_PARAMETERS, int return_array) { zend_bool silent = 0; zval *objptr = getThis(); zval rv; zval *response_writer = solr_read_response_object_property(objptr, "response_writer", silent, &rv); zval *raw_response = solr_read_response_object_property(objptr, "http_raw_response", silent, &rv); zval *success = solr_read_response_object_property(objptr, "success", silent, &rv); zval *parser_mode = solr_read_response_object_property(objptr, "parser_mode", silent, &rv); if (Z_TYPE_P(success) == IS_TRUE && Z_STRLEN_P(raw_response)) { solr_string_t buffer; php_unserialize_data_t var_hash; const unsigned char *raw_resp; size_t raw_res_length; const unsigned char *str_end; int successful = 1; memset(&buffer, 0, sizeof(solr_string_t)); if (Z_STRLEN_P(response_writer)) { if (0 == strcmp(Z_STRVAL_P(response_writer), SOLR_XML_RESPONSE_WRITER)) { /* SOLR_XML_RESPONSE_WRITER */ /* Convert from XML serialization to PHP serialization format */ solr_encode_generic_xml_response(&buffer, Z_STRVAL_P(raw_response), Z_STRLEN_P(raw_response), Z_LVAL_P(parser_mode) TSRMLS_CC); if(return_array) { solr_sobject_to_sarray(&buffer TSRMLS_CC); } } else if (0 == strcmp(Z_STRVAL_P(response_writer), SOLR_PHP_NATIVE_RESPONSE_WRITER) || 0 == strcmp(Z_STRVAL_P(response_writer), SOLR_PHP_SERIALIZED_RESPONSE_WRITER)) { /* SOLR_PHP_NATIVE_RESPONSE_WRITER */ /* Response string is already in Native PHP serialization format */ solr_string_set(&buffer, Z_STRVAL_P(raw_response), Z_STRLEN_P(raw_response)); if(!return_array) { solr_sarray_to_sobject(&buffer TSRMLS_CC); } } else if (0 == strcmp(Z_STRVAL_P(response_writer), SOLR_JSON_RESPONSE_WRITER)) { int json_translation_result = solr_json_to_php_native(&buffer, Z_STRVAL_P(raw_response), Z_STRLEN_P(raw_response) TSRMLS_CC); /* SOLR_JSON_RESPONSE_WRITER */ /* Convert from JSON serialization to PHP serialization format */ if (json_translation_result > 0) { solr_throw_exception_ex(solr_ce_SolrException, SOLR_ERROR_1000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, solr_get_json_error_msg(json_translation_result)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error in JSON->PHP conversion. JSON Error Code %d", json_translation_result); } if(!return_array) { solr_sarray_to_sobject(&buffer TSRMLS_CC); } } } if (buffer.len) { zend_update_property_stringl(Z_OBJCE_P(objptr), objptr, "http_digested_response", sizeof("http_digested_response")-1, buffer.str, buffer.len TSRMLS_CC); } memset(&var_hash, 0, sizeof(php_unserialize_data_t)); PHP_VAR_UNSERIALIZE_INIT(var_hash); raw_resp = (unsigned char *) buffer.str; raw_res_length = buffer.len; str_end = (unsigned char *) (raw_resp + raw_res_length); if (!php_var_unserialize(return_value, &raw_resp, str_end, &var_hash TSRMLS_CC)) { successful = 0; solr_throw_exception_ex(solr_ce_SolrException, SOLR_ERROR_1000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1000_MSG); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error unserializing raw response."); } PHP_VAR_UNSERIALIZE_DESTROY(var_hash); solr_string_free(&buffer); if (successful && !return_array) { /* Overriding the default object handlers */ Z_OBJ_HT_P(return_value) = &solr_object_handlers; } return ; } RETURN_NULL(); } /* {{{ proto string SolrPingResponse::getResponse(void) Ping responses are always empty. Returns null. */ PHP_METHOD(SolrPingResponse, getResponse) { /* Ping responses are not serialized */ RETURN_NULL(); } /* }}} */ /* {{{ proto SolrPingResponse::__construct(void) Constructor */ PHP_METHOD(SolrPingResponse, __construct) { } /* }}} */ /* {{{ proto SolrPingResponse::__destruct(void) Destructor */ PHP_METHOD(SolrPingResponse, __destruct) { } /* }}} */ /* {{{ proto SolrQueryResponse::__construct(void) Constructor */ PHP_METHOD(SolrQueryResponse, __construct) { } /* }}} */ /* {{{ proto SolrQueryResponse::__destruct(void) Destructor */ PHP_METHOD(SolrQueryResponse, __destruct) { } /* }}} */ /* {{{ proto SolrUpdateResponse::__construct(void) Constructor */ PHP_METHOD(SolrUpdateResponse, __construct) { } /* }}} */ /* {{{ proto SolrUpdateResponse::__destruct(void) Destructor */ PHP_METHOD(SolrUpdateResponse, __destruct) { } /* }}} */ /* {{{ proto SolrGenericResponse::__construct(void) Constructor */ PHP_METHOD(SolrGenericResponse, __construct) { } /* }}} */ /* {{{ proto SolrGenericResponse::__destruct(void) Destructor */ PHP_METHOD(SolrGenericResponse, __destruct) { } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/php_solr_utils.c0000644000175000017500000001741112676753707016061 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* {{{ proto string SolrUtils::escapeQueryChars(string unescaped) Escapes the lucene string */ PHP_METHOD(SolrUtils, escapeQueryChars) { solr_char_t *unescaped = NULL; solr_string_t sbuilder; COMPAT_ARG_SIZE_T unescaped_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &unescaped, &unescaped_length) == FAILURE) { RETURN_FALSE; } if (!unescaped_length) { RETURN_NULL(); } memset(&sbuilder, 0, sizeof(solr_string_t)); solr_escape_query_chars(&sbuilder, unescaped, unescaped_length); RETVAL_STRINGL(sbuilder.str, sbuilder.len); solr_string_free(&sbuilder); } /* }}} */ /* {{{ proto string SolrUtils::queryPhrase(string unescaped) Prepares a phrase from an unescaped lucene string. */ PHP_METHOD(SolrUtils, queryPhrase) { solr_char_t *unescaped = NULL; solr_string_t sbuilder; COMPAT_ARG_SIZE_T unescaped_length = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &unescaped, &unescaped_length) == FAILURE) { RETURN_FALSE; } if (!unescaped_length) { RETURN_NULL(); } memset(&sbuilder, 0, sizeof(solr_string_t)); solr_string_appendc(&sbuilder, '"'); solr_escape_query_chars(&sbuilder, unescaped, unescaped_length); solr_string_appendc(&sbuilder, '"'); RETVAL_STRINGL(sbuilder.str, sbuilder.len); solr_string_free(&sbuilder); } /* }}} */ /* {{{ proto string SolrUtils::digestXMLResponse(string xml_response [, int parse_mode]) Digests the xml response into a php serialize string. */ PHP_METHOD(SolrUtils, digestXmlResponse) { solr_char_t *xmlresponse = NULL; COMPAT_ARG_SIZE_T xmlresponse_len = 0; long int parse_mode = 0L; solr_string_t sbuilder; unsigned char *raw_resp = NULL, *str_end = NULL; size_t raw_res_length = 0; php_unserialize_data_t var_hash; int successful = 1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &xmlresponse, &xmlresponse_len, &parse_mode) == FAILURE) { RETURN_FALSE; } if (!xmlresponse_len) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Raw response is empty"); RETURN_NULL(); } parse_mode = ((parse_mode < 0L) ? 0L : ((parse_mode > 1L) ? 1L : parse_mode)); memset(&sbuilder, 0, sizeof(solr_string_t)); solr_encode_generic_xml_response(&sbuilder, xmlresponse, xmlresponse_len, parse_mode TSRMLS_CC); if (sbuilder.str == NULL || sbuilder.len == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Raw response was not valid"); RETURN_NULL(); } memset(&var_hash, 0, sizeof(php_unserialize_data_t)); PHP_VAR_UNSERIALIZE_INIT(var_hash); raw_resp = (unsigned char *) sbuilder.str; raw_res_length = sbuilder.len; str_end = (unsigned char *) (raw_resp + raw_res_length); if (!php_var_unserialize(return_value, (const unsigned char **) &raw_resp, str_end, &var_hash TSRMLS_CC)) { solr_throw_exception_ex(solr_ce_SolrException, SOLR_ERROR_1000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1000_MSG); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error unserializing raw response."); successful = 0; } PHP_VAR_UNSERIALIZE_DESTROY(var_hash); solr_string_free(&sbuilder); if (successful) { /* Overriding the default object handlers */ Z_OBJ_HT_P(return_value) = &solr_object_handlers; } } /* }}} */ /* {{{ proto string SolrUtils::digestJsonResponse(string jsonResponse) Digests the json response into a php serialize string. */ PHP_METHOD(SolrUtils, digestJsonResponse) { solr_char_t *jsonResponse = NULL; COMPAT_ARG_SIZE_T jsonResponse_len = 0; unsigned char *raw_resp = NULL, *str_end = NULL; solr_string_t buffer; php_unserialize_data_t var_hash; COMPAT_ARG_SIZE_T raw_res_length; int successful = 1; int json_translation_result; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &jsonResponse, &jsonResponse_len) == FAILURE) { RETURN_FALSE; } memset(&buffer, 0, sizeof(solr_string_t)); json_translation_result = solr_json_to_php_native(&buffer, jsonResponse, jsonResponse_len TSRMLS_CC); if (json_translation_result > 0) { solr_throw_exception_ex(solr_ce_SolrException, SOLR_ERROR_1000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, solr_get_json_error_msg(json_translation_result)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error in JSON->PHP conversion. JSON Error Code %d", json_translation_result); }else{ solr_sarray_to_sobject(&buffer TSRMLS_CC); } memset(&var_hash, 0, sizeof(php_unserialize_data_t)); PHP_VAR_UNSERIALIZE_INIT(var_hash); raw_resp = (unsigned char *) buffer.str; raw_res_length = buffer.len; str_end = (unsigned char *) (raw_resp + raw_res_length); if (!php_var_unserialize(return_value, (const unsigned char **)&raw_resp, str_end, &var_hash TSRMLS_CC)) { solr_throw_exception_ex(solr_ce_SolrException, SOLR_ERROR_1000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1000_MSG); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error unserializing raw response."); successful = 0; } solr_string_free(&buffer); PHP_VAR_UNSERIALIZE_DESTROY(var_hash); if (successful) { /* Overriding the default object handlers */ Z_OBJ_HT_P(return_value) = &solr_object_handlers; } } /* }}} */ /* {{{ proto string SolrUtils::getSolrVersion(void) Returns the current extension version */ PHP_METHOD(SolrUtils, getSolrVersion) { #ifdef SOLR_DEBUG char * version; asprintf(&version,"%s (DEBUG)", PHP_SOLR_DOTTED_VERSION); ZVAL_STRING(return_value, version); #else RETURN_STRING(PHP_SOLR_DOTTED_VERSION); #endif } /* }}} */ /* {{{ proto array SolrUtils::getSolrStats(void) Returns the number of active documents, clients and SolrParam objects in the current thread. */ PHP_METHOD(SolrUtils, getSolrStats) { int document_count = zend_hash_num_elements(SOLR_GLOBAL(documents)); int client_count = zend_hash_num_elements(SOLR_GLOBAL(clients)); int params_count = zend_hash_num_elements(SOLR_GLOBAL(params)); array_init(return_value); add_assoc_long(return_value, "document_count", document_count); add_assoc_long(return_value, "client_count", client_count); add_assoc_long(return_value, "params_count", params_count); } /* }}} */ /* {{{ proto string solr_get_version(void) Returns the current extension version */ PHP_FUNCTION(solr_get_version) { #ifdef SOLR_DEBUG char * version; asprintf(&version,"%s (DEBUG)", PHP_SOLR_DOTTED_VERSION); ZVAL_STRING(return_value, version); #else RETURN_STRING(PHP_SOLR_DOTTED_VERSION); #endif } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/solr_functions_client.c0000644000175000017500000007372512676753707017432 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* {{{ PHP_SOLR_API int solr_init_options(solr_client_options_t *options TSRMLS_DC) */ PHP_SOLR_API int solr_init_options(solr_client_options_t *options TSRMLS_DC) { solr_string_init(&(options->hostname)); solr_string_init(&(options->path)); solr_string_init(&(options->http_auth_credentials)); solr_string_init(&(options->proxy_hostname)); solr_string_init(&(options->proxy_auth_credentials)); solr_string_init(&(options->ssl_cert)); solr_string_init(&(options->ssl_key)); solr_string_init(&(options->ssl_keypassword)); solr_string_init(&(options->ssl_cainfo)); solr_string_init(&(options->ssl_capath)); solr_string_init(&(options->qs_delimiter)); solr_string_init(&(options->response_writer)); solr_string_init(&(options->update_url)); solr_string_init(&(options->search_url)); solr_string_init(&(options->thread_url)); solr_string_init(&(options->ping_url)); solr_string_init(&(options->terms_url)); solr_string_init(&(options->system_url)); solr_string_init(&(options->get_url)); solr_string_init(&(options->update_servlet)); solr_string_init(&(options->search_servlet)); solr_string_init(&(options->thread_servlet)); solr_string_init(&(options->ping_servlet)); solr_string_init(&(options->terms_servlet)); solr_string_init(&(options->system_servlet)); solr_string_init(&(options->get_servlet)); return SUCCESS; } /* }}} */ /* {{{ static void solr_set_initial_handle_options(solr_curl_t **sch, solr_client_options_t *options TSRMLS_DC) */ static void solr_set_initial_curl_handle_options(solr_curl_t **sch_ptr, solr_client_options_t *options TSRMLS_DC) { solr_curl_t * sch = *sch_ptr; /** Setup all the required CURL options here **/ curl_easy_setopt(sch->curl_handle, CURLOPT_NOPROGRESS, 1L); curl_easy_setopt(sch->curl_handle, CURLOPT_VERBOSE, 1L); curl_easy_setopt(sch->curl_handle, CURLOPT_ERRORBUFFER, sch->err.str); curl_easy_setopt(sch->curl_handle, CURLOPT_WRITEFUNCTION, solr_curl_write); curl_easy_setopt(sch->curl_handle, CURLOPT_WRITEDATA, (void *) sch); curl_easy_setopt(sch->curl_handle, CURLOPT_HEADERFUNCTION, solr_curl_write_header); curl_easy_setopt(sch->curl_handle, CURLOPT_HEADERDATA, (void *) sch); curl_easy_setopt(sch->curl_handle, CURLOPT_DEBUGFUNCTION, solr_curl_debug_callback); curl_easy_setopt(sch->curl_handle, CURLOPT_DEBUGDATA, (void *) sch); curl_easy_setopt(sch->curl_handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); /** #if LIBCURL_VERSION_NUM >= 0x071304 curl_easy_setopt(sch->curl_handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP); #endif */ curl_easy_setopt(sch->curl_handle, CURLOPT_DNS_CACHE_TIMEOUT, 120L); curl_easy_setopt(sch->curl_handle, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(sch->curl_handle, CURLOPT_MAXREDIRS, 16L); /* prevent infinite redirects */ curl_easy_setopt(sch->curl_handle, CURLOPT_UNRESTRICTED_AUTH, 0L); #ifdef ZTS curl_easy_setopt(sch->curl_handle, CURLOPT_NOSIGNAL, 1L); /** Needed in multi-threaded environments **/ #endif curl_easy_setopt(sch->curl_handle, CURLOPT_TIMEOUT, options->timeout); curl_easy_setopt(sch->curl_handle, CURLOPT_USERAGENT, SOLR_CLIENT_USER_AGENT); /* If the login and password options are passed, send the authentication headers */ if (options->http_auth_credentials.len) { curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_easy_setopt(sch->curl_handle, CURLOPT_USERPWD, options->http_auth_credentials.str); } /* If there is proxy info, send it too */ if (options->proxy_hostname.len) { curl_easy_setopt(sch->curl_handle, CURLOPT_PROXY, options->proxy_hostname.str); if (options->proxy_port) { curl_easy_setopt(sch->curl_handle, CURLOPT_PROXYPORT, options->proxy_port); } if (options->proxy_auth_credentials.len) { curl_easy_setopt(sch->curl_handle, CURLOPT_PROXYUSERPWD, options->proxy_auth_credentials.str); } } /* * When negotiating an SSL connection, the server sends a certificate indicating its identity. * cURL verifies whether the certificate is authentic */ if (options->secure) { /* The name of the PEM-formatted private key and private certificate concatenated */ if (options->ssl_cert.len) { curl_easy_setopt(sch->curl_handle, CURLOPT_SSLCERT, options->ssl_cert.str); curl_easy_setopt(sch->curl_handle, CURLOPT_SSLCERTTYPE, "PEM"); } /* The name of the PEM-formatted private key, if certificate and private key are separate */ if (options->ssl_key.len) { curl_easy_setopt(sch->curl_handle, CURLOPT_SSLKEY, options->ssl_key.str); curl_easy_setopt(sch->curl_handle, CURLOPT_SSLKEYTYPE, "PEM"); } /* Password for the PEM-formatted private key */ if (options->ssl_keypassword.len) { curl_easy_setopt(sch->curl_handle, CURLOPT_KEYPASSWD, options->ssl_keypassword.str); } /* The file holding one or more CA certificates to verify the peer with */ if (options->ssl_cainfo.len) { curl_easy_setopt(sch->curl_handle, CURLOPT_CAINFO, options->ssl_cainfo.str); } /* The directory holding multiple CA certificates to verify the peer with */ if (options->ssl_capath.len) { curl_easy_setopt(sch->curl_handle, CURLOPT_CAPATH , options->ssl_capath.str); } /* * Whether curl verifies the authenticity of the host name of server * Based on the Common name section of the certificate */ if (options->ssl_verify_peer && options->ssl_verify_host) { curl_easy_setopt(sch->curl_handle, CURLOPT_SSL_VERIFYHOST, options->ssl_verify_host); } /* * Verify the authenticity of the peer's certificate * This authentication is based on a chain of digital signatures, * rooted in certification authority (CA) certificates. * * If something is not right, the connection will not be valid */ curl_easy_setopt(sch->curl_handle, CURLOPT_SSL_VERIFYPEER, options->ssl_verify_peer); } } /* }}} */ /* {{{ PHP_SOLR_API int solr_init_handle(solr_curl_t *sch, solr_client_options_t *options TSRMLS_DC) */ PHP_SOLR_API int solr_init_handle(solr_curl_t *sch, solr_client_options_t *options TSRMLS_DC) { sch->response_header.response_code = 0L; memset(sch->err.str, 0, sizeof(sch->err.str)); sch->curl_handle = curl_easy_init(); if (NULL == sch->curl_handle) { return FAILURE; } sch->result_code = CURLE_OK; sch->handle_status = 1; #if defined(ZTS) && PHP_VERSION_ID < 70000 sch->tsrm_ls = TSRMLS_C; #endif solr_string_init(&(sch->request_header.buffer)); solr_string_init(&(sch->request_body.buffer)); solr_string_init(&(sch->request_body_debug.buffer)); solr_string_init(&(sch->response_header.buffer)); solr_string_init(&(sch->response_body.buffer)); solr_string_init(&(sch->debug_data_buffer)); solr_set_initial_curl_handle_options(&(sch), options TSRMLS_CC); return SUCCESS; } /* }}} */ /** * solr_curl_write * * Called by libcurl as soon as there is response body data received that needs to be saved. * * The size of the data pointed to by *data is size multiplied with nmemb, it will not be zero terminated * * The *ctx parameter is the solr_curl pointer */ /* {{{ size_t solr_curl_write(solr_char_t *data, size_t size, size_t nmemb, void *ctx) */ size_t solr_curl_write(solr_char_t *data, size_t size, size_t nmemb, void *ctx) { size_t length = (size * nmemb); solr_curl_t *sch = (solr_curl_t *) ctx; solr_string_appends(&(sch->response_body.buffer), data, length); return length; } /* }}} */ /** * solr_curl_write_header * * Called by libcurl as soon as it has received header data * * It will be called once for each header and only complete header lines are passed on to the callback. * * Note: header lines may not be null-terminated so beware. * * The *ctx parameter is the solr_curl pointer */ /* {{{ size_t solr_curl_write_header(solr_char_t *data, size_t size, size_t nmemb, void *ctx) */ size_t solr_curl_write_header(solr_char_t *data, size_t size, size_t nmemb, void *ctx) { size_t length = (size * nmemb); solr_curl_t *sch = (solr_curl_t *) ctx; solr_string_appends(&(sch->response_header.buffer), data, length); return length; } /* }}} */ /** * solr_curl_debug_callback * * The infotype parameter is one of : * * 0 = CURLINFO_TEXT * 1 = CURLINFO_HEADER_IN (Response Headers) * 2 = CURLINFO_HEADER_OUT (Request Headers) * 3 = CURLINFO_DATA_IN (Response Body) * 4 = CURLINFO_DATA_OUT (Request Body) * 5 = CURLINFO_SSL_DATA_IN * 6 = CURLINFO_SSL_DATA_OUT * * The debug_data parameter is not null-terminated but is exactly size characters * * The ctx parameter is a solr_curl * pointer */ /* {{{ int solr_curl_debug_callback(CURL *curl_handle, curl_infotype infotype, solr_char_t *debug_data, size_t size, void *ctx) */ int solr_curl_debug_callback(CURL *curl_handle, curl_infotype infotype, solr_char_t *debug_data, size_t size, void *ctx) { solr_curl_t *sch = (solr_curl_t *) ctx; /* TODO : Check why this function is still called after destructor has been called */ if (!sch->handle_status) { return 0; } switch(infotype) { case CURLINFO_HEADER_OUT : /* Capture the Actual Request Headers Sent to Server */ { solr_string_appends(&(sch->request_header.buffer), debug_data, size); } break; case CURLINFO_DATA_OUT : /* Capture the Actual Request Body Sent to Server */ { solr_string_appends(&(sch->request_body_debug.buffer), debug_data, size); } break; default : { /* do nothing */ } break; } /* Captures ALL debug information */ solr_string_appends(&(sch->debug_data_buffer), debug_data, size); return 0; } /* }}} */ /* {{{ PHP_SOLR_API int solr_make_request(solr_client_t *client, solr_request_type_t request_type TSRMLS_DC) */ PHP_SOLR_API int solr_make_request(solr_client_t *client, solr_request_type_t request_type TSRMLS_DC) { solr_curl_t *sch = &(client->handle); solr_client_options_t *options = &(client->options); solr_http_header_list_t *header_list = NULL; int return_status = SUCCESS; CURLcode info_status = CURLE_OK; header_list = curl_slist_append(header_list, "Accept-Charset: utf-8"); header_list = curl_slist_append(header_list, "Keep-Alive: 300"); header_list = curl_slist_append(header_list, "Connection: keep-alive"); /* Disable the Expect: 100-continue header. Jetty gets confused with this header */ header_list = curl_slist_append(header_list, "Expect:"); /* Reset the buffers */ solr_string_free(&sch->request_header.buffer); solr_string_free(&sch->request_body_debug.buffer); solr_string_free(&sch->response_body.buffer); solr_string_free(&sch->response_header.buffer); solr_string_free(&sch->debug_data_buffer); curl_easy_reset(sch->curl_handle); solr_set_initial_curl_handle_options(&(sch), options TSRMLS_CC); /* Reset the CURL options if the handle is reused */ curl_easy_setopt(sch->curl_handle, CURLOPT_HEADER, 0L); curl_easy_setopt(sch->curl_handle, CURLOPT_POST, 0L); curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPGET, 0L); curl_easy_setopt(sch->curl_handle, CURLOPT_NOBODY, 0L); curl_easy_setopt(sch->curl_handle, CURLOPT_POSTFIELDSIZE, 0L); curl_easy_setopt(sch->curl_handle, CURLOPT_POSTFIELDS, NULL); curl_easy_setopt(sch->curl_handle, CURLOPT_URL, NULL); curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPHEADER, NULL); switch(request_type) { case SOLR_REQUEST_SEARCH : /* HTTP FORM POST */ { header_list = curl_slist_append(header_list, "Content-Type: application/x-www-form-urlencoded;charset=UTF-8"); curl_easy_setopt(sch->curl_handle, CURLOPT_POST, 1L); curl_easy_setopt(sch->curl_handle, CURLOPT_URL, options->search_url.str); curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPHEADER, header_list); curl_easy_setopt(sch->curl_handle, CURLOPT_POSTFIELDSIZE, sch->request_body.buffer.len); curl_easy_setopt(sch->curl_handle, CURLOPT_POSTFIELDS, sch->request_body.buffer.str); } break; case SOLR_REQUEST_TERMS : /* HTTP FORM POST */ { header_list = curl_slist_append(header_list, "Content-Type: application/x-www-form-urlencoded;charset=UTF-8"); curl_easy_setopt(sch->curl_handle, CURLOPT_POST, 1L); curl_easy_setopt(sch->curl_handle, CURLOPT_URL, options->terms_url.str); curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPHEADER, header_list); curl_easy_setopt(sch->curl_handle, CURLOPT_POSTFIELDSIZE, sch->request_body.buffer.len); curl_easy_setopt(sch->curl_handle, CURLOPT_POSTFIELDS, sch->request_body.buffer.str); } break; case SOLR_REQUEST_UPDATE : /* HTTP XML POST */ { header_list = curl_slist_append(header_list, "Content-Type: text/xml;charset=UTF-8"); curl_easy_setopt(sch->curl_handle, CURLOPT_POST, 1L); curl_easy_setopt(sch->curl_handle, CURLOPT_URL, options->update_url.str); curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPHEADER, header_list); curl_easy_setopt(sch->curl_handle, CURLOPT_POSTFIELDSIZE, sch->request_body.buffer.len); curl_easy_setopt(sch->curl_handle, CURLOPT_POSTFIELDS, sch->request_body.buffer.str); } break; case SOLR_REQUEST_THREADS : /* HTTP GET */ { curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPGET, 1L); curl_easy_setopt(sch->curl_handle, CURLOPT_URL, options->thread_url.str); curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPHEADER, header_list); } break; case SOLR_REQUEST_PING : /* HTTP HEAD REQUEST. */ { curl_easy_setopt(sch->curl_handle, CURLOPT_HEADER, 1L); curl_easy_setopt(sch->curl_handle, CURLOPT_NOBODY, 1L); curl_easy_setopt(sch->curl_handle, CURLOPT_URL, options->ping_url.str); curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPHEADER, header_list); } break; case SOLR_REQUEST_SYSTEM: /* HTTP GET to fetch system info */ { curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPGET, 1L); curl_easy_setopt(sch->curl_handle, CURLOPT_URL, options->system_url.str); curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPHEADER, header_list); } break; case SOLR_REQUEST_GET: solr_string_appendc(&(options->get_url), '&'); solr_string_append_solr_string(&(options->get_url), &(sch->request_body.buffer)); curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPGET, 1L); curl_easy_setopt(sch->curl_handle, CURLOPT_URL, options->get_url.str); curl_easy_setopt(sch->curl_handle, CURLOPT_HTTPHEADER, header_list); break; default : { return_status = FAILURE; } break; } sch->result_code = curl_easy_perform(sch->curl_handle); info_status = curl_easy_getinfo(sch->curl_handle, CURLINFO_RESPONSE_CODE, &(sch->response_header.response_code)); if (info_status != CURLE_OK) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "HTTP Transfer status could not be retrieved successfully"); return_status = FAILURE; } if (sch->result_code != CURLE_OK) { /* commented by: Omar Shaban */ /* php_error_docref(NULL TSRMLS_CC, E_WARNING, "Solr HTTP Error : '%s' ", curl_easy_strerror(sch->result_code)); */ solr_throw_exception_ex(solr_ce_SolrClientException, SOLR_ERROR_1004 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Solr HTTP Error %d: '%s' ",sch->result_code, curl_easy_strerror(sch->result_code)); return_status = FAILURE; } if (sch->response_header.response_code != 200L) { return_status = FAILURE; } curl_slist_free_all(header_list); return return_status; } /* }}} */ /** Deallocates memory associated with the Solr CURL Handle. **/ /* {{{ PHP_SOLR_API void solr_free_handle(solr_curl_t *sch) */ PHP_SOLR_API void solr_free_handle(solr_curl_t *sch) { solr_string_free(&((sch)->request_header.buffer)); solr_string_free(&((sch)->request_body.buffer)); solr_string_free(&((sch)->request_body_debug.buffer)); solr_string_free(&((sch)->response_header.buffer)); solr_string_free(&((sch)->response_body.buffer)); solr_string_free(&((sch)->debug_data_buffer)); sch->handle_status = 0; curl_easy_cleanup((sch)->curl_handle); sch->curl_handle = NULL; } /* }}} */ /* {{{ PHP_SOLR_API void solr_free_options(solr_client_options_t *options) */ PHP_SOLR_API void solr_free_options(solr_client_options_t *options) { solr_string_free(&((options)->hostname)); solr_string_free(&((options)->http_auth_credentials)); solr_string_free(&((options)->path)); solr_string_free(&((options)->proxy_auth_credentials)); solr_string_free(&((options)->ssl_cert)); solr_string_free(&((options)->ssl_key)); solr_string_free(&((options)->ssl_keypassword)); solr_string_free(&((options)->ssl_cainfo)); solr_string_free(&((options)->ssl_capath)); solr_string_free(&((options)->proxy_hostname)); solr_string_free(&((options)->qs_delimiter)); solr_string_free(&((options)->response_writer)); solr_string_free(&((options)->update_url)); solr_string_free(&((options)->search_url)); solr_string_free(&((options)->thread_url)); solr_string_free(&((options)->ping_url)); solr_string_free(&((options)->terms_url)); solr_string_free(&((options)->system_url)); solr_string_free(&((options)->get_url)); solr_string_free(&((options)->update_servlet)); solr_string_free(&((options)->search_servlet)); solr_string_free(&((options)->thread_servlet)); solr_string_free(&((options)->ping_servlet)); solr_string_free(&((options)->terms_servlet)); solr_string_free(&((options)->system_servlet)); solr_string_free(&((options)->get_servlet)); } /* }}} */ /* {{{ PHP_SOLR_API void solr_destroy_client(void *client) */ PHP_SOLR_API void solr_destroy_client(zval *client) { solr_client_t *solr_client = (solr_client_t *) Z_PTR_P(client); if (solr_client) { solr_free_options(&(solr_client->options)); solr_free_handle(&(solr_client->handle)); pefree(solr_client, SOLR_CLIENT_PERSISTENT); solr_client = NULL; } } /* }}} */ /* {{{ PHP_SOLR_API int solr_get_xml_error(solr_string_t buffer, solr_exception_t *exceptionData TSRMLS_DC) */ PHP_SOLR_API int solr_get_xml_error(solr_string_t buffer, solr_exception_t *exceptionData TSRMLS_DC) { xmlDoc *doc = xmlReadMemory((const char *)buffer.str, buffer.len, NULL, "UTF-8", XML_PARSE_RECOVER); xmlXPathContext *xpathContext = NULL; xmlXPathObject *xpathObject = NULL; xmlChar *xpathExpression = (unsigned char *)"/response/lst[@name='error']"; xmlNode * nodeCurser; const unsigned char * nodePropName = (const unsigned char *)"name"; if (!doc) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error loading XML document"); return 1; } /* Create xpath evaluation context */ xpathContext = xmlXPathNewContext(doc); if(xpathContext == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error creating xml xpath context"); xmlFreeDoc(doc); return 1; } /* Evaluate xpath expression */ xpathObject = xmlXPathEvalExpression(xpathExpression, xpathContext); if(xpathObject == NULL){ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error evaluating xml xpath expression"); xmlFreeDoc(doc); return 1; } if(!xpathObject->nodesetval){ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Xpath Error: no elements found"); xmlXPathFreeObject(xpathObject); xmlFreeDoc(doc); return 1; } nodeCurser = xpathObject->nodesetval->nodeTab[0]->children; while (nodeCurser != NULL) { if (xmlHasProp(nodeCurser, nodePropName)) { if (strcmp((const char *)xmlGetProp(nodeCurser,nodePropName), (const char *)"msg") == 0) { exceptionData->message = (solr_char_t *)estrdup((const char *)nodeCurser->children->content); } else if(strcmp((const char *)xmlGetProp(nodeCurser,nodePropName),"code") == 0) { exceptionData->code = atoi((const char *)nodeCurser->children->content); } else if(strcmp( (const char *)xmlGetProp(nodeCurser, nodePropName), (const char *) "trace") == 0) { exceptionData->message = (solr_char_t *)estrdup((const char *)nodeCurser->children->content); } } nodeCurser = nodeCurser->next; } xmlXPathFreeObject(xpathObject); xmlXPathFreeContext(xpathContext); xmlFreeDoc(doc); return 0; } /* }}} */ /* {{{ PHP_SOLR_API int hydrate_error_zval(zval *response, solr_exception_t *exceptionData TSRMLS_DC) */ PHP_SOLR_API int hydrate_error_zval(zval *response, solr_exception_t *exceptionData TSRMLS_DC) { zval *error_p; zval *msg_zv_p=(zval *) NULL, *code_zv_p = (zval *) NULL; zend_string *msg_key_str = zend_string_init("msg", sizeof("msg")-1, 1); zend_string *code_key_str = zend_string_init("code", sizeof("code")-1, 1); zend_string *error_key_str = zend_string_init("error", sizeof("error")-1, 1); zend_string *trace_key_str = zend_string_init("trace", sizeof("trace")-1, 1); int return_code = 0; if ( (error_p = zend_hash_find( Z_ARRVAL_P(response), error_key_str)) != NULL) { if (zend_hash_exists(HASH_OF(error_p), msg_key_str)) { if ((msg_zv_p = zend_hash_find(Z_ARRVAL_P(error_p), msg_key_str)) != NULL) { exceptionData->message = (solr_char_t *)estrdup(Z_STRVAL(*msg_zv_p)); } else { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Undefined variable: %s", "msg"); return_code = 1; goto solr_error_func_return_end; } } else if (zend_hash_exists(HASH_OF(error_p), trace_key_str)) { if ((msg_zv_p = zend_hash_find(Z_ARRVAL_P(error_p), trace_key_str)) != NULL) { exceptionData->message = (solr_char_t *)estrdup(Z_STRVAL(*msg_zv_p)); } else { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Undefined variable: %s", "trace"); return_code = 1; goto solr_error_func_return_end; } } else{ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unable to find %s in error response zval", "message or trace" ); return_code = 1; goto solr_error_func_return_end; } if ((code_zv_p = zend_hash_find(Z_ARRVAL_P(error_p), code_key_str)) != NULL) { exceptionData->code = (int)Z_LVAL_P(code_zv_p); } else { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unable to find element with key %s in error response zval","code" ); return_code = 1; goto solr_error_func_return_end; } } else { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unable to find %s in error response", "error element" ); return_code = 1; goto solr_error_func_return_end; } solr_error_func_return_end: zend_string_release(msg_key_str); zend_string_release(code_key_str); zend_string_release(error_key_str); zend_string_release(trace_key_str); return return_code; } /* }}} */ /* {{{ PHP_SOLR_API int solr_get_json_error(solr_string_t buffer, solr_exception_t *exceptionData TSRMLS_DC) */ PHP_SOLR_API int solr_get_json_error(solr_string_t buffer, solr_exception_t *exceptionData TSRMLS_DC) { zval json_response; zval *error_p; zval *msg_zv_p=(zval *)NULL,*code_zv_p=(zval *)NULL; HashTable *errorHashTable; char * key = "error"; long nSize = 1000; int return_code = 0; zend_string *msg_key_str = zend_string_init("msg", sizeof("msg")-1, 1); zend_string *code_key_str = zend_string_init("code", sizeof("code")-1, 1); zend_string *error_key_str = zend_string_init("error", sizeof("error")-1, 1); zend_string *trace_key_str = zend_string_init("trace", sizeof("trace")-1, 1); php_json_decode(&json_response, (char *) buffer.str, buffer.len, 1, 1024L TSRMLS_CC); if (Z_TYPE(json_response) == IS_NULL) { zval_ptr_dtor(&json_response); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to parse Solr Server Error Response. JSON serialization error"); return 1; } ALLOC_HASHTABLE(errorHashTable); zend_hash_init(errorHashTable, nSize, NULL, NULL, 0); if ( (error_p = zend_hash_find( Z_ARRVAL(json_response), error_key_str)) != NULL) { if ((code_zv_p = zend_hash_find(Z_ARRVAL_P(error_p), code_key_str)) != NULL) { exceptionData->code = (int)Z_LVAL_P(code_zv_p); } else { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unable to find %s in json error response","code" ); } if (zend_hash_exists(HASH_OF(error_p), msg_key_str)) { if ((msg_zv_p = zend_hash_find(Z_ARRVAL_P(error_p), msg_key_str)) != NULL) { exceptionData->message = (solr_char_t *)estrdup(Z_STRVAL_P(msg_zv_p)); } } else if (!exceptionData->message && zend_hash_exists(HASH_OF(error_p), trace_key_str)) { if ((msg_zv_p = zend_hash_find(Z_ARRVAL_P(error_p), trace_key_str)) != NULL) { exceptionData->message = (solr_char_t *)estrdup(Z_STRVAL_P(msg_zv_p)); } else { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Undefined variable: %s","trace" ); } } else { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unable to find %s in error response zval","message" ); return_code = 1; goto solr_error_func_return_end; } }else{ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Undefined variable: %s",key ); } solr_error_func_return_end: zend_string_release(msg_key_str); zend_string_release(code_key_str); zend_string_release(error_key_str); zend_string_release(trace_key_str); zval_ptr_dtor(&json_response); zend_hash_destroy(errorHashTable); FREE_HASHTABLE(errorHashTable); return return_code; } /* }}} */ /* {{{ PHP_SOLR_API int solr_get_phpnative_error(solr_string_t buffer, solr_exception_t *exceptionData TSRMLS_DC) */ PHP_SOLR_API int solr_get_phpnative_error(solr_string_t buffer, solr_exception_t *exceptionData TSRMLS_DC) { zval *response_obj; php_unserialize_data_t var_hash; const unsigned char * raw_resp = (const unsigned char *) buffer.str; const unsigned char * str_end = (const unsigned char *) (buffer.str + buffer.len); ALLOC_INIT_ZVAL(response_obj); PHP_VAR_UNSERIALIZE_INIT(var_hash); if(!php_var_unserialize(response_obj, &raw_resp, str_end, &var_hash TSRMLS_CC)) { /* There is a known issue, that solr responses will not always be * with the dictated response format, as jetty or tomcat may return errors in their format */ PHP_VAR_UNSERIALIZE_DESTROY(var_hash); zval_ptr_dtor(response_obj); #ifdef PHP_7 efree(response_obj); #endif return 1; } hydrate_error_zval(response_obj, exceptionData TSRMLS_CC); PHP_VAR_UNSERIALIZE_DESTROY(var_hash); zval_ptr_dtor(response_obj); #ifdef PHP_7 efree(response_obj); #endif return 0; } /* }}} */ /* {{{ PHP_SOLR_API void solr_throw_solr_server_exception(solr_client_t *client,const char * requestType TSRMLS_DC) parse the solr server response and throw a SolrServerException */ PHP_SOLR_API void solr_throw_solr_server_exception(solr_client_t *client,const char * requestType TSRMLS_DC) { const char * response_writer = (char *) client->options.response_writer.str; solr_exception_t *exceptionData; exceptionData = (solr_exception_t*) emalloc(sizeof(solr_exception_t )); exceptionData->code = 0; memset(exceptionData, 0, sizeof(solr_exception_t)); if( 0 == strcmp(response_writer, SOLR_XML_RESPONSE_WRITER)){ if(solr_get_xml_error(client->handle.response_body.buffer, exceptionData TSRMLS_CC) != SUCCESS) { /* fallback to normal exception */ solr_throw_exception_ex(solr_ce_SolrClientException, SOLR_ERROR_1010 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1010_MSG, requestType, SOLR_RESPONSE_CODE_BODY); return; } } if( 0 == strcmp(response_writer, SOLR_JSON_RESPONSE_WRITER)) { if(solr_get_json_error(client->handle.response_body.buffer, exceptionData TSRMLS_CC) != SUCCESS) { solr_throw_exception_ex(solr_ce_SolrClientException, SOLR_ERROR_1010 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1010_MSG, requestType, SOLR_RESPONSE_CODE_BODY); } } if( 0 == strcmp(response_writer, SOLR_PHP_NATIVE_RESPONSE_WRITER) || 0 == strcmp(response_writer, SOLR_PHP_SERIALIZED_RESPONSE_WRITER)) { if(solr_get_phpnative_error(client->handle.response_body.buffer,exceptionData TSRMLS_CC) != SUCCESS) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unable to parse serialized php response" ); } } if(exceptionData->code == 0){ solr_throw_exception_ex(solr_ce_SolrClientException, SOLR_ERROR_1010 TSRMLS_CC, SOLR_FILE_LINE_FUNC, SOLR_ERROR_1010_MSG, requestType, SOLR_RESPONSE_CODE_BODY); }else if (exceptionData->code > 0 && exceptionData->message){ solr_throw_exception_ex(solr_ce_SolrServerException, exceptionData->code TSRMLS_CC, SOLR_FILE_LINE_FUNC, exceptionData->message); } else { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to parse solr exception message, Internal Error" ); } if(exceptionData->message != NULL) { efree(exceptionData->message); } efree(exceptionData); } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/solr_functions_debug.c0000644000175000017500000001106412676753707017226 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Omar Shaban | | Israel Ekpo | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* {{{ void solr_debug_printf(const char *format, ...) */ PHP_SOLR_API void solr_debug_printf(const char *format, ...) { #ifdef SOLR_DEBUG va_list args; va_start(args,format); vprintf(format,args); va_end(args); #endif } /* }}} */ /* {{{ void solr_debug_print_fields(const solr_field_list_t *field_list) */ PHP_SOLR_API void solr_debug_print_fields(const solr_field_list_t *field_list) { /* Used to debug field inserted */ } /* }}} */ /** * print_xpath_nodes: * @nodes: the nodes set. * @output: the output file handle. * * Prints the @nodes content to @output. */ /* {{{ void print_xpath_nodes(xmlNodeSetPtr nodes, FILE* output) */ PHP_SOLR_API void print_xpath_nodes(xmlNodeSetPtr nodes, FILE* output) { xmlNodePtr cur; int size; int i; assert(output); size = (nodes) ? nodes->nodeNr : 0; fprintf(output, "Result (%d nodes):\n", size); for(i = 0; i < size; ++i) { assert(nodes->nodeTab[i]); if(nodes->nodeTab[i]->type == XML_NAMESPACE_DECL) { xmlNsPtr ns; ns = (xmlNsPtr)nodes->nodeTab[i]; cur = (xmlNodePtr)ns->next; if(cur->ns) { fprintf(output, "= namespace \"%s\"=\"%s\" for node %s:%s\n", ns->prefix, ns->href, cur->ns->href, cur->name); } else { fprintf(output, "= namespace \"%s\"=\"%s\" for node %s\n", ns->prefix, ns->href, cur->name); } } else if(nodes->nodeTab[i]->type == XML_ELEMENT_NODE) { cur = nodes->nodeTab[i]; if(cur->ns) { fprintf(output, "= element node \"%s:%s\"\n", cur->ns->href, cur->name); } else { fprintf(output, "= element node \"%s\"\n", cur->name); } } else { cur = nodes->nodeTab[i]; fprintf(output, "= node \"%s\": type %d\n", cur->name, cur->type); } } } /* }}} */ /* {{{ void print_children (xmlNode * node) */ PHP_SOLR_API void print_children (xmlNode * node) { fprintf(stdout,"\n================- start print children -=================\n"); while (node != NULL) { if(node->ns) { fprintf(stdout, "= element node \"%s:%s\"\n", node->ns->href,node->name); } else { fprintf(stdout, "= element node \"%s\"\n", node->name); } if(node->type == XML_ELEMENT_NODE){ xmlNode * cur2 = node->children; while (cur2 != NULL) { if(strcmp((const char *)cur2->name,"text")==0) { fprintf(stdout, "= element node \"%s\", text: %s\n",cur2->name,cur2->content); }else{ fprintf(stdout, "= element node \"%s\"\n", cur2->name); } cur2 = cur2->next; } } if(node->children != NULL) { print_children(node->children); } node = node->next; } fprintf(stdout,"\n======================- end -=====================\n"); } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/solr_functions_document.c0000644000175000017500000004250612676753707017763 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Israel Ekpo | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" PHP_SOLR_API zend_object *solr_document_object_handler_clone(zval *zobject TSRMLS_DC) { zend_object *old_object; zend_object *new_object; solr_document_t *doc_entry, *old_doc_entry; long document_index = SOLR_UNIQUE_DOCUMENT_INDEX(); old_object = Z_OBJ_P(zobject); new_object = zend_objects_new(old_object->ce); zend_objects_clone_members(new_object, old_object); if (solr_fetch_document_entry(zobject, &old_doc_entry TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Clone Failed: Unable to fetch document entry of the source document"); } doc_entry = solr_init_document(document_index); ZVAL_LONG(&(new_object->properties_table[0]), document_index) /* Add the document entry to the directory of documents */ doc_entry->field_count = old_doc_entry->field_count; doc_entry->document_boost = old_doc_entry->document_boost; zend_hash_copy(doc_entry->fields, old_doc_entry->fields, (copy_ctor_func_t) field_copy_constructor); zend_hash_copy(doc_entry->children, old_doc_entry->children, (copy_ctor_func_t) zval_add_ref); return new_object; } PHP_SOLR_API void field_copy_constructor_ex(solr_field_list_t **original_field_queue_ptr) { solr_field_list_t *original_field_queue = *original_field_queue_ptr; solr_field_value_t *ptr = original_field_queue->head; if (ptr == NULL) { return; } solr_field_list_t *new_field_queue = (solr_field_list_t *) pemalloc(sizeof(solr_field_list_t), SOLR_DOCUMENT_FIELD_PERSISTENT); new_field_queue->count = 0L; new_field_queue->field_name = (solr_char_t *) pestrdup((char *) (original_field_queue)->field_name, SOLR_DOCUMENT_FIELD_PERSISTENT); new_field_queue->head = NULL; new_field_queue->last = NULL; new_field_queue->field_boost = original_field_queue->field_boost; while(ptr != NULL) { if (solr_document_insert_field_value(new_field_queue, ptr->field_value, 0) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to insert field value"); } ptr = ptr->next; } *original_field_queue_ptr = new_field_queue; } /* {{{ void field_copy_constructor_zv(zval *field_queue_zv) */ PHP_SOLR_API void field_copy_constructor_zv(zval *field_queue_zv) { solr_field_list_t *original_field_queue = NULL; original_field_queue = Z_PTR_P(field_queue_zv); field_copy_constructor_ex(&original_field_queue); ZVAL_PTR(field_queue_zv, original_field_queue); } /* }}} */ /* {{{ PHP_SOLR_API int solr_document_insert_field_value(solr_field_list_t *queue, const solr_char_t *field_value, double field_boost) */ PHP_SOLR_API int solr_document_insert_field_value(solr_field_list_t *queue, const solr_char_t *field_value, double field_boost) { solr_field_value_t *new_entry = (solr_field_value_t *) pemalloc(sizeof(solr_field_value_t), SOLR_DOCUMENT_FIELD_PERSISTENT); if (new_entry == NULL) { return FAILURE; } new_entry->field_value = (solr_char_t *) pestrdup((char *) field_value, SOLR_DOCUMENT_FIELD_PERSISTENT); if (new_entry->field_value == NULL) { return FAILURE; } new_entry->next = NULL; if (queue->head == NULL) { /* This is the first and only item in the field list */ queue->head = new_entry; queue->last = new_entry; /* Update the field boost value */ if (field_boost > 0.0) { queue->field_boost = field_boost; } } else { /* There are already entries in the list. */ /* Append to the end of the queue */ queue->last->next = new_entry; /* Set the last item in the queue to the latest entry */ queue->last = new_entry; /* Update the field boost value */ if (field_boost > 0.0) { if (queue->field_boost > 0.0) { queue->field_boost *= field_boost; } else { queue->field_boost = field_boost; } } } queue->count++; return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API solr_document_t *solr_init_document(long int document_index) * create and allocate a solr_document_t with the specified index */ PHP_SOLR_API solr_document_t *solr_init_document(long int document_index) { uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE; solr_document_t *doc_ptr = NULL; solr_document_t *doc_entry; #ifdef PHP_7 doc_entry = pemalloc(sizeof(solr_document_t), SOLR_DOCUMENT_PERSISTENT); #endif doc_entry->document_index = document_index; doc_entry->field_count = 0L; doc_entry->document_boost = 0.0f; /* Allocated memory for the fields HashTable using fast cache for HashTables */ ALLOC_HASHTABLE(doc_entry->fields); ALLOC_HASHTABLE(doc_entry->children); /* Initializing the hash table used for storing fields in this SolrDocument */ zend_hash_init(doc_entry->fields, nSize, NULL, (dtor_func_t) solr_destroy_field_list_ht_dtor, SOLR_DOCUMENT_FIELD_PERSISTENT); zend_hash_init(doc_entry->children, nSize, NULL, ZVAL_PTR_DTOR, SOLR_DOCUMENT_FIELD_PERSISTENT); /* Let's check one more time before insert into the HashTable */ if (zend_hash_index_exists(SOLR_GLOBAL(documents), document_index)) { /* todo call dtor ? */ pefree(doc_entry->fields, SOLR_DOCUMENT_FIELD_PERSISTENT); pefree(doc_entry->children, SOLR_DOCUMENT_FIELD_PERSISTENT); return NULL; } /* Add the document entry to the directory of documents */ doc_ptr = zend_hash_index_update_ptr(SOLR_GLOBAL(documents), document_index, (void *) doc_entry); /* Keep track of how many SolrDocument instances we currently have */ SOLR_GLOBAL(document_count)++; return doc_ptr; } /* }}} */ /* {{{ PHP_SOLR_API solr_document_t *solr_input_doc_ctor(zval *objptr) * constructor populate/allocate the new document after object instantiation * and allocates hashtables for fields and children */ PHP_SOLR_API solr_document_t *solr_input_doc_ctor(zval *objptr) { ulong document_index = SOLR_UNIQUE_DOCUMENT_INDEX(); solr_document_t *solr_doc = NULL; if ((solr_doc = solr_init_document(document_index)) == NULL) { return NULL; } /* Set the value of the internal id property */ zend_update_property_long(solr_ce_SolrInputDocument, objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, document_index TSRMLS_CC); /* Overriding the default object handlers */ Z_OBJ_HT_P(objptr) = &solr_input_document_object_handlers; return solr_doc; } /* }}} */ /* {{{ PHP_SOLR_API void solr_destroy_document_zv(zval *document) * destory a solr_document within a zval (ZE 3) */ PHP_SOLR_API void solr_destroy_document_zv(zval *document) { solr_document_t *doc_entry = (solr_document_t *) Z_PTR_P(document); solr_destroy_document_ex(doc_entry); pefree(doc_entry, SOLR_DOCUMENT_PERSISTENT); } /* }}} */ /* {{{ void solr_destroy_document(void *document) * destory a solr_document_t */ PHP_SOLR_API void solr_destroy_document_ex(solr_document_t *doc_entry) { /* Release all the field_lists one at a time with solr_destroy_field_list */ zend_hash_destroy(doc_entry->fields); /* Deallocate memory for the fields HashTable */ pefree(doc_entry->fields, SOLR_DOCUMENT_FIELD_PERSISTENT); if (doc_entry->children) { zend_hash_destroy(doc_entry->children); pefree(doc_entry->children, SOLR_DOCUMENT_FIELD_PERSISTENT); } } /* }}} */ PHP_SOLR_API void solr_destroy_field_list_ht_dtor(zval *zv_field_entry) { solr_field_list_t *field_entry = Z_PTR_P(zv_field_entry); solr_destroy_field_list(field_entry); } /* {{{ void solr_destroy_field_list(solr_field_list_t **field_entry_ptr) */ PHP_SOLR_API void solr_destroy_field_list(solr_field_list_t *field_entry) { solr_field_value_t *tmp = NULL; solr_field_value_t *current_field_value = field_entry->head; /* Go through the list and free all the values */ while(current_field_value != NULL) { tmp = current_field_value->next; pefree(current_field_value->field_value, SOLR_DOCUMENT_FIELD_PERSISTENT); pefree(current_field_value, SOLR_DOCUMENT_FIELD_PERSISTENT); current_field_value = tmp; } field_entry->head = NULL; field_entry->last = NULL; pefree(field_entry->field_name, SOLR_DOCUMENT_FIELD_PERSISTENT); pefree(field_entry, SOLR_DOCUMENT_FIELD_PERSISTENT); } /* }}} */ /* Comparison functions for field entries */ /* {{{ int solr_compare_field_name(const void *a, const void *b TSRMLS_DC) */ PHP_SOLR_API int solr_compare_field_name(const void *a, const void *b TSRMLS_DC) { #ifdef PHP_7 const Bucket *x = (Bucket *) a; const Bucket *y = (Bucket *) b; #else const Bucket *x = *((Bucket **) a); const Bucket *y = *((Bucket **) b); #endif const solr_field_list_t *first = (solr_field_list_t *) Z_PTR(x->val); const solr_field_list_t *second = (solr_field_list_t *) Z_PTR(y->val); const int diff = strcmp((char *) first->field_name, (char *) second->field_name); const int result = ((diff > 0) ? 1 : ((diff < 0) ? -1 : 0)); return result; } /* }}} */ /* {{{ int solr_rcompare_field_name(const void *a, const void *b TSRMLS_DC) */ PHP_SOLR_API int solr_rcompare_field_name(const void *a, const void *b TSRMLS_DC) { return (solr_compare_field_name(a, b TSRMLS_CC) * -1); } /* }}} */ /* {{{ int solr_compare_field_value_count(const void *a, const void *b TSRMLS_DC) */ PHP_SOLR_API int solr_compare_field_value_count(const void *a, const void *b TSRMLS_DC) { #ifdef PHP_7 const Bucket *x = (Bucket *) a; const Bucket *y = (Bucket *) b; #else const Bucket *x = *((Bucket **) a); const Bucket *y = *((Bucket **) b); #endif const solr_field_list_t *first = (solr_field_list_t *) Z_PTR(x->val); const solr_field_list_t *second = (solr_field_list_t *) Z_PTR(y->val); const int diff = first->count - second->count; const int result = ((diff > 0) ? 1 : ((diff < 0) ? -1 : 0)); return result; } /* }}} */ /* {{{ int solr_rcompare_field_value_count(const void *a, const void *b TSRMLS_DC) */ PHP_SOLR_API int solr_rcompare_field_value_count(const void *a, const void *b TSRMLS_DC) { return (solr_compare_field_value_count(a, b TSRMLS_CC) * -1); } /* }}} */ /* {{{ int solr_compare_field_boost_value(const void *a, const void *b TSRMLS_DC) */ PHP_SOLR_API int solr_compare_field_boost_value(const void *a, const void *b TSRMLS_DC) { #ifdef PHP_7 const Bucket *x = (Bucket *) a; const Bucket *y = (Bucket *) b; #else const Bucket *x = *((Bucket **) a); const Bucket *y = *((Bucket **) b); #endif const solr_field_list_t *first = (solr_field_list_t *) Z_PTR(x->val); const solr_field_list_t *second = (solr_field_list_t *) Z_PTR(y->val); const double diff = first->field_boost - second->field_boost; const int result = ((diff > 0.0) ? 1 : ((diff < 0.0) ? -1 : 0)); return result; } /* }}} */ /* {{{ int solr_rcompare_field_boost_value(const void *a, const void *b TSRMLS_DC) */ PHP_SOLR_API int solr_rcompare_field_boost_value(const void *a, const void *b TSRMLS_DC) { return (solr_compare_field_boost_value(a, b TSRMLS_CC) * -1); } /* }}} */ /* {{{ PHP_SOLR_API void solr_create_document_field_object(solr_field_list_t *field_values, zval **field_obj TSRMLS_DC) */ PHP_SOLR_API void solr_create_document_field_object(solr_field_list_t *field_values, zval **field_obj TSRMLS_DC) { zval *doc_field = *field_obj; solr_field_value_t *curr_ptr = NULL; zval field_values_array_tmp; zval *field_values_array = &field_values_array_tmp; array_init(field_values_array); curr_ptr = field_values->head; while(curr_ptr != NULL) { solr_char_t *current_value = curr_ptr->field_value; add_next_index_string(field_values_array, current_value); curr_ptr = curr_ptr->next; } object_init_ex(doc_field, solr_ce_SolrDocumentField); zend_update_property_string(solr_ce_SolrDocumentField, doc_field, SOLR_FIELD_NAME_PROPERTY_NAME, sizeof(SOLR_FIELD_NAME_PROPERTY_NAME)-1, field_values->field_name TSRMLS_CC); zend_update_property_double(solr_ce_SolrDocumentField, doc_field, SOLR_FIELD_BOOST_PROPERTY_NAME, sizeof(SOLR_FIELD_BOOST_PROPERTY_NAME)-1, field_values->field_boost TSRMLS_CC); zend_update_property(solr_ce_SolrDocumentField, doc_field, SOLR_FIELD_VALUES_PROPERTY_NAME, sizeof(SOLR_FIELD_VALUES_PROPERTY_NAME)-1, field_values_array TSRMLS_CC); zval_ptr_dtor(field_values_array); Z_OBJ_HT_P(doc_field) = &solr_document_field_handlers; } /* }}} */ /* {{{ PHP_SOLR_API void solr_create_document_field_object(solr_field_list_t *field_values, zval **field_obj TSRMLS_DC) constructs the element when adding a document to the index */ PHP_SOLR_API void solr_add_doc_node(xmlNode *root_node, solr_document_t *doc_entry TSRMLS_DC) { HashTable *document_fields = NULL; xmlNode *solr_doc_node = NULL; document_fields = doc_entry->fields; solr_doc_node = xmlNewChild(root_node, NULL, (xmlChar *) "doc", NULL); if (doc_entry->document_boost > 0.0f) { auto char tmp_buffer[256]; /* Scratch pad for converting numeric values to strings */ memset(tmp_buffer, 0, sizeof(tmp_buffer)); php_gcvt(doc_entry->document_boost, EG(precision), '.', 'e' , tmp_buffer); xmlNewProp(solr_doc_node, (xmlChar *) "boost", (xmlChar *) tmp_buffer); } solr_generate_document_xml_from_fields(solr_doc_node, document_fields TSRMLS_CC); if (zend_hash_num_elements(doc_entry->children) > 0) { SOLR_HASHTABLE_FOR_LOOP(doc_entry->children) { zval *doc_obj = NULL; solr_document_t *child_doc_entry = NULL; doc_obj = zend_hash_get_current_data(doc_entry->children); if (solr_fetch_document_entry(doc_obj, &child_doc_entry TSRMLS_CC) == SUCCESS) { solr_add_doc_node(solr_doc_node, child_doc_entry TSRMLS_CC); } } } } /* }}} */ /* {{{ static void solr_generate_document_xml_from_fields(xmlNode *solr_doc_node, HashTable *document_fields) */ PHP_SOLR_API void solr_generate_document_xml_from_fields(xmlNode *solr_doc_node, HashTable *document_fields TSRMLS_DC) { xmlDoc *doc_ptr = solr_doc_node->doc; SOLR_HASHTABLE_FOR_LOOP(document_fields) { solr_char_t *doc_field_name; solr_field_value_t *doc_field_value; solr_field_list_t *field = NULL; zend_bool is_first_value = 1; /* Turn on first value flag */ field = (solr_field_list_t *)zend_hash_get_current_data_ptr(document_fields); doc_field_name = field->field_name; doc_field_value = field->head; /* Loop through all the values for this field */ while(doc_field_value != NULL) { xmlChar *escaped_field_value = xmlEncodeEntitiesReentrant(doc_ptr, (xmlChar *) doc_field_value->field_value); xmlNode *solr_field_node = xmlNewChild(solr_doc_node, NULL, (xmlChar *) "field", escaped_field_value); xmlNewProp(solr_field_node, (xmlChar *) "name", (xmlChar *) doc_field_name); /* Set the boost attribute if this is the first value */ if (is_first_value && field->field_boost > 0.0f) { auto char tmp_boost_value_buffer[256]; memset(tmp_boost_value_buffer, 0, sizeof(tmp_boost_value_buffer)); php_gcvt(field->field_boost, EG(precision), '.', 'e' , tmp_boost_value_buffer); xmlNewProp(solr_field_node, (xmlChar *) "boost", (xmlChar *) tmp_boost_value_buffer); is_first_value = 0; /* Turn off the flag */ } /* Release the memory allocated by xmlEncodeEntitiesReentrant */ xmlFree(escaped_field_value); /* Grab the next value for this field if any */ doc_field_value = doc_field_value->next; } /* while(doc_field_value != NULL) */ } /* SOLR_HASHTABLE_FOR_LOOP(document_fields) */ } /* }}} */ PHP_SOLR_API void solr_document_get_field_names(INTERNAL_FUNCTION_PARAMETERS) { solr_document_t *doc_entry = NULL; /* Retrieve the document entry for the SolrDocument instance */ if (solr_fetch_document_entry(getThis(), &doc_entry TSRMLS_CC) == SUCCESS) { HashTable *fields_ht = doc_entry->fields; array_init(return_value); SOLR_HASHTABLE_FOR_LOOP(fields_ht) { solr_field_list_t *field = NULL; field = zend_hash_get_current_data_ptr(fields_ht); add_next_index_string(return_value, (char *) field->field_name); } return; } RETURN_FALSE; } /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/solr_functions_helpers.c0000664000175000017500000015005012676753707017603 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" #if !(PHP_MAJOR_VERSION==5 && PHP_MINOR_VERSION==2) ZEND_EXTERN_MODULE_GLOBALS(json) #endif /** ************************************************************************ **/ /** FUNCTIONS FOR DECLARING CONSTANTS **/ /** ************************************************************************ **/ /* {{{ void solr_extension_register_constants(int type, int module_number TSRMLS_DC) */ PHP_SOLR_API void solr_extension_register_constants(int type, int module_number TSRMLS_DC) { REGISTER_LONG_CONSTANT("SOLR_MAJOR_VERSION", PHP_SOLR_MAJOR_VERSION, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SOLR_MINOR_VERSION", PHP_SOLR_MINOR_VERSION, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SOLR_PATCH_VERSION", PHP_SOLR_PATCH_VERSION, CONST_CS | CONST_PERSISTENT); REGISTER_STRING_CONSTANT("SOLR_EXTENSION_VERSION", PHP_SOLR_DOTTED_VERSION, CONST_CS | CONST_PERSISTENT); } /* }}} */ /* {{{ void solr_document_register_class_constants(zend_class_entry * ce TSRMLS_DC) */ PHP_SOLR_API void solr_document_register_class_constants(zend_class_entry *ce TSRMLS_DC) { zend_declare_class_constant_long(ce, "SORT_DEFAULT", sizeof("SORT_DEFAULT")-1, SOLR_SORT_ASC TSRMLS_CC); zend_declare_class_constant_long(ce, "SORT_ASC", sizeof("SORT_ASC")-1, SOLR_SORT_ASC TSRMLS_CC); zend_declare_class_constant_long(ce, "SORT_DESC", sizeof("SORT_DESC")-1, SOLR_SORT_DESC TSRMLS_CC); zend_declare_class_constant_long(ce, "SORT_FIELD_NAME", sizeof("SORT_FIELD_NAME")-1, SOLR_SORT_FIELD_NAME TSRMLS_CC); zend_declare_class_constant_long(ce, "SORT_FIELD_VALUE_COUNT", sizeof("SORT_FIELD_VALUE_COUNT")-1, SOLR_SORT_FIELD_VALUE_COUNT TSRMLS_CC); zend_declare_class_constant_long(ce, "SORT_FIELD_BOOST_VALUE", sizeof("SORT_FIELD_BOOST_VALUE")-1, SOLR_SORT_FIELD_BOOST_VALUE TSRMLS_CC); } /* }}} */ /* {{{ void solr_collapse_function_register_class_constants(zend_class_entry * ce TSRMLS_DC) */ PHP_SOLR_API void solr_collapse_function_register_class_constants(zend_class_entry *ce TSRMLS_DC) { zend_declare_class_constant_string(ce, "NULLPOLICY_IGNORE", sizeof("NULLPOLICY_IGNORE")-1, "ignore" TSRMLS_CC); zend_declare_class_constant_string(ce, "NULLPOLICY_EXPAND", sizeof("NULLPOLICY_EXPAND")-1, "expand" TSRMLS_CC); zend_declare_class_constant_string(ce, "NULLPOLICY_COLLAPSE", sizeof("NULLPOLICY_COLLAPSE")-1, "collapse" TSRMLS_CC); } /* }}} */ /* {{{ void solr_client_register_class_constants(zend_class_entry *ce TSRMLS_DC) */ PHP_SOLR_API void solr_client_register_class_constants(zend_class_entry *ce TSRMLS_DC) { zend_declare_class_constant_long(ce, "SEARCH_SERVLET_TYPE", sizeof("SEARCH_SERVLET_TYPE")-1, SOLR_SERVLET_TYPE_SEARCH TSRMLS_CC); zend_declare_class_constant_long(ce, "UPDATE_SERVLET_TYPE", sizeof("UPDATE_SERVLET_TYPE")-1, SOLR_SERVLET_TYPE_UPDATE TSRMLS_CC); zend_declare_class_constant_long(ce, "THREADS_SERVLET_TYPE", sizeof("THREADS_SERVLET_TYPE")-1, SOLR_SERVLET_TYPE_THREADS TSRMLS_CC); zend_declare_class_constant_long(ce, "PING_SERVLET_TYPE", sizeof("PING_SERVLET_TYPE")-1, SOLR_SERVLET_TYPE_PING TSRMLS_CC); zend_declare_class_constant_long(ce, "TERMS_SERVLET_TYPE", sizeof("TERMS_SERVLET_TYPE")-1, SOLR_SERVLET_TYPE_TERMS TSRMLS_CC); zend_declare_class_constant_long(ce, "SYSTEM_SERVLET_TYPE", sizeof("SYSTEM_SERVLET_TYPE")-1, SOLR_SERVLET_TYPE_SYSTEM TSRMLS_CC); zend_declare_class_constant_string(ce, "DEFAULT_SEARCH_SERVLET", sizeof("DEFAULT_SEARCH_SERVLET")-1, SOLR_DEFAULT_SEARCH_SERVLET TSRMLS_CC); zend_declare_class_constant_string(ce, "DEFAULT_UPDATE_SERVLET", sizeof("DEFAULT_UPDATE_SERVLET")-1, SOLR_DEFAULT_UPDATE_SERVLET TSRMLS_CC); zend_declare_class_constant_string(ce, "DEFAULT_THREADS_SERVLET", sizeof("DEFAULT_THREADS_SERVLET")-1, SOLR_DEFAULT_THREADS_SERVLET TSRMLS_CC); zend_declare_class_constant_string(ce, "DEFAULT_PING_SERVLET", sizeof("DEFAULT_PING_SERVLET")-1, SOLR_DEFAULT_PING_SERVLET TSRMLS_CC); zend_declare_class_constant_string(ce, "DEFAULT_TERMS_SERVLET", sizeof("DEFAULT_TERMS_SERVLET")-1, SOLR_DEFAULT_TERMS_SERVLET TSRMLS_CC); zend_declare_class_constant_string(ce, "DEFAULT_SYSTEM_SERVLET", sizeof("DEFAULT_SYSTEM_SERVLET")-1, SOLR_DEFAULT_SYSTEM_SERVLET TSRMLS_CC); } /* }}} */ /* {{{ void solr_response_register_class_properties(zend_class_entry *ce TSRMLS_DC) */ PHP_SOLR_API void solr_response_register_class_properties(zend_class_entry *ce TSRMLS_DC) { zend_declare_property_long(ce, "http_status", sizeof("http_status")-1, 0L, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_long(ce, "parser_mode", sizeof("parser_mode")-1, 0L, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_bool(ce, "success", sizeof("success")-1, 0L, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(ce, "response_writer", sizeof("response_writer")-1, SOLR_SPACE_STRING, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(ce, "http_status_message", sizeof("http_status_message")-1, SOLR_SPACE_STRING, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(ce, "http_request_url", sizeof("http_request_url")-1, SOLR_SPACE_STRING, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(ce, "http_raw_request_headers", sizeof("http_raw_request_headers")-1, SOLR_SPACE_STRING, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(ce, "http_raw_request", sizeof("http_raw_request")-1, SOLR_SPACE_STRING, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(ce, "http_raw_response_headers", sizeof("http_raw_response_headers")-1, SOLR_SPACE_STRING, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(ce, "http_raw_response", sizeof("http_raw_response")-1, SOLR_SPACE_STRING, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(ce, "http_digested_response", sizeof("http_digested_response")-1, SOLR_SPACE_STRING, ZEND_ACC_PROTECTED TSRMLS_CC); } /* }}} */ /* {{{ void solr_exception_register_class_properties(zend_class_entry *ce TSRMLS_DC) */ PHP_SOLR_API void solr_exception_register_class_properties(zend_class_entry *ce TSRMLS_DC) { zend_declare_property_long(ce, SOLR_SOURCELINE_NO_PROPERTY_NAME, sizeof(SOLR_SOURCELINE_NO_PROPERTY_NAME)-1, __LINE__, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(ce, SOLR_SOURCEFILE_PROPERTY_NAME, sizeof(SOLR_SOURCEFILE_PROPERTY_NAME)-1, __FILE__, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_string(ce, SOLR_ZIFNAME_PROPERTY_NAME, sizeof(SOLR_ZIFNAME_PROPERTY_NAME)-1, (char *) __func__, ZEND_ACC_PROTECTED TSRMLS_CC); } /* }}} */ /* {{{ void solr_response_register_class_constants(zend_class_entry *ce TSRMLS_DC) */ PHP_SOLR_API void solr_response_register_class_constants(zend_class_entry *ce TSRMLS_DC) { zend_declare_class_constant_long(ce, "PARSE_SOLR_OBJ", sizeof("PARSE_SOLR_OBJ")-1, 0L TSRMLS_CC); zend_declare_class_constant_long(ce, "PARSE_SOLR_DOC", sizeof("PARSE_SOLR_DOC")-1, 1L TSRMLS_CC); } /* }}} */ /* {{{ void solr_query_register_class_constants(zend_class_entry *ce TSRMLS_DC) */ PHP_SOLR_API void solr_query_register_class_constants(zend_class_entry *ce TSRMLS_DC) { zend_declare_class_constant_long(ce, "ORDER_ASC", sizeof("ORDER_ASC")-1, SOLR_SORT_DIR_ASC TSRMLS_CC); zend_declare_class_constant_long(ce, "ORDER_DESC", sizeof("ORDER_DESC")-1, SOLR_SORT_DIR_DESC TSRMLS_CC); zend_declare_class_constant_long(ce, "FACET_SORT_INDEX", sizeof("FACET_SORT_INDEX")-1, 0L TSRMLS_CC); zend_declare_class_constant_long(ce, "FACET_SORT_COUNT", sizeof("FACET_SORT_COUNT")-1, 1L TSRMLS_CC); zend_declare_class_constant_long(ce, "TERMS_SORT_INDEX", sizeof("TERMS_SORT_INDEX")-1, 0L TSRMLS_CC); zend_declare_class_constant_long(ce, "TERMS_SORT_COUNT", sizeof("TERMS_SORT_COUNT")-1, 1L TSRMLS_CC); } /* }}} */ /** ************************************************************************ **/ /** UTILITY FUNCTIONS **/ /** ************************************************************************ **/ /* {{{ int solr_hashtable_get_new_index(HashTable *ht TSRMLS_DC) Retrieves a unique index for this HashTable */ PHP_SOLR_API int solr_hashtable_get_new_index(HashTable *ht TSRMLS_DC) { int new_index = SOLR_GET_RANDOM_NUMBER(); /* If the key already exists in the HashTable, create another one. */ while(zend_hash_index_exists(ht, new_index)) { new_index = SOLR_GET_RANDOM_NUMBER(); } return new_index; } /* }}} */ /* {{{ static inline int solr_fetch_document_entry(zval *objptr, solr_document_t **doc_entry TSRMLS_DC) Retrieves a Document from the HashTable */ PHP_SOLR_API int solr_fetch_document_entry(zval *objptr, solr_document_t **doc_entry TSRMLS_DC) { zval *rv = NULL; zval *id = zend_read_property(Z_OBJCE_P(objptr), objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, 1, rv); /* Retrieving the value of the document index from the zval */ long int document_index = Z_LVAL_P(id); *doc_entry = NULL; /* Retrieve the doc_entry from the HashTable */ if ((*doc_entry = (solr_document_t *)zend_hash_index_find_ptr(SOLR_GLOBAL(documents), document_index)) == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Document Index %ld. HashTable index does not exist.", document_index); php_error_docref(NULL TSRMLS_CC, E_WARNING, SOLR_ERROR_1008_MSG, SOLR_FILE_LINE_FUNC); return FAILURE; } return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API int solr_fetch_client_entry(zval *objptr, solr_client_t **solr_client TSRMLS_DC) */ PHP_SOLR_API int solr_fetch_client_entry(zval *objptr, solr_client_t **solr_client TSRMLS_DC) { zval rv; zval *id = zend_read_property(solr_ce_SolrClient, objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, 1, &rv); /* Retrieving the value of the client index from the zval */ long int client_index = Z_LVAL_P(id); *solr_client = NULL; /* Retrieve the doc_entry from the HashTable */ if ((*solr_client = zend_hash_index_find_ptr(SOLR_GLOBAL(clients), client_index)) == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid SolrClient Index %ld. HashTable index does not exist.", client_index); php_error_docref(NULL TSRMLS_CC, E_WARNING, SOLR_ERROR_1008_MSG, SOLR_FILE_LINE_FUNC); return FAILURE; } return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API int solr_fetch_params_entry(zval *objptr, solr_params_t **solr_params TSRMLS_DC) */ PHP_SOLR_API int solr_fetch_params_entry(zval *objptr, solr_params_t **solr_params TSRMLS_DC) { zval rv; zval *id = zend_read_property(Z_OBJCE_P(objptr), objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, 1, &rv); long int params_index = Z_LVAL_P(id); *solr_params = NULL; if ((*solr_params = zend_hash_index_find_ptr(SOLR_GLOBAL(params), params_index)) == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid SolrParams Index %ld. HashTable index does not exist.", params_index); php_error_docref(NULL TSRMLS_CC, E_WARNING, SOLR_ERROR_1008_MSG, SOLR_FILE_LINE_FUNC); return FAILURE; } return SUCCESS; } /* }}} */ PHP_SOLR_API int solr_fetch_function_entry(zval *objptr, solr_function_t **solr_function TSRMLS_DC) { zval rv; zval *id = zend_read_property(Z_OBJCE_P(objptr), objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, 1, &rv); long int params_index = Z_LVAL_P(id); *solr_function = NULL; if ((*solr_function = zend_hash_index_find_ptr(SOLR_GLOBAL(functions), params_index)) == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid solr_function Index %ld. HashTable index does not exist.", params_index); php_error_docref(NULL TSRMLS_CC, E_WARNING, SOLR_ERROR_1008_MSG, SOLR_FILE_LINE_FUNC); return FAILURE; } return SUCCESS; } /* {{{ PHP_SOLR_API void solr_destroy_function(zval *solr_function) */ PHP_SOLR_API void solr_destroy_function(zval *solr_function) { solr_function_t *function = (solr_function_t *) Z_PTR_P(solr_function); zend_hash_destroy(function->params); pefree(function->params, SOLR_FUNCTIONS_PERSISTENT); #ifdef PHP_7 pefree(function, SOLR_FUNCTIONS_PERSISTENT); #endif } /* }}} */ /* {{{ PHP_SOLR_API xmlDocPtr solr_xml_create_xml_doc(const xmlChar *root_node_name, xmlNode **root_node_ptr) */ PHP_SOLR_API xmlDocPtr solr_xml_create_xml_doc(const xmlChar *root_node_name, xmlNode **root_node_ptr) { xmlNs *ns = NULL; xmlDoc *doc_ptr = xmlNewDoc((xmlChar *) "1.0"); xmlNode *root_node = xmlNewNode(ns, root_node_name); xmlDocSetRootElement(doc_ptr, root_node); if (root_node_ptr) { *root_node_ptr = root_node; } return doc_ptr; } /* }}} */ /** * escapes strings with characters that are part of the Lucene query syntax * * @sbuilder is a solr_string_t pointer used to store the escape char sequence * @unescaped is the unescaped string. It must be null terminated * @unescaped_length is the original length of the unescaped_string */ /* {{{ PHP_SOLR_API void solr_escape_query_chars(solr_string_t *sbuilder, solr_char_t *unescaped, long int unescaped_length) */ PHP_SOLR_API void solr_escape_query_chars(solr_string_t *sbuilder, solr_char_t *unescaped, long int unescaped_length) { register int i = 0; /** * Lucene supports escaping special characters that are part of the query syntax. * * The current list special characters are * + - && || ! ( ) { } [ ] ^ " ~ * ? : \ / * * These characters are part of the query syntax and must be escaped */ for (i = 0; i < unescaped_length; i++) { enter_switchboard : switch(unescaped[i]) { case '\\' : case '+' : case '-' : case '!' : case '(' : case ')' : case ':' : case '/' : case '^' : case '[' : case ']' : case '"' : case '{' : case '}' : case '~' : case '*' : case '?' : case ';' : { solr_string_appendc(sbuilder, '\\'); } break; case '|' : /* || */ { if ('|' == unescaped[i+1]) { solr_string_appendc(sbuilder, '\\'); solr_string_append_const(sbuilder, "||"); i += 2; goto enter_switchboard; } } break; case '&' : /* && */ { if ('&' == unescaped[i+1]) { solr_string_appendc(sbuilder, '\\'); solr_string_append_const(sbuilder, "&&"); i += 2; goto enter_switchboard; } } break; default : /* The current character is not a special character */ { /* Do nothing. Just append the character as is */ } } /* END switch(unescaped[i]) */ solr_string_appendc(sbuilder, unescaped[i]); } /* END for (i = 0; i < unescaped_length; i++) { */ } /* }}} */ /******************************************************************************/ /* SOLR XML RESPONSE DIGEST DATA TYPES AND FUNCTIONS */ /******************************************************************************/ /* {{{ solr_doc_encode_t, solr_php_encode_t, solr_encoding_type_t, solr_php_encode_func_t, solr_document_field_encode_func_t */ typedef enum { SOLR_DOC_ENCODE_START = 0, SOLR_DOC_ENCODE_FIELDS = 1, SOLR_DOC_ENCODE_FIELD = 2, SOLR_DOC_ENCODE_END } solr_doc_encode_t; typedef enum { SOLR_ENCODE_START = 0, SOLR_ENCODE_NULL = 1, SOLR_ENCODE_BOOL = 2, SOLR_ENCODE_INT = 3, SOLR_ENCODE_FLOAT = 4, SOLR_ENCODE_STRING = 5, SOLR_ENCODE_ARRAY = 6, SOLR_ENCODE_OBJECT = 7, SOLR_ENCODE_DOC = 8, SOLR_ENCODE_RESULT = 9, SOLR_ENCODE_END } solr_php_encode_t; typedef enum { SOLR_ENCODE_STANDALONE = 0, SOLR_ENCODE_OBJECT_PROPERTY = 1, SOLR_ENCODE_ARRAY_KEY = 2, SOLR_ENCODE_ARRAY_INDEX = 3 } solr_encoding_type_t; typedef void (*solr_php_encode_func_t)(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode); typedef void (*solr_document_field_encode_func_t)(const xmlNode *node, xmlNode *field); /* }}} */ /* {{{ Macros for XML transcoding */ /* Serializes the current XML node */ #define solr_encode_xml_node(__node, __buf, __enc_type, __arr_idx, __mode) solr_encoder_functions[solr_get_xml_type((__node))]((__node),(__buf), (__enc_type), (__arr_idx), (__mode)) #define solr_write_object_closer(__buf) solr_string_append_const((__buf), "}") #define solr_write_array_closer(__buf) solr_string_append_const((__buf), "}") #define solr_write_root_object_closer(__buf) solr_string_append_const((__buf), "}") /* }}} */ /* {{{ static void solr_encode_* prototypes */ static void solr_encode_null(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode); static void solr_encode_bool(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode); static void solr_encode_int(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode); static void solr_encode_float(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode); static void solr_encode_string(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode); static void solr_encode_array(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode); static void solr_encode_object(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode); static void solr_encode_document(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode); static void solr_encode_result(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode); static void solr_encode_document_field_simple(const xmlNode *fieldNode, xmlNode *field); static void solr_encode_document_field_complex(const xmlNode *fieldNode, xmlNode *field); /* }}} */ /* {{{ global variables solr_encoder_functions[], solr_document_field_encoders[] */ static solr_php_encode_func_t solr_encoder_functions[] = { solr_encode_string, solr_encode_null, solr_encode_bool, solr_encode_int, solr_encode_float, solr_encode_string, solr_encode_array, solr_encode_object, solr_encode_document, solr_encode_result, NULL }; static solr_document_field_encode_func_t solr_document_field_encoders[] = { solr_encode_document_field_simple, /* maps to SOLR_SIMPLE_FIELD */ solr_encode_document_field_complex, /* maps to SOLR_COMPLEX_FIELD */ NULL }; /* }}} */ /* {{{ Constants and Macros for handling node types */ #define SOLR_SIMPLE_FIELD 0 #define SOLR_COMPLEX_FIELD 1 #define solr_xml_field_node_type(node) (xmlStrEqual((node)->name, (xmlChar *)"arr")? SOLR_COMPLEX_FIELD : SOLR_SIMPLE_FIELD) #define solr_encode_document_field(field_in, field_out) solr_document_field_encoders[solr_xml_field_node_type((field_in))]((field_in), (field_out)) /* }}} */ /* Used to figure out now many properties or elements there are in an object or an array */ /* {{{ static inline int solr_get_node_size(const xmlNode *data_node) */ static inline int solr_get_node_size(const xmlNode *data_node) { register int size = 0; xmlNode *curr_node = data_node->children; while(curr_node != NULL) { if (XML_ELEMENT_NODE == curr_node->type) { size++; } curr_node = curr_node->next; } return size; } /* }}} */ /* {{{ static inline int solr_get_xml_type(xmlNode *node) */ static inline int solr_get_xml_type(xmlNode *node) { solr_char_t *node_name = (solr_char_t *) node->name; if (!node_name) { return SOLR_ENCODE_STRING; } if (!strcmp(node_name, "str")) { return SOLR_ENCODE_STRING; } else if (!strcmp(node_name, "int") || !strcmp(node_name, "long") || !strcmp(node_name, "short") || !strcmp(node_name, "byte")) { return SOLR_ENCODE_INT; } else if (!strcmp(node_name, "double") || !strcmp(node_name, "float")) { return SOLR_ENCODE_FLOAT; } else if (!strcmp(node_name, "lst")) { return SOLR_ENCODE_OBJECT; } else if (!strcmp(node_name, "arr")) { return SOLR_ENCODE_ARRAY; } else if (!strcmp(node_name, "bool")) { return SOLR_ENCODE_BOOL; } else if (!strcmp(node_name, "null")) { return SOLR_ENCODE_NULL; } else if (!strcmp(node_name, "result")) { return SOLR_ENCODE_RESULT; }else if (!strcmp(node_name, "doc")) { return SOLR_ENCODE_OBJECT; } else { return SOLR_ENCODE_STRING; } } /* }}} */ /* {{{ static inline void solr_write_variable_opener(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index) */ static inline void solr_write_variable_opener(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index) { switch(enc_type) { case SOLR_ENCODE_OBJECT_PROPERTY : /* fall through */ case SOLR_ENCODE_ARRAY_KEY : { solr_char_t *object_name = "_undefined_property_name"; xmlAttr *name_attr = node->properties; /* get the contents of the name attribute */ if (name_attr) { object_name = (solr_char_t *) solr_xml_get_node_contents(name_attr); } solr_string_append_const(buffer, "s:"); solr_string_append_long(buffer, strlen(object_name)); solr_string_append_const(buffer, ":\""); solr_string_appends(buffer, object_name, strlen(object_name)); solr_string_append_const(buffer, "\";"); } break; case SOLR_ENCODE_ARRAY_INDEX : { solr_string_append_const(buffer, "i:"); solr_string_append_long(buffer, array_index); solr_string_appendc(buffer, ';'); } break; default : { /* do nothing */ } break; } } /* }}} */ /* {{{ static void solr_write_object_opener(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index) */ static void solr_write_object_opener(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index) { int size = solr_get_node_size(node); solr_write_variable_opener(node, buffer, enc_type, array_index); solr_string_append_const(buffer, "O:10:\"SolrObject\":"); solr_string_append_long(buffer, size); solr_string_append_const(buffer, ":{"); } /* }}} */ /* {{{ static void solr_write_solr_document_opener(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, int size) */ static void solr_write_solr_document_opener(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, int size) { solr_write_variable_opener(node, buffer, enc_type, array_index); solr_string_append_const(buffer, "C:12:\"SolrDocument\":"); solr_string_append_long(buffer, size); solr_string_append_const(buffer, ":{"); } /* }}} */ /* {{{ static void solr_write_array_opener(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index) */ static void solr_write_array_opener(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index) { int size = solr_get_node_size(node); solr_write_variable_opener(node, buffer, enc_type, array_index); solr_string_append_const(buffer, "a:"); solr_string_append_long(buffer, size); solr_string_append_const(buffer, ":{"); } /* }}} */ static void solr_serialize_solr_document(const xmlNode *node, solr_string_t *dest); static void solr_encode_solr_document_children(const xmlNode *node, xmlNode* builder_node, int child_docs_found); static void solr_encode_solr_document(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode); static void solr_serialize_solr_document(const xmlNode *node, solr_string_t *dest) { xmlChar *doc_txt_buffer = NULL; int doc_txt_len = 0; xmlNode *solr_document_node = NULL; xmlDoc *doc_ptr = solr_xml_create_xml_doc((xmlChar *) "solr_document", &solr_document_node); xmlNode *fields_node = xmlNewChild(solr_document_node, NULL, (xmlChar *) "fields", NULL); xmlNode *curr_node = node->children; int format = 1; int child_docs_found = 0; while(curr_node != NULL) { if (XML_ELEMENT_NODE == curr_node->type) { if (strcmp((const char *)curr_node->name, "doc") == 0) { child_docs_found++; } else { xmlNode *field = xmlNewChild(fields_node, NULL, (xmlChar *)"field", NULL); solr_encode_document_field(curr_node, field); } } curr_node = curr_node->next; } if (child_docs_found > 0) { solr_encode_solr_document_children(node, solr_document_node, child_docs_found); } /* We have written all the fields to the document */ /* Dumping the document from memory to the buffer */ xmlDocDumpFormatMemoryEnc(doc_ptr, &doc_txt_buffer, &doc_txt_len, "UTF-8", format); solr_string_appends_ex(dest, (solr_char_t *)doc_txt_buffer, doc_txt_len); xmlFreeDoc(doc_ptr); xmlFree(doc_txt_buffer); } /* {{{ static void solr_encode_document_children(const xmlNode *node, solr_string_t* buffer, int child_docs_found, long int parse_mode) encodes the doc/doc child/nested documents */ static void solr_encode_solr_document_children(const xmlNode *node, xmlNode* builder_node, int child_docs_found) { int current_index = 0; xmlXPathContext *xpathctxt = NULL; const xmlChar *xpath_expression = (xmlChar *) "child::doc"; xmlXPathObject *xpathObj = NULL; xmlNodeSet *result = NULL; xmlNode *child_docs_node = NULL; xpathctxt = xmlXPathNewContext(node->doc); xpathctxt->node = (xmlNodePtr) node; xpathObj = xmlXPathEval(xpath_expression, xpathctxt); result = xpathObj->nodesetval; child_docs_found = result->nodeNr; child_docs_node = xmlNewChild(builder_node, NULL, (xmlChar *)"child_docs", NULL); for (current_index=0; current_index < child_docs_found; current_index++) { zend_string *encoded_str = NULL; solr_string_t tmp_buffer; solr_string_t tmp_s_buffer; memset(&tmp_buffer, 0, sizeof(solr_string_t)); memset(&tmp_s_buffer, 0, sizeof(solr_string_t)); solr_serialize_solr_document(result->nodeTab[current_index], &tmp_buffer); solr_string_append_const(&tmp_s_buffer, "C:12:\"SolrDocument\":"); solr_string_append_long(&tmp_s_buffer, tmp_buffer.len); solr_string_append_const(&tmp_s_buffer, ":{"); solr_string_appends_ex(&tmp_s_buffer, tmp_buffer.str, tmp_buffer.len); solr_write_object_closer(&tmp_s_buffer); encoded_str = php_base64_encode((const unsigned char*)tmp_s_buffer.str, tmp_s_buffer.len); xmlNewChild(child_docs_node, NULL, (const xmlChar *) "dochash", (xmlChar *)encoded_str->val); solr_string_free_ex(&tmp_buffer); solr_string_free_ex(&tmp_s_buffer); zend_string_free(encoded_str); } } /* }}} */ /** * * The @enc_type parameter must be SOLR_ENCODE_ARRAY_INDEX */ /* {{{ static void solr_encode_solr_document(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) */ static void solr_encode_solr_document(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) { solr_string_t doc_serialized_buffer; memset(&doc_serialized_buffer, 0, sizeof(solr_string_t)); solr_serialize_solr_document(node, &doc_serialized_buffer); solr_write_solr_document_opener(NULL, buffer, enc_type, array_index, doc_serialized_buffer.len); solr_string_appends(buffer, (char *) doc_serialized_buffer.str, doc_serialized_buffer.len); solr_write_object_closer(buffer); solr_string_free(&doc_serialized_buffer); } /* }}} */ /* {{{ static void solr_write_object_opener(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index) */ static void solr_write_object_opener_child_doc(const xmlNode *node, int num_child_docs ,solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index) { int size = solr_get_node_size(node) - num_child_docs + 1; solr_write_variable_opener(node, buffer, enc_type, array_index); solr_string_append_const(buffer, "O:10:\"SolrObject\":"); solr_string_append_long(buffer, size); solr_string_append_const(buffer, ":{"); } /* }}} */ /* {{{ static void solr_encode_document_children(const xmlNode *node, solr_string_t* buffer, int child_docs_found, long int parse_mode) encodes the doc/doc child/nested documents ONLY FOR SolrObject */ static void solr_encode_document_children(const xmlNode *node, solr_string_t* buffer, int child_docs_found, long int parse_mode) { int current_index = 0; xmlXPathContext *xpathctxt = NULL; const xmlChar *xpath_expression = (xmlChar *) "child::doc"; xmlXPathObject *xpathObj = NULL; xmlNodeSet *result = NULL; solr_php_encode_func_t document_encoder_functions[] = { solr_encode_document, solr_encode_solr_document, NULL }; solr_string_append_const(buffer, "s:"); solr_string_append_long(buffer, sizeof("_childDocuments_")-1); solr_string_append_const(buffer, ":\""); solr_string_appends(buffer, "_childDocuments_", sizeof("_childDocuments_")-1); solr_string_append_const(buffer, "\";"); solr_string_append_const(buffer, "a:"); solr_string_append_long(buffer, child_docs_found); solr_string_append_const(buffer, ":{"); xpathctxt = xmlXPathNewContext(node->doc); xpathctxt->node = (xmlNodePtr) node; xpathObj = xmlXPathEval(xpath_expression, xpathctxt); result = xpathObj->nodesetval; child_docs_found = result->nodeNr; for (current_index=0; current_index < child_docs_found; current_index++) { document_encoder_functions[parse_mode](result->nodeTab[current_index], buffer, SOLR_ENCODE_ARRAY_INDEX, current_index, parse_mode); } solr_write_array_closer(buffer); } /* }}} */ /* {{{ static void solr_encode_document(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) encodes/serializes the element result/doc */ static void solr_encode_document(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) { xmlNode *curr_node = NULL; int child_docs_found = 0; solr_string_t inner_buffer; memset(&inner_buffer, 0, sizeof(solr_string_t)); curr_node = node->children; while(curr_node != NULL) { if (XML_ELEMENT_NODE == curr_node->type) { if (strcmp((const char*) curr_node->name, "doc") == 0) { /* skip doc/doc elements to be processed later */ child_docs_found++; } else { solr_encode_xml_node(curr_node, &inner_buffer, SOLR_ENCODE_OBJECT_PROPERTY, 0L, parse_mode); } } curr_node = curr_node->next; } if (child_docs_found > 0){ solr_encode_document_children(node, &inner_buffer, child_docs_found, parse_mode); /** * write and calculate proper object opener * because the object number of properties depends on whether there are child documents involved */ solr_write_object_opener_child_doc(node, child_docs_found, buffer, enc_type, array_index); } else { solr_write_object_opener(node, buffer, enc_type, array_index); } solr_string_appends_ex(buffer, inner_buffer.str, inner_buffer.len); solr_write_object_closer(buffer); solr_string_free_ex(&inner_buffer); } /* }}} */ /** * Handles simple data types like strings, integers, booleans etc. */ /* {{{ static void solr_encode_document_field_simple(const xmlNode *fieldNode, xmlNode *field) */ static void solr_encode_document_field_simple(const xmlNode *fieldNode, xmlNode *field) { xmlChar *fieldname = solr_xml_get_node_contents(fieldNode->properties); xmlChar *field_value = xmlEncodeEntitiesReentrant(fieldNode->doc, solr_xml_get_node_contents(fieldNode)); xmlNewChild(field, NULL, (xmlChar *) "field_value", field_value); xmlNewProp(field, (xmlChar *) "name", fieldname); xmlFree(field_value); } /* }}} */ /* Handles complex data types like arrays */ /* {{{ static void solr_encode_document_field_complex(const xmlNode *fieldNode, xmlNode *field) */ static void solr_encode_document_field_complex(const xmlNode *fieldNode, xmlNode *field) { xmlChar *fieldname = solr_xml_get_node_contents(fieldNode->properties); xmlNode *current_value = fieldNode->children; while(current_value != NULL) { if (current_value->type == XML_ELEMENT_NODE) { xmlChar *field_value = xmlEncodeEntitiesReentrant(fieldNode->doc, solr_xml_get_node_contents(current_value)); xmlNewChild(field, NULL, (xmlChar *) "field_value", field_value); xmlFree(field_value); } current_value = current_value->next; } xmlNewProp(field, (xmlChar *) "name", fieldname); } /* }}} */ /* {{{ static void solr_encode_result(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) */ static void solr_encode_result(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) { xmlAttr *properties = node->properties; solr_char_t *object_name = (solr_char_t *) node->name; solr_char_t *num_found = NULL; solr_char_t *start = NULL; solr_char_t *max_score = NULL; solr_php_encode_func_t document_encoder_functions[] = { solr_encode_document, solr_encode_solr_document, NULL }; xmlAttr *curr_prop = properties; xmlXPathContext *xpathctxt = NULL; const xmlChar *xpath_expression = (xmlChar *) "child::doc"; xmlXPathObject *xpathObj = NULL; xmlNodeSet *result = NULL; long int document_count = 0; while(curr_prop != NULL) { if (solr_xml_match_node(curr_prop, "numFound")) { num_found = (solr_char_t *) solr_xml_get_node_contents(curr_prop); } if (solr_xml_match_node(curr_prop, "start")) { start = (solr_char_t *) solr_xml_get_node_contents(curr_prop); } if (solr_xml_match_node(curr_prop, "name")) { object_name = (solr_char_t *) solr_xml_get_node_contents(curr_prop); } if (solr_xml_match_node(curr_prop, "maxScore")) { max_score = (solr_char_t *) solr_xml_get_node_contents(curr_prop); } curr_prop = curr_prop->next; } xpathctxt = xmlXPathNewContext(node->doc); xpathctxt->node = (xmlNodePtr) node; xpathObj = xmlXPathEval(xpath_expression, xpathctxt); result = xpathObj->nodesetval; document_count = result->nodeNr; solr_string_append_const(buffer, "s:"); solr_string_append_long(buffer, strlen(object_name)); solr_string_append_const(buffer, ":\""); solr_string_appends(buffer, object_name, strlen(object_name)); solr_string_append_const(buffer, "\";"); solr_string_append_const(buffer, "O:10:\"SolrObject\":"); if (max_score) { solr_string_append_long(buffer, 4); /* numFound, start, docs, maxScore properties */ } else { solr_string_append_long(buffer, 3); /* numFound, start, docs properties */ } solr_string_append_const(buffer, ":{"); /* Object Opener for response */ /* Writing the numFound property */ solr_string_append_const(buffer, "s:"); solr_string_append_long(buffer, sizeof("numFound")-1); solr_string_append_const(buffer, ":\""); solr_string_appends(buffer, "numFound", sizeof("numFound")-1); solr_string_append_const(buffer, "\";"); solr_string_append_const(buffer, "i:"); solr_string_appends(buffer, num_found, solr_strlen(num_found)); solr_string_appendc(buffer, ';'); /* Writing the start property */ solr_string_append_const(buffer, "s:"); solr_string_append_long(buffer, sizeof("start")-1); solr_string_append_const(buffer, ":\""); solr_string_appends(buffer, "start", sizeof("start")-1); solr_string_append_const(buffer, "\";"); solr_string_append_const(buffer, "i:"); solr_string_appends(buffer, start, solr_strlen(start)); solr_string_appendc(buffer, ';'); /* writing max score property */ if (max_score) { solr_string_append_const(buffer, "s:"); solr_string_append_long(buffer, sizeof("maxScore")-1); solr_string_append_const(buffer, ":\""); solr_string_appends(buffer, "maxScore", sizeof("maxScore")-1); solr_string_append_const(buffer, "\";"); solr_string_append_const(buffer, "d:"); solr_string_appends(buffer, max_score, solr_strlen(max_score)); solr_string_appendc(buffer, ';'); } /* Writing the docs property */ solr_string_append_const(buffer, "s:"); solr_string_append_long(buffer, sizeof("docs")-1); solr_string_append_const(buffer, ":\""); solr_string_appends(buffer, "docs", sizeof("docs")-1); solr_string_append_const(buffer, "\";"); if (document_count) { /* Grab all the first /response/result/doc node */ xmlNode *curr_doc = node->children; long int curr_doc_index = 0L; /* Array opener */ solr_string_append_const(buffer, "a:"); solr_string_append_long(buffer, document_count); solr_string_append_const(buffer, ":{"); while(curr_doc != NULL) { /* Absolutely no assumptions. At least for now. */ if (XML_ELEMENT_NODE == curr_doc->type && solr_xml_match_node(curr_doc, "doc")) { /* This is where you decided whether to use SolrDocument or StdClass */ /* parse_mode value of 0 creates SolrObject; 1 creates SolrDocument */ document_encoder_functions[parse_mode](curr_doc, buffer, SOLR_ENCODE_ARRAY_INDEX, curr_doc_index, parse_mode); curr_doc_index++; } curr_doc = curr_doc->next; } solr_write_array_closer(buffer); /* Array closer */ } else { solr_string_append_const(buffer, "b:0;"); /* This means there are no docs */ } solr_write_object_closer(buffer); /* Object closer */ xmlXPathFreeContext(xpathctxt); xmlXPathFreeObject(xpathObj); } /* }}} */ /* {{{ static void solr_encode_null(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) */ static void solr_encode_null(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) { /* SolrObject should not contain nulls because of how magic functionality is implemented */ solr_write_variable_opener(node, buffer, enc_type, array_index); /* Setting nulls to boolean false */ solr_string_append_const(buffer, "b:0;"); } /* }}} */ /* {{{ static void solr_encode_bool(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) */ static void solr_encode_bool(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) { solr_char_t *data_value = (solr_char_t *) solr_xml_get_node_contents(node); long int boolean_value = (!strcmp("true", data_value))? 1 : 0; solr_write_variable_opener(node, buffer, enc_type, array_index); solr_string_append_const(buffer, "b:"); solr_string_append_long(buffer, boolean_value); solr_string_appendc(buffer, ';'); } /* }}} */ /* {{{ static void solr_encode_int(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) */ static void solr_encode_int(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) { solr_char_t *data_value = (solr_char_t *) solr_xml_get_node_contents(node); size_t data_value_len = solr_strlen(data_value); solr_write_variable_opener(node, buffer, enc_type, array_index); solr_string_append_const(buffer, "i:"); solr_string_appends(buffer, data_value, data_value_len); solr_string_appendc(buffer, ';'); } /* }}} */ /* {{{ static void solr_encode_float(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) */ static void solr_encode_float(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) { solr_char_t *data_value = (solr_char_t *) solr_xml_get_node_contents(node); size_t data_value_len = solr_strlen(data_value); solr_write_variable_opener(node, buffer, enc_type, array_index); solr_string_append_const(buffer, "d:"); if (strcmp(data_value, "NaN" ) == 0) { data_value = (solr_char_t *)"NAN"; } solr_string_appends(buffer, data_value, data_value_len); solr_string_appendc(buffer, ';'); } /* }}} */ /* {{{ static void solr_encode_string(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) */ static void solr_encode_string(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) { solr_char_t *data_value = (solr_char_t *) solr_xml_get_node_contents(node); size_t data_value_len = solr_strlen(data_value); solr_write_variable_opener(node, buffer, enc_type, array_index); solr_string_append_const(buffer, "s:"); solr_string_append_long(buffer, data_value_len); solr_string_append_const(buffer, ":\""); solr_string_appends(buffer, data_value, data_value_len); solr_string_append_const(buffer, "\";"); } /* }}} */ /* {{{ static void solr_encode_array(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) */ static void solr_encode_array(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) { xmlNode *curr_node = NULL; long int current_index = 0L; solr_write_array_opener(node, buffer, enc_type, array_index); curr_node = node->children; while(curr_node != NULL) { if (XML_ELEMENT_NODE == curr_node->type) { solr_encode_xml_node(curr_node, buffer, SOLR_ENCODE_ARRAY_INDEX, current_index, parse_mode); current_index++; } curr_node = curr_node->next; } solr_write_array_closer(buffer); } /* }}} */ /* {{{ static void solr_encode_object(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) */ static void solr_encode_object(const xmlNode *node, solr_string_t *buffer, solr_encoding_type_t enc_type, long int array_index, long int parse_mode) { xmlNode *curr_node = NULL; solr_write_object_opener(node, buffer, enc_type, array_index); curr_node = node->children; while(curr_node != NULL) { if (XML_ELEMENT_NODE == curr_node->type) { solr_encode_xml_node(curr_node, buffer, SOLR_ENCODE_OBJECT_PROPERTY, 0L, parse_mode); } curr_node = curr_node->next; } solr_write_object_closer(buffer); } /* }}} */ /** * Used to digest Xml response messages from Solr * */ /* {{{ PHP_SOLR_API void solr_encode_generic_xml_response(solr_string_t *buffer, const solr_char_t *serialized, int size, long int parse_mode TSRMLS_DC) */ PHP_SOLR_API void solr_encode_generic_xml_response(solr_string_t *buffer, const solr_char_t *serialized, int size, long int parse_mode TSRMLS_DC) { xmlDoc *doc = xmlReadMemory(serialized, size, NULL, "UTF-8", XML_PARSE_RECOVER); xmlNode *root = NULL; if (!doc) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error loading XML document"); return; } root = xmlDocGetRootElement(doc); if (!root) { xmlFreeDoc(doc); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error loading root of XML document"); return; } parse_mode = ((parse_mode < 0L) ? 0L : ((parse_mode > 1L) ? 1L : parse_mode)); solr_encode_object(root, buffer, SOLR_ENCODE_STANDALONE, 0L, parse_mode); if (buffer->len == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error parsing XML document"); } xmlFreeDoc(doc); } /* }}} */ /* {{{ PHP_SOLR_API int solr_is_supported_response_writer(const solr_char_t * response_writer, int length) */ PHP_SOLR_API int solr_is_supported_response_writer(const solr_char_t * response_writer, int length) { if (length < 1) { return 0; } if (0 == strcmp(response_writer, SOLR_PHP_SERIALIZED_RESPONSE_WRITER)) { return 1; } if (0 == strcmp(response_writer, SOLR_XML_RESPONSE_WRITER)) { return 1; } if (0 == strcmp(response_writer, SOLR_JSON_RESPONSE_WRITER)) { return 1; } return 0; } /* }}} */ /* {{{ PHP_SOLR_API solr_char_t *solr_get_json_error_msg(solr_json_error_codes_t error_code) */ PHP_SOLR_API solr_char_t *solr_get_json_error_msg(solr_json_error_codes_t error_code) { switch(error_code) { case SOLR_JSON_ERROR_DEPTH: return "JSON maximum recursion depth was exceeded"; break; case SOLR_JSON_ERROR_STATE_MISMATCH: return "JSON error state mismatch"; break; case SOLR_JSON_ERROR_CTRL_CHAR: return "JSON control character was encountered"; break; case SOLR_JSON_ERROR_SYNTAX: return "JSON syntax error"; break; case SOLR_JSON_ERROR_UTF8: return "JSON UTF8 error"; break; default : return "JSON unknown error"; break; } } /* }}} */ /* {{{ PHP_SOLR_API int solr_json_to_php_native(solr_string_t *buffer, const solr_char_t *json_string, int json_string_length TSRMLS_DC) */ PHP_SOLR_API int solr_json_to_php_native(solr_string_t *buffer, const solr_char_t *json_string, int json_string_length TSRMLS_DC) { /* todo php7 review if we ever need that indirection with ret_val */ /* JSON recursion depth. default is 512 */ long recursion_depth = 1024L; long json_error = 0L; php_serialize_data_t var_hash; smart_str serialize_buffer = {0}; /* return value for the function */ zval json_decode_ret_val, *json_decode_ret_val_ptr; zend_uchar json_decode_ret_val_type = IS_NULL; json_decode_ret_val_ptr = &json_decode_ret_val; php_json_decode(&json_decode_ret_val, (char *) json_string, json_string_length, 1, recursion_depth TSRMLS_CC); json_error = solr_get_json_last_error(TSRMLS_C); /* Why ? todo investigate */ /* solr_string_set(buffer, "i:99;", sizeof("i:99;")); */ if (json_error > 0) { zval_dtor(&json_decode_ret_val); php_error_docref(NULL TSRMLS_CC, E_WARNING, "JSON error. JSON->PHP serialization error"); return (int) json_error; } memset(&var_hash, 0, sizeof(php_serialize_data_t)); PHP_VAR_SERIALIZE_INIT(var_hash); php_var_serialize(&serialize_buffer, &json_decode_ret_val, &var_hash TSRMLS_CC); json_decode_ret_val_type = Z_TYPE_P(json_decode_ret_val_ptr); zval_dtor(&json_decode_ret_val); solr_string_set(buffer, serialize_buffer.s->val, serialize_buffer.s->len); PHP_VAR_SERIALIZE_DESTROY(var_hash); smart_str_free(&serialize_buffer); /* return value should not be of NULL type. NULL means an error has occurred */ if (json_decode_ret_val_type == IS_NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "JSON error. Error occurred in php_json_decode(). Raw JSON string is \n %s \n", (char *) json_string); /* json_error always fails to detect an error. * todo investigate */ return (int) SOLR_JSON_ERROR_SERIALIZATION; } return (int) json_error; } /* }}} */ PHP_SOLR_API long solr_get_json_last_error(TSRMLS_D) { long json_error; zval json_last_error_ret_val, *object_p; zval *json_last_error_params = NULL; zval json_last_error_function_name; ZVAL_STRING(&json_last_error_function_name, "json_last_error"); /* object instance to perform the method call */ object_p = (zval *) NULL; call_user_function(EG(function_table), object_p, &json_last_error_function_name, &json_last_error_ret_val, 0, json_last_error_params TSRMLS_CC); json_error = Z_LVAL(json_last_error_ret_val); zval_dtor(&json_last_error_ret_val); #ifdef PHP_7 zval_dtor(&json_last_error_function_name); #endif return json_error; } static inline int solr_pcre_replace_into_buffer(solr_string_t *buffer, char * search, char *replace) { zend_string *result; zval replace_val; int limit = -1; int replace_count = -1; zend_string *regex_str = zend_string_init(search, strlen(search), 0); zend_string *subject_str = zend_string_init(buffer->str, buffer->len, 0); ZVAL_STRING(&replace_val, replace); result = php_pcre_replace( regex_str, subject_str, buffer->str, buffer->len, &replace_val, 0, limit, &replace_count ); solr_string_set_ex(buffer, (solr_char_t *)result->val, (size_t)result->len); /* fprintf(stdout, "%s", buffer->str); */ efree(result); zval_ptr_dtor(&replace_val); zend_string_release(regex_str); zend_string_release(subject_str); return SUCCESS; } /* serialized array to serialized object */ PHP_SOLR_API int solr_sarray_to_sobject(solr_string_t *buffer TSRMLS_DC) { return solr_pcre_replace_into_buffer(buffer, "/a\\:([0-9]+):{s/i", "O:10:\"SolrObject\":\\1:{s"); } /* serialized object to serialized array */ PHP_SOLR_API int solr_sobject_to_sarray(solr_string_t *buffer TSRMLS_DC) { return solr_pcre_replace_into_buffer(buffer, "/O:10:\"SolrObject\":([0-9]+):{s/i", "a:\\1:{s"); } /* }}} */ /* todo document and block this */ PHP_SOLR_API int solr_solrfunc_update_string(zval *obj, solr_char_t *key, int key_len, solr_char_t *value, int value_len TSRMLS_DC) { solr_function_t *function; solr_string_t *string; #ifdef PHP_7 string = pemalloc(sizeof(solr_string_t), SOLR_FUNCTIONS_PERSISTENT); #endif memset(string, 0, sizeof(solr_string_t)); if (solr_fetch_function_entry(obj, &function TSRMLS_CC) == FAILURE) { return FAILURE; } solr_string_set(string, (solr_char_t *)value, value_len); if (zend_hash_str_update_ptr(function->params, key, key_len, (void *)string) == NULL ) { solr_string_free(string); return FAILURE; } return SUCCESS; } PHP_SOLR_API int solr_solrfunc_fetch_string(zval *obj, solr_char_t *key, int key_len, solr_string_t **string TSRMLS_DC) { solr_function_t *function; if (solr_fetch_function_entry(obj, &function TSRMLS_CC) == FAILURE) { return FAILURE; } if ((*string = zend_hash_str_find_ptr(function->params, key, key_len)) == NULL) { return FAILURE; } return SUCCESS; } PHP_SOLR_API int solr_solrfunc_display_string(zval *obj, solr_char_t *key, int key_len, zval **return_value TSRMLS_DC) { solr_string_t *field_string_ptr = NULL; memset(&field_string_ptr, 0, sizeof(solr_string_t *)); if (solr_solrfunc_fetch_string(obj, key, key_len, &field_string_ptr TSRMLS_CC) == SUCCESS) { ZVAL_STRINGL(*return_value, field_string_ptr->str, field_string_ptr->len); return SUCCESS; } else { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to fetch string"); return FAILURE; } } PHP_SOLR_API void solr_solrfunc_to_string(solr_function_t *function, solr_string_t **dest) { solr_string_t *buffer = *dest; solr_string_appends(buffer, (solr_char_t *)"{!", sizeof("{!")-1); solr_string_appends(buffer, function->name, function->name_length); solr_string_appendc(buffer, ' '); solr_string_t *value; zend_string *key; ulong num_idx; ZEND_HASH_FOREACH_KEY_PTR(function->params, num_idx, key, value) { (void)num_idx; /* silent -Wunused-but-set-variable */ /* key is only maintained internally */ if (key) { solr_string_appends(buffer, key->val, key->len-1); } solr_string_appendc(buffer, '='); if (strpbrk(value->str, " ") != NULL && strpbrk(value->str,"'") == NULL) { solr_string_appendc(buffer, '\''); solr_string_append_solr_string (buffer, value); solr_string_appendc(buffer, '\''); } else { solr_string_append_solr_string (buffer, value); } solr_string_appendc(buffer, ' '); } ZEND_HASH_FOREACH_END(); solr_string_remove_last_char(buffer); solr_string_appendc(buffer, '}'); /* todo handle localParams argument */ } /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/solr_functions_params.c0000644000175000017500000013001612676753707017422 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: | | Israel Ekpo | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" PHP_SOLR_API int solr_init_params(solr_params_t *solr_params, long int index) { uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE; solr_params = (solr_params_t *)pemalloc( sizeof(solr_params_t), SOLR_PARAMS_PERSISTENT); memset(solr_params, 0, sizeof(solr_params_t)); if ((solr_params = zend_hash_index_update_ptr(SOLR_GLOBAL(params), index, (void *) solr_params)) == NULL) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error while registering query parameters in HashTable"); return FAILURE; } solr_params->params_index = index; solr_params->params_count = 0U; /* Allocated memory for the parameters HashTable using fast cache for HashTables */ ALLOC_HASHTABLE(solr_params->params); zend_hash_init(solr_params->params, nSize, NULL, (dtor_func_t) solr_destory_param_ht_dtor, SOLR_PARAMS_PERSISTENT); return SUCCESS; } /* {{{ PHP_SOLR_API void solr_destroy_params(zval *solr_params) */ PHP_SOLR_API void solr_destroy_params(zval *solr_params) { solr_params_t *params = (solr_params_t *) Z_PTR_P(solr_params); zend_hash_destroy(params->params); pefree(params->params, SOLR_PARAMS_PERSISTENT); pefree(params, SOLR_PARAMS_PERSISTENT); } /* }}} */ /* {{{ PHP_SOLR_API void solr_destroy_param(solr_param_t **param) */ PHP_SOLR_API void solr_destroy_param(solr_param_t **param) { solr_param_value_t *temp_ptr = NULL; solr_param_value_t *current_ptr = (*param)->head; while(current_ptr != NULL) { temp_ptr = current_ptr->next; (*param)->value_free_func(current_ptr); current_ptr = temp_ptr; } (*param)->head = NULL; (*param)->last = NULL; pefree((*param)->param_name, SOLR_PARAMS_PERSISTENT); (*param)->param_name = NULL; pefree((*param), SOLR_PARAMS_PERSISTENT); (*param) = NULL; } /* }}} */ PHP_SOLR_API void solr_destory_param_ht_dtor(zval *param_zv) { solr_param_t *param = (solr_param_t *) Z_PTR_P(param_zv); solr_destroy_param(¶m); } /* {{{ PHP_SOLR_API int solr_params_delete_param_value(solr_param_t *param, const solr_param_value_t *target_value TSRMLS_DC) */ PHP_SOLR_API int solr_params_delete_param_value(solr_param_t *param, const solr_param_value_t *target_value TSRMLS_DC) { solr_param_value_t *curr_value = param->head; int match_found = 0; if (!target_value) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Invalid pointer. Submitted target cannot be used for the delete search\n"); return FAILURE; } while(!match_found && curr_value != NULL) { match_found = param->value_equal_func(curr_value, target_value); /* If the target was found */ if (match_found) { /* If the target is not the head */ if (curr_value->prev) { curr_value->prev->next = curr_value->next; } else { param->head = curr_value->next; } /* If the target is not the tail */ if (curr_value->next) { curr_value->next->prev = curr_value->prev; } else { param->last = curr_value->prev; } /* Destroy target value */ param->value_free_func(curr_value); goto dpv_end; } curr_value = curr_value->next; } dpv_end : if (!match_found) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Target parameter value could not be found in '%s'. No value was deleted ", param->param_name); return FAILURE; } param->count--; /* Reduce the value count by one */ return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API int solr_params_insert_param_value(solr_param_t *param, solr_param_value_t *param_value) */ PHP_SOLR_API int solr_params_insert_param_value(solr_param_t *param, solr_param_value_t *param_value) { if (!param_value) { return FAILURE; } param_value->next = param_value->prev = NULL; if (!param->allow_multiple) { param->value_free_func(param->head); param->head = param_value; param->last = param_value; param->count = 1U; return SUCCESS; } if (param->head == NULL) { param->head = param_value; param->last = param_value; } else { param_value->prev = param->last; param->last->next = param_value; param->last = param_value; } param->count++; return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API solr_param_t *solr_create_new_param(const solr_char_t *param_name, size_t param_name_len, solr_param_type_t param_type, solr_bool allow_multiple, solr_param_value_equal_func_t value_equal_func, solr_param_fetch_func_t param_fetch_func, solr_param_value_free_func_t value_free_func, solr_char_t delimiter, solr_char_t arg_separator TSRMLS_DC) */ PHP_SOLR_API solr_param_t *solr_create_new_param(const solr_char_t *param_name, size_t param_name_len, solr_param_type_t param_type, solr_bool allow_multiple, solr_param_value_equal_func_t value_equal_func, solr_param_fetch_func_t param_fetch_func, solr_param_value_free_func_t value_free_func, solr_char_t delimiter, solr_char_t arg_separator TSRMLS_DC) { solr_param_t *query_param = (solr_param_t *) pemalloc(sizeof(solr_param_t), SOLR_PARAMS_PERSISTENT); /* Always initialize linked list containers to NULL. */ /* Member pointers may contain unallocated addresses */ /* This notice applies to all solr_param_t member pointers here */ memset(query_param, 0, sizeof(solr_param_t)); query_param->type = param_type; query_param->count = 0L; query_param->param_name = solr_strndup(param_name, param_name_len); query_param->param_name_length = param_name_len; query_param->allow_multiple = allow_multiple; query_param->head = query_param->last = NULL; query_param->value_equal_func = value_equal_func; query_param->fetch_func = param_fetch_func; query_param->value_free_func = value_free_func; query_param->delimiter = delimiter; query_param->arg_separator = arg_separator; return query_param; } /* }}} */ /* {{{ PHP_SOLR_API int solr_add_or_set_normal_param(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length, zend_bool allow_multiple TSRMLS_DC) parameter value addition functions */ PHP_SOLR_API int solr_add_or_set_normal_param(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length, zend_bool allow_multiple TSRMLS_DC) { solr_params_t *solr_params = NULL; HashTable *params = NULL; solr_param_type_t param_type = SOLR_PARAM_TYPE_NORMAL; solr_param_t *param = NULL; solr_param_value_t *parameter_value = NULL; if (!pname_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter name"); /* php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameter name"); */ return FAILURE; } if (!pvalue_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter value"); /* php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameter value"); */ return FAILURE; } if (solr_fetch_params_entry(objptr, &solr_params TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "SolrParams instance could not be retrieved from HashTable"); return FAILURE; } params = solr_params->params; if ((param = zend_hash_str_find_ptr(params, (char *) pname, pname_length)) != NULL) { parameter_value = (solr_param_value_t *) pemalloc(sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); memset(parameter_value, 0, sizeof(solr_param_value_t)); solr_string_appends(&(parameter_value->contents.normal), pvalue, pvalue_length); solr_params_insert_param_value(param, parameter_value); return SUCCESS; } param = solr_create_new_param(pname, pname_length, param_type, allow_multiple, solr_normal_param_value_equal, (solr_param_fetch_func_t) solr_normal_param_value_fetch, solr_normal_param_value_free, '&', 0 TSRMLS_CC); parameter_value = (solr_param_value_t *) pemalloc(sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); memset(parameter_value, 0, sizeof(solr_param_value_t)); solr_string_appends(&(parameter_value->contents.normal), pvalue, pvalue_length); solr_params_insert_param_value(param, parameter_value); if (zend_hash_str_add_ptr(params, pname, pname_length, (void *) param) == NULL) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error from %s %s=%s", __func__, (char *) pname, pvalue); return FAILURE; } return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API int solr_add_simple_list_param(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC) */ PHP_SOLR_API int solr_add_simple_list_param(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC) { zend_bool allow_multiple = 1; /* This value type by definition allows multiple. add parameters can be added more than once */ solr_params_t *solr_params = NULL; HashTable *params = NULL; solr_param_type_t param_type = SOLR_PARAM_TYPE_SIMPLE_LIST; solr_param_t *param = NULL; solr_param_value_t *parameter_value = NULL; if (!pname_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter name"); return FAILURE; } if (!pvalue_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter value"); return FAILURE; } if (solr_fetch_params_entry(objptr, &solr_params TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "SolrParams instance could not be retrieved from HashTable"); return FAILURE; } params = solr_params->params; if ((param = zend_hash_str_find_ptr(params, pname, pname_length)) != NULL) { parameter_value = (solr_param_value_t *) pemalloc(sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); memset(parameter_value, 0, sizeof(solr_param_value_t)); solr_string_appends(&(parameter_value->contents.simple_list), pvalue, pvalue_length); solr_params_insert_param_value(param, parameter_value); return SUCCESS; } param = solr_create_new_param(pname, pname_length, param_type, allow_multiple, solr_simple_list_param_value_equal, (solr_param_fetch_func_t) solr_simple_list_param_value_fetch, solr_simple_list_param_value_free, ',', 0 TSRMLS_CC); parameter_value = (solr_param_value_t *) pemalloc(sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); memset(parameter_value, 0, sizeof(solr_param_value_t)); solr_string_appends(&(parameter_value->contents.simple_list), pvalue, pvalue_length); solr_params_insert_param_value(param, parameter_value); if (zend_hash_str_add_ptr(params, pname, pname_length, (void *) param) == NULL) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error from %s %s=%s", __func__, (char *) pname, pvalue); return FAILURE; } return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API int solr_add_simple_list_param(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC) */ PHP_SOLR_API int solr_add_simple_list_param_ex(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length,solr_char_t *separator TSRMLS_DC) { zend_bool allow_multiple = 1; /* This value type by definition allows multiple. add parameters can be added more than once */ solr_params_t *solr_params = NULL; HashTable *params = NULL; solr_param_type_t param_type = SOLR_PARAM_TYPE_SIMPLE_LIST; solr_param_t *param = NULL; solr_param_value_t *parameter_value = NULL; if (!pname_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter name"); return FAILURE; } if (!pvalue_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter value"); return FAILURE; } if (solr_fetch_params_entry(objptr, &solr_params TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "SolrParams instance could not be retrieved from HashTable"); return FAILURE; } params = solr_params->params; if ((param = zend_hash_str_find_ptr(params, pname, pname_length)) != NULL) { parameter_value = (solr_param_value_t *) pemalloc(sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); memset(parameter_value, 0, sizeof(solr_param_value_t)); solr_string_appends(&(parameter_value->contents.simple_list), pvalue, pvalue_length); solr_params_insert_param_value(param, parameter_value); return SUCCESS; } param = solr_create_new_param(pname, pname_length, param_type, allow_multiple, solr_simple_list_param_value_equal, (solr_param_fetch_func_t) solr_simple_list_param_value_fetch, solr_simple_list_param_value_free, *separator, 0 TSRMLS_CC); parameter_value = (solr_param_value_t *) pemalloc(sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); memset(parameter_value, 0, sizeof(solr_param_value_t)); solr_string_appends(&(parameter_value->contents.simple_list), pvalue, pvalue_length); solr_params_insert_param_value(param, parameter_value); if (zend_hash_str_add_ptr(params, pname, pname_length, (void *) param) == NULL) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error from %s %s=%s", __func__, (char *) pname, pvalue); return FAILURE; } return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API int solr_add_arg_list_param(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length, solr_char_t *avalue, int avalue_length, solr_char_t delimiter, solr_char_t arg_separator TSRMLS_DC) */ PHP_SOLR_API int solr_add_arg_list_param(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length, solr_char_t *avalue, int avalue_length, solr_char_t delimiter, solr_char_t arg_separator TSRMLS_DC) { zend_bool allow_multiple = 1; /* This value type by definition allows multiple */ solr_params_t *solr_params = NULL; solr_param_type_t param_type = SOLR_PARAM_TYPE_ARG_LIST; solr_param_t *param = NULL; /* holds a pointer to the param structure e.g. sort */ solr_param_value_t *parameter_value = NULL; HashTable *params = NULL; if (!pname_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter name"); return FAILURE; } if (!pvalue_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter value"); return FAILURE; } /* if (!avalue_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid argument value"); return FAILURE; } */ if (solr_fetch_params_entry(objptr, &solr_params TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "SolrParams instance could not be retrieved from HashTable"); return FAILURE; } params = solr_params->params; /* if parameter exists add the new value argument(param_value) */ if ((param = zend_hash_str_find_ptr(params, pname, pname_length)) != NULL) { parameter_value = create_parameter_value_arg_list(pvalue, pvalue_length, avalue, avalue_length, "", 0 TSRMLS_CC); solr_params_insert_param_value(param, parameter_value); return SUCCESS; } param = solr_create_new_param(pname, pname_length, param_type, allow_multiple, solr_arg_list_param_value_equal, (solr_param_fetch_func_t) solr_arg_list_param_value_fetch, solr_arg_list_param_value_free, delimiter, arg_separator TSRMLS_CC); parameter_value = create_parameter_value_arg_list(pvalue, pvalue_length, avalue, avalue_length, (solr_char_t*)"", 0 TSRMLS_CC); solr_params_insert_param_value(param, parameter_value); if (zend_hash_str_add_ptr(params, pname, pname_length, (void *) param) == NULL) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error from %s %s=%s", __func__, (char *) pname, pvalue); return FAILURE; } return SUCCESS; } /* }}} */ PHP_SOLR_API solr_param_value_t* create_parameter_value_arg_list(solr_char_t *pvalue, int pvalue_length, solr_char_t *avalue, int avalue_length, solr_char_t *delimiter_override, solr_bool delimiter_overriden TSRMLS_DC) { solr_param_value_t *parameter_value = NULL; parameter_value = (solr_param_value_t *) pemalloc(sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); memset(parameter_value, 0, sizeof(solr_param_value_t)); solr_string_appends(&(parameter_value->contents.arg_list.value), pvalue, pvalue_length); solr_string_appends(&(parameter_value->contents.arg_list.arg), avalue, avalue_length); if(delimiter_overriden){ parameter_value->contents.arg_list.delimiter_override = solr_strndup(delimiter_override, sizeof(delimiter_override)); parameter_value->contents.arg_list.delimiter_overriden = delimiter_overriden; } return parameter_value; } PHP_SOLR_API int solr_add_arg_list_param_ex(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length, solr_char_t *avalue, int avalue_length, solr_char_t delimiter, solr_char_t arg_separator, solr_char_t delimiter_override TSRMLS_DC) { zend_bool allow_multiple = 1; /* This value type by definition allows multiple */ solr_params_t *solr_params = NULL; solr_param_type_t param_type = SOLR_PARAM_TYPE_ARG_LIST; solr_param_t *param = NULL; /* holds a pointer to the param structure e.g. sort */ solr_param_value_t *parameter_value = NULL; HashTable *params = NULL; if (!pname_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter name"); return FAILURE; } if (!pvalue_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid parameter value"); return FAILURE; } /* * commented for the favor of having empty value if (!avalue_length) { solr_throw_exception_ex(solr_ce_SolrIllegalArgumentException, SOLR_ERROR_4000 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Invalid argument value"); return FAILURE; } */ if (solr_fetch_params_entry(objptr, &solr_params TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "SolrParams instance could not be retrieved from HashTable"); return FAILURE; } params = solr_params->params; /* if parameter exists add the new value argument(param_value) */ if ((param = zend_hash_str_find_ptr(params, pname, pname_length)) != NULL) { parameter_value = create_parameter_value_arg_list(pvalue, pvalue_length, avalue, avalue_length, &delimiter_override, 1 TSRMLS_CC); solr_params_insert_param_value(param, parameter_value); return SUCCESS; } param = solr_create_new_param(pname, pname_length, param_type, allow_multiple, solr_arg_list_param_value_equal, (solr_param_fetch_func_t) solr_arg_list_param_value_fetch, solr_arg_list_param_value_free, delimiter, arg_separator TSRMLS_CC); parameter_value = create_parameter_value_arg_list(pvalue, pvalue_length, avalue, avalue_length, &delimiter_override, 1 TSRMLS_CC); solr_params_insert_param_value(param, parameter_value); if (zend_hash_str_add_ptr(params, pname, pname_length, (void *) param) == NULL) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error from %s %s=%s", __func__, (char *) pname, pvalue); return FAILURE; } return SUCCESS; } /* {{{ Parameter value EQUALITY FUNCTIONS */ /* {{{ PHP_SOLR_API int solr_normal_param_value_equal(const solr_param_value_t *a, const solr_param_value_t *b) */ PHP_SOLR_API int solr_normal_param_value_equal(const solr_param_value_t *a, const solr_param_value_t *b) { return solr_string_equal(&(a->contents.normal), &(b->contents.normal)); } /* }}} */ /* {{{ PHP_SOLR_API int solr_simple_list_param_value_equal(const solr_param_value_t *a, const solr_param_value_t *b) */ PHP_SOLR_API int solr_simple_list_param_value_equal(const solr_param_value_t *a, const solr_param_value_t *b) { return solr_string_equal(&(a->contents.simple_list), &(b->contents.simple_list)); } /* }}} */ /* {{{ PHP_SOLR_API int solr_arg_list_param_value_equal(const solr_param_value_t *a, const solr_param_value_t *b) */ PHP_SOLR_API int solr_arg_list_param_value_equal(const solr_param_value_t *a, const solr_param_value_t *b) { return solr_string_equal(&(a->contents.arg_list.value), &(b->contents.arg_list.value)); } /* }}} */ /* }}} */ /* {{{ Parameter values retrieval functions */ /* {{{ PHP_SOLR_API void solr_normal_param_value_fetch(solr_param_t *solr_param, solr_string_t *buffer) */ PHP_SOLR_API void solr_normal_param_value_fetch(solr_param_t *solr_param, solr_string_t *buffer) { zend_string *url_encoded_param_value; solr_param_value_t *current_ptr = solr_param->head; solr_char_t glue = '&'; if (!solr_param->allow_multiple) { url_encoded_param_value = php_raw_url_encode((char *) current_ptr->contents.normal.str, current_ptr->contents.normal.len); solr_string_appends(buffer, solr_param->param_name, solr_param->param_name_length); solr_string_appendc(buffer, '='); solr_string_appends(buffer, url_encoded_param_value->val, url_encoded_param_value->len); zend_string_free(url_encoded_param_value); } else { ulong n_loops = solr_param->count - 1; while(n_loops) { url_encoded_param_value = NULL; url_encoded_param_value = php_raw_url_encode(current_ptr->contents.normal.str, current_ptr->contents.normal.len); solr_string_appends(buffer, solr_param->param_name, solr_param->param_name_length); solr_string_appendc(buffer, '='); solr_string_appends(buffer, url_encoded_param_value->val, url_encoded_param_value->len); zend_string_release(url_encoded_param_value); solr_string_appendc(buffer, glue); n_loops--; current_ptr = current_ptr->next; } url_encoded_param_value = NULL; url_encoded_param_value = php_raw_url_encode(current_ptr->contents.normal.str, current_ptr->contents.normal.len); solr_string_appends(buffer, solr_param->param_name, solr_param->param_name_length); solr_string_appendc(buffer, '='); solr_string_appends(buffer, url_encoded_param_value->val, url_encoded_param_value->len); zend_string_free(url_encoded_param_value); } } /* }}} */ /* {{{ PHP_SOLR_API void solr_simple_list_param_value_fetch(solr_param_t *solr_param, solr_string_t *buffer) */ PHP_SOLR_API void solr_simple_list_param_value_fetch(solr_param_t *solr_param, solr_string_t *buffer) { solr_param_value_t *current_ptr = solr_param->head; solr_char_t list_delimiter = ','; /* Comma 0x2C */ ulong n_loops = solr_param->count - 1; auto solr_string_t tmp_buffer; zend_string *url_encoded_list = NULL; solr_string_appends(buffer, solr_param->param_name, solr_param->param_name_length); solr_string_appendc(buffer, '='); memset(&tmp_buffer, 0, sizeof(solr_string_t)); while(n_loops) { solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.simple_list)); solr_string_appendc(&tmp_buffer, list_delimiter); n_loops--; current_ptr = current_ptr->next; } solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.simple_list)); url_encoded_list = php_raw_url_encode(tmp_buffer.str, tmp_buffer.len); solr_string_appends(buffer, url_encoded_list->val, url_encoded_list->len); zend_string_release(url_encoded_list); url_encoded_list = NULL; solr_string_free(&tmp_buffer); } /* }}} */ /* {{{ PHP_SOLR_API void solr_arg_list_param_value_fetch(solr_param_t *solr_param, solr_string_t *buffer) */ PHP_SOLR_API void solr_arg_list_param_value_fetch(solr_param_t *solr_param, solr_string_t *buffer) { solr_param_value_t *current_ptr = solr_param->head; solr_char_t list_delimiter = solr_param->delimiter; solr_char_t separator = solr_param->arg_separator; ulong n_loops = solr_param->count - 1; solr_string_t tmp_buffer; zend_string *url_encoded_list = NULL; solr_string_appends(buffer, solr_param->param_name, solr_param->param_name_length); solr_string_appendc(buffer, '='); memset(&tmp_buffer, 0, sizeof(solr_string_t)); while(n_loops) { solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.arg_list.value)); solr_string_appendc(&tmp_buffer, separator); solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.arg_list.arg)); solr_string_appendc(&tmp_buffer, list_delimiter); n_loops--; current_ptr = current_ptr->next; } solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.arg_list.value)); solr_string_appendc(&tmp_buffer, separator); solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.arg_list.arg)); url_encoded_list = php_raw_url_encode(tmp_buffer.str, tmp_buffer.len); solr_string_appends(buffer, url_encoded_list->val, url_encoded_list->len); zend_string_release(url_encoded_list); url_encoded_list = NULL; solr_string_free(&tmp_buffer); } /* }}} */ /* }}} */ /* {{{ Parameter retrieval functions. Only used for display. */ /* {{{ PHP_SOLR_API void solr_normal_param_value_display_string(solr_param_t *solr_param, zval *param_value) */ PHP_SOLR_API void solr_normal_param_value_display_string(solr_param_t *solr_param, zval *param_value) { solr_param_value_t *current_ptr = solr_param->head; ZVAL_STRINGL(param_value, current_ptr->contents.normal.str, current_ptr->contents.normal.len); } /* }}} */ /* {{{ PHP_SOLR_API void solr_normal_param_value_display_integer(solr_param_t *solr_param, zval *param_value) */ PHP_SOLR_API void solr_normal_param_value_display_integer(solr_param_t *solr_param, zval *param_value) { solr_param_value_t *current_ptr = solr_param->head; long int return_value = atol(current_ptr->contents.normal.str); ZVAL_LONG(param_value, return_value); } /* }}} */ /* {{{ PHP_SOLR_API void solr_normal_param_value_display_double(solr_param_t *solr_param, zval *param_value) */ PHP_SOLR_API void solr_normal_param_value_display_double(solr_param_t *solr_param, zval *param_value) { solr_param_value_t *current_ptr = solr_param->head; double return_value = atof(current_ptr->contents.normal.str); ZVAL_DOUBLE(param_value, return_value); } /* }}} */ /* Checks if current_ptr->contents.normal.str matches str_const */ #define solr_npvdb_strcmp(str_const) (0 == strcmp(str_const, current_ptr->contents.normal.str)) /* {{{ PHP_SOLR_API void solr_normal_param_value_display_boolean(solr_param_t *solr_param, zval *param_value) */ PHP_SOLR_API void solr_normal_param_value_display_boolean(solr_param_t *solr_param, zval *param_value) { solr_param_value_t *current_ptr = solr_param->head; zend_bool return_value = (zend_bool) (solr_npvdb_strcmp("true") || solr_npvdb_strcmp("on") ); ZVAL_BOOL(param_value, return_value); } /* }}} */ /* {{{ PHP_SOLR_API void solr_normal_param_value_display_sort_type(solr_param_t *solr_param, zval *param_value) */ PHP_SOLR_API void solr_normal_param_value_display_sort_type(solr_param_t *solr_param, zval *param_value) { solr_param_value_t *current_ptr = solr_param->head; long int return_value = (long int) (solr_npvdb_strcmp("count")); ZVAL_LONG(param_value, return_value); } /* }}} */ /* {{{ PHP_SOLR_API void solr_normal_param_value_display(solr_param_t *solr_param, zval *param_value_array) */ PHP_SOLR_API void solr_normal_param_value_display(solr_param_t *solr_param, zval *param_value_array) { solr_param_value_t *current_ptr = solr_param->head; while (current_ptr != NULL) { add_next_index_stringl(param_value_array, current_ptr->contents.normal.str, current_ptr->contents.normal.len); current_ptr = current_ptr->next; } } /* }}} */ /* {{{ PHP_SOLR_API void solr_simple_list_param_value_display(solr_param_t *solr_param, zval *param_value_array) */ PHP_SOLR_API void solr_simple_list_param_value_display(solr_param_t *solr_param, zval *param_value_array) { solr_param_value_t *current_ptr = solr_param->head; while (current_ptr != NULL) { add_next_index_stringl(param_value_array, current_ptr->contents.simple_list.str, current_ptr->contents.simple_list.len); current_ptr = current_ptr->next; } } /* }}} */ /* {{{ PHP_SOLR_API void solr_arg_list_param_value_display(solr_param_t *solr_param, zval *param_value_array) */ PHP_SOLR_API void solr_arg_list_param_value_display(solr_param_t *solr_param, zval *param_value_array) { solr_param_value_t *current_ptr = solr_param->head; while (current_ptr != NULL) { solr_string_t tmp_buffer; memset(&tmp_buffer, 0, sizeof(solr_string_t)); solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.arg_list.value)); solr_string_appendc(&tmp_buffer, solr_param->arg_separator); solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.arg_list.arg)); add_next_index_stringl(param_value_array, tmp_buffer.str, tmp_buffer.len); solr_string_free(&tmp_buffer); current_ptr = current_ptr->next; } } /* }}} */ /* }}} */ /* {{{ Parameter retrieval functions. Only used for toString() */ /* {{{ PHP_SOLR_API void solr_normal_param_value_tostring(solr_param_t *solr_param, solr_string_t *buffer, zend_bool url_encode) */ PHP_SOLR_API void solr_normal_param_value_tostring(solr_param_t *solr_param, solr_string_t *buffer, zend_bool url_encode) { solr_param_value_t *current_ptr = solr_param->head; solr_char_t glue = '&'; if (!solr_param->allow_multiple) { zend_string *url_encoded_param_value = NULL; if (url_encode) { url_encoded_param_value = php_raw_url_encode((char *) current_ptr->contents.normal.str, current_ptr->contents.normal.len); } else { url_encoded_param_value = zend_string_init(current_ptr->contents.normal.str, current_ptr->contents.normal.len, 0); } solr_string_appends(buffer, solr_param->param_name, solr_param->param_name_length); solr_string_appendc(buffer, '='); solr_string_appends(buffer, url_encoded_param_value->val, url_encoded_param_value->len); zend_string_release(url_encoded_param_value); } else { ulong n_loops = solr_param->count - 1; zend_string *url_encoded_param_value = NULL; while(n_loops) { if (url_encode) { url_encoded_param_value = php_raw_url_encode(current_ptr->contents.normal.str, current_ptr->contents.normal.len); } else { url_encoded_param_value = zend_string_init(current_ptr->contents.normal.str, current_ptr->contents.normal.len, 0); } solr_string_appends(buffer, solr_param->param_name, solr_param->param_name_length); solr_string_appendc(buffer, '='); solr_string_appends(buffer, url_encoded_param_value->val, url_encoded_param_value->len); zend_string_free(url_encoded_param_value); url_encoded_param_value = NULL; solr_string_appendc(buffer, glue); n_loops--; current_ptr = current_ptr->next; } if (url_encode) { url_encoded_param_value = php_raw_url_encode(current_ptr->contents.normal.str, current_ptr->contents.normal.len); } else { url_encoded_param_value = zend_string_init(current_ptr->contents.normal.str, current_ptr->contents.normal.len, 0); } solr_string_appends(buffer, solr_param->param_name, solr_param->param_name_length); solr_string_appendc(buffer, '='); solr_string_appends(buffer, url_encoded_param_value->val, url_encoded_param_value->len); zend_string_free(url_encoded_param_value); url_encoded_param_value = NULL; } } /* }}} */ /* {{{ PHP_SOLR_API void solr_simple_list_param_value_tostring(solr_param_t *solr_param, solr_string_t *buffer, zend_bool url_encode) */ PHP_SOLR_API void solr_simple_list_param_value_tostring(solr_param_t *solr_param, solr_string_t *buffer, zend_bool url_encode) { solr_param_value_t *current_ptr = solr_param->head; solr_char_t list_delimiter = solr_param->delimiter; /* Comma 0x2C */ ulong n_loops = solr_param->count - 1; auto solr_string_t tmp_buffer; zend_string *url_encoded_list = NULL; solr_string_appends(buffer, solr_param->param_name, solr_param->param_name_length); solr_string_appendc(buffer, '='); memset(&tmp_buffer, 0, sizeof(solr_string_t)); while(n_loops) { solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.simple_list)); solr_string_appendc(&tmp_buffer, list_delimiter); n_loops--; current_ptr = current_ptr->next; } solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.simple_list)); if (url_encode) { url_encoded_list = php_raw_url_encode(tmp_buffer.str, tmp_buffer.len); } else { url_encoded_list = zend_string_init(tmp_buffer.str, tmp_buffer.len, 0); } solr_string_appends(buffer, url_encoded_list->val, url_encoded_list->len); zend_string_free(url_encoded_list); url_encoded_list = NULL; solr_string_free(&tmp_buffer); } /* }}} */ /* {{{ PHP_SOLR_API void solr_arg_list_param_value_tostring(solr_param_t *solr_param, solr_string_t *buffer, zend_bool url_encode) */ PHP_SOLR_API void solr_arg_list_param_value_tostring(solr_param_t *solr_param, solr_string_t *buffer, zend_bool url_encode) { solr_param_value_t *current_ptr = solr_param->head; solr_char_t list_delimiter = solr_param->delimiter; solr_char_t separator = solr_param->arg_separator; ulong n_loops = solr_param->count - 1; solr_string_t tmp_buffer; zend_string *url_encoded_list = NULL; solr_string_appends(buffer, solr_param->param_name, solr_param->param_name_length); solr_string_appendc(buffer, '='); memset(&tmp_buffer, 0, sizeof(solr_string_t)); while(n_loops) { solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.arg_list.value)); if(current_ptr->contents.arg_list.delimiter_overriden) { if(strlen(current_ptr->contents.arg_list.delimiter_override) > 0) { solr_string_appendc(&tmp_buffer, (*current_ptr->contents.arg_list.delimiter_override)); } }else{ solr_string_appendc(&tmp_buffer, separator); } solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.arg_list.arg)); solr_string_appendc(&tmp_buffer, list_delimiter); n_loops--; current_ptr = current_ptr->next; } /* process last parameter value */ solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.arg_list.value)); /* check for separator override */ if(current_ptr->contents.arg_list.delimiter_overriden) { if(strlen(current_ptr->contents.arg_list.delimiter_override) > 0) { solr_string_appendc(&tmp_buffer, (*current_ptr->contents.arg_list.delimiter_override)); } }else{ solr_string_appendc(&tmp_buffer, separator); } solr_string_append_solr_string(&tmp_buffer, &(current_ptr->contents.arg_list.arg)); if (url_encode) { url_encoded_list = php_raw_url_encode(tmp_buffer.str, tmp_buffer.len); } else { url_encoded_list = zend_string_init(tmp_buffer.str, tmp_buffer.len, 0); } solr_string_appends(buffer, url_encoded_list->val, url_encoded_list->len); zend_string_free(url_encoded_list); url_encoded_list = NULL; solr_string_free(&tmp_buffer); } /* }}} */ /* }}} */ /* {{{ Memory deallocation functions for parameter values */ /* {{{ PHP_SOLR_API void solr_normal_param_value_free(solr_param_value_t *param_value) */ PHP_SOLR_API void solr_normal_param_value_free(solr_param_value_t *param_value) { if (param_value) { solr_string_free(&(param_value->contents.normal)); pefree(param_value, SOLR_PARAMS_PERSISTENT); param_value = NULL; } } /* }}} */ /* {{{ PHP_SOLR_API void solr_simple_list_param_value_free(solr_param_value_t *param_value) */ PHP_SOLR_API void solr_simple_list_param_value_free(solr_param_value_t *param_value) { if (param_value) { solr_string_free(&(param_value->contents.simple_list)); pefree(param_value, SOLR_PARAMS_PERSISTENT); param_value = NULL; } } /* }}} */ /* {{{ PHP_SOLR_API void solr_arg_list_param_value_free(solr_param_value_t *param_value) */ PHP_SOLR_API void solr_arg_list_param_value_free(solr_param_value_t *param_value) { if (param_value) { solr_string_free(&(param_value->contents.arg_list.value)); solr_string_free(&(param_value->contents.arg_list.arg)); if(param_value->contents.arg_list.delimiter_override != NULL){ efree(param_value->contents.arg_list.delimiter_override); } pefree(param_value, SOLR_PARAMS_PERSISTENT); param_value = NULL; } } /* }}} */ /* {{{ PHP_SOLR_API void solr_set_return_solr_params_object(zval *return_value_ptr, zval *current_objptr TSRMLS_DC) */ PHP_SOLR_API void solr_set_return_solr_params_object(zval *return_value_ptr, zval *current_objptr TSRMLS_DC) { #ifdef PHP_7 ZVAL_COPY(return_value_ptr, current_objptr); #else zval_ptr_dtor(return_value_ptr); ZVAL_MAKE_REF(current_objptr); Z_ADDREF_P(current_objptr); return_value_ptr = current_objptr; #endif } /* }}} */ /* {{{ PHP_SOLR_API int solr_delete_solr_parameter(zval *objptr, solr_char_t *name, int name_length TSRMLS_DC) */ PHP_SOLR_API int solr_delete_solr_parameter(zval *objptr, solr_char_t *name, int name_length TSRMLS_DC) { solr_params_t *solr_params = NULL; HashTable *params_ht = NULL; if (solr_fetch_params_entry(objptr, &solr_params TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "SolrParams instance could not be retrieved from HashTable"); return FAILURE; } params_ht = solr_params->params; if (zend_hash_str_del(params_ht, name, name_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "parameter '%s' was not set. Attempting to remove an undefined parameter.", name); return FAILURE; } return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API int solr_delete_normal_param_value(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC) */ PHP_SOLR_API int solr_delete_normal_param_value(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC) { solr_params_t *solr_params = NULL; HashTable *params_ht = NULL; solr_param_t *param_ptr = NULL; solr_param_value_t *target_value = NULL; if (!pname_length) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameter name"); return FAILURE; } if (!pvalue_length) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameter value"); return FAILURE; } if (solr_fetch_params_entry(objptr, &solr_params TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "SolrParams instance could not be retrieved from HashTable"); return FAILURE; } params_ht = solr_params->params; if ((param_ptr = zend_hash_str_find_ptr(params_ht, pname, pname_length)) == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "parameter could not be retrieved from HashTable"); return FAILURE; } target_value = (solr_param_value_t *) pecalloc(1, sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); solr_string_appends(&(target_value->contents.normal), pvalue, pvalue_length); solr_params_delete_param_value(param_ptr, target_value TSRMLS_CC); /* We are done with target_value. */ param_ptr->value_free_func(target_value); if (param_ptr->count < 1U) { zend_hash_str_del(params_ht, pname, pname_length); #if SOLR_DEBUG php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Deleted last value from parameter. Removing parameter '%s' from object instance.", pname); #endif } return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API int solr_delete_simple_list_param_value(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC) */ PHP_SOLR_API int solr_delete_simple_list_param_value(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC) { solr_params_t *solr_params = NULL; solr_param_t *param_ptr = NULL; HashTable *params_ht = NULL; solr_param_value_t *target_value = NULL; if (!pname_length) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameter name"); return FAILURE; } if (!pvalue_length) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameter value"); return FAILURE; } if (solr_fetch_params_entry(objptr, &solr_params TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "SolrParams instance could not be retrieved from HashTable"); return FAILURE; } params_ht = solr_params->params; if ((param_ptr = zend_hash_str_find_ptr(params_ht, pname, pname_length)) == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "parameter could not be retrieved from HashTable"); return FAILURE; } target_value = (solr_param_value_t *) pecalloc(1, sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); solr_string_appends(&(target_value->contents.simple_list), pvalue, pvalue_length); solr_params_delete_param_value(param_ptr, target_value TSRMLS_CC); /* We are done with target_value. */ param_ptr->value_free_func(target_value); if (param_ptr->count < 1U) { zend_hash_str_del(params_ht, pname, pname_length); #if SOLR_DEBUG php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Deleted last value from parameter. Removing parameter '%s' from object instance.", pname); #endif } return SUCCESS; } /* }}} */ /* {{{ PHP_SOLR_API int solr_delete_arg_list_param_value(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC) */ PHP_SOLR_API int solr_delete_arg_list_param_value(zval *objptr, solr_char_t *pname, int pname_length, solr_char_t *pvalue, int pvalue_length TSRMLS_DC) { solr_params_t *solr_params = NULL; HashTable *params_ht = NULL; solr_param_t *param_ptr = NULL; solr_param_value_t *target_value = NULL; if (!pname_length) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameter name"); return FAILURE; } if (!pvalue_length) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameter value"); return FAILURE; } if (solr_fetch_params_entry(objptr, &solr_params TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "SolrParams instance could not be retrieved from HashTable"); return FAILURE; } params_ht = solr_params->params; if ((param_ptr = zend_hash_str_find_ptr(params_ht, pname, pname_length)) == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "parameter could not be retrieved from HashTable"); return FAILURE; } target_value = (solr_param_value_t *) pecalloc(1, sizeof(solr_param_value_t), SOLR_PARAMS_PERSISTENT); solr_string_appends(&(target_value->contents.arg_list.value), pvalue, pvalue_length); solr_params_delete_param_value(param_ptr, target_value TSRMLS_CC); /* We are done with target_value. */ param_ptr->value_free_func(target_value); if (param_ptr->count < 1U) { zend_hash_str_del(params_ht, pname, pname_length); #if SOLR_DEBUG php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Deleted last value from parameter. Removing parameter '%s' from object instance.", pname); #endif } return SUCCESS; } /* }}} */ /* }}} */ /* {{{ PHP_SOLR_API int solr_param_find(zval *objptr, solr_char_t *pname, int pname_length, solr_param_t **solr_param TSRMLS_DC) */ PHP_SOLR_API int solr_param_find(zval *objptr, solr_char_t *pname, int pname_length, solr_param_t **solr_param TSRMLS_DC) { solr_params_t *solr_params = NULL; HashTable *params_ht = NULL; solr_param_t *solr_param_tmp = NULL; if (!pname_length) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameter name"); return FAILURE; } if (solr_fetch_params_entry(objptr, &solr_params TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "SolrParams instance could not be retrieved from HashTable"); return FAILURE; } params_ht = solr_params->params; if ((solr_param_tmp = zend_hash_str_find_ptr(params_ht, pname, pname_length)) == NULL) { return FAILURE; } (*solr_param) = solr_param_tmp; return SUCCESS; } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/solr_functions_response.c0000644000175000017500000000730012676753707017774 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Israel Ekpo | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* Used to set the properties of the SolrResponse instance after a call to the server */ /* {{{ PHP_SOLR_API void solr_set_response_object_properties(zend_class_entry *scope, zval *response_object, const solr_client_t *client, const solr_string_t *request_url, zend_bool success TSRMLS_DC) */ PHP_SOLR_API void solr_set_response_object_properties(zend_class_entry *scope, zval *response_object, const solr_client_t *client, const solr_string_t *request_url, zend_bool success TSRMLS_DC) { const solr_curl_t *handle = &(client->handle); const solr_string_t *raw_request_headers = &(handle->request_header.buffer); const solr_string_t *raw_request = &(handle->request_body_debug.buffer); const solr_string_t *raw_response_headers = &(handle->response_header.buffer); const solr_string_t *raw_response = &(handle->response_body.buffer); const solr_string_t *response_writer = &(client->options.response_writer); long int http_status = handle->response_header.response_code; zend_update_property_long(scope, response_object, "http_status", sizeof("http_status")-1, http_status TSRMLS_CC); zend_update_property_bool(scope, response_object, "success", sizeof("success")-1, success TSRMLS_CC); if (response_writer->str) { zend_update_property_stringl(scope, response_object, "response_writer", sizeof("response_writer")-1, (char *)response_writer->str, response_writer->len TSRMLS_CC); } if (request_url->str) { zend_update_property_stringl(scope, response_object, "http_request_url", sizeof("http_request_url")-1, (char *)request_url->str, request_url->len TSRMLS_CC); } if (raw_request_headers->str) { zend_update_property_stringl(scope, response_object, "http_raw_request_headers", sizeof("http_raw_request_headers")-1, (char *)raw_request_headers->str, raw_request_headers->len TSRMLS_CC); } if (raw_request->str) { zend_update_property_stringl(scope, response_object, "http_raw_request", sizeof("http_raw_request")-1, (char *)raw_request->str, raw_request->len TSRMLS_CC); } if (raw_response_headers->str) { zend_update_property_stringl(scope, response_object, "http_raw_response_headers", sizeof("http_raw_response_headers")-1, (char *)raw_response_headers->str, raw_response_headers->len TSRMLS_CC); } if (raw_response->str) { zend_update_property_stringl(scope, response_object, "http_raw_response", sizeof("http_raw_response")-1, (char *)raw_response->str, raw_response->len TSRMLS_CC); } } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/solr_string.c0000644000175000017500000001637512676753707015370 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Israel Ekpo | +----------------------------------------------------------------------+ */ /* $Id$ */ #include "php_solr.h" /* {{{ static inline void solr_string_alloc(solr_string_t *dest, size_t length, size_t *new_length SOLR_MEM_DEBUG_DC) */ static inline void solr_string_alloc(solr_string_t *dest, size_t length, size_t *new_length SOLR_MEM_DEBUG_DC) { /* If buffer is empty */ if (!dest->str) { (*new_length) = length; dest->cap = ((*new_length) < SOLR_STRING_START_SIZE) ? SOLR_STRING_START_SIZE : (length + SOLR_STRING_INCREMENT_SIZE); dest->str = (solr_char_t *) perealloc(dest->str, dest->cap * sizeof(solr_char_t), SOLR_STRING_PERSISTENT); } else { (*new_length) = dest->len + length; /* If the buffer full, get more space */ if ((*new_length) >= dest->cap) { dest->cap = (*new_length) + SOLR_STRING_INCREMENT_SIZE; dest->str = (solr_char_t *) perealloc(dest->str, dest->cap * sizeof(solr_char_t), SOLR_STRING_PERSISTENT); } } #ifdef SOLR_MEM_DEBUG php_printf("solr_string_alloc() [Re]allocated %u bytes at %p in %s(), %s Line %d \n", dest->cap, dest->str SOLR_MEM_DEBUG_CC); #endif } /* }}} */ /* {{{ PHP_SOLR_API void solr_string_appends(solr_string_t *dest, const solr_char_t *src, size_t length SOLR_MEM_DEBUG_DC) */ PHP_SOLR_API void solr_string_appends_ex(solr_string_t *dest, const solr_char_t *src, size_t length SOLR_MEM_DEBUG_DC) { auto size_t __new_length = 0U; /* (Re)allocates memory and increases the capacity if necessary */ solr_string_alloc(dest, length, &__new_length SOLR_MEM_DEBUG_CC); /* Copy the data from the source to the destination */ memcpy(dest->str + dest->len, src, length); /* Reset the length of the solr_string to the new value */ dest->len = __new_length; /* Always make it a null-terminated string */ dest->str[__new_length] = (solr_char_t) 0x00; } /* }}} */ /* {{{ PHP_SOLR_API void solr_string_appendc(solr_string_t *dest, solr_char_t ch SOLR_MEM_DEBUG_DC) */ PHP_SOLR_API void solr_string_appendc_ex(solr_string_t *dest, solr_char_t ch SOLR_MEM_DEBUG_DC) { auto size_t __new_length = 0U; /* (Re)allocates memory and increases the capacity if necessary */ solr_string_alloc(dest, 1, &__new_length SOLR_MEM_DEBUG_CC); dest->str[dest->len] = ch; /* Reset the length of the solr_string to the new value (dest->len + 1) */ dest->len = __new_length; /* Always make it a null-terminated string */ dest->str[__new_length] = (solr_char_t) 0x00; } /* }}} */ /* {{{ PHP_SOLR_API void solr_string_remove_last_char(solr_string_t *dest) */ PHP_SOLR_API void solr_string_remove_last_char(solr_string_t *dest) { if (dest->str && dest->len) { dest->str[dest->len - 1] = (solr_char_t) 0x00; dest->len--; } } /* }}} */ /* {{{ PHP_SOLR_API void solr_string_append_long(solr_string_t *dest, long int long_val) */ PHP_SOLR_API void solr_string_append_long_ex(solr_string_t *dest, long int long_val SOLR_MEM_DEBUG_DC) { auto size_t __new_length = 0U; auto char tmp_buffer[SOLR_STRING_LONG_BUFFER_SIZE]; size_t length = 0; /* Write the formated long to the buffer */ php_sprintf(tmp_buffer, "%ld", long_val); length = strlen(tmp_buffer); /* (Re)allocates memory and increases the capacity if necessary */ solr_string_alloc(dest, length, &__new_length SOLR_MEM_DEBUG_CC); /* Copy the data from the source to the destination */ memcpy(dest->str + dest->len, tmp_buffer, length); /* Reset the length of the solr_string to the new value */ dest->len = __new_length; /* Always make it a null-terminated string */ dest->str[__new_length] = (solr_char_t) 0x00; } /* }}} */ /* {{{ PHP_SOLR_API void solr_string_append_unsigned_long(solr_string_t *dest, unsigned long int long_val) */ PHP_SOLR_API void solr_string_append_unsigned_long_ex(solr_string_t *dest, unsigned long int long_val SOLR_MEM_DEBUG_DC) { auto size_t __new_length = 0U; auto char tmp_buffer[SOLR_STRING_UNSIGNED_LONG_BUFFER_SIZE]; size_t length = 0; /* Write the formated unsigned long to the buffer */ php_sprintf(tmp_buffer, "%lu", long_val); length = strlen(tmp_buffer); /* (Re)allocates memory and increases the capacity if necessary */ solr_string_alloc(dest, length, &__new_length SOLR_MEM_DEBUG_CC); /* Copy the data from the source to the destination */ memcpy(dest->str + dest->len, tmp_buffer, length); /* Reset the length of the solr_string to the new value */ dest->len = __new_length; /* Always make it a null-terminated string */ dest->str[__new_length] = (solr_char_t) 0x00; } /* }}} */ /** * Checks if both strings are equal OR have same exact content. * * Returns 1 if they are equal, 0 if they are different. */ /* {{{ PHP_SOLR_API int solr_string_equal(const solr_string_t *a, const solr_string_t *b) */ PHP_SOLR_API int solr_string_equal(const solr_string_t *a, const solr_string_t *b) { const solr_char_t *str1 = a->str; const solr_char_t *str2 = b->str; if (str1 == str2) return 1; if (str1 == NULL) return 0; if (str2 == NULL) return 0; do { if (*str1++ != *str2) return(0); } while (*str2++); return 1; } /* }}} */ /* Deallocates memory for the buffer */ /* {{{ PHP_SOLR_API void solr_string_free(solr_string_t *dest SOLR_MEM_DEBUG_DC) */ PHP_SOLR_API void solr_string_free_ex(solr_string_t *dest SOLR_MEM_DEBUG_DC) { /* Only attempt this if the buffer is still valid */ if (dest->str) { #ifdef SOLR_MEM_DEBUG php_printf("solr_string_free_ex() Releasing %u bytes at %p in %s(), %s Line %d \n", dest->cap, dest->str SOLR_MEM_DEBUG_CC); #endif pefree(dest->str, SOLR_STRING_PERSISTENT); dest->str = (solr_char_t *) 0x00; dest->cap = dest->len = 0U; } } /* }}} */ PHP_SOLR_API void solr_destory_solr_string_zv(zval *solr_string_zv) { solr_string_t *string = (solr_string_t *) Z_PTR_P(solr_string_zv); solr_string_free_ex(string); pefree(string, SOLR_STRING_PERSISTENT); } /* Update the contents of the dest solr_string */ /* {{{ PHP_SOLR_API void solr_string_set(solr_string_t *dest, const solr_char_t *value, size_t length SOLR_MEM_DEBUG_DC) */ PHP_SOLR_API void solr_string_set_ex(solr_string_t *dest, const solr_char_t *value, size_t length SOLR_MEM_DEBUG_DC) { solr_string_free(dest); solr_string_appends(dest, value, length); } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/src/php7/php_solr_dismax_query.c0000644000175000017500000010560612676753707017437 0ustar omaromar#include "php_solr.h" /* extern function_entry; */ zend_class_entry *solr_ce_SolrDixMaxQuery; ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_zero_arg_info, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_addQueryField_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(0, field) ZEND_ARG_INFO(0, boost) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery__construct_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 0) ZEND_ARG_INFO(0, q) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery__queryAlt_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(0, q) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_remove_field_arg, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(0, field) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_addPhraseField_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 2) ZEND_ARG_INFO(0, field) ZEND_ARG_INFO(0, boost) ZEND_ARG_INFO(0, slop) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_addBoostQuery_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 2) ZEND_ARG_INFO(0, field) ZEND_ARG_INFO(0, value) ZEND_ARG_INFO(0, boost) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_setPhraseSlop_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(0, slop) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_setBoostFunction_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(0, function) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_setMinimumMatch_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_setTieBreaker_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(0, tieBreaker) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_setFields_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(0, fields) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_uf_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(0, field) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(SolrDisMaxQuery_setufs_args, SOLR_ARG_PASS_REMAINING_BY_REF_FALSE, SOLR_METHOD_RETURN_REFERENCE_FALSE, 1) ZEND_ARG_INFO(0, fields) ZEND_END_ARG_INFO() static zend_function_entry solr_dismax_query_methods[] = { PHP_ME(SolrDisMaxQuery, __construct, SolrDisMaxQuery__construct_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setQueryAlt, SolrDisMaxQuery__queryAlt_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, addQueryField, SolrDisMaxQuery_addQueryField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, removeQueryField, SolrDisMaxQuery_remove_field_arg, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, addPhraseField, SolrDisMaxQuery_addPhraseField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, removePhraseField, SolrDisMaxQuery_remove_field_arg, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setPhraseFields, SolrDisMaxQuery_setFields_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setPhraseSlop, SolrDisMaxQuery_setPhraseSlop_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setQueryPhraseSlop, SolrDisMaxQuery_setPhraseSlop_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setBoostQuery, SolrDisMaxQuery__queryAlt_args , ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, addBoostQuery, SolrDisMaxQuery_addBoostQuery_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, removeBoostQuery, SolrDisMaxQuery_remove_field_arg, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setBoostFunction, SolrDisMaxQuery_setBoostFunction_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setMinimumMatch, SolrDisMaxQuery_setMinimumMatch_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setTieBreaker, SolrDisMaxQuery_setTieBreaker_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, useDisMaxQueryParser, SolrDisMaxQuery_zero_arg_info, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, useEDisMaxQueryParser, SolrDisMaxQuery_zero_arg_info, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setBigramPhraseFields, SolrDisMaxQuery_setFields_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, addBigramPhraseField, SolrDisMaxQuery_addPhraseField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, removeBigramPhraseField, SolrDisMaxQuery_remove_field_arg, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setBigramPhraseSlop, SolrDisMaxQuery_setPhraseSlop_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setTrigramPhraseFields, SolrDisMaxQuery_setFields_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, addTrigramPhraseField, SolrDisMaxQuery_addPhraseField_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, removeTrigramPhraseField, SolrDisMaxQuery_remove_field_arg, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setTrigramPhraseSlop, SolrDisMaxQuery_setPhraseSlop_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, addUserField, SolrDisMaxQuery_uf_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, removeUserField, SolrDisMaxQuery_uf_args, ZEND_ACC_PUBLIC) PHP_ME(SolrDisMaxQuery, setUserFields, SolrDisMaxQuery_setufs_args, ZEND_ACC_PUBLIC) PHP_FE_END }; void init_solr_dismax_query(TSRMLS_D){ zend_class_entry ce; INIT_CLASS_ENTRY(ce, "SolrDisMaxQuery", solr_dismax_query_methods); solr_ce_SolrDixMaxQuery = zend_register_internal_class_ex( &ce, solr_ce_SolrQuery ); } /* {{{ proto SolrQuery::__construct([string q]) Constructor for SolrDisMaxQuery */ PHP_METHOD(SolrDisMaxQuery, __construct) { zval *param_value = NULL; solr_char_t *deftype_param_name = "defType", *deftype_param_value = SOLR_DISMAX_DEFAULT_PARSER; COMPAT_ARG_SIZE_T deftype_param_name_len = strlen("defType"), deftype_param_value_len = strlen(SOLR_DISMAX_DEFAULT_PARSER); if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", ¶m_value) == FAILURE){ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters"); RETURN_NULL(); } if(param_value == NULL){ zend_call_method_with_0_params(getThis(), solr_ce_SolrDixMaxQuery, &solr_ce_SolrDixMaxQuery->parent->constructor, "__construct", NULL); }else{ zend_call_method_with_1_params(getThis(), solr_ce_SolrDixMaxQuery, &solr_ce_SolrDixMaxQuery->parent->constructor, "__construct", NULL, param_value); } solr_add_or_set_normal_param( getThis(), deftype_param_name, deftype_param_name_len, deftype_param_value, deftype_param_value_len, 0 TSRMLS_CC ); } /* }}} */ /* {{{ proto SolrQuery::useDisMaxQueryParser() Switch Query Parser to dismax */ PHP_METHOD(SolrDisMaxQuery, useDisMaxQueryParser) { solr_char_t *param_name = "defType", *param_value = "dismax"; COMPAT_ARG_SIZE_T param_name_len = strlen("defType"), param_value_len = strlen("dismax"), result=1; result = solr_add_or_set_normal_param( getThis(), param_name, param_name_len, param_value, param_value_len, 0 TSRMLS_CC ); if(result != SUCCESS) { RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrQuery::useDisMaxQueryParser() Switch Query Parser to edismax */ PHP_METHOD(SolrDisMaxQuery, useEDisMaxQueryParser) { solr_char_t *pname = "defType", *param_value = "edismax"; COMPAT_ARG_SIZE_T pname_len = strlen("defType"), param_value_len = strlen("edismax"), result=1; result = solr_add_or_set_normal_param( getThis(), pname, pname_len, param_value, param_value_len, 0 TSRMLS_CC ); if(result != SUCCESS) { RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrQuery::setQueryAlt(string q) SetQueryAlt uses q.alt if the q param is not defined */ PHP_METHOD(SolrDisMaxQuery, setQueryAlt) { solr_char_t *pname = "q.alt"; COMPAT_ARG_SIZE_T pname_len = sizeof("q.alt")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0, set_param_return = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE){ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters"); RETURN_NULL(); } set_param_return = solr_add_or_set_normal_param(getThis(), pname, pname_len, param_value, param_value_len, 0 TSRMLS_CC); if(set_param_return == FAILURE) { RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrQuery::addQueryField(string field[, bool boost]) SetQueryAlt uses q.alt if the q param is not defined */ PHP_METHOD(SolrDisMaxQuery, addQueryField) { solr_char_t *pname = "qf"; COMPAT_ARG_SIZE_T pname_len = sizeof("qf")-1; solr_char_t *boost_str = NULL; solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; int add_result = 0; solr_char_t *delimiter = " "; solr_char_t *separator = "^"; solr_char_t *separator_override=""; zval * boost = NULL; int boost_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &field_name, &field_name_len, &boost) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters"); RETURN_NULL(); } if(boost != NULL) { convert_to_string(boost); boost_str = Z_STRVAL_P(boost); boost_len = Z_STRLEN_P(boost); add_result = solr_add_arg_list_param( getThis(), pname, pname_len, field_name, field_name_len, boost_str, boost_len, *delimiter, *separator TSRMLS_CC ); }else{ boost_str = ""; add_result = solr_add_arg_list_param_ex( getThis(), pname, pname_len, field_name, field_name_len, boost_str, boost_len, *delimiter, *separator, *separator_override TSRMLS_CC ); } if(add_result == FAILURE) { RETURN_NULL(); } SOLR_RETURN_THIS(); } /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::removeQueryField(string field) Removes a sort field from the sort parameter. */ PHP_METHOD(SolrDisMaxQuery, removeQueryField) { solr_char_t *pname = (solr_char_t*) "qf"; COMPAT_ARG_SIZE_T pname_len = sizeof("qf")-1; solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_arg_list_param_value( getThis(), pname, pname_len, field_name, field_name_len TSRMLS_CC ); SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::addPhraseField(string field, float boost [, float slop]) * Adds a new phrase field */ PHP_METHOD(SolrDisMaxQuery, addPhraseField) { solr_char_t *pname = (solr_char_t*) "pf"; COMPAT_ARG_SIZE_T pname_len = sizeof("pf")-1; solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; zval *boost = NULL; zval *slop = NULL; solr_char_t *boost_str = NULL; solr_char_t *slop_str = NULL; int add_result = 0; char * separator = "^"; solr_char_t * delimiter_override = ""; solr_string_t boost_slop_buffer; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|z", &field_name, &field_name_len, &boost, &slop) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } if(boost != NULL) { convert_to_string(boost); boost_str = Z_STRVAL_P(boost); } if (slop != NULL) { convert_to_string(slop); slop_str = Z_STRVAL_P(slop); } if (slop != NULL && boost !=NULL) { delimiter_override = "~"; memset(&boost_slop_buffer, 0, sizeof(solr_string_t)); solr_string_appends(&boost_slop_buffer, (solr_char_t *)slop_str , Z_STRLEN_P(slop)); solr_string_appendc(&boost_slop_buffer, '^'); solr_string_appends(&boost_slop_buffer, boost_str , Z_STRLEN_P(boost)); add_result = solr_add_arg_list_param_ex( getThis(), pname, pname_len, field_name, field_name_len, boost_slop_buffer.str, boost_slop_buffer.len, ' ', *separator, *delimiter_override TSRMLS_CC ); solr_string_free(&boost_slop_buffer); } else { add_result = solr_add_arg_list_param( getThis(), pname, pname_len, field_name, field_name_len, boost_str, Z_STRLEN_P(boost),' ',*separator TSRMLS_CC ); } if(add_result == FAILURE) { RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::removeQueryField(string field) Removes a phrase field from pf. */ PHP_METHOD(SolrDisMaxQuery, removePhraseField) { solr_char_t *pname = (solr_char_t*) "pf"; COMPAT_ARG_SIZE_T pname_len = sizeof("pf")-1; solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_arg_list_param_value( getThis(), pname, pname_len, field_name, field_name_len TSRMLS_CC ); SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrQuery::setPhraseFields(string fields) setPhraseFields uses pf parameter */ PHP_METHOD(SolrDisMaxQuery, setPhraseFields) { solr_char_t *pname = "pf"; COMPAT_ARG_SIZE_T pname_len = sizeof("pf")-1; int add_result = -1; solr_char_t *pvalue = NULL; COMPAT_ARG_SIZE_T pvalue_len = 0; solr_param_t *param = NULL; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pvalue, &pvalue_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } /* if the parameter is registered with a different type, remove it first */ if(solr_param_find(getThis(), pname, pname_len, ¶m TSRMLS_CC) == SUCCESS && param->type != SOLR_PARAM_TYPE_NORMAL) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Parameter %s value(s) was overwritten by this call", pname); solr_delete_solr_parameter(getThis(), pname, pname_len TSRMLS_CC); } add_result = solr_add_or_set_normal_param(getThis(), pname, pname_len, pvalue, pvalue_len, 0 TSRMLS_CC); if(add_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add parameter %s", pname); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::setPhraseSlop(integer slop) sets Phrase Slop ps argument. */ PHP_METHOD(SolrDisMaxQuery, setPhraseSlop) { solr_char_t *pname = (solr_char_t*) "ps"; COMPAT_ARG_SIZE_T pname_len = sizeof("ps")-1; int add_result = -1; solr_char_t *pvalue = NULL; COMPAT_ARG_SIZE_T pvalue_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pvalue, &pvalue_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } add_result = solr_add_or_set_normal_param(getThis(), pname, pname_len, pvalue, pvalue_len, 0 TSRMLS_CC); if(add_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter value"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::setQueryPhraseSlop(integer slop) sets QueryPhrase Slop qs argument. */ PHP_METHOD(SolrDisMaxQuery, setQueryPhraseSlop) { solr_char_t *pname = (solr_char_t*) "qs"; COMPAT_ARG_SIZE_T pname_len = sizeof("qs")-1; int add_result = -1; solr_char_t *pvalue = NULL; COMPAT_ARG_SIZE_T pvalue_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pvalue, &pvalue_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } add_result = solr_add_or_set_normal_param(getThis(), pname, pname_len, pvalue, pvalue_len, 0 TSRMLS_CC); if(add_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter value"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::setBoostQuery(string q) sets Boost Query bq parameter. */ PHP_METHOD(SolrDisMaxQuery, setBoostQuery) { solr_char_t *pname = (solr_char_t*) "bq"; COMPAT_ARG_SIZE_T pname_len = sizeof("bq")-1; int add_result = -1; solr_char_t *pvalue = NULL; COMPAT_ARG_SIZE_T pvalue_len = 0; solr_param_t *param = NULL; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pvalue, &pvalue_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } /* if the parameter is registered with a different type, remove it first */ if(solr_param_find(getThis(), pname, pname_len, ¶m TSRMLS_CC) == SUCCESS && param->type != SOLR_PARAM_TYPE_NORMAL) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Parameter %s value(s) was overwritten by this call", pname); solr_delete_solr_parameter(getThis(), pname, pname_len TSRMLS_CC); } add_result = solr_add_or_set_normal_param(getThis(), pname, pname_len, pvalue, pvalue_len, 0 TSRMLS_CC); if(add_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add parameter %s", pname); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::addBoostQueryField(string field, string value [, float boost]) * Adds a new boost query field using the bq parameter */ PHP_METHOD(SolrDisMaxQuery, addBoostQuery) { solr_char_t *pname = (solr_char_t*) "bq"; COMPAT_ARG_SIZE_T pname_len = sizeof("bq")-1; solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; zval *boost = NULL; solr_char_t *field_value = NULL; COMPAT_ARG_SIZE_T field_value_len = 0; solr_char_t *boost_str = NULL; int add_result = 0; char * separator = ":"; solr_char_t *boost_separator = "^"; solr_string_t *value_boost_str = NULL; solr_param_t *param = NULL; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|z", &field_name, &field_name_len, &field_value, &field_value_len, &boost) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } /* if the parameter is registered with a different type, remove it first */ if(solr_param_find(getThis(), pname, pname_len, ¶m TSRMLS_CC) == SUCCESS && param->type != SOLR_PARAM_TYPE_ARG_LIST) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Parameter %s value(s) was overwritten by this call", pname); solr_delete_solr_parameter(getThis(), pname, pname_len TSRMLS_CC); } if(boost != NULL) { convert_to_string(boost); boost_str = Z_STRVAL_P(boost); } if(boost !=NULL) { value_boost_str = emalloc(sizeof(solr_string_t)); memset(value_boost_str, 0, sizeof(solr_string_t)); solr_string_appends(value_boost_str, field_value, field_value_len); solr_string_appendc(value_boost_str, *boost_separator); solr_string_appends(value_boost_str, boost_str, Z_STRLEN_P(boost)); add_result = solr_add_arg_list_param( getThis(),pname, pname_len, field_name, field_name_len, value_boost_str->str, value_boost_str->len,' ',*separator TSRMLS_CC ); solr_string_free(value_boost_str); efree(value_boost_str); }else{ add_result = solr_add_arg_list_param( getThis(),pname, pname_len, field_name, field_name_len, field_value, field_value_len,' ',*separator TSRMLS_CC ); } if(add_result == FAILURE) { RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::removeBoostQuery(string field) Removes a sort field from the sort parameter. */ PHP_METHOD(SolrDisMaxQuery, removeBoostQuery) { solr_char_t *pname = (solr_char_t*) "bq"; COMPAT_ARG_SIZE_T pname_len = sizeof("bq")-1; solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_arg_list_param_value( getThis(), pname, pname_len, field_name, field_name_len TSRMLS_CC ); SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::setBoostFunction(string function) sets Boost Query bf parameter. */ PHP_METHOD(SolrDisMaxQuery, setBoostFunction) { solr_char_t *pname = (solr_char_t*) "bf"; COMPAT_ARG_SIZE_T pname_len = sizeof("bf")-1; int add_result = -1; solr_char_t *pvalue = NULL; COMPAT_ARG_SIZE_T pvalue_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pvalue, &pvalue_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } add_result = solr_add_or_set_normal_param(getThis(), pname, pname_len, pvalue, pvalue_len, 0 TSRMLS_CC); if(add_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add parameter %s", pname); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::setMinimumMatch(string value) sets Minimum Match (mm) parameter. */ PHP_METHOD(SolrDisMaxQuery, setMinimumMatch) { solr_char_t *pname = (solr_char_t*) "mm"; COMPAT_ARG_SIZE_T pname_len = sizeof("mm")-1; int add_result = -1; solr_char_t *pvalue = NULL; COMPAT_ARG_SIZE_T pvalue_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pvalue, &pvalue_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } add_result = solr_add_or_set_normal_param(getThis(), pname, pname_len, pvalue, pvalue_len, 0 TSRMLS_CC); if(add_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add parameter %s", pname); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::setTieBreaker(float tieBreaker) sets Tie Breaker (tie) parameter. */ PHP_METHOD(SolrDisMaxQuery, setTieBreaker) { solr_char_t *pname = (solr_char_t*) "tie"; COMPAT_ARG_SIZE_T pname_len = sizeof("tie")-1; int add_result = -1; solr_char_t *pvalue = NULL; COMPAT_ARG_SIZE_T pvalue_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pvalue, &pvalue_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } add_result = solr_add_or_set_normal_param(getThis(), pname, pname_len, pvalue, pvalue_len, 0 TSRMLS_CC); if(add_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add parameter %s", pname); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::setBigramPhraseFields(string bigramFields) setBigramPhraseFields uses pf2 parameter */ PHP_METHOD(SolrDisMaxQuery, setBigramPhraseFields) { solr_char_t *pname = "pf2"; COMPAT_ARG_SIZE_T pname_len = sizeof("pf2")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; int set_param_return = 0; solr_param_t *param = NULL; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE){ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters"); RETURN_NULL(); } /* if the parameter is registered with a different type, remove it first */ if(solr_param_find(getThis(), pname, pname_len, ¶m TSRMLS_CC) == SUCCESS && param->type != SOLR_PARAM_TYPE_NORMAL) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Parameter %s value(s) was overwritten by this call", pname); solr_delete_solr_parameter(getThis(), pname, pname_len TSRMLS_CC); } set_param_return = solr_add_or_set_normal_param(getThis(), pname, pname_len, param_value, param_value_len, 0 TSRMLS_CC); if(set_param_return == FAILURE) { RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::addBigramPhraseField(string field, float boost [, float slop]) * Adds a new bigram phrase field (pf2) to the list of fields */ PHP_METHOD(SolrDisMaxQuery, addBigramPhraseField) { solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; zval *boost = NULL; zval *slop = NULL; int add_result = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|z", &field_name, &field_name_len, &boost, &slop) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } add_result = add_phrase_field(getThis(), "pf2", boost, slop, field_name, field_name_len TSRMLS_CC); if(add_result == FAILURE) { RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::removeQueryField(string field) Removes a bigram phrase field. */ PHP_METHOD(SolrDisMaxQuery, removeBigramPhraseField) { solr_char_t *pname = (solr_char_t*) "pf2"; COMPAT_ARG_SIZE_T pname_len = sizeof("pf2")-1; solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_arg_list_param_value( getThis(), pname, pname_len, field_name, field_name_len TSRMLS_CC ); SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::setBigramPhraseSlop(integer slop) sets Bigram Phrase Slop ps argument. */ PHP_METHOD(SolrDisMaxQuery, setBigramPhraseSlop) { solr_char_t *pname = (solr_char_t*) "ps2"; COMPAT_ARG_SIZE_T pname_len = sizeof("ps2")-1; int add_result = -1; solr_char_t *pvalue = NULL; COMPAT_ARG_SIZE_T pvalue_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pvalue, &pvalue_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } add_result = solr_add_or_set_normal_param(getThis(), pname, pname_len, pvalue, pvalue_len, 0 TSRMLS_CC); if(add_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter value"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::setTrigramPhraseFields(string fields) setTrigramPhraseFields uses pf3 parameter */ PHP_METHOD(SolrDisMaxQuery, setTrigramPhraseFields) { solr_char_t *pname = "pf3"; COMPAT_ARG_SIZE_T pname_len = sizeof("pf3")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; int set_param_return = 0; solr_param_t *param = NULL; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE){ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters"); RETURN_NULL(); } /* if the parameter is registered with a different type, remove it first */ if(solr_param_find(getThis(), pname, pname_len, ¶m TSRMLS_CC) == SUCCESS && param->type != SOLR_PARAM_TYPE_NORMAL) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Parameter %s value(s) was overwritten by this call", pname); solr_delete_solr_parameter(getThis(), pname, pname_len TSRMLS_CC); } set_param_return = solr_add_or_set_normal_param(getThis(), pname, pname_len, param_value, param_value_len, 0 TSRMLS_CC); if(set_param_return == FAILURE) { RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::addTrigramPhraseField(string field, float boost [, float slop]) * Adds a new trigram phrase field (pf3) to the list of fields */ PHP_METHOD(SolrDisMaxQuery, addTrigramPhraseField) { solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; zval *boost = NULL; zval *slop = NULL; int add_result = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|z", &field_name, &field_name_len, &boost, &slop) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } add_result = add_phrase_field(getThis(), "pf3", boost, slop, field_name, field_name_len TSRMLS_CC); if(add_result == FAILURE) { RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::removeQueryField(string field) Removes a trigram phrase field. */ PHP_METHOD(SolrDisMaxQuery, removeTrigramPhraseField) { solr_char_t *pname = (solr_char_t*) "pf3"; COMPAT_ARG_SIZE_T pname_len = sizeof("pf3")-1; solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_arg_list_param_value( getThis(), pname, pname_len, field_name, field_name_len TSRMLS_CC ); SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::setTrigramPhraseSlop(integer slop) sets Trigram Phrase Slop ps3 argument. */ PHP_METHOD(SolrDisMaxQuery, setTrigramPhraseSlop) { solr_char_t *pname = (solr_char_t*) "ps3"; COMPAT_ARG_SIZE_T pname_len = sizeof("ps3")-1; int add_result = -1; solr_char_t *pvalue = NULL; COMPAT_ARG_SIZE_T pvalue_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pvalue, &pvalue_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } add_result = solr_add_or_set_normal_param(getThis(), pname, pname_len, pvalue, pvalue_len, 0 TSRMLS_CC); if(add_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter value"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::addUserField(string field) Adds a userfield rule to uf parameter. */ PHP_METHOD(SolrDisMaxQuery, addUserField) { solr_char_t *pname = (solr_char_t*) "uf"; COMPAT_ARG_SIZE_T pname_len = sizeof("uf")-1; int add_result = -1; solr_char_t *pvalue = NULL; COMPAT_ARG_SIZE_T pvalue_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pvalue, &pvalue_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } add_result = solr_add_simple_list_param_ex(getThis(), pname, pname_len, pvalue, pvalue_len, " " TSRMLS_CC); if(add_result == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add user field: Invalid parameter value"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::removeUserField(string field) Removes a userfield rule from uf parameter. */ PHP_METHOD(SolrDisMaxQuery, removeUserField) { solr_char_t *pname = (solr_char_t*) "uf"; COMPAT_ARG_SIZE_T pname_len = sizeof("uf")-1; solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameters"); RETURN_NULL(); } solr_delete_simple_list_param_value(getThis(), pname, pname_len, field_name, field_name_len TSRMLS_CC); SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto SolrDisMaxQuery SolrDisMaxQuery::setUserFields(string fields) Sets user fields (uf parameter) */ PHP_METHOD(SolrDisMaxQuery, setUserFields) { solr_char_t *pname = "uf"; COMPAT_ARG_SIZE_T pname_len = sizeof("uf")-1; solr_char_t *param_value = NULL; COMPAT_ARG_SIZE_T param_value_len = 0; int set_param_return = 0; solr_param_t *param = NULL; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m_value, ¶m_value_len) == FAILURE){ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters"); RETURN_NULL(); } /* if the parameter is registered with a different type, remove it first */ if(solr_param_find(getThis(), pname, pname_len, ¶m TSRMLS_CC) == SUCCESS && param->type != SOLR_PARAM_TYPE_NORMAL) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Parameter %s value(s) was overwritten by this call", pname); solr_delete_solr_parameter(getThis(), pname, pname_len TSRMLS_CC); } set_param_return = solr_add_or_set_normal_param(getThis(), pname, pname_len, param_value, param_value_len, 0 TSRMLS_CC); if(set_param_return == FAILURE) { RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ int add_phrase_field(zval *obj, solr_char_t *pname, zval *boost, zval *slop, solr_char_t *field_name, COMPAT_ARG_SIZE_T field_name_len TSRMLS_DC) { COMPAT_ARG_SIZE_T pname_len = strlen(pname); int add_result = 0; solr_char_t *boost_str = NULL; solr_char_t *slop_str = NULL; char * separator = "^"; solr_char_t * delimiter_override = ""; solr_string_t boost_slop_buffer; if(boost != NULL) { convert_to_string(boost); boost_str = Z_STRVAL_P(boost); } if (slop != NULL) { convert_to_string(slop); slop_str = Z_STRVAL_P(slop); } if (slop != NULL && boost !=NULL) { delimiter_override = "~"; memset(&boost_slop_buffer, 0, sizeof(solr_string_t)); solr_string_appends(&boost_slop_buffer, (solr_char_t *)slop_str , Z_STRLEN_P(slop)); solr_string_appendc(&boost_slop_buffer, '^'); solr_string_appends(&boost_slop_buffer, boost_str , Z_STRLEN_P(boost)); add_result = solr_add_arg_list_param_ex( obj, pname, pname_len, field_name, field_name_len, boost_slop_buffer.str, boost_slop_buffer.len, ' ', *separator, *delimiter_override TSRMLS_CC ); solr_string_free(&boost_slop_buffer); } else { add_result = solr_add_arg_list_param( obj, pname, pname_len, field_name, field_name_len, boost_str, Z_STRLEN_P(boost),' ',*separator TSRMLS_CC ); } return add_result; } solr-2.4.0/src/php7/php_solr_dismax_query.h0000644000175000017500000000507512676753707017443 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Omar Shaban | +----------------------------------------------------------------------+ */ #ifndef SOLR_DISMAX_QUERY_H_ #define SOLR_DISMAX_QUERY_H_ void init_solr_dismax_query(TSRMLS_D); PHP_METHOD(SolrDisMaxQuery, __construct); PHP_METHOD(SolrDisMaxQuery, setQueryAlt); PHP_METHOD(SolrDisMaxQuery, addQueryField); PHP_METHOD(SolrDisMaxQuery, removeQueryField); PHP_METHOD(SolrDisMaxQuery, addPhraseField); PHP_METHOD(SolrDisMaxQuery, removePhraseField); PHP_METHOD(SolrDisMaxQuery, setPhraseFields); PHP_METHOD(SolrDisMaxQuery, setPhraseSlop); PHP_METHOD(SolrDisMaxQuery, setQueryPhraseSlop); PHP_METHOD(SolrDisMaxQuery, setBoostQuery); PHP_METHOD(SolrDisMaxQuery, addBoostQuery); PHP_METHOD(SolrDisMaxQuery, removeBoostQuery); PHP_METHOD(SolrDisMaxQuery, setBoostFunction); PHP_METHOD(SolrDisMaxQuery, setMinimumMatch); PHP_METHOD(SolrDisMaxQuery, setTieBreaker); PHP_METHOD(SolrDisMaxQuery, useDisMaxQueryParser); PHP_METHOD(SolrDisMaxQuery, useEDisMaxQueryParser); PHP_METHOD(SolrDisMaxQuery, setBigramPhraseFields); PHP_METHOD(SolrDisMaxQuery, addBigramPhraseField); PHP_METHOD(SolrDisMaxQuery, removeBigramPhraseField); PHP_METHOD(SolrDisMaxQuery, setBigramPhraseSlop); PHP_METHOD(SolrDisMaxQuery, setTrigramPhraseFields); PHP_METHOD(SolrDisMaxQuery, addTrigramPhraseField); PHP_METHOD(SolrDisMaxQuery, removeTrigramPhraseField); PHP_METHOD(SolrDisMaxQuery, setTrigramPhraseSlop); PHP_METHOD(SolrDisMaxQuery, addUserField); PHP_METHOD(SolrDisMaxQuery, removeUserField); PHP_METHOD(SolrDisMaxQuery, setUserFields); #endif /* SOLR_DISMAX_QUERY_H_ */ solr-2.4.0/src/php7/php_solr_collapse_function.c0000644000175000017500000002543512676753707020435 0ustar omaromar/* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: | | Omar Shaban | +----------------------------------------------------------------------+ */ #include "php_solr.h" /* {{{ proto void SolrFunction::__construct([string field]) Constructor. */ PHP_METHOD(SolrCollapseFunction, __construct) { long int index = SOLR_UNIQUE_FUNCTION_INDEX(); uint nSize = SOLR_INITIAL_HASH_TABLE_SIZE; solr_function_t *solr_function_dest = NULL; zval *objptr = getThis(); #ifdef PHP_7 solr_function_dest = pemalloc(sizeof(solr_function_t), SOLR_FUNCTIONS_PERSISTENT); #endif solr_char_t *param_name = (solr_char_t *)"field"; COMPAT_ARG_SIZE_T param_name_len = sizeof("field"); solr_char_t *field_name = NULL; COMPAT_ARG_SIZE_T field_name_len = 0; if ((solr_function_dest = zend_hash_index_update_ptr(SOLR_GLOBAL(functions),index,(void *) solr_function_dest)) == NULL) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error while registering query parameters in HashTable"); return ; } zend_update_property_long(solr_ce_SolrCollapseFunction, objptr, SOLR_INDEX_PROPERTY_NAME, sizeof(SOLR_INDEX_PROPERTY_NAME) - 1, index TSRMLS_CC); solr_function_dest->function_index = index; solr_function_dest->name_length = strlen("collapse"); solr_function_dest->name = (solr_char_t *)"collapse"; /* Allocated memory for the params HashTable using fast cache for HashTables */ ALLOC_HASHTABLE(solr_function_dest->params); zend_hash_init(solr_function_dest->params, nSize, NULL, (dtor_func_t) solr_destroy_solr_string, SOLR_FUNCTIONS_PERSISTENT); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &field_name, &field_name_len) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error Parsing Parameters"); return; } if (field_name_len > 0 ) { solr_solrfunc_update_string(getThis(), param_name, param_name_len, field_name, field_name_len); } Z_OBJ_HT_P(getThis()) = &solr_collapse_function_object_handlers; } /* }}} */ /* {{{ proto void SolrFunction::__destruct(void) Destructor. */ PHP_METHOD(SolrCollapseFunction, __destruct) { solr_function_t *function = NULL; /* Retrieve the document entry for this SolrDocument */ if (solr_fetch_function_entry(getThis(), &function TSRMLS_CC) == SUCCESS ) { zend_hash_index_del(SOLR_GLOBAL(functions), function->function_index); } return; } /* {{{ proto string SolrFunction::setField(string field) Set the field that is being collapsed on. The field must be a single valued String, Int or Float. */ PHP_METHOD(SolrCollapseFunction, setField) { solr_char_t *key = "field", *arg; COMPAT_ARG_SIZE_T key_len = sizeof("field"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::getField(void) Get Collapse Field */ PHP_METHOD(SolrCollapseFunction, getField) { solr_char_t *key = "field"; COMPAT_ARG_SIZE_T key_len = sizeof("field"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::setMin(string value) Selects the group heads by the min value of a numeric field or function query. */ PHP_METHOD(SolrCollapseFunction, setMin) { solr_char_t *key = "min", *arg; COMPAT_ARG_SIZE_T key_len = sizeof("min"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::setMax(string value) Selects the group heads by the max value of a numeric field or function query. */ PHP_METHOD(SolrCollapseFunction, setMax) { solr_char_t *key = "max", *arg; COMPAT_ARG_SIZE_T key_len = sizeof("max"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::getMin(void) Get min parameter */ PHP_METHOD(SolrCollapseFunction, getMin) { solr_char_t *key = "min"; COMPAT_ARG_SIZE_T key_len = sizeof("min"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::getMax(void) Get max parameter */ PHP_METHOD(SolrCollapseFunction, getMax) { solr_char_t *key = "max"; COMPAT_ARG_SIZE_T key_len = sizeof("max"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::setSize(void) Sets the initial size of the collapse data structures when collapsing on a numeric field only */ PHP_METHOD(SolrCollapseFunction, setSize) { solr_char_t *key = "size", *arg; COMPAT_ARG_SIZE_T key_len = sizeof("size"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::getSize(void) Get size parameter */ PHP_METHOD(SolrCollapseFunction, getSize) { solr_char_t *key = "size"; COMPAT_ARG_SIZE_T key_len = sizeof("size"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::setHint(void) Set collapse hint Currently there is only one hint available "top_fc", which stands for top level FieldCache */ PHP_METHOD(SolrCollapseFunction, setHint) { solr_char_t *key = "hint", *arg; COMPAT_ARG_SIZE_T key_len = sizeof("hint"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::getHint(void) Get Hint */ PHP_METHOD(SolrCollapseFunction, getHint) { solr_char_t *key = "hint"; COMPAT_ARG_SIZE_T key_len = sizeof("hint"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::setNullPolicy(void) Sets the NULL Policy. Accepts ignore, expand, or collapse */ PHP_METHOD(SolrCollapseFunction, setNullPolicy) { solr_char_t *key = "nullPolicy", *arg; COMPAT_ARG_SIZE_T key_len = sizeof("nullPolicy"), arg_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { RETURN_NULL(); } if (solr_solrfunc_update_string(getThis(), key, key_len, (solr_char_t *)arg, arg_len TSRMLS_CC) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error assigning field"); RETURN_NULL(); } SOLR_RETURN_THIS(); } /* }}} */ /* {{{ proto string SolrFunction::getNullPolicy(void) Get NullPolicy */ PHP_METHOD(SolrCollapseFunction, getNullPolicy) { solr_char_t *key = "nullPolicy"; COMPAT_ARG_SIZE_T key_len = sizeof("nullPolicy"); solr_solrfunc_display_string(getThis(), key, key_len, &return_value TSRMLS_CC); } /* }}} */ /* {{{ proto string SolrFunction::__toString(void) String value of the function object */ PHP_METHOD(SolrCollapseFunction, __toString) { solr_function_t *collapse_func; solr_string_t *buffer = NULL; if(solr_fetch_function_entry(getThis(), &collapse_func TSRMLS_CC) == FAILURE) { RETURN_NULL(); } buffer = (solr_string_t *)emalloc(sizeof(solr_string_t)); memset(buffer, 0, sizeof(solr_string_t)); solr_solrfunc_to_string(collapse_func, &buffer); ZVAL_STRINGL(return_value, buffer->str, buffer->len); solr_string_free(buffer); efree(buffer); } /* }}} */ /* {{{ proto SolrClient::__sleep(void) Should not be called directly. Serialization is not supported. */ PHP_METHOD(SolrCollapseFunction, __sleep) { solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1001 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Serialization of SolrCollapseFunction objects is currently not supported"); } /* }}} */ /* {{{ proto SolrClient::__wakeup(void) Should not be called directly. Serialization is not supported. */ PHP_METHOD(SolrCollapseFunction, __wakeup) { solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_1001 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Unserialization of SolrCollapseFunction objects is currently not supported"); } /* }}} */ /* {{{ throw exception on cloning (clone handler) */ zend_object* solr_collapse_function_object_handler_clone(zval *object TSRMLS_DC) { zend_object *fake; fake = zend_objects_new(zend_standard_class_def); solr_throw_exception_ex(solr_ce_SolrIllegalOperationException, SOLR_ERROR_4001 TSRMLS_CC, SOLR_FILE_LINE_FUNC, "Cloning of SolrCollapseFunction objects is currently not supported"); return fake; } /* }}} */ solr-2.4.0/CREDITS0000644000175000017500000000004212676753707012212 0ustar omaromarsolr Israel Koko Ekpo Omar Shaban solr-2.4.0/README.CONTRIBUTORS0000644000175000017500000000634412676753707014021 0ustar omaromar ================================================================================ Omar Shaban (omars@php.net) ================================================================================ - Lead Maintainer ================================================================================ Thanks to all our [contributors](https://github.com/php/pecl-search_engine-solr/graphs/contributors). ================================================================================ These are the people that made version 1.0 release of the Apache Solr PECL extension possible. If I have left anyone out or mis-stated your contributions, please let me know so that it can be correct to reflect your contributions accurately. Thanks again for making this possible. ================================================================================ Israel Ekpo (iekpo@php.net) ================================================================================ - Orignal Author of the Apache Solr PECL extension - Orignal Extension Concept and Design - Lead Maintainer ================================================================================ Pierre-Alain Joye (pajoye@php.net) ================================================================================ - Fine tuned and created the final version of the config.w32 script (291135) - Compiled and made available several versions of the .dll binaries for Windows. - Currently hosting the windows .dll binaries for the Apache Solr PECL extension. ================================================================================ Kalle Sommer Nielsen (kalle@php.net) ================================================================================ - Significant refactoring of the config.w32 script for Windows (288890) - Corrected Windows C++ compiler bugs (288890) ================================================================================ Pierrick Charron (pierrick@php.net) ================================================================================ - Assisted in the testing of the extension using various test cases. - Uncovered and reported several bugs due to his insight of the extension internals. - Discovered bugs 16943 and 16924 - Patched the config.w32 for its first successful compilation on Windows (291101). ================================================================================ Felipe Pena (felipe@php.net) ================================================================================ - Participated significantly after the intial release and uncovered a serious bug that lead to segfaults. - Discovered bugs 16855 thru 16859 - Contributed to development of UNIX config.m4 script (289148) ================================================================================ Alex Samorukov (alexey.samorukov@varien.com) ================================================================================ - Lowered minimum supported version for libcurl to 7.15.0 - Lowered minimum supported version for libxml2 to 2.6.26 ================================================================================ (trevor at blubolt dot com, max at blubolt dot com) ================================================================================ - Fixed PECL Bug# 17172 MoreLikeThis only parses one doc solr-2.4.0/LICENSE0000644000175000017500000000622112676753707012204 0ustar omaromar-------------------------------------------------------------------- The PHP License, version 3.01 Copyright (c) 1999 - 2009 The PHP Group. All rights reserved. -------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without modification, is permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "PHP" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact group@php.net. 4. Products derived from this software may not be called "PHP", nor may "PHP" appear in their name, without prior written permission from group@php.net. You may indicate that your software works in conjunction with PHP by saying "Foo for PHP" instead of calling it "PHP Foo" or "phpfoo" 5. The PHP Group may publish revised and/or new versions of the license from time to time. Each version will be given a distinguishing version number. Once covered code has been published under a particular version of the license, you may always continue to use it under the terms of that version. You may also choose to use such covered code under the terms of any subsequent version of the license published by the PHP Group. No one other than the PHP Group has the right to modify the terms applicable to covered code created under this License. 6. Redistributions of any form whatsoever must retain the following acknowledgment: "This product includes PHP software, freely available from ". THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------- This software consists of voluntary contributions made by many individuals on behalf of the PHP Group. The PHP Group can be contacted via Email at group@php.net. For more information on the PHP Group and the PHP project, please see . PHP includes the Zend Engine, freely available at .solr-2.4.0/README.ABOUT_SOLR_EXTENSION0000644000175000017500000001411712676753707015226 0ustar omaromar $Id$ ================================================================================ Introducing the Solr PHP Extension ================================================================================ The Solr extension is an extremely fast, light-weight, feature-rich library that allows PHP developers to communicate effectively with Solr server instances. There are tools to add documents and make updates to the solr server. It also contains tools that allows you to build advanced queries to the server when searching for documents. There are also special objects that simplifies the sending of name-value requests to the server. This includes the SolrParams class and all its child classes. The SolrClient object allows one to communicate with Solr containers that are behind proxy servers or that require HTTP Authentication to proceed. The SolrClient constructor accepts options such as http authentication username and passwor, proxy server name, port, login and passwords etc. Using an advanced http client like libcurl allows us to leverage the features available with the library. We can reuse the HTTP connections without having to create a separate one for each request. ================================================================================ How to Install ================================================================================ Please refer to the README.INSTALLATION file. ================================================================================ Magic Methods and Interfaces Implemented ================================================================================ SolrDocument implements the following interfaces. (1) ArrayAccess - to access the fields as array keys using field names. (2) Iterator - to iterate over the document fields using foreach() (3) Serializable - provides custom serialization of the object. SolrDocument also contains the __get and __set magic methods which allows developers to access the fields directly. When setting fields, if the field already has a value the new value will be appended to the list of values for that field. Each field is a SolrDocumentField object with the following public properties : (a) name - a string with name of the field. (b) boost - a double representing the boost value of the field (intentionally empty) (c) values - an array of all the field values as strings. Custom Serialization string SolrDocument::serialize(void) returns an XML document representing a SolrDocument as shown below : A0F43D Israel Ekpo Israel.Ekpo@israel.ekpo.com Reading Writing Soccer Teaching Inglés Espanól Here is a complete example of a serialized SolrDocument object: C:12:"SolrDocument":679:{ A0F43D Israel Ekpo Israel.Ekpo@israel.ekpo.com Reading Writing Soccer Teaching Inglés Espanól } One of the items on my todo list is to create a response writer to return serialized SolrDocument objects instead of document arrays. SolrDocument::unserialize(string $serialized) accepts an XML document representing the SolrDocument object. It will the bring the object back to live. The SolrDocument class also has the method SolrDocument::getInputDocument() to allow one do get the SolrInputDocument version of a SolrDocument instance. This method may be helpful if one needs to resubmit the document to the server to updates. The Solr extension has the SolrQuery object (a child of SolrParams) that enables the developer to send custom advanced name-value requests to the solr server. The SolrQuery object can also be serialized and reused later, which makes it very helpful to saving the state of the application across multiple requests. This may be very useful in cases such as facet browsing where additional parameters may need to be added to the current object or removed from it to get the desired results without having to start over from scratch. ================================================================================ Parsing of XML Responses from the Solr Server ================================================================================ XML responses from the solr server are expected to be formatted using version 2.2 These xml documents are parsed into serialized php code and returned as read-only SolrObject instances whose properties can also be accessed as array keys in addition to being accessible directly via the object->member notation. Having the properties accessible via object[member] notation is helpful in cases where the property name is not valid (contains dots and other characters not legal in php. ================================================================================ How to Report Bugs ================================================================================ Please report bugs to http://bugs.php.net If you experience a crash due to a segmentation fault, please follow the instructions on the link below to get a gdb backtrace and then submit the trace in your bug report as well http://bugs.php.net/bugs-generating-backtrace.php Thank you for using PHP solr-2.4.0/README.INSTALLATION0000644000175000017500000001661112676753707013763 0ustar omaromar $Id$ ================================================================================ PHP VERSION Dependencies ================================================================================ PHP version 5.3 or later is needed ================================================================================ Extension Dependencies ================================================================================ LIBXML extension JSON extension ================================================================================ Library Dependencies ================================================================================ libxml2 2.6.26 or later is required libcurl 7.15.0 or later is required ================================================================================ On UNIX ================================================================================ As mentioned before, the libxml and curl extensions must be enabled for the Apache Solr extension to be functional. Do not attempt to hack the code to make it compile. It will fail, possibly with errors that could be hard to debug To install the Apache Solr extension directly from PECL, please enter the following command, then follow the prompts pecl install solr To compile from source, please follow the following steps $ phpize $ ./configure $ make && make install This should compile the code and install it in the extension_dir specified in the ini file. Then open your php.ini file and add the following line to it extension=solr.so Then restart your webserver. For CLI only, you do not have to restart your webserver. Note : If your system does not have the minimum version of the libcurl or libxml libraries, you can download the libraries and compile them from source into a separate install prefix. wget http://curl.haxx.se/download/curl-7.19.6.tar.gz tar -zxvf curl-7.19.6.tar.gz cd curl-7.19.6 configure --prefix=/root/custom/software make && make install cd .. wget ftp://xmlsoft.org/libxml2/libxml2-2.7.6.tar.gz tar -zxvf libxml2-2.7.6.tar.gz cd libxml2-2.7.6 configure --prefix=/root/custom/software make && make install This example assumes that the libxml2 and libcurl libraries were compiled from source and installed using "/root/custom/software" as the --prefix So the absolute path to the easy.h header file will be /root/custom/software/include/curl/easy.h And the absolute path to the libxml/parser.h header file wil be /root/custom/software/include/libxml2/libxml/parser.h The absolute path to the xml2-config script will be /root/custom/software/bin/xml2-config And the absolute path to the curl-config script will be /root/custom/software/bin/curl-config Then you can pass libcurl prefix to the configure script for CURL and LIBXML respectively during the configuration phase as shown here : 4B ./configure --enable-solr --with-curl=/root/custom/software --with-libxml-dir=/root/custom/software If you already have the latest versions of the libraries then the step listed in 4A alone is sufficient. 5. make && make install This should compile the code and install it in the extension_dir specified in the ini file. Then open your php.ini file and add the following line to it extension=solr.so If you would prefer to compile the Solr extension statically into php, you will need to follow the following steps. 1. copy the solr_xxx folder into the ext folder in the php source 2. Include the --enable-solr flag as one of the options when configuring php This will build the Solr extension statically into php. After the installation is completed, you will have to restart your webserver for the changes to take effect. For CLI only use, you do not have to restart your webserver. ================================================================================ On Windows ================================================================================ If you are using a pre-compiled dll, simply copy the php_solr.dll file to your extension_dir specified in the ini file. Then open your php.ini file and add the following line to it extension=php_solr.dll Then restart your webserver. For CLI only, you do not have to restart your webserver. If you are building from source, you will need to download the library dependencies for libxml and libcurl from the following link to the deps folder before running buildconf.bat http://wiki.php.net/internals/windows/libs http://pecl2.php.net/downloads/php-windows-builds/php-libs/ More details are avialable here http://wiki.php.net/internals/windows Windows DLLs are now available here http://downloads.php.net/pierre/ If you are building from source, you will need to download the library dependencies for libxml and libcurl from the following link to the deps folder before running buildconf.bat The Apache Solr extension can be compiled statically or shared. - Shared compilation creates a php_solr.dll file. - Static compilation puts the Solr extension directly into PHP (therefore it does not need to be loaded and cannot be unloaded). You can toggle between compiling statically or as library by adding =static or =shared to the configure.js command during the compilation. configure --with-solr=static configure --with-solr=shared - In the first configure command, the Apache Solr extension will be included in PHP - In the second configure command, the Apache Solr extension will be compiled as separate DLL Here is a more detail list of steps to follow : 1. Get visual studio 2008 ((express edition or professional) and install it. 2. Get and install windows sdk 6.1. 3. Get a php 5.3 snapshot (do not extract yet!). 4. Create the folder "c:\php-sdk" 5. Unpack the binary tools archive into this directory, there should be one sub-directory called "bin" and one called "script" 6. Open the "windows sdk 6.1 shell" (which is available from the start menu group) and execute the following commands in it: setenv /x86 /xp /release cd c:\php-sdk\ bin\phpsdk_setvars.bat bin\phpsdk_buildtree.bat php53dev 7. Now extract the snapshot from Step 3 to C:\php-sdk\php53dev\vc9\x86 with your favourite unpacker so that the following directory gets created: C:\php-sdk\php53dev\vc9\x86\php5.3-xyz 8. run in the windows-sdk-shell: cd C:\php-sdk\php53dev\vc9\x86\php5.3-xyz buildconf 9. now run configure --help, to get an overview of the compiling flags 10. configure --disable-all --enable-cli --with-solr=yes --with-curl=yes --with-libxml=yes 11. nmake If you are using Visual Studio 2005, use vc8 wherever you see vc9. If you are on a 64-bit system, use x64 instead of x86. The following resources can provide you with more information : http://wiki.php.net/internals/windows/libs http://pecl2.php.net/downloads/php-windows-builds/php-libs/ More details are avialable here : http://wiki.php.net/internals/windows The binary tools archive is available at : http://pecl2.php.net/downloads/php-windows-builds/php-libs/binary-tools.zip Windows SDK 6.1 is available at : http://www.microsoft.com/downloads/details.aspx?FamilyId=E6E1C3DF-A74F-4207-8586-711EBE331CDC&displaylang=en The PHP 5.3 shapshot is available at: http://windows.php.net/downloads/snaps/php-5.3/php-5.3-src-latest.zip ================================================================================ How to Report Bugs ================================================================================ Please report bugs to omars@php.net You can also register bugs here http://pecl.php.net/bugs/report.php?package=solr Thank you for using PHP solr-2.4.0/README.SUBMITTING_CONTRIBUTIONS0000644000175000017500000000433212676753707015666 0ustar omaromar $Id$ ================================================================================ Submitting contributions ================================================================================ A lot of time has been put into designing, implementing and documenting this extension. A lot of work has also been put into ensuring that users of the extension experience very minimal defects during usage. New ideas, corrections, bug fixes, feature improvements are always welcome. However, you must discuss any changes you are about to make to any of the source files prior to making or submitting such changes either in the PECL developers mailing list (pecl-dev@lists.php.net) or by contacting the current author(s) or maintainer(s) of this extension directly. Test scripts should be included when making the submissions. Also explain thoroughly what has been fixed/added/changed by your patch. If your patch is easy to review and has obviously no side-effects, it might take up to a few hours until it is committed. Since this is a volunteer-driven effort, more complex patches will require more patience on the part of the submitter. ================================================================================ Testing thoroughly before submissions ================================================================================ This is a fairly large library and each component is dependent on another component either directly or indirectly. As a consequence, any and all changes must be tested thoroughly before commiting them. It is only polite to the users, author(s) or maintainer(s) that you do so. ================================================================================ Checklist for making submissions ================================================================================ - Did you run "make test" to check if your patch didn't break other features? - Did you compile PHP with --enable-debug and check the PHP and web server error logs when you test your patch? - Did you build PHP for multi-threaded web servers. - Did you create test script for "make test"? (Recommended) - Did you check your patch is unified format and it does not contain white space changes? - Did you read the patch again? solr-2.4.0/README.MEMORY_ALLOCATION0000644000175000017500000000531512676753707014576 0ustar omaromar $Id$ ================================================================================ Solr Notes about Memory Allocation and interaction with HashTables ================================================================================ The following notes are for C-space PHP developers. If you are not really familiar with how the Zend HashTable API or the memory allocation marcros really works, please take sometime to read the notes below : This is correct as of Zend Engine version 2.3.0 - If memory was allocated with emalloc(), it has to be freed with efree(). - If memory was allocated using pemalloc(), the same value for the persistent parameter must be used during pefree() to deallocated the allocated memory. The memory manager for the Zend API will then decide whether to use free() or efree() depending on whether persistent is 1 or 0 respectively. The same principle applies to pestrdup(), pecalloc() and the other memory allocation macros. - When inserting values into the HashTables, if the value for the persistent parameter is set, then the memory allocation for the entered item should be persistent to i.e. pemalloc() with persistent set to 1. The following will apply when adding new values into a HashTable for items that were dynamically allocated : (a) If the value for the nDataSize parameter is the size of that of a pointer sizeof(void *), the HashTable API copies the contents of the pData parameter into the Bucket->pDataPtr member for that data Bucket. Then it sets the Bucket->pData member to the address of the Bucket->pDataPtr member for that data Bucket. (b) If the value for the nDataSize parameter is not equal to sizeof(void *), the HashTable API allocates new memory for the Bucket->pData member using the size equivalent to nDataSize and the same value for the persistent flag set for the target HashTable. The the contents of the pData parameter is copied into the Bucket->pData member in this newly allocated memory location. Then the Bucket->pDataPtr member for this Bucket is set to NULL. Do not worry about the newly allocated memory allocated by the HashTable API; if the nDataSize parameter was not equal to sizeof(void *), then during the cleanup process, the Zend API will free the new memory it allocated during the insert process. It will also call the destructor function if a valid one was passed when the HashTable was initialized with zend_hash_init(). In the extension, I have used the p* version of the memory allocation functions to allow me toggle if there is any need to do so in the future. This will prevent a massive search and replace effort. For all the HashTables, I set the intial size to 8 to reduce the looping when zend_hash_init() is setting up the HashTable pointer to use. solr-2.4.0/TODO0000644000175000017500000000146712676753707011676 0ustar omaromar 2014-02-17 $Id$ ================================================================================ Features and things to do in the library ================================================================================ - Set up php.ini entries for default servlet values. This will allow developers to set custom values for the servlets. - Ability to send custom requests to Solr (custom url, custom request contents) - Ability to add files (pdf, office documents, etc) - Ensure the SolrQuery::getFields(), SolrQuery::getFacets() et all returns an array consistently. - More frequent compilations of releases for PHP 5.3 on Windows - Support JSON Writer - Support Solr Spatial Features Natively - Introduce SolrServerException to parse and return Solr Server error messages instead of dumping xml docs solr-2.4.0/docs/documentation.php0000644000175000017500000024447712676753707015532 0ustar omaromar | | Omar Shaban | +----------------------------------------------------------------------+ */ /* $Id$ */ define('SOLR_MAJOR_VERSION', 2); define('SOLR_MINOR_VERSION', 3); define('SOLR_PATCH_VERSION', 0); define('SOLR_EXTENSION_VERSION', '2.3.0'); /** * Returns the current version of the Apache Solr extension * * @return string */ function solr_get_version() { return SOLR_EXTENSION_VERSION; } /** * This is the base class for all exception thrown by the Solr extension classes. * * @author Israel Ekpo */ class SolrException extends Exception { /* Properties */ protected $sourceline; protected $sourcefile; protected $zif_name; /** * Returns internal information where the Exception was thrown * @return array * @link http://docs.php.net/manual/en/solrexception.getinternalinfo.php */ public function getInternalInfo() {} } /** * An exception thrown when there is an error while making a request to the server from the client. * @author Israel Ekpo */ class SolrClientException extends SolrException { /** * Returns internal information where the Exception was thrown * * @return array * @link http://docs.php.net/manual/en/solrclientexception.getinternalinfo.php */ public function getInternalInfo() {} } /** * Used for Solr Related Exceptions * * @author Omar Shaban */ class SolrServerException extends SolrException { /** * Returns internal information where the Exception was thrown * * @return array * @link http://docs.php.net/manual/en/solrserverexception.getinternalinfo.php */ public function getInternalInfo() {} } /** * This object is thrown when an illeglal or invalid argument is passed to a method. * * @link http://docs.php.net/manual/en/class.solrillegalargumentexception.php * @author Israel Ekpo */ class SolrIllegalArgumentException extends SolrException { /** * Returns internal information where the Exception was thrown * @return string * @link http://docs.php.net/manual/en/solrillegalargumentexception.getinternalinfo.php */ public function getInternalInfo() {} } /** * @link http://docs.php.net/manual/en/class.solrillegaloperationexception.php * @author Israel Ekpo */ class SolrIllegalOperationException extends SolrException { /** * Returns internal information where the Exception was thrown * * @return string * @link http://docs.php.net/manual/en/solrillegaloperationexception.getinternalinfo.php */ public function getInternalInfo() {} } /** * @author Omar Shaban */ class SolrMissingMandatoryParameterException extends SolrException { } /** * * @author Israel Ekpo */ abstract class SolrUtils { /** * Parses an response XML string into a SolrObject * * @param string $xmlresponse * @param int $parse_mode * @return SolrObject * @link http://docs.php.net/manual/en/solrutils.digestxmlresponse.php */ public static function digestXmlResponse($xmlresponse, $parse_mode = 0) {} /** * Escapes a lucene query string * * @param string $str String to be escaped * @return string * @link http://docs.php.net/manual/en/solrutils.escapequerychars.php */ public static function escapeQueryChars($str) {} /** * Returns the current version of the Solr extension * @return string * @link http://docs.php.net/manual/en/solrutils.getsolrversion.php */ public static function getSolrVersion() {} /** * Prepares a phrase from an unescaped lucene string * * @param string $str * @return string * @link http://docs.php.net/manual/en/solrutils.queryphrase.php */ public static function queryPhrase($str) {} } /** * Represents a field in a Solr document. All its properties are read-only. * * @author Israel Ekpo */ class SolrDocumentField { /** * The name of the field * * @var string */ public $name; /** * The boost value for the field * * @var float */ public $boost; /** * An array of values for this field * @var array */ public $values; /** * Constructor */ public function __construct() {} /** * Destructor */ public function __destruct() {} } /** * Represents a Solr document that is about to be submitted to the Solr index * * @link http://docs.php.net/manual/en/class.solrinputdocument.php * @author Israel Ekpo */ final class SolrInputDocument { /** * Sorts the fields in ascending order */ const SORT_DEFAULT = 1 ; /** * Sorts the fields in ascending order */ const SORT_ASC = 1 ; /** * Sorts the fields in descending order */ const SORT_DESC = 2 ; /** * Sorts the fields by name */ const SORT_FIELD_NAME = 1 ; /** * Sorts the fields by number of values */ const SORT_FIELD_VALUE_COUNT = 2 ; /** * Sorts the fields by boost value */ const SORT_FIELD_BOOST_VALUE = 4 ; /** * Adds a field to the document * * @param string $fieldName The name of the field * @param string $fieldValue The value for the field * @param float $fieldBoostValue The index time boost for the field. Though this cannot be negative, you can still pass values less than 1.0 but they must be greater than zero. * @link http://docs.php.net/manual/en/solrinputdocument.addfield.php */ public function addField($fieldName, $fieldValue, $fieldBoostValue = 0.0) {} /** * Resets the document by dropping all the fields and resets the document boost to zero * * @link http://docs.php.net/manual/en/solrinputdocument.clear.php * @return bool Returns TRUE on success or FALSE on failure */ public function clear() {} public function __clone() {} public function __construct() {} public function __destruct() {} /** * Removes a field from the document * @param string $fieldName * @link http://docs.php.net/manual/en/solrinputdocument.deletefield.php */ public function deleteField($fieldName) {} /** * Checks if a field exists * * @param $fieldName * @return bool * @link http://docs.php.net/manual/en/solrinputdocument.fieldexists.php */ public function fieldExists($fieldName) {} /** * Retrieves the current boost value for the document * * @return float * @link http://docs.php.net/manual/en/solrinputdocument.getboost.php */ public function getBoost() {} /** * Retrieves a field by name * * @param string $fieldName * @return SolrDocumentField */ public function getField($fieldName) {} /** * Retrieves the boost value for a particular field * * @param string $fieldName * @return float * @link http://docs.php.net/manual/en/solrinputdocument.getfieldboost.php */ public function getFieldBoost($fieldName) {} /** * Returns the number of fields in the document * * @return int * @link http://docs.php.net/manual/en/solrinputdocument.getfieldcount.php */ public function getFieldCount() {} /** * Returns an array containing all the fields in the document * * @return array * @link http://docs.php.net/manual/en/solrinputdocument.getfieldnames.php */ public function getFieldNames() {} /** * Merges one input document into another * * @param SolrInputDocument $sourceDoc * @param bool $overwrite * @link http://docs.php.net/manual/en/solrinputdocument.merge.php */ public function merge(SolrInputDocument $sourceDoc, $overwrite = true) {} /** * This is an alias of SolrInputDocument::clear * * @return bool * @link http://docs.php.net/manual/en/solrinputdocument.reset.php */ public function reset() {} /** * Sets the boost value for this document * * @param float $documentBoostValue * @link http://docs.php.net/manual/en/solrinputdocument.setboost.php */ public function setBoost($documentBoostValue) {} /** * Sets the index-time boost value for a field * * @param string $fieldName * @param float $fieldBoostValue * @link http://docs.php.net/manual/en/solrinputdocument.setfieldboost.php */ public function setFieldBoost($fieldName, $fieldBoostValue) {} /** * Sorts the fields within the document * * @param int $sortOrderBy * @param int $sortDirection One of the SolrInputDocument::SORT_* constants * @link http://docs.php.net/manual/en/solrinputdocument.sort.php */ public function sort($sortOrderBy, $sortDirection = SolrInputDocument::SORT_ASC) {} /** * Returns an array representation of the input document * * @return array * @link http://docs.php.net/manual/en/solrinputdocument.toarray.php */ public function toArray() {} /** * Adds a child document * * @param SolrInputDocument $child * @return void * @throws SolrIllegalArgumentException * @throws SolrException */ public function addChildDocument(SolrInputDocument $child) {} /** * Adds child documents * * @param array $children * @return void * @throws SolrIllegalArgumentException * @throws SolrException */ public function addChildDocuments(array $children) {} /** * Whether this input document has child documents * * @return bool */ public function hasChildDocuments() {} /** * Returns an array of child documents (SolrInputDocument) * * @return array */ public function getChildDocuments() {} /** * Returns the number of child documents * * @return int */ public function getChildDocumentsCount() {} } /** * Represents a Solr document retrieved from a query response * * @link http://docs.php.net/manual/en/class.solrdocument.php * @author Israel Ekpo * @author Omar Shaban */ final class SolrDocument implements ArrayAccess, Iterator, Serializable { const SORT_DEFAULT = 1 ; const SORT_ASC = 1 ; const SORT_DESC = 2 ; const SORT_FIELD_NAME = 1 ; const SORT_FIELD_VALUE_COUNT = 2 ; const SORT_FIELD_BOOST_VALUE = 4 ; public function __construct() {} public function __clone() {} public function __destruct() {} /** * Adds a field to the document * * @param string $fieldName * @param string $fieldValue * @return Returns TRUE on success or FALSE on failure * @link http://docs.php.net/manual/en/solrdocument.addfield.php */ public function addField($fieldName, $fieldValue) {} /** * Drops all the fields in the document * * @return Returns TRUE on success or FALSE on failure * @link http://docs.php.net/manual/en/solrdocument.addfield.php */ public function clear() {} /** * Retrieves the current field * * @return SolrDocumentField * @link http://docs.php.net/manual/en/solrdocument.current.php */ public function current() {} /** * Removes a field from the document * * @param string $fieldName * @link http://docs.php.net/manual/en/solrdocument.deletefield.php */ public function deleteField($fieldName) {} /** * Checks if a field exists in the document * @param string $fieldName * @return Returns TRUE if the field is present and FALSE if it does not * @link http://docs.php.net/manual/en/solrdocument.fieldexists.php */ public function fieldExists($fieldName) {} /** * Magic method for accessing the field as a property * * @param string $fieldName * @link http://docs.php.net/manual/en/solrdocument.get.php */ public function __get($fieldName) {} /** * Retrieves a field by name * * @param string $fieldName * @return SolrDocumentField */ public function getField($fieldName) {} /** * Returns the number of fields in this document. Multi-value fields are only counted once. * * @return int * @link http://docs.php.net/manual/en/solrdocument.getfieldcount.php */ public function getFieldCount() {} /** * Returns an array of fields names in the document * * @return array * @link http://docs.php.net/manual/en/solrdocument.getfieldcount.php */ public function getFieldNames() {} /** * Returns a SolrInputDocument equivalent of the object * * @return SolrInputDocument * @link http://docs.php.net/manual/en/solrdocument.getinputdocument.php */ public function getInputDocument() {} public function __isset($fieldName) {} public function key() {} /** * Merges source to the current SolrDocument * * @param SolrDocument $sourceDoc * @param bool $overwrite * @link http://docs.php.net/manual/en/solrdocument.merge.php */ public function merge(SolrDocument $sourceDoc, $overwrite = true) {} public function next() {} public function offsetExists($fieldName) {} public function offsetGet($fieldName) {} public function offsetSet($fieldName, $fieldValue) {} public function offsetUnset($fieldName) {} public function reset() {} public function rewind() {} public function serialize() {} public function __set($fieldName, $fieldValue) {} public function sort($sortOrderBy, $sortDirection) {} public function toArray() {} public function unserialize($serialized) {} public function __unset($fieldName) {} public function valid() {} /** * Checks whether this document contains child documents * * @return bool */ public function hasChildDocuments() {} /** * Returns an array of child documents (SolrDocument) * * @return array */ public function getChildDocuments() {} /** * Returns the number of child documents * * @return int */ public function getChildDocumentsCount() {} } /** * * @author Israel Ekpo */ class SolrObject implements ArrayAccess { /* Methods */ public function __construct() {} public function __destruct() {} public function getPropertyNames() {} public function offsetExists($property_name) {} public function offsetGet($property_name) {} public function offsetSet($property_name, $property_value) {} public function offsetUnset($property_name) {} } /** * * @author Israel Ekpo * @author Omar Shaban */ final class SolrClient { /* Constants */ const SEARCH_SERVLET_TYPE = 1 ; const UPDATE_SERVLET_TYPE = 2 ; const THREADS_SERVLET_TYPE = 4 ; const PING_SERVLET_TYPE = 8 ; const TERMS_SERVLET_TYPE = 16 ; const SYSTEM_SERVLET_TYPE = 32; const DEFAULT_SEARCH_SERVLET = 'select' ; const DEFAULT_UPDATE_SERVLET = 'update' ; const DEFAULT_THREADS_SERVLET = 'admin/threads' ; const DEFAULT_PING_SERVLET = 'admin/ping' ; const DEFAULT_TERMS_SERVLET = 'terms' ; const DEFAULT_SYSTEM_SERVLET = 'admin/system' ; /** * Constructor * * @param array $clientOptions */ public function __construct(array $clientOptions) {} public function __destruct() {} /** * Adds a document to the index * * @param SolrInputDocument $doc * @param bool $overwrite * @param int $commitWithin 0 means disabled * @return SolrUpdateResponse */ public function addDocument(SolrInputDocument &$doc, $overwrite = true, $commitWithin = 0) {} /** * Adds a collection of SolrInputDocument instances to the index * * @param array $docs An array of SolrInputDocument objects * @param bool $overwrite * @param int $commitWithin * @return SolrUpdateResponse */ public function addDocuments(array &$docs, $overwrite = true, $commitWithin = 0) {} /** * Finalizes all add/deletes made to the index * * @param bool $softCommit * @param bool $waitSearcher * @param bool $expungeDeletes * @return SolrUpdateResponse */ public function commit($softCommit = false, $waitSearcher = true, $expungeDeletes = false) {} /** * Get Document By Id. Utilizes Solr Realtime Get (RTG). * * @param string $id * @return SolrQueryResponse */ public function getById($id) {} /** * Get Documents by their Ids. Utilizes Solr Realtime Get (RTG). * * @param array $ids * @return SolrQueryResponse */ public function getByIds(array $ids) {} /** * Deletes the document with the specified ID. * * Where ID is the value of the uniqueKey field declared in the schema * * @param string $id * @return SolrUpdateResponse */ public function deleteById($id) {} /** * Deletes a collection of documents with the specified set of ids * * @param array $ids * @return SolrUpdateResponse */ public function deleteByIds(array $ids) {} /** * Removes all documents matching any of the queries * * @param array $queries * @return SolrUpdateResponse */ public function deleteByQueries(array $queries) {} /** * Deletes all documents matching the given query * * @param string $query * @return SolrUpdateResponse */ public function deleteByQuery($query) {} /** * Returns the debug data for the last connection attempt * * @return string */ public function getDebug() {} /** * Returns the client options set internally * * @return array */ public function getOptions() {} /** * Defragments the index for faster search performance * * @param int $maxSegments * @param bool $softCommit * @param bool $waitSearcher * @return SolrUpdateResponse */ public function optimize($maxSegments = 1, $softCommit = false, $waitSearcher = true) {} /** * Checks if Solr server is still up * * @return SolrPingResponse */ public function ping() {} /** * Sends a query to the server * * @param SolrParams $query * @return SolrQueryResponse */ public function query(SolrParams $query) {} /** * Sends a raw XML update request to the server * * @param string $raw_request * @return SolrUpdateResponse */ public function request($raw_request) {} /** * Rollbacks all add/deletes made to the index since the last commit * * @return SolrUpdateResponse */ public function rollback() {} /** * Changes the specified servlet type to a new value * * @param int $type * @param string $value * * @return bool * @link http://docs.php.net/manual/en/solrclient.setservlet.php */ public function setServlet($type, $value) {} /** * Checks the threads status * * @return SolrGenericResponse * @link http://docs.php.net/manual/en/solrclient.threads.php */ public function threads() {} /** * Retrieve Solr Server System Information * * @return SolrGenericResponse */ public function system() {} } /** * * @author Israel Ekpo */ class SolrResponse { /* Constants */ const PARSE_SOLR_OBJ = 0 ; const PARSE_SOLR_DOC = 1 ; /* Properties */ protected $http_status; protected $parser_mode; protected $success; protected $http_status_message; protected $http_request_url; protected $http_raw_request_headers; protected $http_raw_request; protected $http_raw_response_headers; protected $http_raw_response; protected $http_digested_response; /* Methods */ public function __construct() {} public function __destruct() {} /** * Returns the XML response as serialized PHP data * * @return string * @link http://docs.php.net/manual/en/solrresponse.getdigestedresponse.php */ public function getDigestedResponse() {} /** * @return int * @link http://docs.php.net/manual/en/solrresponse.gethttpstatus.php */ public function getHttpStatus() {} /** * @return string * @link http://docs.php.net/manual/en/solrresponse.gethttpstatusmessage.php */ public function getHttpStatusMessage() {} /** * @return string * @link http://docs.php.net/manual/en/solrresponse.getrawrequest.php */ public function getRawRequest() {} /** * @return string * @link http://docs.php.net/manual/en/solrresponse.getrawrequestheaders.php */ public function getRawRequestHeaders() {} /** * @return string * @link http://docs.php.net/manual/en/solrresponse.getrawresponse.php */ public function getRawResponse() {} /** * Returns the raw response headers from the server * * @return string * @link http://docs.php.net/manual/en/solrresponse.getrawresponseheaders.php */ public function getRawResponseHeaders() {} /** * Returns the full URL the request was sent to * * @return string * @link http://docs.php.net/manual/en/solrresponse.getrequesturl.php */ public function getRequestUrl() {} /** * Returns a SolrObject representing the XML response from the server * * @return SolrObject * @link http://docs.php.net/manual/en/solrresponse.getresponse.php */ public function getResponse() {} /** * @param int $parser_mode * @return bool * @link http://docs.php.net/manual/en/solrresponse.setparsemode.php */ public function setParseMode($parser_mode) {} /** * @return bool * @link http://docs.php.net/manual/en/solrresponse.success.php */ public function success() {} } /** * * @author Israel Ekpo */ class SolrQueryResponse extends SolrResponse { } /** * * @author Israel Ekpo */ class SolrUpdateResponse extends SolrResponse { } /** * * @author Israel Ekpo */ class SolrPingResponse extends SolrResponse { } /** * * @author Israel Ekpo */ class SolrGenericResponse extends SolrResponse { } /** * * @author Israel Ekpo */ abstract class SolrParams implements Serializable { /** * This is an alias for SolrParams::addParam * * @param $name * @param $value * @return SolrParams */ public function add($name, $value) {} /** * Adds a parameter to the object * * @param string $name Param name * @param string $value Param value * @return SolrParams */ public function addParam($name, $value) {} /** * This is an alias for SolrParams::getParam * * Returns an array or string depending on the type of parameter * * @param string $param_name * * @return mixed */ public function get($param_name) {} /** * Returns an array or string depending on the type of parameter * * @param string $param_name * * @return mixed */ public function getParam($param_name) {} /** * Returns an array of non URL-encoded parameters * * @return array */ public function getParams() {} /** * Returns an array on URL-encoded parameters * * @return array */ public function getPreparedParams() {} /** * Used for custom serialization * * @return string */ public function serialize() {} /** * * @param $name * @param $value * @return SolrParams */ public function set($name, $value) {} /** * * @param $name * @param $value * @return SolrParams */ public function setParam($name, $value) {} /** * Returns all the name-value pair parameters in the object * * @param bool $url_encode Whether to return URL-encoded values * * @return string */ public function toString($url_encode) {} /** * Used for Custom serialization * * @param string $serialized * @return void */ public function unserialize($serialized) {} } /** * Represents a collection of name-value pairs sent to the Solr server during a request * * @author Israel Ekpo */ class SolrModifiableParams extends SolrParams implements Serializable { public function __construct() {} public function __destruct() {} /** * This is an alias for SolrParams::addParam * * @param $name * @param $value * @return SolrModifiableParams */ public function add($name, $value) {} /** * Adds a parameter to the object * * @param string $name Param name * @param string $value Param value * @return SolrParams */ public function addParam($name, $value) {} /** * Returns an array on URL-encoded parameters * * @return array */ public function getPreparedParams() {} /** * Used for custom serialization * * @return string */ public function serialize() {} /** * * @param $name * @param $value * @return SolrModifiableParams */ public function set($name, $value) {} /** * * @param $name * @param $value * @return SolrModifiableParams */ public function setParam($name, $value) {} /** * Returns all the name-value pair parameters in the object * * @param bool $url_encode Whether to return URL-encoded values * * @return string */ public function toString($url_encode) {} /** * Used for Custom serialization * * @param string $serialized * @return void */ public function unserialize($serialized) {} } /** * * @author Israel Ekpo * @author Omar Shaban */ class SolrQuery extends SolrModifiableParams implements Serializable { /* Constants */ const ORDER_ASC = 0 ; const ORDER_DESC = 1 ; const FACET_SORT_INDEX = 0 ; const FACET_SORT_COUNT = 1 ; const TERMS_SORT_INDEX = 0 ; const TERMS_SORT_COUNT = 1 ; /** * * @param string $q Query string */ public function __construct($q = null) {} public function __destruct() {} /** * This is an alias for SolrParams::addParam * * @param $name * @param $value * @return SolrQuery */ public function add($name, $value) {} /** * Adds a parameter to the object * * @param string $name Param name * @param string $value Param value * @return SolrParams */ public function addParam($name, $value) {} /** * This is an alias for SolrParams::getParam * * Returns an array or string depending on the type of parameter * * @param string $param_name * * @return mixed */ public function get($param_name) {} /** * Returns an array or string depending on the type of parameter * * @param string $param_name * * @return mixed */ public function getParam($param_name) {} /** * Returns an array of non URL-encoded parameters * * @return array */ public function getParams() {} /** * Returns an array on URL-encoded parameters * * @return array */ public function getPreparedParams() {} /** * Used for custom serialization * * @return string */ public function serialize() {} /** * * @param $name * @param $value * @return SolrQuery */ public function set($name, $value) {} /** * * @param $name * @param $value * @return SolrQuery */ public function setParam($name, $value) {} /** * Returns all the name-value pair parameters in the object * * @param bool $url_encode Whether to return URL-encoded values * * @return string */ public function toString($url_encode) {} /** * Used for Custom serialization * * @param string $serialized * @return void */ public function unserialize($serialized) {} /** * @param string $dateField * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.addfacetdatefield.php */ public function addFacetDateField($dateField) {} /** * Adds another facet.date.other parameter * * @param string $value * @param string $field_override [optional] Field name for the override * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.addfacetdateother.php */ public function addFacetDateOther($value, $field_override = null) {} /** * Adds another field to the facet * * @param string $field * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.addfacetfield.php */ public function addFacetField($field) {} /** * @param string $facetQuery * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.addfacetquery.php */ public function addFacetQuery($facetQuery) {} /** * @param string $field * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.addfield.php */ public function addField($field) {} /** * @param string $fq * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.addfilterquery.php */ public function addFilterQuery($fq) {} /** * @param string $field * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.addhighlightfield.php */ public function addHighlightField($field) {} /** * @param string $field * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.addmltfield.php */ public function addMltField($field) {} /** * @param string $field * @param float $boost * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.addmltqueryfield.php */ public function addMltQueryField($field, $boost) {} /** * @param string $field * @param int $order * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.addsortfield.php */ public function addSortField($field, $order) {} /** * @param string $field * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.addstatsfacet.php */ public function addStatsFacet($field) {} /** * @param string $field * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.addstatsfield.php */ public function addStatsField($field) {} /** * @return bool * @link http://docs.php.net/manual/en/solrquery.getfacet.php */ public function getFacet() {} /** * @param string $field_override [optional] * @return string * @link http://docs.php.net/manual/en/solrquery.getfacetdateend.php */ public function getFacetDateEnd($field_override = null) {} /** * @return array * @link http://docs.php.net/manual/en/solrquery.getfacetdatefields.php */ public function getFacetDateFields() {} /** * @param string $field_override [optional] * @return string * @link http://docs.php.net/manual/en/solrquery.getfacetdategap.php */ public function getFacetDateGap($field_override = null) {} /** * @param string $field_override [optional] * @return string * @link http://docs.php.net/manual/en/solrquery.getfacetdatehardend.php */ public function getFacetDateHardEnd($field_override = null) {} /** * @param string $field_override [optional] * @return array * @link http://docs.php.net/manual/en/solrquery.getfacetdateother.php */ public function getFacetDateOther($field_override = null) {} /** * @param string $field_override [optional] * @return string * @link http://docs.php.net/manual/en/solrquery.getfacetdatestart.php */ public function getFacetDateStart($field_override = null) {} /** * @return array * @link http://docs.php.net/manual/en/solrquery.getfacetfields.php */ public function getFacetFields() {} /** * @param string $field_override [optional] * @return int * @link http://docs.php.net/manual/en/solrquery.getfacetlimit.php */ public function getFacetLimit($field_override) {} /** * @param string $field_override [optional] * @return string * @link http://docs.php.net/manual/en/solrquery.getfacetmethod.php */ public function getFacetMethod($field_override) {} /** * @param string $field_override [optional] * @return int * @link http://docs.php.net/manual/en/solrquery.getfacetmincount.php */ public function getFacetMinCount($field_override) {} /** * @param string $field_override [optional] * * @return bool * @link http://docs.php.net/manual/en/solrquery.getfacetmissing.php */ public function getFacetMissing($field_override) {} /** * @param string $field_override [optional] * * @return int * @link http://docs.php.net/manual/en/solrquery.getfacetoffset.php */ public function getFacetOffset($field_override) {} /** * @param string $field_override [optional] * * @return string * @link http://docs.php.net/manual/en/solrquery.getfacetprefix.php */ public function getFacetPrefix($field_override) {} /** * @return array * @link http://docs.php.net/manual/en/solrquery.getfacetqueries.php */ public function getFacetQueries() {} /** * @param string $field_override [optional] * * @return int * @link http://docs.php.net/manual/en/solrquery.getfacetsort.php */ public function getFacetSort($field_override) {} /** * @return array * @link http://docs.php.net/manual/en/solrquery.getfields.php */ public function getFields() {} /** * @return array * @link http://docs.php.net/manual/en/solrquery.getfilterqueries.php */ public function getFilterQueries() {} /** * @return bool * @link http://docs.php.net/manual/en/solrquery.gethighlight.php */ public function getHighlight() {} /** * @param string $field_override [optional] * * @return string * @link http://docs.php.net/manual/en/solrquery.gethighlightalternatefield.php */ public function getHighlightAlternateField($field_override = null) {} /** * @return array * @link http://docs.php.net/manual/en/solrquery.gethighlightfields.php */ public function getHighlightFields() {} /** * @param string $field_override [optional] * * @return string * @link http://docs.php.net/manual/en/solrquery.gethighlightformatter.php */ public function getHighlightFormatter($field_override = null) {} /** * @param string $field_override [optional] * @return string * @link http://docs.php.net/manual/en/solrquery.gethighlightfragmenter.php */ public function getHighlightFragmenter($field_override = null) {} /** * @param string $field_override [optional] * @return int * @link http://docs.php.net/manual/en/solrquery.gethighlightfragsize.php */ public function getHighlightFragsize($field_override = null) {} /** * @return bool * @link http://docs.php.net/manual/en/solrquery.gethighlighthighlightmultiterm.php */ public function getHighlightHighlightMultiTerm() {} /** * @param string $field_override [optional] * @return int * @link http://docs.php.net/manual/en/solrquery.gethighlightmaxalternatefieldlength.php */ public function getHighlightMaxAlternateFieldLength($field_override = null) {} /** * @return int * @link http://docs.php.net/manual/en/solrquery.gethighlightmaxanalyzedchars.php */ public function getHighlightMaxAnalyzedChars() {} /** * @param string $field_override [optional] * @return bool * @link http://docs.php.net/manual/en/solrquery.gethighlightmergecontiguous.php */ public function getHighlightMergeContiguous($field_override = null) {} /** * @return int * @link http://docs.php.net/manual/en/solrquery.gethighlightregexmaxanalyzedchars.php */ public function getHighlightRegexMaxAnalyzedChars() {} /** * @return string * @link http://docs.php.net/manual/en/solrquery.gethighlightregexpattern.php */ public function getHighlightRegexPattern() {} /** * @return float * @link http://docs.php.net/manual/en/solrquery.gethighlightregexslop.php */ public function getHighlightRegexSlop() {} /** * @return bool * @link http://docs.php.net/manual/en/solrquery.gethighlightrequirefieldmatch.php */ public function getHighlightRequireFieldMatch() {} /** * @param string $field_override [optional] * @return string * @link http://docs.php.net/manual/en/solrquery.gethighlightsimplepost.php */ public function getHighlightSimplePost($field_override = null) {} /** * @param string $field_override [optional] * @return string * @link http://docs.php.net/manual/en/solrquery.gethighlightsimplepre.php */ public function getHighlightSimplePre($field_override = null) {} /** * @param string $field_override [optional] * @return int * @link http://docs.php.net/manual/en/solrquery.gethighlightsnippets.php */ public function getHighlightSnippets($field_override = null) {} /** * @return bool * @link http://docs.php.net/manual/en/solrquery.gethighlightusephrasehighlighter.php */ public function getHighlightUsePhraseHighlighter() {} /** * @return bool * @link http://docs.php.net/manual/en/solrquery.getmlt.php */ public function getMlt() {} /** * @return bool * @link http://docs.php.net/manual/en/solrquery.getmltboost.php */ public function getMltBoost() {} /** * @return int * @link http://docs.php.net/manual/en/solrquery.getmltcount.php */ public function getMltCount() {} /** * @return array * @link http://docs.php.net/manual/en/solrquery.getmltfields.php */ public function getMltFields() {} /** * @return int * @link http://docs.php.net/manual/en/solrquery.getmltmaxnumqueryterms.php */ public function getMltMaxNumQueryTerms() {} /** * @return int * @link http://docs.php.net/manual/en/solrquery.getmltmaxnumtokens.php */ public function getMltMaxNumTokens() {} /** * @return int * @link http://docs.php.net/manual/en/solrquery.getmltmaxwordlength.php */ public function getMltMaxWordLength() {} /** * @return int * @link http://docs.php.net/manual/en/solrquery.getmltmindocfrequency.php */ public function getMltMinDocFrequency() {} /** * @return int * @link http://docs.php.net/manual/en/solrquery.getmltmintermfrequency.php */ public function getMltMinTermFrequency() {} /** * @return int * @link http://docs.php.net/manual/en/solrquery.getmltminwordlength.php */ public function getMltMinWordLength() {} /** * @return array * @link http://docs.php.net/manual/en/solrquery.getmltqueryfields.php */ public function getMltQueryFields() {} /** * @return string * @link http://docs.php.net/manual/en/solrquery.getquery.php */ public function getQuery() {} /** * @return int * @link http://docs.php.net/manual/en/solrquery.getrows.php */ public function getRows() {} /** * @return array * @link http://docs.php.net/manual/en/solrquery.getsortfields.php */ public function getSortFields() {} /** * @return int * @link http://docs.php.net/manual/en/solrquery.getstart.php */ public function getStart() {} /** * @return bool * @link http://docs.php.net/manual/en/solrquery.getstats.php */ public function getStats() {} /** * @return array * @link http://docs.php.net/manual/en/solrquery.getstatsfacets.php */ public function getStatsFacets() {} /** * @return array * @link http://docs.php.net/manual/en/solrquery.getstatsfields.php */ public function getStatsFields() {} /** * @return bool * @link http://docs.php.net/manual/en/solrquery.getterms.php */ public function getTerms() {} /** * @return string * @link http://docs.php.net/manual/en/solrquery.gettermsfield.php */ public function getTermsField() {} /** * @return bool * @link http://docs.php.net/manual/en/solrquery.gettermsincludelowerbound.php */ public function getTermsIncludeLowerBound() {} /** * @return bool * @link http://docs.php.net/manual/en/solrquery.gettermsincludeupperbound.php */ public function getTermsIncludeUpperBound() {} /** * @return int * @link http://docs.php.net/manual/en/solrquery.gettermslimit.php */ public function getTermsLimit() {} /** * @return string * @link http://docs.php.net/manual/en/solrquery.gettermslowerbound.php */ public function getTermsLowerBound() {} /** * @return int * @link http://docs.php.net/manual/en/solrquery.gettermsmaxcount.php */ public function getTermsMaxCount() {} /** * @return int * @link http://docs.php.net/manual/en/solrquery.gettermsmincount.php */ public function getTermsMinCount() {} /** * @return string * @link http://docs.php.net/manual/en/solrquery.gettermsprefix.php */ public function getTermsPrefix() {} /** * @return bool * @link http://docs.php.net/manual/en/solrquery.gettermsreturnraw.php */ public function getTermsReturnRaw() {} /** * @return int * @link http://docs.php.net/manual/en/solrquery.gettermssort.php */ public function getTermsSort() {} /** * @return string * @link http://docs.php.net/manual/en/solrquery.gettermsupperbound.php */ public function getTermsUpperBound() {} /** * @return int * @link http://docs.php.net/manual/en/solrquery.gettimeallowed.php */ public function getTimeAllowed() {} /** * @param string $field * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.removefacetdatefield.php */ public function removeFacetDateField($field) {} /** * @param string $value * @param string $field_override [optional] * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.removefacetdateother.php */ public function removeFacetDateOther($value, $field_override) {} /** * @param string $field * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.removefacetfield.php */ public function removeFacetField($field) {} /** * @param string $value * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.removefacetquery.php */ public function removeFacetQuery($value) {} /** * @param string $field * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.removefield.php */ public function removeField($field) {} /** * @param string $fq * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.removefilterquery.php */ public function removeFilterQuery($fq) {} /** * @param string $field * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.removehighlightfield.php */ public function removeHighlightField($field) {} /** * @param string $field * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.removemltfield.php */ public function removeMltField($field) {} /** * @param string $queryField * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.removemltqueryfield.php */ public function removeMltQueryField($queryField) {} /** * @param string $field * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.removesortfield.php */ public function removeSortField($field) {} /** * @param string $value * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.removestatsfacet.php */ public function removeStatsFacet($value) {} /** * @param string $field * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.removestatsfield.php */ public function removeStatsField($field) {} /** * @param bool $flag * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.setechohandler.php */ public function setEchoHandler($flag) {} /** * @param string $type * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.setechoparams.php */ public function setEchoParams($type) {} /** * @param string $query * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.setexplainother.php */ public function setExplainOther($query) {} /** * @param bool $flag * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.setfacet.php */ public function setFacet($flag) {} /** * @param string $value * @param string $field_override [optional] * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.setfacetdateend.php */ public function setFacetDateEnd($value, $field_override) {} /** * @param string $value * @param string $field_override [optional] * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.setfacetdategap.php */ public function setFacetDateGap($value, $field_override) {} /** * @param bool $value * @param string $field_override [optional] * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.setfacetdatehardend.php */ public function setFacetDateHardEnd($value, $field_override) {} /** * @param string $value * @param string $field_override [optional] * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.setfacetdatestart.php */ public function setFacetDateStart($value, $field_override) {} /** * @param int $frequency * @param string $field_override [optional] * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.setfacetenumcachemindefaultfrequency.php */ public function setFacetEnumCacheMinDefaultFrequency($frequency, $field_override = null) {} /** * @param int $limit * @param string $field_override [optional] * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.setfacetlimit.php */ public function setFacetLimit($limit, $field_override = null) {} /** * @param string $method * @param string $field_override [optional] * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.setfacetmethod.php */ public function setFacetMethod($method, $field_override = null) {} /** * @param int $mincount * @param string $field_override [optional] * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.setfacetmincount.php */ public function setFacetMinCount($mincount, $field_override = null) {} /** * @param bool $flag * @param string $field_override [optional] * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.setfacetmissing.php */ public function setFacetMissing($flag, $field_override = null) {} /** * @param int $offset * @param string $field_override [optional] * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.setfacetoffset.php */ public function setFacetOffset($offset, $field_override = null) {} /** * @param string $prefix * @param string $field_override [optional] * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.setfacetprefix.php */ public function setFacetPrefix($prefix, $field_override = null) {} /** * @param int $facetSort * @param string $field_override [optional] * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.setfacetsort.php */ public function setFacetSort($facetSort, $field_override = null) {} /** * Enables or disables highlighting * * @param bool $flag * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.sethighlight.php */ public function setHighlight($flag) {} /** * Specifies the highlithing backup field to use * * @param string $field * @param string $field_override [optional] * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.sethighlightalternatefield.php */ public function setHighlightAlternateField($field, $field_override = null) {} /** * Specify a formatter for the highlight output * * @param string $formatter * @param string $field_override [optional] * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.sethighlightformatter.php */ public function setHighlightFormatter($formatter, $field_override) {} /** * Sets a text snippet generator for highlighted text * * @param string $fragmenter * @param string $field_override * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.sethighlightfragmenter.php */ public function setHighlightFragmenter($fragmenter, $field_override = null) {} /** * The size of fragments to consider for highlighting * * @param int $size Size (in characters) of fragments to consider for highlighting * @param string $field_override Name of the field * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.sethighlightfragsize.php */ public function setHighlightFragsize($size, $field_override = null) {} /** * @param bool $flag * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.sethighlighthighlightmultiterm.php */ public function setHighlightHighlightMultiTerm($flag) {} /** * Sets the maximum number of characters of the field to return * * @param int $fieldLength Length of the field * @param string $field_override Name of the field * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.sethighlightmaxalternatefieldlength.php */ public function setHighlightMaxAlternateFieldLength($fieldLength, $field_override = null) {} /** * Specifies the number of characters into a document to look for suitable snippets * * @param int $value The number of characters into a document to look for suitable snippets * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.sethighlightmaxanalyzedchars.php */ public function setHighlightMaxAnalyzedChars($value) {} /** * Sets whether or not to collapse contiguous fragments into a single fragment * * @param bool $flag Whether or not to collapse contiguous fragments into a single fragment * @param null $field_override * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.sethighlightmergecontiguous.php */ public function setHighlightMergeContiguous($flag, $field_override = null) {} /** * Specify the maximum number of characters to analyze * * @param int $maxAnalyzedChars * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.sethighlightregexmaxanalyzedchars.php */ public function setHighlightRegexMaxAnalyzedChars($maxAnalyzedChars) {} /** * Specify the regular expression for fragmenting * * @param string $value The regular expression for fragmenting. This could be used to extract sentences * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.sethighlightregexpattern.php */ public function setHighlightRegexPattern($value) {} /** * Sets the factor by which the regex fragmenter can stray from the ideal fragment size * * @param float $factor The factor by which the regex fragmenter can stray from the ideal fragment size * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.sethighlightregexslop.php */ public function setHighlightRegexSlop($factor) {} /** * Sets whether field matching is required when highlighting * * @param bool $flag If TRUE, then a field will only be highlighted if the query * matched in this particular field. This will only work if * SolrQuery::setHighlightUsePhraseHighlighter() was set to TRUE * * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.sethighlightrequirefieldmatch.php */ public function setHighlightRequireFieldMatch($flag) {} /** * Sets the text which appears after a highlighted term * * @param string $simplePost * @param string $field_override [optional] Name of the field * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.sethighlightsimplepost.php */ public function setHighlightSimplePost($simplePost, $field_override = null) {} /** * Sets the text which appears before a highlighted term * * @param string $simplePre * @param string $field_override [optional] Name of the field * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.sethighlightsimplepre.php */ public function setHighlightSimplePre($simplePre, $field_override = null) {} /** * @param int $value Maximum number of highlighted snippets to generate per field * @param string $field_override [optional] Name of the field * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.sethighlightsnippets.php */ public function setHighlightSnippets($value, $field_override = null) {} /** * Whether to highlight phrase terms only when they appear within the query phrase * * @param bool $flag * @return SolrQuery * @link http://docs.php.net/manual/en/solrquery.sethighlightusephrasehighlighter.php */ public function setHighlightUsePhraseHighlighter($flag) {} /** * Enables or disables moreLikeThis * * @param bool $flag TRUE enables it and FALSE turns it off * * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.setmlt.php */ public function setMlt($flag) {} /** * Set if the query will be boosted by the interesting term relevance * * @param bool $flag * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.setmltboost.php */ public function setMltBoost($flag) {} /** * Set the number of similar documents to return for each result * * @param int $count * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.setmltcount.php */ public function setMltCount($count) {} /** * Sets the maximum number of query terms included * * @param int $value The maximum number of query terms that will be included in any generated query * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.setmltmaxnumqueryterms.php */ public function setMltMaxNumQueryTerms($value) {} /** * Specifies the maximum number of tokens to parse * * @param int $value The maximum number of tokens to parse * * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.setmltmaxnumtokens.php */ public function setMltMaxNumTokens($value) {} /** * Sets the maximum word length * * @param int $maxWordLength The maximum word length above which words will be ignored * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.setmltmaxwordlength.php */ public function setMltMaxWordLength($maxWordLength) {} /** * The frequency at which words will be ignored which do not occur in at least this many docs * * @param int $minDocFrequency * * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.setmltmindocfrequency.php */ public function setMltMinDocFrequency($minDocFrequency) {} /** * Sets the frequency below which terms will be ignored in the source docs * * @param int $minTermFrequency * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.setmltmintermfrequency.php */ public function setMltMinTermFrequency($minTermFrequency) {} /** * Sets the minimum word length below which words will be ignored * * @param int $minWordLength * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.setmltminwordlength.php */ public function setMltMinWordLength($minWordLength) {} /** * Exclude the header from the returned results * * @param bool $flag TRUE excludes the header from the result * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.setomitheader.php */ public function setOmitHeader($flag) {} /** * Sets the search query * * @param string $query * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.setquery.php */ public function setQuery($query) {} /** * Specifies the maximum number of rows to return in the result * * @param int $rows * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.setrows.php */ public function setRows($rows) {} /** * Flag to show debug information * * @param bool $flag * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.setshowdebuginfo.php */ public function setShowDebugInfo($flag) {} /** * Specifies the number of rows to skip * * @param int $start * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.setstart.php */ public function setStart($start) {} /** * Enables or disables the Stats component * * @param bool $flag * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.setstats.php */ public function setStats($flag) {} /** * Enables or disables the TermsComponent * * @param bool $flag * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.setterms.php */ public function setTerms($flag) {} /** * Sets the name of the field to get the Terms from * * @param string $fieldname * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.settermsfield.php */ public function setTermsField($fieldname) {} /** * Sets whether to include the lower bound term in the result set * * @param bool $flag * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.settermsincludelowerbound.php */ public function setTermsIncludeLowerBound($flag) {} /** * Include the upper bound term in the result set * * @param bool $flag * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.settermsincludeupperbound.php */ public function setTermsIncludeUpperBound($flag) {} /** * Sets the maximum number of terms to return * * @param int $limit * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.settermslimit.php */ public function setTermsLimit($limit) {} /** * Specifies the Term to start from * * @param string $lowerBound * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.settermslowerbound.php */ public function setTermsLowerBound($lowerBound) {} /** * Sets the maximum document frequency * * @param int $frequency * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.settermsmaxcount.php */ public function setTermsMaxCount($frequency) {} /** * Sets the minimum document frequency * * @param int $frequency * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.settermsmincount.php */ public function setTermsMinCount($frequency) {} /** * Restrict matches to terms that start with the prefix * * @param string $prefix * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.settermsprefix.php */ public function setTermsPrefix($prefix) {} /** * Return the raw characters of the indexed term * * @param bool $flag * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.settermsreturnraw.php */ public function setTermsReturnRaw($flag) {} /** * Specifies how to sort the returned terms * * @param int $sortType If SolrQuery::TERMS_SORT_COUNT, sorts the terms by the term frequency (highest count first). If SolrQuery::TERMS_SORT_INDEX, returns the terms in index order * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.settermssort.php */ public function setTermsSort($sortType) {} /** * Sets the term to stop at * * @param string $upperBound * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.settermsupperbound.php */ public function setTermsUpperBound($upperBound) {} /** * The time allowed for search to finish * * @param int $timeAllowed Time in milliseconds * @return SolrQuery Returns the current SolrQuery object * @link http://docs.php.net/manual/en/solrquery.settimeallowed.php */ public function setTimeAllowed($timeAllowed) {} /** * Collapses the result set to a single document per group before it forwards * the result set to the rest of the search components. * So all downstream components (faceting, highlighting, etc...) will work with * the collapsed result set. * * A collapse function object is passed to collapse the query * * @param SolrCollapseFunction $function * @throws SolrMissingMandatoryParameterException * @return SolrQuery */ public function collapse(SolrCollapseFunction $function) {} /** * Enable/Disable result grouping (group parameter) * * @param bool $value * @return SolrQuery */ public function setGroup($value) {} /** * Returns true if grouping is enabled * @return bool */ public function getGroup() {} /** * The name of the field by which to group results. The field must be single-valued, and either be indexed * or a field type that has a value source and works in a function query, * such as ExternalFileField. It must also be a string-based field, such as StrField or TextField * * @param string $value * @return SolrQuery */ public function addGroupField($value) {} /** * Returns group fields (group.field parameter values) * * @return array */ public function getGroupFields() {} /** * Adds a group function (group.func parameter) * Allows grouping results based on the unique values of a function query. * * @param string $value * @return SolrQuery */ public function addGroupFunction($value) {} /** * Returns group functions (group.func parameter values) * * @return array */ public function getGroupFunctions () {} /** * Adds query to the group.query parameter * Allows grouping of documents that match the given query. * * @param string $value * @return SolrQuery */ public function addGroupQuery($value) {} /** * Returns all the group.query parameter values * * @return array */ public function getGroupQueries() {} /** * Specifies the number of results to return for each group. The server default value is 1. * * @param integer $value * @return SolrQuery */ public function setGroupLimit($value) {} /** * Returns the group.limit value * @return integer */ public function getGroupLimit() {} /** * Sets the group.offset parameter. * @param integer $offset * @return SolrQuery */ public function setGroupOffset($offset) {} /** * Returns the group.offset value * * @return integer */ public function getGroupOffset() {} /** * Adds a group sort field (group.sort parameter). * * @param string $sort * @param integer $direction * @return SolrQuery */ public function addGroupSortField($sort, $direction) {} /** * Returns the group.sort value * * @return array */ public function getGroupSortFields() {} /** * Sets the group.format parameter. * If this parameter is set to simple, the grouped documents are presented in a single flat list, and the start and * rows parameters affect the numbers of documents instead of groups. * * @param string $value * @return SolrQuery */ public function setGroupFormat($value) {} /** * Returns the group.format value * * @return string */ public function getGroupFormat() {} /** * If true, the result of the first field grouping command is used as the main result list in the response, using group.format=simple. * * @param bool $value * @return SolrQuery */ public function setGroupMain($value) {} /** * Returns the group.main value * * @return bool */ public function getGroupMain() {} /** * If true, Solr includes the number of groups that have matched the query in the results. * The default value is false. (group.ngroups parameter) * * @param bool $value * @return SolrQuery */ public function setGroupNGroups($value) {} /** * Returns the group.ngroups value * @return bool */ public function getGroupNGroups() {} /** * If true, facet counts are based on the most relevant document of each group matching the query. * The server default value is false. * group.truncate parameter * * @param bool $value * @return SolrQuery */ public function setGroupTruncate($value) {} /** * Returns the group.truncate value * * @return bool */ public function getGroupTruncate() {} /** * Determines whether to compute grouped facets for the field facets specified in facet.field parameters. * Grouped facets are computed based on the first specified group. * group.facet parameter * * @param bool $value * @return SolrQuery */ public function setGroupFacet($value) {} /** * Returns the group.facet parameter value * * @return bool */ public function getGroupFacet() {} /** * Setting this parameter to a number greater than 0 enables caching for result grouping. * Result Grouping executes two searches; this option caches the second search. The default value is 0. * * Testing has shown that group caching only improves search time with Boolean, wildcard, and fuzzy queries. For simple queries like term or "match all" queries, group caching degrades performance. * group.cache.percent parameter * * @param integer * @throws SolrIllegalArgumentException * @return SolrQuery */ public function setGroupCachePercent($value) {} /** * Returns the group cache percent group.cache.percent value * * @return integer */ public function getGroupCachePercent() {} /** * Sets the expand parameter. This enables or disables group expanding. * * @param bool $value * @return SolrQuery */ public function setExpand($value) {} /** * Returns true if group expanding is enabled * @return bool */ public function getExpand() {} /** * Orders the documents within the expanded groups (expand.sort parameter). * * @param string $sort * @param integer $direction defaults to DESC * @return SolrQuery */ public function addExpandSortField($sort, $direction = SolrQuery::ORDER_DESC) {} /** * Removes an expand sort field from the expand.sort parameter. * * @param string $field * @return SolrQuery */ public function removeExpandSortField($field) {} /** * Returns an array of fields * * @return array */ public function getExpandSortFields() {} /** * Sets the number of rows to display in each group (expand.rows). Server Default 5 * @param integer $rows * @return SolrQuery */ public function setExpandRows($rows) {} /** * Returns The number of rows to display in each group (expand.rows) * * @return integer */ public function getExpandRows() {} /** * Sets the expand.q parameter. Overrides the main q parameter, * determines which documents to include in the main group. * * @param string $q * @return SolrQuery */ public function setExpandQuery($q) {} /** * Returns the expand query expand.q parameter * * @return string */ public function getExpandQuery() {} /** * Overrides main fq's, determines which documents to include in the main group. * * @param string $fq * @return SolrQuery */ public function addExpandFilterQuery($fq) {} /** * Removes an expand filter query. * * @param string $fq * @return SolrQuery */ public function removeExpandFilterQuery($fq) {} /** * Returns the expand filter queries * * @return array */ public function getExpandFilterQueries() {} } /** * SolrDisMaxQuery Makes use of the Solr's DisMax query parser * and eases the use of it using class methods * * @author Omar Shaban */ class SolrDisMaxQuery extends SolrQuery { public function __construct($q = null) {} /** * Switch Query Parser to dismax */ public function useDisMaxQueryParser() {} /** * Switch Query Parser to edismax */ public function useEDisMaxQueryParser() {} /** * Set Query Alternate (q.alt parameter) * When the main q parameter is not specified or is blank. The q.alt parameter is used * * @param string $q */ public function setQueryAlt($q) {} /** * Add a query field with optional boost (qf parameter) * * @see https://cwiki.apache.org/confluence/display/solr/The+DisMax+Query+Parser#TheDisMaxQueryParser-Theqf%28QueryFields%29Parameter * @param string $field * @param string $boost * @return SolrDisMaxQuery */ public function addQueryField ($field, $boost=null) {} /** * Remove query field (qf parameter) * * @param string $field * @return SolrDisMaxQuery */ public function removeQueryField($field) {} /** * Add a phrase field (pf parameter) * output format: field~slop^boost * * Sample output: title~2^4 * * @see https://cwiki.apache.org/confluence/display/solr/The+DisMax+Query+Parser#TheDisMaxQueryParser-Thepf%28PhraseFields%29Parameter * @param string $field * @param float $boost * @param integer $slop * @return SolrDisMaxQuery */ public function addPhraseField($field, $boost, $slop=null) {} /** * Removes a phrase field (pf parameter) * @param string $field * @return SolrDisMaxQuery */ public function removePhraseField($field) {} /** * Set Phrase Fields (pf parameter) * @param string $fields * @return SolrDisMaxQuery */ public function setPhraseFields($fields) {} /** * Set Phrase Slop (ps parameter) * @see https://cwiki.apache.org/confluence/display/solr/The+DisMax+Query+Parser#TheDisMaxQueryParser-Theps%28PhraseSlop%29Parameter * @param integer $slop * @return SolrDisMaxQuery */ public function setPhraseSlop($slop) {} /** * Set Query Phrase Slop (qs parameter) * * @see https://cwiki.apache.org/confluence/display/solr/The+DisMax+Query+Parser#TheDisMaxQueryParser-Theqs%28QueryPhraseSlop%29Parameter * @param integer $slop * @return SolrDisMaxQuery */ public function setQueryPhraseSlop($slop) {} /** * Add a boost query field with value and boost * Sample Output: type:lucene^2 * * @see https://cwiki.apache.org/confluence/display/solr/The+DisMax+Query+Parser#TheDisMaxQueryParser-Thebq%28BoostQuery%29Parameter * * @param string $field * @param string $value * @param string $boost * @return SolrDisMaxQuery */ public function addBoostQuery($field, $value, $boost=null) {} /** * Remove a boost query field * * @param string $field * @return SolrDisMaxQuery */ public function removeBoostQuery($field) {} /** * Sets Boost Query Parameter (bq) * * @see https://cwiki.apache.org/confluence/display/solr/The+DisMax+Query+Parser#TheDisMaxQueryParser-Thebq%28BoostQuery%29Parameter * * @param string $q * @return SolrDisMaxQuery * */ public function setBoostQuery($q) {} /** * Sets the boost function (bf) * * @see https://cwiki.apache.org/confluence/display/solr/The+DisMax+Query+Parser#TheDisMaxQueryParser-Thebf%28BoostFunctions%29Parameter * * @param string $function * @return SolrDisMaxQuery */ public function setBoostFunction($function) {} /** * Set Tie Minimum *Should* Match parameter (mm) * * @see https://cwiki.apache.org/confluence/display/solr/The+DisMax+Query+Parser#TheDisMaxQueryParser-Themm%28MinimumShouldMatch%29Parameter * * @param mixed $value * @return SolrDisMaxQuery */ public function setMinimumMatch($value) {} /** * Set Tie Breaker parameter (tie) * * @see https://cwiki.apache.org/confluence/display/solr/The+DisMax+Query+Parser#TheDisMaxQueryParser-Thetie%28TieBreaker%29Parameter * @param float $tieBreaker * @return SolrDisMaxQuery */ public function setTieBreaker($tieBreaker) {} /** * Set Bigram Phrase Slop (ps2 parameter) * * @see https://cwiki.apache.org/confluence/display/solr/The+Extended+DisMax+Query+Parser * * @param integer $slop * @return SolrDisMaxQuery */ public function setBigramPhraseSlop($slop) {} /** * Add a phrase Bigram field (pf2 parameter) * output format: field~slop^boost * * Sample output: title~2^4 * * @see https://cwiki.apache.org/confluence/display/solr/The+DisMax+Query+Parser#TheDisMaxQueryParser-Thepf%28PhraseFields%29Parameter * * @param string $field * @param float $boost * @param integer $slop * @return SolrDisMaxQuery */ public function addBigramPhraseField($field, $boost, $slop=null) {} /** * Removes phrase bigram field (pf2 parameter) * * @param string $field * @return SolrDisMaxQuery */ public function removeBigramPhraseField($field) {} /** * Sets pf2 parameter * * @param string $fields * @return SolrDisMaxQuery */ public function setBigramPhraseFields($fields) {} /** * Add a Trigram Phrase Field (pf3 parameter) * output format: field~slop^boost * * Sample output: title~2^4 * * @see https://cwiki.apache.org/confluence/display/solr/The+DisMax+Query+Parser#TheDisMaxQueryParser-Thepf%28PhraseFields%29Parameter * @param string $field * @param float $boost * @param integer $slop * @return SolrDisMaxQuery */ public function addTrigramPhraseField($field, $boost, $slop=null) {} /** * Removes a Trigram Phrase Field (pf3 parameter) * @param string $field * @return SolrDisMaxQuery */ public function removeTrigramPhraseField($field) {} /** * Sets pf3 parameter * * @param string $fields * @return SolrDisMaxQuery */ public function setTrigramPhraseFields($fields) {} /** * Set Trigram Phrase Slop (ps3 parameter) * * @see https://cwiki.apache.org/confluence/display/solr/The+Extended+DisMax+Query+Parser * * @param integer $slop * @return SolrDisMaxQuery */ public function setTrigramPhraseSlop ($slop) {} /** * Adds a field to User Fields Parameter (uf) * * Specifies which schema fields the end user shall be allowed to query for explicitly. * This parameter supports wildcards. * * @param string $field * @return SolrDisMaxQuery */ public function addUserField($field){} /** * Removes a field from User Fields Parameter (uf) * * @param string $field * @return SolrDisMaxQuery */ public function removeUserField($field){} /** * Sets User Fields parameter (uf) * * Specifies which schema fields the end user shall be allowed to query for explicitly. * This parameter supports wildcards. * * @param string $fields * @return SolrDisMaxQuery */ public function setUserFields($fields){} } /** * Collapses the result set to a single document per group before it forwards * the result set to the rest of the search components. * So all downstream components (faceting, highlighting, etc...) will work with * the collapsed result set. * * @see https://cwiki.apache.org/confluence/display/solr/Collapse+and+Expand+Results * * @author Omar Shaban */ class SolrCollapseFunction { const NULLPOLICY_IGNORE = 'ignore'; const NULLPOLICY_EXPAND = 'expand'; const NULLPOLICY_COLLAPSE = 'collapse'; /** * Accepts the field to collapse on. * * @param string $field */ public function __construct($field = null) {} /** * Set the field that is being collapsed on. * In order to collapse a result. The field type must be a single valued String, Int or Float. * * @param string $field * @return SolrCollapseFunction */ public function setField($field) {} /** * Get the field that is being collapsed on. * * @return string */ public function getField() {} /** * Selects the group heads by the max value of a numeric field or function query. * * @param string $max * @return SolrCollapseFunction */ public function setMax($max) {} /** * Get max * * @return string */ public function getMax() {} /** * Sets the initial size of the collapse data structures when collapsing on a numeric field only. * * @param string $min * @return SolrCollapseFunction */ public function setMin($min) {} /** * Return min parameter * * @return string */ public function getMin() {} /** * Currently there is only one hint available "top_fc", which stands for top level FieldCache. * * @param string $hint * @return SolrCollapseFunction */ public function setHint($hint) {} /** * Get collapse hint. * * @return string */ public function getHint() {} /** * Sets the NULL Policy. * Accepts ignore, expand, or collapse. * * @param string $policy * @return SolrCollapseFunction */ public function setNullPolicy($policy) {} /** * Returns null policy * * @return string */ public function getNullPolicy() {} /** * Sets the initial size of the collapse data structures when collapsing on a numeric field only. * * @param integer $size * @return SolrCollapseFunction */ public function setSize($size) {} /** * Gets the initial size of the collapse data structures when collapsing on a numeric field only. * * @return integer */ public function getSize() {} /** * A string representation (Solr LocalParams) of the function. * @return string */ public function __toString() {} } /* phpdoc -f documentation.php --title Solr --parseprivate on --defaultpackagename Solr --output "HTML:frames:phphtmllib" -t solr_phpdoc */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: fdm=marker * vim: noet sw=4 ts=4 */ solr-2.4.0/config.m40000644000175000017500000001261712676753707012714 0ustar omaromar dnl $Id$ dnl config.m4 for the solr extension dnl Configuring the CURL external library dnl This folder is the grand-parent folder of easy.h PHP_ARG_WITH(curl, for cURL support, [ --with-curl[=DIR] SOLR : libcurl install prefix]) if test -r $PHP_CURL/include/curl/easy.h; then CURL_DIR=$PHP_CURL AC_MSG_RESULT(curl headers found in $PHP_CURL) else AC_MSG_CHECKING(for cURL in default path) for i in /usr/local /usr; do if test -r $i/include/curl/easy.h; then CURL_DIR=$i AC_MSG_RESULT(found in $i) break fi done fi if test -z "$CURL_DIR"; then AC_MSG_RESULT(not found) AC_MSG_ERROR([Please reinstall the libcurl distribution - easy.h should be in /include/curl/]) fi CURL_CONFIG="curl-config" AC_MSG_CHECKING(for cURL 7.15.0 or greater) if ${CURL_DIR}/bin/curl-config --libs > /dev/null 2>&1; then CURL_CONFIG=${CURL_DIR}/bin/curl-config else if ${CURL_DIR}/curl-config --libs > /dev/null 2>&1; then CURL_CONFIG=${CURL_DIR}/curl-config fi fi curl_version_full=`$CURL_CONFIG --version` curl_version=`echo ${curl_version_full} | sed -e 's/libcurl //' | $AWK 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'` if test "$curl_version" -ge 7015000; then AC_MSG_RESULT($curl_version_full) CURL_LIBS=`$CURL_CONFIG --libs` else AC_MSG_ERROR([The Solr extension does not support libcurl libraries < 7.15.0. Please update your libraries]) fi PHP_ARG_ENABLE(solr, whether to enable the Solr extension, [ --enable-solr Enable solr support]) PHP_ARG_ENABLE(solr-debug, whether to compile with solr in verbose mode, [ --enable-solr-debug Compile with solr in verbose mode], no, no) dnl Configuring the LibXML external Library if test -z "$PHP_LIBXML_DIR"; then PHP_ARG_WITH(libxml-dir, libxml2 install dir, [ --with-libxml-dir=[DIR] SOLR : libxml2 install prefix], no, no) fi PHP_ARG_ENABLE(coverage, whether to enable code coverage, [ --enable-coverage Enable developer code coverage information],, no) dnl Setting up the apache Solr extension if test "$PHP_SOLR" != "no"; then if test "$PHP_CURL" = "no"; then AC_MSG_ERROR([Solr extension requires curl extension, add --with-curl]) fi PHP_CHECK_LIBRARY(curl,curl_easy_perform, [ AC_DEFINE(HAVE_CURL,1,[ ]) ],[ AC_MSG_ERROR(There is something wrong. Please check config.log for more information.) ],[ $CURL_LIBS -L$CURL_DIR/$PHP_LIBDIR ]) PHP_ADD_INCLUDE($CURL_DIR/include) PHP_EVAL_LIBLINE($CURL_LIBS, SOLR_SHARED_LIBADD) PHP_ADD_LIBRARY_WITH_PATH(curl, $CURL_DIR/lib, SOLR_SHARED_LIBADD) if test "$PHP_LIBXML" = "no"; then AC_MSG_ERROR([Solr extension requires LIBXML extension, add --enable-libxml]) fi AC_MSG_CHECKING(for JSON) if test -f "$phpincludedir/ext/json/php_json.h" || test "$HAVE_JSON" != "no"; then AC_DEFINE(HAVE_JSON, 1, [JSON support]) AC_MSG_RESULT(Yes) else AC_MSG_ERROR([Solr extension requires json or jsonc support]) fi PHP_SETUP_LIBXML(SOLR_SHARED_LIBADD, [ AC_DEFINE(HAVE_SOLR, 1,[Setting the value of HAVE_SOLR to 1 ]) if test "$PHP_SOLR_DEBUG" != "no"; then AC_DEFINE(SOLR_DEBUG, 1, [Setting the value of SOLR_DEBUG to 1 ]) else AC_DEFINE(SOLR_DEBUG_OFF, 1, [Setting the value of SOLR_DEBUG_OFF to 1 ]) fi if test "$PHP_COVERAGE" = "yes"; then PHP_CHECK_GCC_ARG(-fprofile-arcs, COVERAGE_CFLAGS="$COVERAGE_CFLAGS -fprofile-arcs") PHP_CHECK_GCC_ARG(-ftest-coverage, COVERAGE_CFLAGS="$COVERAGE_CFLAGS -ftest-coverage") EXTRA_LDFLAGS="$COVERAGE_CFLAGS" fi export OLD_CPPFLAGS="$CPPFLAGS" export CPPFLAGS="$CPPFLAGS $INCLUDES" AC_MSG_CHECKING(PHP version) AC_TRY_COMPILE([ #include ],[ #if PHP_MAJOR_VERSION > 5 #error PHP > 5 #endif ],[ subdir=src/php5 AC_MSG_RESULT([PHP 5]) ],[ subdir=src/php7 AC_MSG_RESULT([PHP 7]) ]) PHP_SOLR_SRC_FILES="$subdir/php_solr.c \ $subdir/php_solr_object.c \ $subdir/php_solr_document.c \ $subdir/php_solr_input_document.c \ $subdir/php_solr_client.c \ $subdir/php_solr_params.c \ $subdir/php_solr_query.c \ $subdir/php_solr_response.c \ $subdir/php_solr_exception.c \ $subdir/php_solr_utils.c \ $subdir/php_solr_dismax_query.c \ $subdir/php_solr_collapse_function.c \ $subdir/solr_string.c \ $subdir/solr_functions_document.c \ $subdir/solr_functions_client.c \ $subdir/solr_functions_helpers.c \ $subdir/solr_functions_params.c \ $subdir/solr_functions_response.c \ $subdir/solr_functions_debug.c" PHP_NEW_EXTENSION(solr, $PHP_SOLR_SRC_FILES, $ext_shared,, [$COVERAGE_CFLAGS]) PHP_ADD_BUILD_DIR($abs_builddir/$subdir, 1) PHP_SUBST(SOLR_SHARED_LIBADD) ], [ AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.]) ]) fi solr-2.4.0/config.w320000644000175000017500000000655012676753707013006 0ustar omaromar// $Id$ // vim:ft=javascript // config.w32 for solr extension ARG_ENABLE('solr', 'Whether to enable Apache Solr support', 'no'); ARG_ENABLE('solr-debug', 'Whether to enable Solr debugging support', 'no'); if(PHP_SOLR != 'no') { if(!CHECK_LIB('libcurl_a.lib;libcurl.lib', 'solr', PHP_SOLR) || !CHECK_HEADER_ADD_INCLUDE('curl/easy.h', 'CFLAGS_SOLR')) { WARNING('solr was not enabled; curl libraries and/or headers not found'); PHP_SOLR = "no"; } if(!CHECK_LIB('ssleay32.lib', 'solr', PHP_SOLR) || !CHECK_LIB('libeay32.lib', 'solr', PHP_SOLR)) { WARNING('solr was not enabled; openssl libraries not found'); PHP_SOLR = "no"; } if(!CHECK_LIB('winmm.lib', 'solr', PHP_SOLR) || !CHECK_LIB('wldap32.lib', 'solr', PHP_SOLR)) { WARNING('solr not enabled; ldap libraries not found'); PHP_SOLR = "no"; } if(!((PHP_ZLIB == 'no' && CHECK_LIB('zlib_a.lib;zlib.lib', 'solr', PHP_SOLR)) || (PHP_ZLIB_SHARED && CHECK_LIB('zlib.lib', 'solr', PHP_SOLR)) || (PHP_ZLIB == 'yes' && !PHP_ZLIB_SHARED))) { WARNING('solr not enabled; zlib libraries not found'); PHP_SOLR = "no"; } if(PHP_LIBXML == 'no' || !ADD_EXTENSION_DEP('solr', 'libxml')) { WARNING('solr was not enabled; libxml is not enabled'); PHP_SOLR = "no"; } else { if (!CHECK_LIB("libxml2_a_dll.lib;libxml2_a.lib", "solr", PHP_SOLR) || !CHECK_LIB("libiconv_a.lib;iconv_a.lib;libiconv.lib;iconv.lib", "solr", PHP_SOLR) || !CHECK_HEADER_ADD_INCLUDE('libxml/parser.h', 'CFLAGS_SOLR', PHP_PHP_BUILD + "\\include\\libxml2") || !CHECK_HEADER_ADD_INCLUDE('libxml/tree.h', 'CFLAGS_SOLR', PHP_PHP_BUILD + "\\include\\libxml2") ) { WARNING('solr was not enabled; libxml or iconv not found'); PHP_SOLR = "no"; } } if(PHP_JSON == 'no' || !ADD_EXTENSION_DEP('solr', 'json')) { WARNING('solr was not enabled; json is not enabled'); PHP_SOLR = "no"; } if(PHP_SOLR != 'no') { if(PHP_SOLR_DEBUG == 'no') { AC_DEFINE('SOLR_DEBUG_OFF', 1, 'Solr debugging set to off'); } else { AC_DEFINE('SOLR_DEBUG', 1, 'Solr debugging set to on'); } var dll = get_define('PHPDLL'); var old_conf_dir = configure_module_dirname; /* XXX tricky job here, override configure_module_dirname, define the basic extension, then set it back*/ if (null != dll.match(/^php5/)) { configure_module_dirname = configure_module_dirname + "\\src\\php5"; } else if (null != dll.match(/^php7/)) { configure_module_dirname = configure_module_dirname + "\\src\\php7"; } else { ERROR("Cannot match any known PHP version with '" + dll + "'"); } EXTENSION('solr', 'php_solr.c php_solr_client.c php_solr_document.c php_solr_exception.c ' + 'php_solr_input_document.c php_solr_object.c php_solr_params.c php_solr_query.c ' + 'php_solr_response.c php_solr_utils.c solr_functions_client.c solr_functions_debug.c ' + 'solr_functions_document.c solr_functions_helpers.c solr_functions_params.c ' + 'solr_functions_response.c solr_string.c php_solr_dismax_query.c ' + 'php_solr_collapse_function.c' ); configure_module_dirname = old_conf_dir; ADD_FLAG('CFLAGS_SOLR', '/I"' + configure_module_dirname + '" /D CURL_STATICLIB /D LIBXML_STATICLIB'); AC_DEFINE('HAVE_SOLR', 1, 'Solr support'); if (!PHP_SOLR_SHARED) { ADD_FLAG("CFLAGS_SOLR", "/D LIBXML_STATIC"); } ADD_EXTENSION_DEP('solr', 'libxml'); } } solr-2.4.0/solr.dsp0000644000175000017500000001410512676753707012666 0ustar omaromar# Microsoft Developer Studio Project File - Name="Solr" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # $Id$ # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=Solr - Win32 Debug_TS !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "Solr.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "Solr.mak" CFG="Solr - Win32 Debug_TS" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "Solr - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "Solr - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "Solr - Win32 Release_TS" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release_TS" # PROP BASE Intermediate_Dir "Release_TS" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release_TS" # PROP Intermediate_Dir "Release_TS" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SOLR_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D "WIN32" /D "PHP_EXPORTS" /D "COMPILE_DL_SOLR" /D ZTS=1 /D HAVE_SOLR=1 /D ZEND_DEBUG=0 /D "NDEBUG" /D "_WINDOWS" /D "ZEND_WIN32" /D "PHP_WIN32" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x407 /d "NDEBUG" # ADD RSC /l 0x407 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php5ts.lib /nologo /dll /machine:I386 # ADD LINK32 wsock32.lib php5ts.lib libcurl.lib resolv.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /machine:I386 /out:"..\..\Release_TS/php_solr.dll" /implib:"..\..\Release_TS/php_solr.lib" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" /libpath:"..\..\..\bindlib_w32\Release" # SUBTRACT LINK32 /pdb:none !ELSEIF "$(CFG)" == "Solr - Win32 Debug_TS" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug_TS" # PROP BASE Intermediate_Dir "Debug_TS" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug_TS" # PROP Intermediate_Dir "Debug_TS" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SOLR_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=1 /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "PHP_EXPORTS" /D "COMPILE_DL_SOLR" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_SOLR=1 /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x407 /d "_DEBUG" # ADD RSC /l 0x407 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php5ts.lib /nologo /dll /machine:I386 # ADD LINK32 php5ts_debug.lib libcurl.lib ws2_32.lib resolv.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /debug /machine:I386 /nodefaultlib:"msvcrt" /out:"..\..\Debug_TS\php_solr.dll" /implib:"..\..\Debug_TS/php_solr.lib" /libpath:"..\..\Debug_TS" /libpath:"..\..\..\bindlib_w32\Release" !ENDIF # Begin Target # Name "Solr - Win32 Release_TS" # Name "Solr - Win32 Debug_TS" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=./php_solr.c # End Source File # Begin Source File SOURCE=./php_solr_exception.c # End Source File # Begin Source File SOURCE=./php_solr_object.c # End Source File # Begin Source File SOURCE=./php_solr_response.c # End Source File # Begin Source File SOURCE=./php_solr_document.c # End Source File # Begin Source File SOURCE=./php_solr_input_document.c # End Source File # Begin Source File SOURCE=./php_solr_query.c # End Source File # Begin Source File SOURCE=./php_solr_client.c # End Source File # Begin Source File SOURCE=./php_solr_functions.c # End Source File # Begin Source File SOURCE=./php_solr_params.c # End Source File # Begin Source File SOURCE=./php_solr_utils.c # End Source File # Begin Source File SOURCE=./solr_functions_debug.c # End Source File # Begin Source File SOURCE=./solr_functions_params.c # End Source File # Begin Source File SOURCE=./solr_functions_document.c # End Source File # Begin Source File SOURCE=./solr_functions_response.c # End Source File # Begin Source File SOURCE=./solr_functions_client.c # End Source File # Begin Source File SOURCE=./solr_functions_helpers.c # End Source File # Begin Source File SOURCE=./solr_string.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\php_solr.h # End Source File # Begin Source File SOURCE=.\php_solr_api.h # End Source File # Begin Source File SOURCE=.\solr_constants.h # End Source File # Begin Source File SOURCE=.\solr_macros.h # End Source File # Begin Source File SOURCE=.\solr_string.h # End Source File # Begin Source File SOURCE=.\solr_types.h # End Source File # End Group # End Target # End Project