-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix EZP-28165: Incorrect increment of object_count in ezsearch_word #1319
Conversation
@@ -185,16 +184,17 @@ function buildWordIDArray( $indexArrayOnlyWords ) | |||
// Build a has of the existing words | |||
$wordResCount = count( $wordRes ); | |||
$existingWordArray = array(); | |||
$wordIDArrayChuck = array(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we just move init of $wordIDArray
here to avoid needing to change lines below?
Done. |
Thanks! Could you btw create JIRA issue for this? Affected version will be 2017.10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, seems like >=1.7 LTS is affected as well (I trusted in The Legacy Code when porting this ;)).
I'll fix it there as well once I have more time (in the new stack requires test and some naming changes as they're misleading IMHO - see $wordIDArray
, $wordArray
and buildWordIDArray
which returns $wordArray
)
When updating object_count in ezsearch_word, eZSearchEngine splits the list of words in chunks of 500. But in every cycle of the loop not only the current chunk but all of the previous chunks are incremented. Which means that if there are, lets say 3 chunks, the first chunk gets an increment of +3, the second of +2, and the third of +1.
Steps to reproduce:
Result:
The object_count has a larger value than it should.
Fix:
Simply move
$wordIDArray
from outside thefor
to inside, so that it is reset on every loop. I also renamed the variable to$wordIDArrayChuck
, to make it consistent with$wordArrayChuck
, but that's not necessary.