Repository navigation
fix: resolve effective limitations in non-primary networks and isolate caches #1879
Description
Goal
Resolve product/membership effective limitations from the correct network metadata
tables and isolate limitation caches between networks. This is required before
relying on product limits during native trial-site provisioning.
Observed behaviour
With Ultimate Multisite 2.16.1 and the Multi-Network addon active, read-only checks
on a non-primary network found two products where
count((array) $product->get_meta('wu_limitations', [])) was 11 but
count($product->get_limitations()->to_array()) was 0. Another product resolved
11 modules. No product settings or customer records were modified for the check.
The reason for that third product's differing result has not been established.
Upstream main was inspected and retains the same relevant code:
inc/objects/class-limitations.php:461-502,early_get_limitations(), builds
the table directly as{$wpdb->base_prefix}{$wu_prefix}{$slug}meta.- Its static cache key is only
sprintf('%s-%s', $slug, $id). inc/models/traits/trait-limitable.php:73-76switches from the model's normal
metadata API to this early lookup aftermuplugins_loaded.
This suggests a mismatch between the early lookup and the active network's model
metadata routing, with a separate risk of cache collisions for overlapping IDs.
Verify the routing contract before choosing a fix; do not assume missing limits
are simply a product configuration error.
Implementation scope
- Audit and fix the early metadata lookup in
inc/objects/class-limitations.php.
Use the canonical network-aware table resolver; do not hard-code an addon table
prefix. The appropriate resolver must be identified during implementation. - Include effective network/table identity in static cache keys and audit the
corresponding invalidation paths, includingremove_limitations(). - Preserve the special handling of native site/blog metadata and early bootstrap
when the full model layer or addon hooks are not available. - Inspect
inc/models/traits/trait-limitable.phpfor related per-object cache
isolation requirements. Do not weaken or bypass limits as a workaround. - If the routing contract belongs to the Multi-Network addon, coordinate that
fix there instead of adding an incompatible core-only naming assumption.
Verification
Extend the existing tests/WP_Ultimo/Objects/Limitations_Test.php and applicable
limitation tests; no new test framework is needed. Create fixture products in two
networks with distinct site/disk limits and overlapping IDs when the storage
model permits that. Verify:
- Normal model metadata and effective limitation results agree in each network.
- Switching networks and restoring the original network in one request does not
reuse another network's cached result. - Updating/removing limits invalidates only the intended cached data.
- Membership/site inheritance enforces the correct product limits.
- Primary-network, site/blog metadata and early-bootstrap behaviour remain valid.
Use synthetic fixtures only. Do not reproduce by altering live customer records.
aidevops.sh v3.34.13 plugin for OpenCode v1.18.31 with gpt-6-astra
Activity