Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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( null );
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( null );

return array(
'contents' => $contents,
Expand Down
Loading