Commit e3523f11ece for woocommerce

commit e3523f11ece66c3890a7e2597b356f5d3fbe0bb8
Author: Luis Felipe Zaguini <26530524+zaguiini@users.noreply.github.com>
Date:   Fri Dec 4 16:20:43 2026 -0300

    Keep a saved object in its sync when another resource deletes the same ID (#71825)

    The sync list left out a saved object when an object of another resource
    with the same class and ID was deleted or trashed in the same call. The
    check now includes the resource name in the key.

    Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

diff --git a/plugins/woocommerce/changelog/wooai-1992-keep-a-saved-object-in-its-sync b/plugins/woocommerce/changelog/wooai-1992-keep-a-saved-object-in-its-sync
new file mode 100644
index 00000000000..68eb7d8e7a2
--- /dev/null
+++ b/plugins/woocommerce/changelog/wooai-1992-keep-a-saved-object-in-its-sync
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+Comment: Fix the experimental extensible abilities sync list when two resources share an object class and ID.
+
diff --git a/plugins/woocommerce/src/Abilities/ActionableAbility.php b/plugins/woocommerce/src/Abilities/ActionableAbility.php
index 2e2b73fbe54..704bc249eec 100644
--- a/plugins/woocommerce/src/Abilities/ActionableAbility.php
+++ b/plugins/woocommerce/src/Abilities/ActionableAbility.php
@@ -382,13 +382,13 @@ abstract class ActionableAbility extends Ability {
 	private function sync( array $objects, array $sent ): ?\WP_Error {
 		$deleted = $this->get_deleted_objects();
 		$trashed = $this->get_trashed_objects();
-		$gone    = array_map( fn( $item ) => get_class( $item ) . ':' . ExtensibleAbilities::get_object_id( $item, $this->get_resource() ), array_merge( $deleted, $trashed ) );
+		$gone    = array_map( fn( $item ) => $this->get_resource() . ':' . get_class( $item ) . ':' . ExtensibleAbilities::get_object_id( $item, $this->get_resource() ), array_merge( $deleted, $trashed ) );
 		$saved   = array();
 		$own     = array();
 		foreach ( $objects as list( $object, , $resource_name ) ) {
 			$own[ $resource_name ] ??= array();
 			$id                      = ExtensibleAbilities::get_object_id( $object, $resource_name );
-			if ( $id > 0 && ! in_array( get_class( $object ) . ':' . $id, $gone, true ) ) {
+			if ( $id > 0 && ! in_array( $resource_name . ':' . get_class( $object ) . ':' . $id, $gone, true ) ) {
 				$saved[]                 = $object;
 				$own[ $resource_name ][] = $object;
 			}
diff --git a/plugins/woocommerce/tests/php/src/Internal/AbilitiesApi/ExtensibleAbilitiesTest.php b/plugins/woocommerce/tests/php/src/Internal/AbilitiesApi/ExtensibleAbilitiesTest.php
index 6065b135593..8c755cf4c08 100644
--- a/plugins/woocommerce/tests/php/src/Internal/AbilitiesApi/ExtensibleAbilitiesTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/AbilitiesApi/ExtensibleAbilitiesTest.php
@@ -4179,6 +4179,110 @@ class ExtensibleAbilitiesTest extends \WC_REST_Unit_Test_Case {
 		$this->assertSame( array( 'saved' => array( 'WC_Order_Item_Product' ) ) + $whole_call, $seen['order_item'] );
 	}

+	/**
+	 * @testdox Should leave a deleted object out of its own sync only, when an object of another resource has the same class and ID.
+	 */
+	public function test_a_deleted_object_leaves_out_only_its_own_resource_in_the_syncs(): void {
+		$this->add_test_action(
+			'woocommerce_extensible_abilities_resources_init',
+			static function () {
+				ExtensibleAbilities::register_resource( 'ticket', self::get_ticket_resource_args() );
+				ExtensibleAbilities::register_resource( 'gadget', self::get_ticket_resource_args() );
+			}
+		);
+		$seen = array();
+		foreach ( array( 'ticket', 'gadget' ) as $resource_name ) {
+			$this->register_sync(
+				$resource_name,
+				'test-ext',
+				static function ( array $saved ) use ( &$seen, $resource_name ) {
+					$seen[ $resource_name ] = array_column( $saved, 'id' );
+					return null;
+				}
+			);
+		}
+		AbilitiesLoader::init_extensions();
+		$ability = new class(
+			'test-ext/ticket-delete',
+			array(
+				'label'               => 'Delete ticket',
+				'description'         => 'Deletes a ticket and saves a gadget with the same ID.',
+				'category'            => 'woocommerce',
+				'output_schema'       => array( 'type' => 'object' ),
+				'permission_callback' => '__return_true',
+			)
+		) extends ActionableAbility {
+			/**
+			 * The ticket resource.
+			 *
+			 * @return string
+			 */
+			public function get_resource(): string {
+				return 'ticket';
+			}
+
+			/**
+			 * Load the ticket.
+			 *
+			 * @param array $input Ability input.
+			 * @return object
+			 */
+			protected function load( array $input ) {
+				return (object) array( 'id' => 7 );
+			}
+
+			/**
+			 * Return a gadget with the ID of the ticket.
+			 *
+			 * @param object $subject Ticket.
+			 * @param array  $input   Ability input.
+			 * @return array
+			 */
+			protected function change( $subject, array $input ) {
+				return array( array( (object) array( 'id' => 7 ), array(), 'gadget' ) );
+			}
+
+			/**
+			 * Save nothing.
+			 *
+			 * @param object $subject Ticket.
+			 * @return null
+			 */
+			protected function save( $subject ) {
+				return null;
+			}
+
+			/**
+			 * The deleted ticket.
+			 *
+			 * @return object[]
+			 */
+			protected function get_deleted_objects(): array {
+				return array( (object) array( 'id' => 7 ) );
+			}
+
+			/**
+			 * An empty response.
+			 *
+			 * @param object $subject Ticket.
+			 * @return array
+			 */
+			protected function prepare_response( $subject ) {
+				return array();
+			}
+		};
+
+		$ability->execute_change( array() );
+
+		$this->assertSame(
+			array(
+				'ticket' => array(),
+				'gadget' => array( 7 ),
+			),
+			$seen
+		);
+	}
+
 	/**
 	 * @testdox Should give a sync the parent that a variation update saves.
 	 */