Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.6.0RC2
-
Fix Version/s: 1.8.4
-
Component/s: Zend_Search_Lucene
-
Labels:None
Description
I tried Zend_Search_Lucene on a 32 bit and all was fine. Trying on a 64 bit simply doesn't work.
The same index correctly opened on the 32 bit machine raises an exception on 64 bit.
Looking in the code I discovered that there's a problem with integer precision:
on line 422 of Zend/Search/Lucene.php the code:
$numField = $segmentsFile->readInt();
gives -1 on 32 bit, 4294967295 on 64 bit, reading the same index.
moreover, on line 425 the code
if ($numField != (int)0xFFFFFFFF)
fails, since 0xFFFFFFFF has a different value on 32 bit and 64 bit.
As workaround I changed numField to -1 and skipped the check and it works. So I think it's sufficent to change the test and the readInt function.
Hello guys,
I've just experienced this issue, quick-looked into the code and just made a patch for this. It's changing -1 to (int)0xFFFFFFFF in more places, like in other places it is done already.
The patch (looks like this is reverse patch, but you'll deal with it):
Index: library/Zend/Search/Lucene.php
===================================================================
— library/Zend/Search/Lucene.php (revision 13711)
+++ library/Zend/Search/Lucene.php (working copy)
@@ -413,7 +413,7 @@
if ($this->_formatVersion == self::FORMAT_2_3) {
$docStoreOffset = $segmentsFile->readInt();
+ if ($docStoreOffset != (int)0xFFFFFFFF) {
$docStoreSegment = $segmentsFile->readString();
$docStoreIsCompoundFile = $segmentsFile->readByte();
Index: library/Zend/Search/Lucene/Index/Writer.php
===================================================================
— library/Zend/Search/Lucene/Index/Writer.php (revision 13711)
+++ library/Zend/Search/Lucene/Index/Writer.php (working copy)
@@ -496,7 +496,7 @@
if ($srcFormat == Zend_Search_Lucene::FORMAT_2_3) {
$docStoreOffset = $segmentsFile->readInt();
+ if ($docStoreOffset != (int)0xFFFFFFFF) {
$docStoreSegment = $segmentsFile->readString();
$docStoreIsCompoundFile = $segmentsFile->readByte();
- if ($docStoreOffset != -1) {
+ if ($docStoreOffset != (int)0xFFFFFFFF) {
$docStoreSegment = $segmentsFile->readString();
$docStoreIsCompoundFile = $segmentsFile->readByte();
Index: library/Zend/Search/Lucene/Index/Writer.php =================================================================== — library/Zend/Search/Lucene/Index/Writer.php (revision 13711) +++ library/Zend/Search/Lucene/Index/Writer.php (working copy) @@ -496,7 +496,7 @@ if ($srcFormat == Zend_Search_Lucene::FORMAT_2_3) { $docStoreOffset = $segmentsFile->readInt();