Skip to content
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

Merged
merged 8 commits into from
Apr 9, 2021

Conversation

alongosz
Copy link
Member

@alongosz alongosz commented Apr 6, 2021

Question Answer
JIRA issue IBX-143
Type improvement
Target Ibexa version v2.5, v3.2, v3.3
BC breaks no

Since eZ Platform 2.5 requires Doctrine Bundle ^1.9 which requires doctrine/dbal:^2.5.12, it's safe to force doctrine/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:

  • Provided PR description.
  • Tested the solution manually.
  • Provided automated test coverage.
  • Checked that target branch is set correctly (master for features, the oldest supported for bugs).
  • Ran PHP CS Fixer for new PHP code (use $ composer fix-cs).
  • Asked for a review (ping @ibexa/engineering).

Copy link
Contributor

@Steveb-p Steveb-p left a 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.

eZ/Publish/SPI/Search/Content/IndexerGateway.php Outdated Show resolved Hide resolved
@alongosz
Copy link
Member Author

alongosz commented Apr 7, 2021

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...

@alongosz alongosz marked this pull request as ready for review April 7, 2021 14:50
Comment on lines 132 to 145
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));
Copy link
Member

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...

Copy link
Contributor

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 😝

Copy link
Member Author

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.

Copy link
Member

@Nattfarinn Nattfarinn Apr 8, 2021

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.

Copy link
Contributor

@Steveb-p Steveb-p Apr 8, 2021

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?

Copy link
Contributor

@Steveb-p Steveb-p left a 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.

@alongosz alongosz merged commit 9f1c87e into 7.5 Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
7 participants