Changeset 33291
- Timestamp:
- 12/22/11 09:12:31 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfSphinxPlugin/trunk/lib/sfSphinxClient.class.php
- Property svn:keywords set to Id
r33240 r33291 2 2 /** 3 3 * This file is derived from PHP API of the sfSphinx package. 4 * (c) 2001-201 0Andrew Aksyonoff5 * (c) 200 7 Rick Olson <rick@napalmriot.com>6 * (c) 2008-201 0Massimiliano 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> 7 7 * 8 8 * For the full copyright and license information, please view the LICENSE … … 17 17 * @package sfSphinxPlugin 18 18 * @author Massimiliano Arione <garakkio@gmail.com> 19 * @version SVN: $Id$ 19 20 */ 20 21 class sfSphinxClient … … 32 33 33 34 // current client-side command implementation versions 34 const VER_COMMAND_SEARCH = 0x11 7;35 const VER_COMMAND_EXCERPT = 0x10 2;35 const VER_COMMAND_SEARCH = 0x119; 36 const VER_COMMAND_EXCERPT = 0x104; 36 37 const VER_COMMAND_UPDATE = 0x102; 37 38 const VER_COMMAND_KEYWORDS = 0x100; … … 65 66 const SPH_RANK_FIELDMASK = 6; 66 67 const SPH_RANK_SPH04 = 7; 67 const SPH_RANK_TOTAL = 8; 68 const SPH_RANK_EXPR = 8; 69 const SPH_RANK_TOTAL = 9; 68 70 69 71 // known sort modes … … 88 90 const SPH_ATTR_BIGINT = 6; 89 91 const SPH_ATTR_STRING = 7; 90 const SPH_ATTR_MULTI = 0x40000000; 92 const SPH_ATTR_MULTI = 0x40000001; 93 const SPH_ATTR_MULTI64 = 0x40000002; 91 94 92 95 // known grouping functions … … 156 159 'sortby' => '', 157 160 'min_id' => 0, 158 'max_id' => 0 xFFFFFFFF,161 'max_id' => 0, 159 162 'filters' => array(), 160 163 'groupby' => '', … … 549 552 550 553 /** 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 /** 551 577 * check if there's an error or not 552 578 * @return string … … 1377 1403 list($doc, $weight) = array_values(unpack('N*N*', substr($response, $p, 8))); 1378 1404 $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); 1393 1406 } 1394 1407 $weight = sprintf('%u', $weight); … … 1437 1450 list(, $val) = unpack('N*', substr($response, $p, 4)); 1438 1451 $p += 4; 1439 $attrvals[$attr][] = sprintf('%u',$val);1452 $attrvals[$attr][] = $this->sphFixUint($val); 1440 1453 } 1441 1454 } … … 1447 1460 else 1448 1461 { 1449 $attrvals[$attr] = sprintf('%u',$val);1462 $attrvals[$attr] = $this->sphFixUint($val); 1450 1463 } 1451 1464 }