Patch sphinx.c.diff for sphinx Bug #61392
Patch version 2012-03-24 18:31 UTC
Return to Bug #61392 |
Download this patch
Patch Revisions:
Developer: pfalcone@gmail.com
Index: sphinx.c
===================================================================
--- sphinx.c (revision 324460)
+++ sphinx.c (working copy)
@@ -763,21 +763,22 @@
}
/* }}} */
-/* {{{ proto bool SphinxClient::setRankingMode(int ranker) */
+/* {{{ proto bool SphinxClient::setRankingMode(int ranker, const char* rankexpr) */
static PHP_METHOD(SphinxClient, setRankingMode)
{
php_sphinx_client *c;
long ranker;
- int res;
+ int rankexpr_len,res;
+ char *rankexpr = "";
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &ranker) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &ranker, &rankexpr, &rankexpr_len) == FAILURE) {
return;
}
c = (php_sphinx_client *)zend_object_store_get_object(getThis() TSRMLS_CC);
SPHINX_INITIALIZED(c)
- res = sphinx_set_ranking_mode(c->sphinx, (int)ranker);
+ res = sphinx_set_ranking_mode(c->sphinx, (int)ranker, rankexpr);
if (!res) {
RETURN_FALSE;
@@ -1045,7 +1046,7 @@
vals_mva = safe_emalloc(values_mva_size, sizeof(unsigned int), 0);
}
if (vals_mva) {
- memset(vals_mva, NULL, values_mva_size);
+ memset(vals_mva, 0, values_mva_size);
}
j = 0;
@@ -1781,6 +1782,7 @@
ZEND_BEGIN_ARG_INFO_EX(arginfo_sphinxclient_setrankingmode, 0, 0, 1)
ZEND_ARG_INFO(0, ranker)
+ ZEND_ARG_INFO(0, rankexpr)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_sphinxclient_setsortmode, 0, 0, 1)
@@ -1926,8 +1928,17 @@
#ifdef SPH_RANK_FIELDMASK
SPHINX_CONST(SPH_RANK_FIELDMASK);
#endif
-
- SPHINX_CONST(SPH_SORT_RELEVANCE);
+#ifdef SPH_RANK_SPH04
+ SPHINX_CONST(SPH_RANK_SPH04);
+#endif
+#ifdef SPH_RANK_EXPR
+ SPHINX_CONST(SPH_RANK_EXPR);
+#endif
+#ifdef SPH_RANK_TOTAL
+ SPHINX_CONST(SPH_RANK_TOTAL);
+#endif
+
+ SPHINX_CONST(SPH_SORT_RELEVANCE);
SPHINX_CONST(SPH_SORT_ATTR_DESC);
SPHINX_CONST(SPH_SORT_ATTR_ASC);
SPHINX_CONST(SPH_SORT_TIME_SEGMENTS);
|