-
Notifications
You must be signed in to change notification settings - Fork 29
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-5385: Add option content-type to reindex command #370
IBX-5385: Add option content-type to reindex command #370
Conversation
Changed from VALUE_OPTIONAL to VALUE_REQUIRED for content-type option Co-authored-by: Paweł Niedzielski <[email protected]>
@@ -40,6 +40,18 @@ public function getContentInSubtree(string $locationPath, int $iterationCount): | |||
*/ | |||
public function countContentInSubtree(string $locationPath): int; | |||
|
|||
/** | |||
* @throws \Doctrine\DBAL\Exception |
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.
As far as the indexing is concerned, I'm not sure if we want to declare that this can throw this exception. The fact that we are using Doctrine is irrelevant for indexing (at least for the interface). @alongosz ?
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.
As far as the indexing is concerned, I'm not sure if we want to declare that this can throw this exception. The fact that we are using Doctrine is irrelevant for indexing (at least for the interface). @alongosz ?
You're right. On SPI level we can throw SPI or API exceptions.
'content-type', | ||
null, | ||
InputOption::VALUE_REQUIRED, | ||
'Content type identifier to refresh (deleted/updated/added). Implies "no-purge", cannot be combined with "since", "subtree" or "content-ids"' |
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.
Side note, outside of the scope of this PR:
We are not actually checking that conflicting options are passed.
Relaxed constraints for getContentWithContentTypeIdentifier in IndexerGateway interface. Co-authored-by: Paweł Niedzielski <[email protected]>
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
@@ -63,6 +63,22 @@ public function countContentInSubtree(string $locationPath): int | |||
return (int)$query->execute()->fetchOne(); | |||
} | |||
|
|||
public function getContentWithContentTypeIdentifier(string $contentTypeIdentifier, int $iterationCount): Generator |
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.
The issue reported is relevant. Narrowing down of return type is available for PHP 7.4+, and this version of ezplatform-kernel supports PHP 7.3, which means you cannot use this feature.
public function getContentWithContentTypeIdentifier(string $contentTypeIdentifier, int $iterationCount): Generator | |
public function getContentWithContentTypeIdentifier(string $contentTypeIdentifier, int $iterationCount): iterable |
public function getContentWithContentTypeIdentifier(string $contentTypeIdentifier, int $iterationCount): iterable; | ||
|
||
/** | ||
* @throws \Doctrine\DBAL\Exception | ||
*/ | ||
public function countContentWithContentTypeIdentifier(string $contentTypeIdentifier): int; |
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.
Are we actually ok with introducing new method into this class @alongosz? It is a contract.
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.
Are we actually ok with introducing new method into this class @alongosz? It is a contract.
No, this is strict SPI, any additions to contracts there (except for SPI\Persistence) are hard BC break.
OT: Though, TBH I'm not sure what idea I had in mind when placing this in SPI. Maybe I thought it's gonna be implemented by each search engine, but AFAICS it should just fetch data related to indexing directly from Repository. Maybe the purpose was rather Legacy Storage strategy...
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.
This improvement is not directly related to a bug fix, but it's rather a new feature making easier to reindex data after a bug fix, right? Moreover AFAICS related CS tickets are 4.x. We fix bugs and performance issues on the oldest supported version, but we don't add features to it.
As a compromise, I would accept this solution for 4.5 instead of 4.6.x-dev, if @webhdx agrees.
Review remarks:
@@ -128,23 +128,28 @@ protected function configure() | |||
'since', | |||
null, | |||
InputOption::VALUE_OPTIONAL, | |||
'Refresh changes since a time provided in any format understood by DateTime. Implies "no-purge", cannot be combined with "content-ids" or "subtree"' | |||
'Refresh changes since a time provided in any format understood by DateTime. Implies "no-purge", cannot be combined with "content-ids", "subtree" or "content-type"' |
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.
Punctuation: use Oxford comma here and in the other related places please
'Refresh changes since a time provided in any format understood by DateTime. Implies "no-purge", cannot be combined with "content-ids", "subtree" or "content-type"' | |
'Refresh changes since a time provided in any format understood by DateTime. Implies "no-purge", cannot be combined with "content-ids", "subtree", or "content-type"' |
@@ -40,6 +40,18 @@ public function getContentInSubtree(string $locationPath, int $iterationCount): | |||
*/ | |||
public function countContentInSubtree(string $locationPath): int; | |||
|
|||
/** | |||
* @throws \Doctrine\DBAL\Exception |
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.
As far as the indexing is concerned, I'm not sure if we want to declare that this can throw this exception. The fact that we are using Doctrine is irrelevant for indexing (at least for the interface). @alongosz ?
You're right. On SPI level we can throw SPI or API exceptions.
public function getContentWithContentTypeIdentifier(string $contentTypeIdentifier, int $iterationCount): iterable; | ||
|
||
/** | ||
* @throws \Doctrine\DBAL\Exception | ||
*/ | ||
public function countContentWithContentTypeIdentifier(string $contentTypeIdentifier): int; |
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.
Are we actually ok with introducing new method into this class @alongosz? It is a contract.
No, this is strict SPI, any additions to contracts there (except for SPI\Persistence) are hard BC break.
OT: Though, TBH I'm not sure what idea I had in mind when placing this in SPI. Maybe I thought it's gonna be implemented by each search engine, but AFAICS it should just fetch data related to indexing directly from Repository. Maybe the purpose was rather Legacy Storage strategy...
$count = $this->gateway->countContentWithContentTypeIdentifier($contentType); | ||
$generator = $this->gateway->getContentWithContentTypeIdentifier($contentType, $iterationCount); | ||
$purge = false; |
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.
Given you can't add anything to that Gateway without breaking BC promise (see previous comment), I think better solution would be to either use Repository Filtering (\eZ\Publish\API\Repository\ContentService::find
) or make a dedicated method in \eZ\Publish\SPI\Persistence\Content\Handler
. The latter option would be more performant and require implementing cache layer (which is good).
Closing this PR, moving changes to ibexa/core#259 in order to merge this to 4.5 |
v3.3
+Checklist:
$ composer fix-cs
).@ezsystems/engineering-team
).