fix: save correctly any match when closing search modal#13099
Conversation
Signed-off-by: greta <gretadoci@gmail.com>
|
Can you please explain what the fix does and why? |
Signed-off-by: greta <gretadoci@gmail.com>
The initial proposal didnt work well. I pushed a different approach. The problem is that the body was not populated from the simple search box, and now it is. |
|
I don't get it :/ |
📝 WalkthroughWalkthroughTwo changes address a bug where the search box returns no results for body-only matches. In 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: cadecb34-947a-46f6-beec-f9ef05740d0f
📒 Files selected for processing (2)
lib/Service/Search/MailSearch.phpsrc/components/SearchMessages.vue
| return $this->messageMapper->findIdsByQuery($mailbox, $query, $sortOrder, $limit); | ||
| } | ||
|
|
||
| return $this->messageMapper->findIdsByQuery($mailbox, $query, $sortOrder, $limit, $fromImap); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Find and examine the MessageMapper::findIdsByQuery implementation
# Locate MessageMapper and extract the findIdsByQuery method
ast-grep --pattern $'class MessageMapper {
$$$
findIdsByQuery($$$) {
$$$
}
$$$
}'
# Also search for how the $fromImap parameter is used
rg -nP -A 20 'function findIdsByQuery\(' --glob '**/MessageMapper.php'Repository: nextcloud/mail
Length of output: 1595
🏁 Script executed:
# Read the complete findIdsByQuery method from MessageMapper.php
sed -n '807,900p' lib/Db/MessageMapper.phpRepository: nextcloud/mail
Length of output: 4427
🏁 Script executed:
# Continue reading to see how $uids is handled and the rest of the method
sed -n '900,1000p' lib/Db/MessageMapper.phpRepository: nextcloud/mail
Length of output: 3947
🏁 Script executed:
# Continue reading to see parameter binding
sed -n '995,1020p' lib/Db/MessageMapper.phpRepository: nextcloud/mail
Length of output: 920
🏁 Script executed:
# Check the MailSearch.php file around line 167 to see how findIdsByQuery is called
sed -n '150,180p' lib/Service/Search/MailSearch.phpRepository: nextcloud/mail
Length of output: 1146
The merge uses AND logic instead of OR when no subjects are specified, breaking the intended behavior.
When $uids (IMAP body results) is provided without subject criteria (lines 923-930), the UIDs are merged using andWhere(), creating AND logic instead of OR. This breaks the expected behavior for anyof match mode.
Example: A search for "test" in body + from="user@example.com" with anyof mode should return messages from that email OR containing "test" in the body. Instead, it returns only messages that match BOTH criteria—filtering out messages that match body criteria but have a different sender.
The condition at line 927 adds UIDs to $textOrs (OR logic) only when subjects exist; otherwise it uses andWhere() (AND logic). For consistency with anyof semantics, UIDs should be added to $textOrs in all cases when body search is performed with other header criteria, not just when subjects are specified.
fixes #13068
🤖 AI (if applicable)