Skip to content

Commit cec47ab

Browse files
authored
Merge branch 'trunk' into collaboration/single-table
2 parents d549a14 + bccb9c1 commit cec47ab

12 files changed

Lines changed: 84 additions & 17 deletions

File tree

src/wp-admin/css/common.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3340,7 +3340,7 @@ img {
33403340
.postbox .handle-order-higher:focus,
33413341
.postbox .handle-order-lower:focus,
33423342
.postbox .handlediv:focus {
3343-
box-shadow: 0 0 0 var(--wp-admin-border-width-focus, 1.5px) var(--wp-admin-theme-color);
3343+
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus, 1.5px) var(--wp-admin-theme-color);
33443344
border-radius: 50%;
33453345
/* Only visible in Windows High Contrast mode */
33463346
outline: 2px solid transparent;

src/wp-admin/css/install.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ body {
1616
}
1717

1818
a {
19-
color: #2271b1;
19+
color: var(--wp-admin-theme-color);
2020
}
2121

2222
a:hover,
2323
a:active {
24-
color: #135e96;
24+
color: var(--wp-admin-theme-color-darker-20);
2525
}
2626

2727
a:focus {
28-
color: #043959;
28+
color: var(--wp-admin-theme-color-darker-20);
2929
border-radius: 2px;
3030
box-shadow: 0 0 0 var(--wp-admin-border-width-focus, 1.5px) var(--wp-admin-theme-color, #3858e9);
3131
/* Only visible in Windows High Contrast mode */

src/wp-includes/abilities-api/class-wp-ability.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,15 +502,27 @@ public function validate_input( $input = null ) {
502502
*
503503
* @param callable $callback The callable to invoke.
504504
* @param mixed $input Optional. The input data for the ability. Default `null`.
505-
* @return mixed The result of the callable execution.
505+
* @return mixed The result of the callable execution, or a `WP_Error` if the callback threw.
506506
*/
507507
protected function invoke_callback( callable $callback, $input = null ) {
508508
$args = array();
509509
if ( ! empty( $this->get_input_schema() ) ) {
510510
$args[] = $input;
511511
}
512512

513-
return $callback( ...$args );
513+
try {
514+
return $callback( ...$args );
515+
} catch ( Throwable $e ) {
516+
return new WP_Error(
517+
'ability_callback_exception',
518+
sprintf(
519+
/* translators: 1: Ability name, 2: Exception message. */
520+
__( 'Ability "%1$s" callback threw an exception: %2$s' ),
521+
esc_html( $this->name ),
522+
esc_html( $e->getMessage() )
523+
)
524+
);
525+
}
514526
}
515527

516528
/**

src/wp-includes/ai-client.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,22 @@
1717
* @return bool Whether AI features are supported.
1818
*/
1919
function wp_supports_ai(): bool {
20-
$is_enabled = defined( 'WP_AI_SUPPORT' ) ? WP_AI_SUPPORT : true;
20+
// Return early if AI is disabled by the current environment.
21+
if ( defined( 'WP_AI_SUPPORT' ) && ! WP_AI_SUPPORT ) {
22+
return false;
23+
}
2124

2225
/**
23-
* Filters whether the current request should use AI.
26+
* Filters whether the current request can use AI.
2427
*
2528
* This allows plugins and 3rd-party code to disable AI features on a per-request basis, or to even override explicit
2629
* preferences defined by the site owner.
2730
*
2831
* @since 7.0.0
2932
*
30-
* @param bool $is_enabled Whether the current request should use AI. Default to WP_AI_SUPPORT constant, or true if
31-
* the constant is not defined.
33+
* @param bool $is_enabled Whether AI is available. Default to true.
3234
*/
33-
return (bool) apply_filters( 'wp_supports_ai', $is_enabled );
35+
return (bool) apply_filters( 'wp_supports_ai', true );
3436
}
3537

3638
/**

src/wp-includes/functions.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3975,14 +3975,14 @@ function _default_wp_die_handler( $message, $title = '', $args = array() ) {
39753975
font-size: 14px ;
39763976
}
39773977
a {
3978-
color: #2271b1;
3978+
color: #3858e9;
39793979
}
39803980
a:hover,
39813981
a:active {
3982-
color: #135e96;
3982+
color: #183ad6;
39833983
}
39843984
a:focus {
3985-
color: #043959;
3985+
color: #183ad6;
39863986
box-shadow: 0 0 0 var(--wp-admin-border-width-focus, 1.5px) var(--wp-admin-theme-color, #3858e9);
39873987
outline: 2px solid transparent;
39883988
}

tests/phpunit/tests/abilities-api/wpAbility.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,54 @@ public function test_execute_no_input() {
497497
$this->assertSame( 42, $ability->execute() );
498498
}
499499

500+
/**
501+
* Tests that an exception thrown by the execute callback is converted to a WP_Error
502+
* instead of being propagated as an uncaught throwable.
503+
*
504+
* @ticket 65058
505+
*/
506+
public function test_execute_catches_callback_exception() {
507+
$args = array_merge(
508+
self::$test_ability_properties,
509+
array(
510+
'execute_callback' => static function (): int {
511+
throw new RuntimeException( 'boom' );
512+
},
513+
)
514+
);
515+
516+
$ability = new WP_Ability( self::$test_ability_name, $args );
517+
$result = $ability->execute();
518+
519+
$this->assertWPError( $result, 'Ability::execute() should return WP_Error when the callback throws.' );
520+
$this->assertSame( 'ability_callback_exception', $result->get_error_code() );
521+
$this->assertStringContainsString( 'boom', $result->get_error_message() );
522+
}
523+
524+
/**
525+
* Tests that an exception thrown by the permission callback is converted to a WP_Error
526+
* instead of being propagated as an uncaught throwable.
527+
*
528+
* @ticket 65058
529+
*/
530+
public function test_check_permissions_catches_callback_exception() {
531+
$args = array_merge(
532+
self::$test_ability_properties,
533+
array(
534+
'permission_callback' => static function (): bool {
535+
throw new RuntimeException( 'permission exploded' );
536+
},
537+
)
538+
);
539+
540+
$ability = new WP_Ability( self::$test_ability_name, $args );
541+
$result = $ability->check_permissions();
542+
543+
$this->assertWPError( $result, 'Ability::check_permissions() should return WP_Error when the callback throws.' );
544+
$this->assertSame( 'ability_callback_exception', $result->get_error_code() );
545+
$this->assertStringContainsString( 'permission exploded', $result->get_error_message() );
546+
}
547+
500548
/**
501549
* Tests that before_execute_ability action is fired with correct parameters.
502550
*

tests/phpunit/tests/admin/includesTheme.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ public function test_get_theme_featured_list_api() {
241241
*
242242
* Differences in the structure can also trigger failure by causing PHP notices/warnings.
243243
*
244-
* @group external-http
245244
* @ticket 28121
246245
*/
247246
public function test_get_theme_featured_list_hardcoded() {

tests/phpunit/tests/multisite/getBlogDetails.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* @group ms-required
66
* @group ms-site
77
* @group multisite
8+
*
9+
* @covers ::get_blog_details
810
*/
911
class Tests_Multisite_GetBlogDetails extends WP_UnitTestCase {
1012

tests/phpunit/tests/multisite/updateBlogDetails.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* @group ms-required
55
* @group ms-site
66
* @group multisite
7+
*
8+
* @covers ::update_blog_details
79
*/
810
class Tests_Multisite_UpdateBlogDetails extends WP_UnitTestCase {
911

tests/phpunit/tests/multisite/updateBlogStatus.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* @group ms-required
55
* @group ms-site
66
* @group multisite
7+
*
8+
* @covers ::update_blog_status
79
*/
810
class Tests_Multisite_UpdateBlogStatus extends WP_UnitTestCase {
911

0 commit comments

Comments
 (0)