Open emixolydian opened 5 months ago
Hi, I am in no way expecting this to get sorted immediately, just checking that someone's seen it. Thanks!
@emixolydian, no worries, we haven't had a chance to triage it yet but it's not forgotten. Thanks for the detailed investigation (particularly the bitfield stuff, which is pretty arcane for a PHP app).
@asmecher ready for review OJS_3_3_0 pkp/pkp-lib#10139 fix Author search pulls in keywords too #4380
Ready for review again. @jonasraoni OJS_3_3_0: pkp/pkp-lib#10139 fix Author search pulls in keywords too #4380
Describe the bug
When searching "By Author", the author type (type 1 in the submission_search_objects table) and the keyword type (type 17 in the submission_search_objects table) are both searched, which makes the search behavior pretty confusing (particularly obvious for journals where proper names appear both as author names and as keywords). "By Author" should only search authors.
To Reproduce
What application are you using?
OJS 3.3.0.13
Additional information
The reason this happens appears to be a bug with how the keywords type is encoded that was introduced when keywords were added back to search in OJS 3.x This issue is where the problem was introduced: #5388 Specifically this comment https://github.com/pkp/pkp-lib/issues/5388#issuecomment-764834374
In that issue, it was decided to use 17 (0x11) for keywords, suggesting that it was fine to use since bitmasking was never implemented for search. However, bitmasking does actually happen for search here: https://github.com/pkp/ojs/blob/43b3ad0ea124dc38ec88f9733e1a6f49dfd941a4/classes/search/ArticleSearchDAO.php#L67
Because of this, using 17 (0x11) for the keywords has the effect of making it look for author AND subject AND keywords because of how the type is handled here: https://github.com/pkp/pkp-lib/blob/843b4ac67f9090fab2054b17af047f3994b72608/classes/search/SubmissionSearch.php#L41
Searching for keyword also gets both authors and subjects because it includes both of those positions (shown above).