Don't attempt to index users before a Review Board site is fully set up.
Review Request #10700 — Created Sept. 7, 2019 and submitted — Latest diff uploaded
Our Haystack signal processor listens for newly-saved users and, if
search indexing is enabled, adds them to the index. The problem is,
the act of checking if they're enabled (looking up a
SiteConfiguration) can fail when creating a new database with a
superuser for the first time.
The reason this happens is that
django.contrib.authwill prompt the
admin to create a superuser in response to the
post_migratesignal the first time that the
Usermodel is added to
the database. This occurs before
django.contrib.siteshas a chance to
Siteobject. Normally that's fine, but our signal processor
is getting in the way by operating on that new superuser and accessing
This wasn't a problem in the past because we used to shell out to the
syncdbcommand, which never invoked the code that registers our signal
processor. A recent change removed that in favor of directly interfacing
with the Django Evolution
Evolverclass, meaning that the process is
now taking place in an environment where the signal processor is
This change updates the signal processor to check whether we have the
right entries in the database before handling each signal. This fixes
Unit tests pass.
prepare-dev.pyfor the first time with a superuser,
and saw that the database populated correctly.