Fix deadlocks during search tests.
Review Request #12053 — Created Feb. 12, 2022 and submitted
Search tests which used on-the-fly indexing were hitting deadlocks under
the new haystack version. The problem here was that our indexing
templates were calling
get_profile, which would end up creating new
profile objects if they didn't already exist. This would attempt to
write from inside the indexer stack, which would hit a lock.
I've added a new helper that can check if a profile is public without
creating ones that don't exist. Other related code has been updated to
use this new helper appropriately instead of reinventing the wheel.
Ran unit tests.