Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion includes/Handlers/Prompts/PromptsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,14 @@ public function get_prompt( array $params, int $request_id = 0 ): array {
*
* @var \WP_Ability $ability
*/
$ability = $prompt->get_ability();
$ability = $prompt->get_ability();

// If ability has no input schema and arguments is empty, pass null
// This is required by WP_Ability::validate_input() which expects null when no schema
$ability_input_schema = $ability->get_input_schema();
if ( empty( $ability_input_schema ) && empty( $arguments ) ) {
$arguments = null;
}
$has_permission = $ability->check_permissions( $arguments );
if ( true !== $has_permission ) {
// Extract detailed error message and code if WP_Error was returned
Expand Down
4 changes: 2 additions & 2 deletions includes/Handlers/Resources/ResourcesHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function read_resource( array $params, int $request_id = 0 ): array {
$ability = $resource->get_ability();

try {
$has_permission = $ability->check_permissions( $request_params );
$has_permission = $ability->check_permissions();
if ( true !== $has_permission ) {
// Extract detailed error message and code if WP_Error was returned
$error_message = 'Access denied for resource: ' . $resource->get_name();
Expand All @@ -128,7 +128,7 @@ public function read_resource( array $params, int $request_id = 0 ): array {
);
}

$contents = $ability->execute( $request_params );
$contents = $ability->execute();

// Handle WP_Error objects that weren't converted by the ability.
if ( is_wp_error( $contents ) ) {
Expand Down
5 changes: 2 additions & 3 deletions tests/Fixtures/DummyAbility.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,10 @@ public static function register_abilities(): void {
'label' => 'Resource',
'description' => 'A text resource',
'category' => 'test',
'input_schema' => array( 'type' => 'object' ),
'execute_callback' => static function ( array $input ) {
'execute_callback' => static function () {
return 'content';
},
'permission_callback' => static function ( array $input ) {
'permission_callback' => static function () {
return true;
},
'meta' => array(
Expand Down
Loading