| @@ -74,16 +74,8 @@ | ||
| 74 | 74 | public static function compute( array $data ): string { |
| 75 | 75 | return 'sha256:' . hash( 'sha256', (string) wp_json_encode( self::canonicalize( $data ) ) ); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - public static function pre_taxonomy_sort_revision( array $data ): string { | |
| 79 | - $excluded = apply_filters( 'woocommerce_pos_sync_revision_excluded_fields', array( 'related_ids', '_links', 'links' ) ); | |
| 80 | - foreach ( (array) $excluded as $field ) { | |
| 81 | - unset( $data[ $field ] ); | |
| 82 | - } | |
| 83 | - return 'sha256:' . hash( 'sha256', (string) wp_json_encode( self::sort_keys_recursive( $data, false ) ) ); | |
| 84 | - } | |
| 85 | - | |
| 86 | 78 | public static function canonicalize( array $data ): array { |
| 87 | 79 | $excluded = apply_filters( 'woocommerce_pos_sync_revision_excluded_fields', array( 'related_ids', '_links', 'links' ) ); |
| 88 | 80 | foreach ( (array) $excluded as $field ) { |
| 89 | 81 | unset( $data[ $field ] ); |
| @@ -90,15 +82,15 @@ | ||
| 90 | 82 | } |
| 91 | 83 | return self::sort_keys_recursive( $data ); |
| 92 | 84 | } |
| 93 | 85 | |
| 94 | - private static function sort_keys_recursive( array $data, bool $sort_taxonomy_terms = true ): array { | |
| 86 | + private static function sort_keys_recursive( array $data ): array { | |
| 95 | 87 | ksort( $data ); |
| 96 | 88 | foreach ( $data as $key => $value ) { |
| 97 | 89 | if ( is_array( $value ) ) { |
| 98 | - $data[ $key ] = self::sort_keys_recursive( $value, $sort_taxonomy_terms ); | |
| 90 | + $data[ $key ] = self::sort_keys_recursive( $value ); | |
| 99 | 91 | // Taxonomy collections are sets; other lists retain semantic order. |
| 100 | - if ( ! $sort_taxonomy_terms || ! in_array( $key, array( 'categories', 'tags', 'brands' ), true ) || count( $value ) < 2 || array_keys( $value ) !== range( 0, count( $value ) - 1 ) ) { | |
| 92 | + if ( ! in_array( $key, array( 'categories', 'tags', 'brands' ), true ) || count( $value ) < 2 || array_keys( $value ) !== range( 0, count( $value ) - 1 ) ) { | |
| 101 | 93 | continue; |
| 102 | 94 | } |
| 103 | 95 | foreach ( $value as $term ) { |
| 104 | 96 | $id = is_array( $term ) ? ( $term['id'] ?? null ) : ( is_object( $term ) ? ( $term->id ?? null ) : null ); |