|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66272 Some constants are not defined
Submitted: 2013-12-12 11:57 UTC Modified: 2013-12-13 10:30 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: sergey dot zavg at gmail dot com Assigned: tony2001 (profile)
Status: Closed Package: sphinx (PECL)
PHP Version: 5.5Git-2013-12-12 (snap) OS: Linux CentOS-64-64-minimal 2.6.3
Private report: No CVE-ID: None
 [2013-12-12 11:57 UTC] sergey dot zavg at gmail dot com
This piece of code in sphinx.c is not working, cause #ifdef does not check enum values definitions.

#ifdef SPH_RANK_SPH04

So the constants SPH_RANK_PROXIMITY, SPH_RANK_MATCHANY,  SPH_RANK_FIELDMASK, SPH_RANK_SPH04, SPH_RANK_EXPR, SPH_RANK_TOTAL are anavailable from PHP even if they are defined in enum in sphinxclient.h.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-12-12 12:11 UTC]
-Status: Open +Status: Feedback
 [2013-12-12 12:11 UTC]
Could you please clarify what exactly you mean by "#ifdef does not check enum values definitions" ?
These are constants. If there are defined, then ifdef result is true. If they aren't defined - it's false.
 [2013-12-12 14:41 UTC] sergey dot zavg at gmail dot com
-Status: Feedback +Status: Open
 [2013-12-12 14:41 UTC] sergey dot zavg at gmail dot com
Here is the part of content of my sphinxclinet.h file.

/// known ranking modes (ext2 only)
        SPH_RANK_PROXIMITY_BM25 = 0,
        SPH_RANK_BM25                   = 1,
        SPH_RANK_NONE                   = 2,
        SPH_RANK_WORDCOUNT              = 3,
        SPH_RANK_PROXIMITY              = 4,
        SPH_RANK_MATCHANY               = 5,
        SPH_RANK_FIELDMASK              = 6,
        SPH_RANK_SPH04                  = 7,
        SPH_RANK_EXPR                   = 8,
        SPH_RANK_TOTAL                  = 9,

        SPH_RANK_DEFAULT                = SPH_RANK_PROXIMITY_BM25

You can see that SPH_RANK_EXPR is here but #ifdef SPH_RANK_EXPR will not got it.                   

So I have to use $s->setRankingMode($8, "sum(1)"); in my PHP code.
 [2013-12-12 14:43 UTC] sergey dot zavg at gmail dot com
Sorry, noticed 2 typos in the previous comment
 - sphinxclient.h 
 - $s->setRankingMode(8, "sum(1)");
 [2013-12-12 15:08 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: tony2001
 [2013-12-12 15:08 UTC]
Ah, you're absolutely right, these constants are undefined for the preprocessor.
I'll have to think how to detect them in compile time properly..
 [2013-12-13 10:30 UTC]
-Status: Assigned +Status: Closed
 [2013-12-13 10:30 UTC]
Ok, unfortunately it looks like there's no other way than to check for these constants in ./configure.
I've committed a patch for it and will probably release a new version sometime soon.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Nov 29 21:03:58 2022 UTC