Skip to content

Commit b9b1e6c

Browse files
committed
Use json encoded data to avoid serialization issues.
1 parent dd4c7f1 commit b9b1e6c

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/wp-includes/collaboration/class-wp-sync-post-meta-storage.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ public function add_update( string $room, $update ): bool {
7979
return false;
8080
}
8181

82-
$meta_id = add_post_meta( $post_id, self::SYNC_UPDATE_META_KEY, $update, false );
82+
$update = wp_json_encode( $update );
83+
$meta_id = add_post_meta( $post_id, wp_slash( self::SYNC_UPDATE_META_KEY ), wp_slash( $update ), false );
8384

8485
return (bool) $meta_id;
8586
}
@@ -266,7 +267,7 @@ public function get_updates_after_cursor( string $room, int $cursor ): array {
266267

267268
$updates = array();
268269
foreach ( $rows as $row ) {
269-
$updates[] = maybe_unserialize( $row->meta_value );
270+
$updates[] = json_decode( $row->meta_value, true );
270271
}
271272

272273
return $updates;

tests/phpunit/tests/rest-api/rest-sync-server.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ private function inject_update(): void {
670670
add_post_meta(
671671
$this->storage_post_id,
672672
WP_Sync_Post_Meta_Storage::SYNC_UPDATE_META_KEY,
673-
$this->injected_update,
673+
wp_slash( wp_json_encode( $this->injected_update ) ),
674674
false
675675
);
676676
}

0 commit comments

Comments
 (0)