Changeset 65864
- Timestamp:
- 12/02/2026 06:53:35 PM (2 days ago)
- Location:
- trunk
- Files:
-
- 11 edited
-
src/wp-includes/abilities/class-wp-abilities-content.php (modified) (10 diffs)
-
src/wp-includes/abilities/class-wp-abilities-settings.php (modified) (3 diffs)
-
src/wp-includes/abilities/class-wp-abilities-users.php (modified) (2 diffs)
-
src/wp-includes/rest-api.php (modified) (3 diffs)
-
tests/phpstan/baselines-strict/argument.type.neon (modified) (1 diff)
-
tests/phpstan/baselines-strict/cast.double.neon (modified) (1 diff)
-
tests/phpstan/baselines-strict/cast.int.neon (modified) (1 diff)
-
tests/phpstan/baselines-strict/cast.string.neon (modified) (1 diff)
-
tests/phpstan/baselines-strict/foreach.nonIterable.neon (modified) (1 diff)
-
tests/phpstan/baselines-strict/offsetAccess.nonOffsetAccessible.neon (modified) (1 diff)
-
tests/phpstan/baselines-strict/return.type.neon (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/abilities/class-wp-abilities-content.php
r65824 r65864 304 304 */ 305 305 private function can_query_status( string $status, WP_Post_Type $post_type_object ): bool { 306 return in_array( $status, array( 'publish', 'private' ), true ) || is_post_status_viewable( $status ) || current_user_can( $post_type_object->cap->edit_posts ); 306 return in_array( $status, array( 'publish', 'private' ), true ) || is_post_status_viewable( $status ) || $this->current_user_can_for_post_type( $post_type_object, 'edit_posts' ); 307 } 308 309 /** 310 * Checks whether the current user has a capability of a post type, such as `edit_posts`. 311 * 312 * @since 7.3.0 313 * 314 * @param WP_Post_Type $post_type_object The post type. 315 * @param string $capability The name of the capability in the post type's `cap` object. 316 * @return bool Whether the current user has the capability. 317 */ 318 private function current_user_can_for_post_type( WP_Post_Type $post_type_object, string $capability ): bool { 319 $cap = $post_type_object->cap->$capability ?? null; 320 321 return is_string( $cap ) && current_user_can( $cap ); 307 322 } 308 323 … … 607 622 'posts_per_page' => $per_page, 608 623 'paged' => $page, 609 'perm' => current_user_can( $post_type_object->cap->read_private_posts) ? '' : 'readable',624 'perm' => $this->current_user_can_for_post_type( $post_type_object, 'read_private_posts' ) ? '' : 'readable', 610 625 'ignore_sticky_posts' => true, 611 626 'update_post_meta_cache' => $prime_post_caches, … … 647 662 * paging, the query returns every post on one page. 648 663 */ 649 $query_per_page = (int)$query->get( 'posts_per_page' );650 if ( $query->get( 'nopaging' ) || $query_per_page < 1 ) {664 $query_per_page = $query->get( 'posts_per_page' ); 665 if ( $query->get( 'nopaging' ) || ! is_int( $query_per_page ) || $query_per_page < 1 ) { 651 666 $total_pages = $total > 0 ? 1 : 0; 652 667 } else { … … 669 684 * with setup_postdata(), which reads the author. 670 685 */ 671 update_post_parent_caches( $query->posts ); 672 update_post_author_caches( $query->posts ); 686 $query_posts = array_filter( $query->posts ?? array(), static fn( $post ): bool => $post instanceof WP_Post ); 687 update_post_parent_caches( $query_posts ); 688 update_post_author_caches( $query_posts ); 673 689 674 690 $posts = array(); 675 foreach ( $query ->posts as $post ) {691 foreach ( $query_posts as $post ) { 676 692 /* 677 693 * Skip posts of other post types, which query filters can add, such as a … … 679 695 * is_main_query() check. 680 696 */ 681 if ( ! $post instanceof WP_Post ||$post_type !== $post->post_type ) {697 if ( $post_type !== $post->post_type ) { 682 698 continue; 683 699 } … … 969 985 * @since 7.2.0 970 986 * 971 * @return array<string, mixed> Post field definitions.987 * @return array<string, array<string, mixed>> Post field definitions. 972 988 */ 973 989 private function get_post_properties(): array { … … 1124 1140 $paths[] = $name; 1125 1141 1126 foreach ( array_keys( $schema['properties'] ?? array() ) as $sub_field ) {1142 foreach ( array_keys( (array) ( $schema['properties'] ?? array() ) ) as $sub_field ) { 1127 1143 $paths[] = "{$name}.{$sub_field}"; 1128 1144 } … … 1551 1567 * @since 7.2.0 1552 1568 * 1553 * @param bool$required Whether the post currently requires a password.1554 * @param WP_Post|null$post The post being checked, or null if no post is found.1569 * @param mixed $required Whether the post currently requires a password. 1570 * @param mixed $post The post being checked, or null if no post is found. 1555 1571 * @return bool Whether the post still requires a password. 1556 1572 */ … … 1693 1709 * @since 7.2.0 1694 1710 * 1711 * @global array<string, positive-int> $wp_actions Stores the number of times each action was triggered. 1712 * 1695 1713 * @param array<string, mixed> $previous_context The loop globals that get_post_context() returned. 1696 1714 * @param bool $the_post_fired Whether the `the_post` action had fired before the ability set up the post. 1697 1715 */ 1698 1716 private function restore_post_context( array $previous_context, bool $the_post_fired ): void { 1717 global $wp_actions; 1718 1699 1719 $previous_post = $previous_context['post'] ?? null; 1700 1720 … … 1736 1756 */ 1737 1757 if ( ! $previous_post instanceof WP_Post && ! $the_post_fired ) { 1738 unset( $ GLOBALS['wp_actions']['the_post'] );1758 unset( $wp_actions['the_post'] ); 1739 1759 } 1740 1760 } -
trunk/src/wp-includes/abilities/class-wp-abilities-settings.php
r65861 r65864 708 708 709 709 $option_name = (string) $option_name; 710 $exposed_name = empty( $show['name']) ? $option_name : (string) $show['name'];710 $exposed_name = ( empty( $show['name'] ) || ! is_scalar( $show['name'] ) ) ? $option_name : (string) $show['name']; 711 711 712 712 if ( isset( $settings[ $exposed_name ] ) ) { … … 753 753 * 754 754 * @param array<string, mixed> $args The setting registration arguments. 755 * @return array< string,mixed> The exposure arguments, with optional `name` and `schema` keys.755 * @return array<mixed> The exposure arguments, with optional `name` and `schema` keys. 756 756 */ 757 757 private function get_exposure_args( array $args ): array { … … 772 772 * 773 773 * @param array<string, mixed> $args The setting registration arguments. 774 * @param array< string, mixed>$show The exposure arguments, see get_exposure_args().774 * @param array<mixed> $show The exposure arguments, see get_exposure_args(). 775 775 * @return array<string, mixed> The value JSON Schema. 776 776 */ 777 private function get_value_schema( array $args, $show ): array {777 private function get_value_schema( array $args, array $show ): array { 778 778 $schema = array( 779 779 'type' => $args['type'], -
trunk/src/wp-includes/abilities/class-wp-abilities-users.php
r65726 r65864 439 439 * @since 7.2.0 440 440 * 441 * @return array<string, mixed> User field definitions.441 * @return array<string, array<string, mixed>> User field definitions. 442 442 */ 443 443 private function get_user_properties(): array { … … 558 558 $paths[] = $name; 559 559 560 foreach ( array_keys( $schema['properties'] ?? array() ) as $sub_field ) {560 foreach ( array_keys( (array) ( $schema['properties'] ?? array() ) ) as $sub_field ) { 561 561 $paths[] = "{$name}.{$sub_field}"; 562 562 } -
trunk/src/wp-includes/rest-api.php
r65794 r65864 1676 1676 * @since 4.7.0 1677 1677 * 1678 * @param bool|string$maybe_bool The value being evaluated.1678 * @param mixed $maybe_bool The value being evaluated. 1679 1679 * @return bool True if a boolean, otherwise false. 1680 * 1681 * @phpstan-assert-if-true bool|int|string $maybe_bool 1680 1682 */ 1681 1683 function rest_is_boolean( $maybe_bool ) { … … 1720 1722 * @param mixed $maybe_integer The value being evaluated. 1721 1723 * @return bool True if an integer, otherwise false. 1724 * 1725 * @phpstan-assert-if-true int|float|string $maybe_integer 1722 1726 */ 1723 1727 function rest_is_integer( $maybe_integer ): bool { … … 3312 3316 * @since 5.6.0 Support the "patternProperties" keyword. 3313 3317 * 3314 * @param array $schema The schema to modify.3315 * @return array The modified schema.3318 * @param array<string, mixed> $schema The schema to modify. 3319 * @return array<string, mixed> The modified schema. 3316 3320 */ 3317 3321 function rest_default_additional_properties_to_false( $schema ) { -
trunk/tests/phpstan/baselines-strict/argument.type.neon
r65861 r65864 30 30 path: ../../../src/wp-includes/abilities-api/class-wp-ability.php 31 31 - 32 message: '#^Parameter \#1 \$capability of function current_user_can expects string, mixed given\.$#'33 identifier: argument.type34 count: 235 path: ../../../src/wp-includes/abilities/class-wp-abilities-content.php36 -37 message: '#^Parameter \#1 \$input of function array_keys expects array, mixed given\.$#'38 identifier: argument.type39 count: 140 path: ../../../src/wp-includes/abilities/class-wp-abilities-content.php41 -42 message: '#^Parameter \#1 \$posts of function update_post_author_caches expects array\<WP_Post\>, array\<int\|WP_Post\>\|null given\.$#'43 identifier: argument.type44 count: 145 path: ../../../src/wp-includes/abilities/class-wp-abilities-content.php46 -47 message: '#^Parameter \#1 \$posts of function update_post_parent_caches expects array\<WP_Post\>, array\<int\|WP_Post\>\|null given\.$#'48 identifier: argument.type49 count: 150 path: ../../../src/wp-includes/abilities/class-wp-abilities-content.php51 -52 message: '#^Parameter \#1 \$required of method WP_Abilities_Content\:\:allow_password_content\(\) expects bool, mixed given\.$#'53 identifier: argument.type54 count: 155 path: ../../../src/wp-includes/abilities/class-wp-abilities-content.php56 -57 message: '#^Parameter \#2 \$post of method WP_Abilities_Content\:\:allow_password_content\(\) expects WP_Post\|null, mixed given\.$#'58 identifier: argument.type59 count: 160 path: ../../../src/wp-includes/abilities/class-wp-abilities-content.php61 -62 message: '#^Parameter \#1 \$input of function array_keys expects array, mixed given\.$#'63 identifier: argument.type64 count: 165 path: ../../../src/wp-includes/abilities/class-wp-abilities-users.php66 -67 message: '#^Parameter \#1 \$maybe_bool of function rest_is_boolean expects bool\|string, mixed given\.$#'68 identifier: argument.type69 count: 170 path: ../../../src/wp-includes/abilities/class-wp-abilities-users.php71 -72 message: '#^Parameter \#1 \$value of function rest_sanitize_boolean expects bool\|int\|string, mixed given\.$#'73 identifier: argument.type74 count: 175 path: ../../../src/wp-includes/abilities/class-wp-abilities-users.php76 -77 32 message: '#^Parameter \#1 \$name of method WordPress\\AiClientDependencies\\Psr\\Http\\Message\\MessageInterface\:\:withHeader\(\) expects string, mixed given\.$#' 78 33 identifier: argument.type -
trunk/tests/phpstan/baselines-strict/cast.double.neon
r65861 r65864 1 # PHPStan baseline for the `cast.double` errors in WordPress core.2 #3 # https://phpstan.org/error-identifiers/cast.double4 #5 # Each entry is scoped to a single file and carries an exact occurrence count,6 # so that a new instance is reported as a new error rather than being absorbed7 # silently. Fixing an occurrence therefore means decrementing or removing its8 # entry here as part of the same change.9 #10 # The goal is to empty this file and delete it.11 #12 # Generated by `composer phpstan:baselines`. Do not edit by hand. Regenerate with:13 #14 # composer phpstan:baselines -- --identifier=cast.double --config=phpstan-strict.neon.dist15 #16 # This reruns the analysis with the baselines in this directory suppressed, so17 # that their errors surface again, and rewrites only this file.18 19 parameters:20 ignoreErrors:21 -22 message: '#^Cannot cast mixed to float\.$#'23 identifier: cast.double24 count: 125 path: ../../../src/wp-includes/abilities/class-wp-abilities-content.php26 -27 message: '#^Cannot cast mixed to float\.$#'28 identifier: cast.double29 count: 130 path: ../../../src/wp-includes/abilities/class-wp-abilities-users.php -
trunk/tests/phpstan/baselines-strict/cast.int.neon
r65861 r65864 23 23 identifier: cast.int 24 24 count: 1 25 path: ../../../src/wp-includes/abilities/class-wp-abilities-content.php26 -27 message: '#^Cannot cast mixed to int\.$#'28 identifier: cast.int29 count: 130 25 path: ../../../src/wp-includes/class-wp-post.php -
trunk/tests/phpstan/baselines-strict/cast.string.neon
r65861 r65864 1 # PHPStan baseline for the `cast.string` errors in WordPress core.2 #3 # https://phpstan.org/error-identifiers/cast.string4 #5 # Each entry is scoped to a single file and carries an exact occurrence count,6 # so that a new instance is reported as a new error rather than being absorbed7 # silently. Fixing an occurrence therefore means decrementing or removing its8 # entry here as part of the same change.9 #10 # The goal is to empty this file and delete it.11 #12 # Generated by `composer phpstan:baselines`. Do not edit by hand. Regenerate with:13 #14 # composer phpstan:baselines -- --identifier=cast.string --config=phpstan-strict.neon.dist15 #16 # This reruns the analysis with the baselines in this directory suppressed, so17 # that their errors surface again, and rewrites only this file.18 19 parameters:20 ignoreErrors:21 -22 message: '#^Cannot cast mixed to string\.$#'23 identifier: cast.string24 count: 125 path: ../../../src/wp-includes/abilities/class-wp-abilities-settings.php -
trunk/tests/phpstan/baselines-strict/foreach.nonIterable.neon
r65861 r65864 1 # PHPStan baseline for the `foreach.nonIterable` errors in WordPress core.2 #3 # https://phpstan.org/error-identifiers/foreach.nonIterable4 #5 # Each entry is scoped to a single file and carries an exact occurrence count,6 # so that a new instance is reported as a new error rather than being absorbed7 # silently. Fixing an occurrence therefore means decrementing or removing its8 # entry here as part of the same change.9 #10 # The goal is to empty this file and delete it.11 #12 # Generated by `composer phpstan:baselines`. Do not edit by hand. Regenerate with:13 #14 # composer phpstan:baselines -- --identifier=foreach.nonIterable --config=phpstan-strict.neon.dist15 #16 # This reruns the analysis with the baselines in this directory suppressed, so17 # that their errors surface again, and rewrites only this file.18 19 parameters:20 ignoreErrors:21 -22 message: '#^Argument of an invalid type array\<int\|WP_Post\>\|null supplied for foreach, only iterables are supported\.$#'23 identifier: foreach.nonIterable24 count: 125 path: ../../../src/wp-includes/abilities/class-wp-abilities-content.php -
trunk/tests/phpstan/baselines-strict/offsetAccess.nonOffsetAccessible.neon
r65861 r65864 34 34 count: 1 35 35 path: ../../../src/wp-includes/abilities-api/class-wp-ability.php 36 -37 message: '#^Cannot access offset ''properties'' on mixed\.$#'38 identifier: offsetAccess.nonOffsetAccessible39 count: 140 path: ../../../src/wp-includes/abilities/class-wp-abilities-content.php41 -42 message: '#^Cannot access offset ''the_post'' on mixed\.$#'43 identifier: offsetAccess.nonOffsetAccessible44 count: 145 path: ../../../src/wp-includes/abilities/class-wp-abilities-content.php46 -47 message: '#^Cannot access offset ''properties'' on mixed\.$#'48 identifier: offsetAccess.nonOffsetAccessible49 count: 150 path: ../../../src/wp-includes/abilities/class-wp-abilities-users.php -
trunk/tests/phpstan/baselines-strict/return.type.neon
r65861 r65864 24 24 count: 1 25 25 path: ../../../src/wp-includes/abilities-api/class-wp-ability-categories-registry.php 26 -27 message: '#^Method WP_Abilities_Settings\:\:get_exposure_args\(\) should return array\<string, mixed\> but returns array\<mixed, mixed\>\.$#'28 identifier: return.type29 count: 130 path: ../../../src/wp-includes/abilities/class-wp-abilities-settings.php31 -32 message: '#^Method WP_Abilities_Settings\:\:get_exposure_args\(\) should return array\<string, mixed\> but returns array\<mixed\>\.$#'33 identifier: return.type34 count: 135 path: ../../../src/wp-includes/abilities/class-wp-abilities-settings.php36 -37 message: '#^Method WP_Abilities_Settings\:\:get_value_schema\(\) should return array\<string, mixed\> but returns array\.$#'38 identifier: return.type39 count: 140 path: ../../../src/wp-includes/abilities/class-wp-abilities-settings.php
Note:
See TracChangeset
for help on using the changeset viewer.