cameronterry / dark-matter

A highly opinionated domain mapping plugin for WordPress Networks
Other
12 stars 2 forks source link

Fix cache / DB sync issue with primary domains #94

Closed cameronterry closed 2 years ago

cameronterry commented 2 years ago

This resolves the issue found in the new unit tests by rearranging the logic for primary domains to ensure both the database and cache stay in sync.

Namely, the cache handling is mostly moved to DarkMatter_Domains instead of DarkMatter_Primary by ensuring the "updates" for domains are managed in a single place. This also removes some duplicate database logic that was missed in previous iterations of the plugin since version 2.0.0.

Resolves the two unit test errors:

5) PrimaryDomainTest::test_set_primary_domain
Cached update to primary.
Failed asserting that false is true.

/home/runner/work/dark-matter/dark-matter/tests/phpunit/domain-mapping/PrimaryDomainTest.php:124

6) PrimaryDomainTest::test_unset_primary_domain
Cached update to unset primary.
Failed asserting that true is false.

/home/runner/work/dark-matter/dark-matter/tests/phpunit/domain-mapping/PrimaryDomainTest.php:160

Fixes: https://github.com/cameronterry/dark-matter/issues/93