Skip to content

Commit 1470b56

Browse files
shekharnwaghshekharnwaghchriszarate
authored
RTC: Fix undefined array_first() call in sync storage (WordPress#75869)
Co-authored-by: shekharnwagh <shekharnwagh@git.wordpress.org> Co-authored-by: chriszarate <czarate@git.wordpress.org>
1 parent 08e61bc commit 1470b56

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

backport-changelog/7.0/10894.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ https://github.com/WordPress/wordpress-develop/pull/10894
66
* https://github.com/WordPress/gutenberg/pull/75708
77
* https://github.com/WordPress/gutenberg/pull/75711
88
* https://github.com/WordPress/gutenberg/pull/75746
9+
* https://github.com/WordPress/gutenberg/pull/75869

lib/compat/wordpress-7.0/class-wp-sync-post-meta-storage.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,13 @@ private function get_storage_post_id( string $room ): ?int {
213213
)
214214
);
215215

216-
$post_id = array_first( $posts );
216+
/*
217+
* array_first() is a PHP 8.5 function. WordPress added
218+
* a polyfill in WP 6.9 (see https://core.trac.wordpress.org/ticket/63853).
219+
* Since Gutenberg must support the two most recent WordPress
220+
* versions (currently 6.8+), we cannot rely on it here.
221+
*/
222+
$post_id = $posts[0] ?? null;
217223
if ( is_int( $post_id ) ) {
218224
self::$storage_post_ids[ $room_hash ] = $post_id;
219225
return $post_id;

0 commit comments

Comments
 (0)