mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-17 03:49:22 +00:00
Fix #11333
This commit is contained in:
@@ -40,7 +40,7 @@ class RemovesLinksToDeletedObjects extends Command
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'correction:remove-links-to-deleted-objects';
|
protected $signature = 'correction:remove-links-to-deleted-objects';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
@@ -86,17 +86,27 @@ class RemovesLinksToDeletedObjects extends Command
|
|||||||
|
|
||||||
private function cleanupJournals(array $journals): void
|
private function cleanupJournals(array $journals): void
|
||||||
{
|
{
|
||||||
$count = DB::table('tag_transaction_journal')->whereIn('transaction_journal_id', $journals)->delete();
|
$countTags = 0;
|
||||||
if ($count > 0) {
|
$countBudgets= 0;
|
||||||
$this->friendlyInfo(sprintf('Removed %d old relationship(s) between tags and transactions.', $count));
|
$countCategories = 0;
|
||||||
|
// #11333
|
||||||
|
foreach (array_chunk($journals, 1337) as $set) {
|
||||||
|
$countTags += DB::table('tag_transaction_journal')->whereIn('transaction_journal_id', $set)->delete();
|
||||||
|
$countBudgets += DB::table('budget_transaction_journal')->whereIn('transaction_journal_id', $set)->delete();
|
||||||
|
$countCategories += DB::table('category_transaction_journal')->whereIn('transaction_journal_id', $set)->delete();
|
||||||
}
|
}
|
||||||
$count = DB::table('budget_transaction_journal')->whereIn('transaction_journal_id', $journals)->delete();
|
|
||||||
if ($count > 0) {
|
|
||||||
$this->friendlyInfo(sprintf('Removed %d old relationship(s) between budgets and transactions.', $count));
|
|
||||||
|
if ($countTags > 0) {
|
||||||
|
$this->friendlyInfo(sprintf('Removed %d old relationship(s) between tags and transactions.', $countTags));
|
||||||
}
|
}
|
||||||
$count = DB::table('category_transaction_journal')->whereIn('transaction_journal_id', $journals)->delete();
|
|
||||||
if ($count > 0) {
|
if ($countBudgets > 0) {
|
||||||
$this->friendlyInfo(sprintf('Removed %d old relationship(s) categories and transactions.', $count));
|
$this->friendlyInfo(sprintf('Removed %d old relationship(s) between budgets and transactions.', $countBudgets));
|
||||||
|
}
|
||||||
|
if ($countCategories > 0) {
|
||||||
|
$this->friendlyInfo(sprintf('Removed %d old relationship(s) categories and transactions.', $countCategories));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user