-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
EZP-29451: As an Administrator I want to have a CLI command for database cleanup #2431
Conversation
eZ/Bundle/EzPublishCoreBundle/Command/RemoveVersionsCommand.php
Outdated
Show resolved
Hide resolved
eZ/Bundle/EzPublishCoreBundle/Command/RemoveVersionsCommand.php
Outdated
Show resolved
Hide resolved
eZ/Bundle/EzPublishCoreBundle/Command/RemoveVersionsCommand.php
Outdated
Show resolved
Hide resolved
eZ/Bundle/EzPublishCoreBundle/Command/RemoveVersionsCommand.php
Outdated
Show resolved
Hide resolved
eZ/Bundle/EzPublishCoreBundle/Command/RemoveVersionsCommand.php
Outdated
Show resolved
Hide resolved
I think so, but the best way to find the answer will be to run command on some large database. Can you help @alongosz / @vidarl with this ? |
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.
Looks ok to me, but maybe invalid values for --keep option should throw InvalidArgumentException too?
fbc534b
to
5a90c66
Compare
eZ/Bundle/EzPublishCoreBundle/Command/RemoveVersionsCommand.php
Outdated
Show resolved
Hide resolved
eZ/Bundle/EzPublishCoreBundle/Command/RemoveVersionsCommand.php
Outdated
Show resolved
Hide resolved
eZ/Bundle/EzPublishCoreBundle/Command/RemoveVersionsCommand.php
Outdated
Show resolved
Hide resolved
eZ/Bundle/EzPublishCoreBundle/Command/RemoveVersionsCommand.php
Outdated
Show resolved
Hide resolved
eZ/Bundle/EzPublishCoreBundle/Command/RemoveVersionsCommand.php
Outdated
Show resolved
Hide resolved
582ac51
to
f843198
Compare
eZ/Bundle/EzPublishCoreBundle/Command/RemoveVersionsCommand.php
Outdated
Show resolved
Hide resolved
… for database cleanup
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 code looks good to me, basic tests went ok. 👍
eZ/Bundle/EzPublishCoreBundle/Command/CleanupVersionsCommand.php
Outdated
Show resolved
Hide resolved
eZ/Bundle/EzPublishCoreBundle/Command/CleanupVersionsCommand.php
Outdated
Show resolved
Hide resolved
@micszo fixed what you've found. Could you please do a second round of tests? |
eZ/Bundle/EzPublishCoreBundle/Command/CleanupVersionsCommand.php
Outdated
Show resolved
Hide resolved
@m-tyrala covered a case with |
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.
QA approve 🚀
@DominikaK we need a few bits of doc here |
|
||
$this | ||
->setName('ezplatform:content:cleanup-versions') | ||
->setDescription('Remove unwanted content versions. It keeps published version untouched. By default, it keeps also the last archived/draft version.') |
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.
Nipick: 'unwanted' is not the best term to use here: it is not descriptive of what it is considered unwanted
'keep', | ||
'k', | ||
InputOption::VALUE_OPTIONAL, | ||
"Sets number of the most recent versions (both drafts and archived) which won't be removed.", |
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.
Not sure having 1 value for the sum of both archived versions and drafts makes a lot of sense here.
I generally operate on the basis of "keep the last 4 archived versions", "keep all drafts", "keep no drafts".
I see no reason for anyone ever wanting to keep only the 4 most recent drafts, or, even weirder, the 4 most recent drafts-or-archives
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.
ps: my bad, reading the code it seems that the number of versions to keep is not a sum, which makes a lot more sense. Maybe the help text could be improved a bit to explain this more clearly ?
const VERSION_DRAFT = 'draft'; | ||
const VERSION_ARCHIVED = 'archived'; | ||
const VERSION_PUBLISHED = 'published'; | ||
const VERSION_ALL = 'all'; |
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.
nitpick: replace 'all' with something akin to 'all-except-published'
Q: does ez5 have a mechanism to automatically purge drafts older than X days? If not, it would be a nice addition. Adding an option to this command to operate on a basis of last-modified besides the max-items to keep would allow it to be used for such scenarios |
master
This PR introduces the new command which allows to clean up the database from the unwanted, archived content versions as well as unwanted drafts.
Big thanks for XROW (https://github.com/xrowgmbh) who provided POC for this command!
Open questions to reviewers:
flatten
script (https://github.com/ezsystems/ezpublish-legacy/blob/master/bin/php/flatten.php), the question is whether we want to make it smart enough to clean up also temporary content classes and temporary roles as the previous script could do? I think that if we want these functionalities, then it should be done as a separated command.iteration count
be implemented there? In other commands, it's supposed to decrease memory usage, but this command operates on a simple array containing content IDs and version counter only. Each ContentInfo object is loaded within the loop, so it's always only one at the time.TODO:
$ composer fix-cs
).