From 00d617fcc363fb3a96a9cfad352e138e7b00ecba Mon Sep 17 00:00:00 2001 From: David Stone Date: Fri, 22 May 2026 11:20:37 -0600 Subject: [PATCH 1/2] Revert "wip: add wu_pre_* filters to 6 model methods (#1260)" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit ef74b6ab8168da1223fd98dc41e1d960f82fe0e5. Under ADR-001 Amendment 1 — Direct-DB Push Model (Ultimate-Multisite/ultimate-multisite-multi-tenancy#86), sovereign tenants do not read network state via filter chokepoints at request time. Instead, the network pushes state into each tenant's local wp_options / wp_blogmeta via a Tenant_State_Pusher Action Scheduler job, and the tenant reads only from its local DB. These wu_pre_* filters on Base_Model::get_by, ::get_by_hash, ::query_by_columns, and the upstream model methods were the load-bearing interception points for the original REST-pull plan (Phase 3.4 / Phase 3.5). Under the push model they are dead-code surface — no sovereign tenant code hooks them. Reverting to keep core's surface area minimal. Ref Ultimate-Multisite/ultimate-multisite-multi-tenancy#86 --- inc/models/class-customer.php | 6 ------ inc/models/class-domain.php | 6 ------ inc/models/class-membership.php | 6 ------ inc/models/class-site.php | 18 ------------------ 4 files changed, 36 deletions(-) diff --git a/inc/models/class-customer.php b/inc/models/class-customer.php index 01ef9634..22a16be0 100644 --- a/inc/models/class-customer.php +++ b/inc/models/class-customer.php @@ -813,12 +813,6 @@ public function set_type($type) { */ public function get_total_grossed() { - $pre = apply_filters( 'wu_pre_customer_get_total_grossed', null, $this ); - - if ( null !== $pre ) { - return $pre; - } - global $wpdb; static $sum; diff --git a/inc/models/class-domain.php b/inc/models/class-domain.php index 4a921709..cac48875 100644 --- a/inc/models/class-domain.php +++ b/inc/models/class-domain.php @@ -610,12 +610,6 @@ public function delete() { */ public static function get_by_site($site) { - $pre = apply_filters( 'wu_pre_domain_get_by_site', null, $site ); - - if ( null !== $pre ) { - return $pre; - } - global $wpdb; // Allow passing a site object in diff --git a/inc/models/class-membership.php b/inc/models/class-membership.php index 0b4be1bb..a386b595 100644 --- a/inc/models/class-membership.php +++ b/inc/models/class-membership.php @@ -2320,12 +2320,6 @@ public function set_recurring($recurring): void { */ public function get_total_grossed() { - $pre = apply_filters( 'wu_pre_membership_get_total_grossed', null, $this ); - - if ( null !== $pre ) { - return $pre; - } - global $wpdb; static $sum; diff --git a/inc/models/class-site.php b/inc/models/class-site.php index 83b0d714..a40acf2c 100644 --- a/inc/models/class-site.php +++ b/inc/models/class-site.php @@ -1158,12 +1158,6 @@ public function get_membership() { return $this->membership; } - $pre = apply_filters( 'wu_pre_site_get_membership', null, $this ); - - if ( null !== $pre ) { - return $pre; - } - global $wpdb; $table_name = "{$wpdb->base_prefix}wu_memberships"; @@ -2232,12 +2226,6 @@ public function to_search_results() { */ public static function get_all_by_type($type = 'customer_owned', $query_args = []) { - $pre = apply_filters( 'wu_pre_site_get_all_by_type', null, $type, $query_args ); - - if ( null !== $pre ) { - return $pre; - } - global $wpdb; if ('pending' === $type) { @@ -2330,12 +2318,6 @@ public static function get_all_by_categories($categories = [], $query_args = []) */ public static function get_all_categories($sites = []) { - $pre = apply_filters( 'wu_pre_site_get_all_categories', null, $sites ); - - if ( null !== $pre ) { - return $pre; - } - global $wpdb; $site_ids = []; From 9acf0c7f657ea05865da060eb486b17cbd3307ff Mon Sep 17 00:00:00 2001 From: David Stone Date: Fri, 22 May 2026 11:20:37 -0600 Subject: [PATCH 2/2] Revert "GH#1251: feat: add wu_pre_* filters to Base_Model getters (#1259)" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit f87f1e2421537a3183cfea4f585f61afab4d2c0e. Under ADR-001 Amendment 1 — Direct-DB Push Model (Ultimate-Multisite/ultimate-multisite-multi-tenancy#86), the sovereign tenant runs as a single-site WordPress install that reads only its local DB. The Base_Model getter filters (get_by_id, get_by, get_by_hash) were intended as the interception points for the tenant's planned Network_Client SDK, allowing the tenant to service model reads from network state. That entire plan is replaced by direct-DB push from network into the tenant's local wp_options / wp_blogmeta. The tenant has no SDK, no HTTP client, no cache, no filter hook into Base_Model. These filters become dead-code surface in core and are reverted to keep the upstream API minimal. The companion 6-model-method filters PR (#1260) is reverted in the preceding commit. Ref Ultimate-Multisite/ultimate-multisite-multi-tenancy#86 --- inc/models/class-base-model.php | 18 -- tests/WP_Ultimo/Models/Base_Model_Test.php | 192 --------------------- 2 files changed, 210 deletions(-) diff --git a/inc/models/class-base-model.php b/inc/models/class-base-model.php index 330abd03..c35fb505 100644 --- a/inc/models/class-base-model.php +++ b/inc/models/class-base-model.php @@ -340,12 +340,6 @@ public static function get_by_id($item_id) { $instance = new static(); - $pre = apply_filters( "wu_pre_get_by_id_{$instance->model}", null, $item_id ); - - if ( null !== $pre ) { - return $pre; - } - $query_class = new $instance->query_class(); return $query_class->get_item($item_id); @@ -364,12 +358,6 @@ public static function get_by_hash($item_hash) { $instance = new static(); - $pre = apply_filters( "wu_pre_get_by_hash_{$instance->model}", null, $item_hash ); - - if ( null !== $pre ) { - return $pre; - } - $item_id = Hash::decode($item_hash, sanitize_key((new \ReflectionClass(static::class))->getShortName())); $query_class = new $instance->query_class(); @@ -390,12 +378,6 @@ public static function get_by($column, $value) { $instance = new static(); - $pre = apply_filters( "wu_pre_get_by_{$instance->model}", null, $column, $value ); - - if ( null !== $pre ) { - return $pre; - } - $query_class = new $instance->query_class(); return $query_class->get_item_by($column, $value); diff --git a/tests/WP_Ultimo/Models/Base_Model_Test.php b/tests/WP_Ultimo/Models/Base_Model_Test.php index a49bf6e6..1a613eca 100644 --- a/tests/WP_Ultimo/Models/Base_Model_Test.php +++ b/tests/WP_Ultimo/Models/Base_Model_Test.php @@ -559,198 +559,6 @@ public function test_get_formatted_date_formats_valid_date(): void { $this->assertNotSame('2030-06-15 10:30:00', $result); } - /** - * Test wu_pre_get_by_id filter returns null by default (no-callback case). - */ - public function test_wu_pre_get_by_id_filter_returns_null_by_default(): void { - - $user_id = self::factory()->user->create(); - $customer = wu_create_customer([ - 'user_id' => $user_id, - 'skip_validation' => true, - ]); - - $this->assertNotWPError($customer); - $customer_id = $customer->get_id(); - - // No callback registered — filter returns null, normal query proceeds. - $result = Customer::get_by_id($customer_id); - - $this->assertNotFalse($result); - $this->assertSame($customer_id, $result->get_id()); - } - - /** - * Test wu_pre_get_by_id filter returns instance when callback returns instance. - */ - public function test_wu_pre_get_by_id_filter_returns_instance_when_callback_returns_instance(): void { - - $user_id = self::factory()->user->create(); - $customer = wu_create_customer([ - 'user_id' => $user_id, - 'skip_validation' => true, - ]); - - $this->assertNotWPError($customer); - $customer_id = $customer->get_id(); - - // Create a stub customer to return from the filter. - $stub = new Customer(['id' => 9999]); - - // Register callback that returns the stub. - add_filter('wu_pre_get_by_id_customer', function() use ($stub) { - return $stub; - }); - - $result = Customer::get_by_id($customer_id); - - // Should return the stub, not the real customer. - $this->assertSame(9999, $result->get_id()); - - remove_filter('wu_pre_get_by_id_customer', function() use ($stub) { - return $stub; - }); - } - - /** - * Test wu_pre_get_by filter returns null by default (no-callback case). - */ - public function test_wu_pre_get_by_filter_returns_null_by_default(): void { - - $user_id = self::factory()->user->create(); - $customer = wu_create_customer([ - 'user_id' => $user_id, - 'skip_validation' => true, - ]); - - $this->assertNotWPError($customer); - - // No callback registered — filter returns null, normal query proceeds. - $result = Customer::get_by('user_id', $user_id); - - $this->assertNotFalse($result); - $this->assertSame($user_id, $result->get_user_id()); - } - - /** - * Test wu_pre_get_by filter returns instance when callback returns instance. - */ - public function test_wu_pre_get_by_filter_returns_instance_when_callback_returns_instance(): void { - - $user_id = self::factory()->user->create(); - $customer = wu_create_customer([ - 'user_id' => $user_id, - 'skip_validation' => true, - ]); - - $this->assertNotWPError($customer); - - // Create a stub customer to return from the filter. - $stub = new Customer(['id' => 8888]); - - // Register callback that returns the stub. - add_filter('wu_pre_get_by_customer', function() use ($stub) { - return $stub; - }); - - $result = Customer::get_by('user_id', $user_id); - - // Should return the stub, not the real customer. - $this->assertSame(8888, $result->get_id()); - - remove_filter('wu_pre_get_by_customer', function() use ($stub) { - return $stub; - }); - } - - /** - * Test wu_pre_get_by_hash filter returns null by default (no-callback case). - */ - public function test_wu_pre_get_by_hash_filter_returns_null_by_default(): void { - - $user_id = self::factory()->user->create(); - $customer = wu_create_customer([ - 'user_id' => $user_id, - 'skip_validation' => true, - ]); - - $this->assertNotWPError($customer); - - $hash = $customer->get_hash('id'); - - // No callback registered — filter returns null, normal query proceeds. - $result = Customer::get_by_hash($hash); - - $this->assertNotFalse($result); - $this->assertSame($customer->get_id(), $result->get_id()); - } - - /** - * Test wu_pre_get_by_hash filter returns instance when callback returns instance. - */ - public function test_wu_pre_get_by_hash_filter_returns_instance_when_callback_returns_instance(): void { - - $user_id = self::factory()->user->create(); - $customer = wu_create_customer([ - 'user_id' => $user_id, - 'skip_validation' => true, - ]); - - $this->assertNotWPError($customer); - - $hash = $customer->get_hash('id'); - - // Create a stub customer to return from the filter. - $stub = new Customer(['id' => 7777]); - - // Register callback that returns the stub. - add_filter('wu_pre_get_by_hash_customer', function() use ($stub) { - return $stub; - }); - - $result = Customer::get_by_hash($hash); - - // Should return the stub, not the real customer. - $this->assertSame(7777, $result->get_id()); - - remove_filter('wu_pre_get_by_hash_customer', function() use ($stub) { - return $stub; - }); - } - - /** - * Test wu_pre_get_by_id filter discriminates by model name. - */ - public function test_wu_pre_get_by_id_filter_discriminates_by_model(): void { - - $user_id = self::factory()->user->create(); - $customer = wu_create_customer([ - 'user_id' => $user_id, - 'skip_validation' => true, - ]); - - $this->assertNotWPError($customer); - $customer_id = $customer->get_id(); - - // Create a stub to return from the filter. - $stub = new Customer(['id' => 6666]); - - // Register callback for 'membership' model (not 'customer'). - add_filter('wu_pre_get_by_id_membership', function() use ($stub) { - return $stub; - }); - - // Customer::get_by_id should NOT be affected by the 'membership' filter. - $result = Customer::get_by_id($customer_id); - - $this->assertNotFalse($result); - $this->assertSame($customer_id, $result->get_id()); - - remove_filter('wu_pre_get_by_id_membership', function() use ($stub) { - return $stub; - }); - } - /** * Tear down test environment. */