From f13e0991fbedd51e873c145a5816075de2a38c42 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 13 Sep 2025 07:13:30 +0200 Subject: [PATCH] Fix #10898 --- .../Collector/Extensions/MetaCollection.php | 17 ++++++++++------- app/Helpers/Collector/GroupCollector.php | 4 ++-- app/Http/Controllers/TagController.php | 5 +---- changelog.md | 1 + 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/app/Helpers/Collector/Extensions/MetaCollection.php b/app/Helpers/Collector/Extensions/MetaCollection.php index 42a025e8b7..11a15ef799 100644 --- a/app/Helpers/Collector/Extensions/MetaCollection.php +++ b/app/Helpers/Collector/Extensions/MetaCollection.php @@ -598,16 +598,16 @@ trait MetaCollection $foundTagCount = 0; foreach ($object['transactions'] as $transaction) { $transactionTagCount = count($transaction['tags']); - app('log')->debug(sprintf('Transaction #%d has %d tag(s)', $transaction['transaction_journal_id'], $transactionTagCount)); + Log::debug(sprintf('Transaction #%d has %d tag(s)', $transaction['transaction_journal_id'], $transactionTagCount)); if ($transactionTagCount < $expectedTagCount) { - app('log')->debug(sprintf('Transaction has %d tag(s), we expect %d tag(s), return false.', $transactionTagCount, $expectedTagCount)); + Log::debug(sprintf('Transaction has %d tag(s), we expect %d tag(s), return false.', $transactionTagCount, $expectedTagCount)); return false; } foreach ($transaction['tags'] as $tag) { Log::debug(sprintf('"%s" versus', strtolower((string) $tag['name'])), $list); if (in_array(strtolower((string) $tag['name']), $list, true)) { - app('log')->debug(sprintf('Transaction has tag "%s" so count++.', $tag['name'])); + Log::debug(sprintf('Transaction has tag "%s" so count++.', $tag['name'])); ++$foundTagCount; $journalId = $transaction['transaction_journal_id']; // #8377 prevent adding a transaction twice when multiple tag searches find this transaction @@ -776,6 +776,9 @@ trait MetaCollection $this->withTagInformation(); $this->query->whereNotNull('tag_transaction_journal.tag_id'); + // Added this while fixing #10898, not sure why a post filter was ever necessary. + $this->query->whereIn('tag_transaction_journal.tag_id', $tags->pluck('id')->toArray()); + // this method adds a "postFilter" to the collector. $list = $tags->pluck('tag')->toArray(); $list = array_map('strtolower', $list); @@ -785,13 +788,13 @@ trait MetaCollection foreach ($transaction['tags'] as $tag) { Log::debug(sprintf('"%s" versus', strtolower((string) $tag['name'])), $list); if (in_array(strtolower((string) $tag['name']), $list, true)) { - app('log')->debug(sprintf('Transaction has tag "%s" so return true.', $tag['name'])); + Log::debug(sprintf('Transaction has tag "%s" so return true.', $tag['name'])); return true; } } } - app('log')->debug('Transaction has no tags from the list, so return false.'); + Log::debug('Transaction has no tags from the list, so return false.'); return false; }; @@ -813,11 +816,11 @@ trait MetaCollection $filter = static function (array $object) use ($list): bool { Log::debug(sprintf('Now in setWithoutSpecificTags(%s) filter', implode(', ', $list))); foreach ($object['transactions'] as $transaction) { - app('log')->debug(sprintf('Transaction has %d tag(s)', count($transaction['tags']))); + Log::debug(sprintf('Transaction has %d tag(s)', count($transaction['tags']))); foreach ($transaction['tags'] as $tag) { Log::debug(sprintf('"%s" versus', strtolower((string) $tag['name'])), $list); if (in_array(strtolower((string) $tag['name']), $list, true)) { - app('log')->debug(sprintf('Transaction has tag "%s", but should not have it, return false.', $tag['name'])); + Log::debug(sprintf('Transaction has tag "%s", but should not have it, return false.', $tag['name'])); return false; } diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.php index abc28ee56f..d8d12cf498 100644 --- a/app/Helpers/Collector/GroupCollector.php +++ b/app/Helpers/Collector/GroupCollector.php @@ -631,7 +631,7 @@ class GroupCollector implements GroupCollectorInterface } // also merge attachments: - if (array_key_exists('attachment_id', $result)) { + if (array_key_exists('attachment_id', $result) && null !== $result['attachment_id']) { $uploaded = 1 === (int)$result['attachment_uploaded']; $attachmentId = (int)$augumentedJournal['attachment_id']; if (0 !== $attachmentId && $uploaded) { @@ -659,7 +659,7 @@ class GroupCollector implements GroupCollectorInterface private function convertToInteger(array $array): array { foreach ($this->integerFields as $field) { - $array[$field] = array_key_exists($field, $array) ? (int)$array[$field] : null; + $array[$field] = array_key_exists($field, $array) && null !== $array[$field] ? (int)$array[$field] : null; } return $array; diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 82020490e3..f69cd62c24 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -250,10 +250,7 @@ class TagController extends Controller /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); - $collector->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withAccountInformation() - ->setTag($tag)->withBudgetInformation()->withCategoryInformation() - ->withAttachmentInformation() - ; + $collector->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withAccountInformation()->setTag($tag)->withBudgetInformation()->withCategoryInformation()->withAttachmentInformation(); $groups = $collector->getPaginatedGroups(); $groups->setPath($path); $sums = $this->repository->sumsOfTag($tag, $start, $end); diff --git a/changelog.md b/changelog.md index c3f105011f..63af89f3bd 100644 --- a/changelog.md +++ b/changelog.md @@ -32,6 +32,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - [Discussion 10883](https://github.com/orgs/firefly-iii/discussions/10883) (Initial balance for account is missing from exported CSV) started by @ajaskiewiczpl - #10888 - #10891 +- #10898 ### API