-
Notifications
You must be signed in to change notification settings - Fork 206
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
IBX-143: Refactored reindexing command to be DBAL 2.13-compatible #3094
Conversation
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.
Only a minor suggestion, but otherwise LGTM.
Co-Authored-By: Adam Wójs <adamwojs@users.noreply.github.com>
Update: I've reworked IndexerGateway to encapsulate all database operation, exposing only ready to consume generators. Added new namespace for SPI gateway integration test. Tests are re-using legacy Repository setup schema & data due to time constraints. Waiting for Travis... |
do { | ||
$contentIds = []; | ||
for ($i = 0; $i < $iterationCount; ++$i) { | ||
if ($contentId = $stmt->fetchOne()) { | ||
$contentIds[] = $contentId; | ||
} elseif (empty($contentIds)) { | ||
return; | ||
} else { | ||
break; | ||
} | ||
} | ||
|
||
yield $contentIds; | ||
} while (!empty($contentId)); |
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.
I have feeling that something is wrong here but maybe it's lack of coffee...
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.
Lack of coffee 😄
I was also bewildered by this code though, and for this reason wanted phpdoc to include the fact that the generator built here will actually return arrays of integers (int[]
), not single integers (int
). But PHPStorm refused to understand the @return \Generator<int[]>
annotation 😝
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.
I have feeling that something is wrong here but maybe it's lack of coffee...
It's a multidimensional array - a list of Content IDs for each iteration.
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.
Variable names are misleading, $contentId
as an array of IDs, and $contentIds
as an array of arrays of IDs bring a lot of confusion to this code.
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.
@Nattfarinn actually no. $contentId
is a single ID indeed.
To resolve the readability issue, I suggest we move the internal iteration to a separate, private method that will just build that $contentIds
chunk?
Co-authored-by: Adam Wójs <adam@wojs.pl>
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.
We can improve readability of the contested method generating $contentIds
, but it's optional. I was able to read throught that generator just fine.
v2.5
,v3.2
,v3.3
Since eZ Platform 2.5 requires Doctrine Bundle ^1.9 which requires
doctrine/dbal:^2.5.12
, it's safe to forcedoctrine/dbal:^2.13
, which introduces some changes ResultStatement-related class structure.This PR besides fixing the issue at hand, refactors the code to be more future-proof and adds test coverage to prevent further regressions.
Checklist:
$ composer fix-cs
).@ibexa/engineering
).