Changeset 62648 for trunk/src/wp-includes/class-wp-post.php
- Timestamp:
- 07/06/2026 08:53:46 PM (30 hours ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/class-wp-post.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-post.php
r62437 r62648 219 219 * @since 3.5.0 220 220 * @var string 221 * @phpstan-var 'raw'|'edit'|'db'|'display'|'attribute'|'js' 221 222 */ 222 223 public $filter; … … 231 232 * @param int $post_id Post ID. 232 233 * @return WP_Post|false Post object, false otherwise. 234 * 235 * @phpstan-param int|numeric-string $post_id 233 236 */ 234 237 public static function get_instance( $post_id ) { … … 242 245 $_post = wp_cache_get( $post_id, 'posts' ); 243 246 244 if ( ! $_post) {247 if ( ! ( $_post instanceof stdClass ) && ! ( $_post instanceof WP_Post ) ) { 245 248 $_post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post_id ) ); 246 249 … … 250 253 251 254 $_post = sanitize_post( $_post, 'raw' ); 252 wp_cache_add( $_post->ID, $_post, 'posts' );255 wp_cache_add( (int) $_post->ID, $_post, 'posts' ); 253 256 } elseif ( empty( $_post->filter ) || 'raw' !== $_post->filter ) { 254 257 $_post = sanitize_post( $_post, 'raw' ); … … 317 320 } 318 321 319 if ( empty( $terms ) ) {322 if ( empty( $terms ) || $terms instanceof WP_Error ) { 320 323 return array(); 321 324 } … … 329 332 } 330 333 331 if ( empty( $terms ) ) {334 if ( empty( $terms ) || $terms instanceof WP_Error ) { 332 335 return array(); 333 336 } … … 351 354 352 355 /** 353 * {@Missing Summary} 356 * Applies the provided context filter for the current post. 357 * 358 * If the requested filter was already applied, then it returns without any changes. 359 * 360 * If the 'raw' filter is supplied, then a new instance of the post is obtained and this method _may_ return false 361 * in case the underlying post was deleted. 354 362 * 355 363 * @since 3.5.0 356 364 * 357 365 * @param string $filter Filter. 358 * @return WP_Post 366 * @return WP_Post|false 367 * 368 * @phpstan-param 'raw'|'edit'|'db'|'display'|'attribute'|'js' $filter 369 * @phpstan-return ( 370 * $filter is 'raw' ? WP_Post|false : WP_Post 371 * ) 359 372 */ 360 373 public function filter( $filter ) { … … 375 388 * @since 3.5.0 376 389 * 377 * @return array Object as array.390 * @return array<string, mixed> Object as array. 378 391 */ 379 392 public function to_array() { 393 /** @var array<string, mixed> $post */ 380 394 $post = get_object_vars( $this ); 381 395
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)