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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance prunes command #35719
Enhance prunes command #35719
Conversation
$totalDeleted += $deleted; | ||
} while ($deleted !== 0); | ||
foreach ($items as $item) { | ||
$item->delete(); |
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.
Memory issue should be solved, but will this not fire a query each time?
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 agree this will be much slower and I am also not convinced there is any memory issues with the previous version of the code which was taken from the official Laravel telescope package.
https://github.com/laravel/telescope/blob/master/src/Console/PruneCommand.php
Not sure if the original code was misread but is not loading any models into memory as it is just doing a delete query with a limit of 1000 records per delete.
* @return void | ||
*/ | ||
public function handle() | ||
public function handle(PrunableBatchRepository $repository) |
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 I can tell, This interface is not in the container and won鈥檛 be resolved and the command will break.
The point of the original check was that some future repository may not be prunable so it should still use the BatchRepository interface to get the repository and I think the check is still required.
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 PR introduces small tweaks to enhance the feature introduced in #35694
cursor
to avoid memory issues reading from tables with a bunch of records.prune
interface instead to avoid checking for types to decide paths.I will be happy to add the missing tests for it (couldn't find them) if the proposed changes are accepted.
Merry Christmas 馃馃徎