Fix and improve loading of cached profiles in User.

Review Request #12318 — Created May 31, 2022 and submitted — Latest diff uploaded

Information

Review Board
release-5.0.x

Reviewers

User.get_profile() attempts to cache or make use of a cached result
from a previous call. It used to make use of _profile_set_cache, which
was the name used in Django 1.6 and 1.11. Newer versions use different
mechanisms for cache, for both prefetch_related() and
select_related(). This was a regression from Review Board 4.

This change fixes that support and expands upon it. A new series of unit
tests have been added that ensure caching works exactly as expected in a
variety of situations.

As part of this, various datagrid unit tests have been updated to once
again have reduced query counts. These counts were initially increased
in commit ceab149f415ade7432a3ff6e625beb0cdc5645f2, thought to have been
due to middleware changes, but were actually due to the Django relation
caching changes.

Unit tests pass.

Commits

Files

    Loading...