Development

Changeset 33291

You must first sign up to be able to contribute.

Changeset 33291

Show
Ignore:
Timestamp:
12/22/11 09:12:31 (1 year ago)
Author:
garak
Message:

[sfSphinxPlugin] updated main lib to version 2.0.2-beta

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfSphinxPlugin/trunk/lib/sfSphinxClient.class.php

    • Property svn:keywords set to Id
    r33240 r33291  
    22/** 
    33 * This file is derived from PHP API of the sfSphinx package. 
    4  * (c) 2001-2010 Andrew Aksyonoff 
    5  * (c) 2007      Rick Olson <rick@napalmriot.com> 
    6  * (c) 2008-2010 Massimiliano Arione <garakkio@gmail.com> 
     4 * (c) 2001-2011 Andrew Aksyonoff 
     5 * (c) 2008-2011 Sphinx Technologies Inc 
     6 * (c) 2008-2011 Massimiliano Arione <garakkio@gmail.com> 
    77 * 
    88 * For the full copyright and license information, please view the LICENSE 
     
    1717 * @package    sfSphinxPlugin 
    1818 * @author     Massimiliano Arione <garakkio@gmail.com> 
     19 * @version    SVN: $Id$ 
    1920 */ 
    2021class sfSphinxClient 
     
    3233 
    3334  // current client-side command implementation versions 
    34   const VER_COMMAND_SEARCH     = 0x117
    35   const VER_COMMAND_EXCERPT    = 0x102
     35  const VER_COMMAND_SEARCH     = 0x119
     36  const VER_COMMAND_EXCERPT    = 0x104
    3637  const VER_COMMAND_UPDATE     = 0x102; 
    3738  const VER_COMMAND_KEYWORDS   = 0x100; 
     
    6566  const SPH_RANK_FIELDMASK      = 6; 
    6667  const SPH_RANK_SPH04          = 7; 
    67   const SPH_RANK_TOTAL          = 8; 
     68  const SPH_RANK_EXPR           = 8; 
     69  const SPH_RANK_TOTAL          = 9; 
    6870 
    6971  // known sort modes 
     
    8890  const SPH_ATTR_BIGINT    = 6; 
    8991  const SPH_ATTR_STRING    = 7; 
    90   const SPH_ATTR_MULTI     = 0x40000000; 
     92  const SPH_ATTR_MULTI     = 0x40000001; 
     93  const SPH_ATTR_MULTI64   = 0x40000002; 
    9194 
    9295  // known grouping functions 
     
    156159      'sortby'        => '', 
    157160      'min_id'        => 0, 
    158       'max_id'        => 0xFFFFFFFF
     161      'max_id'        => 0
    159162      'filters'       => array(), 
    160163      'groupby'       => '', 
     
    549552 
    550553  /** 
     554   * @param  integer 
     555   * @return integer 
     556   */ 
     557  private function sphFixUint($value) 
     558  { 
     559    if (PHP_INT_SIZE >= 8) 
     560    { 
     561      // x64 route, workaround broken unpack() in 5.2.2+ 
     562      if ($value < 0) 
     563      { 
     564        $value += (1 << 32); 
     565      } 
     566 
     567      return $value; 
     568    } 
     569    else 
     570    { 
     571      // x32 route, workaround php signed/unsigned braindamage 
     572      return sprintf('%u', $value); 
     573    } 
     574  } 
     575 
     576  /** 
    551577   * check if there's an error or not 
    552578   * @return string 
     
    13771403          list($doc, $weight) = array_values(unpack('N*N*', substr($response, $p, 8))); 
    13781404          $p += 8; 
    1379  
    1380           if (PHP_INT_SIZE >= 8) 
    1381           { 
    1382             // x64 route, workaround broken unpack() in 5.2.2+ 
    1383             if ($doc < 0) 
    1384             { 
    1385               $doc += (1 << 32); 
    1386             } 
    1387           } 
    1388           else 
    1389           { 
    1390             // x32 route, workaround php signed/unsigned braindamage 
    1391             $doc = sprintf('%u', $doc); 
    1392           } 
     1405          $doc = $this->sphFixUint($doc); 
    13931406        } 
    13941407        $weight = sprintf('%u', $weight); 
     
    14371450              list(, $val) = unpack('N*', substr($response, $p, 4)); 
    14381451              $p += 4; 
    1439               $attrvals[$attr][] = sprintf('%u', $val); 
     1452              $attrvals[$attr][] = $this->sphFixUint($val); 
    14401453            } 
    14411454          } 
     
    14471460          else 
    14481461          { 
    1449             $attrvals[$attr] = sprintf('%u', $val); 
     1462            $attrvals[$attr] = $this->sphFixUint($val); 
    14501463          } 
    14511464        }