Skip to content

Commit 74f9260

Browse files
committed
Miscellaneous type fixes
1 parent 90749a1 commit 74f9260

2 files changed

Lines changed: 10 additions & 13 deletions

File tree

src/wp-includes/collaboration/class-wp-http-polling-sync-server.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,7 @@ public function check_permissions( WP_REST_Request $request ) {
190190

191191
$entity_kind = $type_parts[0];
192192
$entity_name = $object_parts[0];
193-
$object_id = null;
194-
195-
if ( isset( $object_parts[1] ) ) {
196-
$object_id = $object_parts[1];
197-
}
193+
$object_id = $object_parts[1] ?? null;
198194

199195
if ( ! $this->can_user_sync_entity_type( $entity_kind, $entity_name, $object_id ) ) {
200196
return new WP_Error(
@@ -428,7 +424,7 @@ private function get_time_marker(): int {
428424
* @param int $client_id Client identifier.
429425
* @param int $cursor Return updates after this cursor.
430426
* @param bool $is_compactor True if this client is nominated to perform compaction.
431-
* @return array Response data for this room.
427+
* @return array<string, mixed> Response data for this room.
432428
*/
433429
private function get_updates_after( string $room, int $client_id, int $cursor, bool $is_compactor ): array {
434430
$end_cursor = $this->get_time_marker() - 100; // Small buffer to ensure consistency.

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class WP_Sync_Post_Meta_Storage implements WP_Sync_Storage {
3030
* @since 6.8.0
3131
* @var int|null
3232
*/
33-
private static $storage_post_id = null;
33+
private static ?int $storage_post_id = null;
3434

3535
/**
3636
* Initializer.
@@ -152,9 +152,9 @@ private function get_room_meta_key( string $room ): string {
152152
*
153153
* @since 6.8.0
154154
*
155-
* @return int Post ID.
155+
* @return int|null Post ID.
156156
*/
157-
private function get_storage_post_id(): int {
157+
private function get_storage_post_id(): ?int {
158158
if ( is_int( self::$storage_post_id ) ) {
159159
return self::$storage_post_id;
160160
}
@@ -165,13 +165,14 @@ private function get_storage_post_id(): int {
165165
'post_type' => self::POST_TYPE,
166166
'posts_per_page' => 1,
167167
'post_status' => 'publish',
168-
'orderby' => 'ID',
168+
'fields' => 'ids',
169169
'order' => 'ASC',
170170
)
171171
);
172172

173-
if ( ! empty( $posts ) ) {
174-
self::$storage_post_id = $posts[0]->ID;
173+
$post_id = array_first( $posts );
174+
if ( is_int( $post_id ) ) {
175+
self::$storage_post_id = $post_id;
175176
return self::$storage_post_id;
176177
}
177178

@@ -184,7 +185,7 @@ private function get_storage_post_id(): int {
184185
)
185186
);
186187

187-
if ( ! is_wp_error( $post_id ) ) {
188+
if ( is_int( $post_id ) ) {
188189
self::$storage_post_id = $post_id;
189190
}
190191

0 commit comments

Comments
 (0)