Skip to content
This repository was archived by the owner on Nov 21, 2025. It is now read-only.
This repository was archived by the owner on Nov 21, 2025. It is now read-only.

WP_Feature::get_input_schema() method throws a "Schema exceeds maximum allowed properties (0)" #81

@tolecar

Description

@tolecar

I'm using prebuilt release zip wp-feature-api.zip v0.1.6, and I was able to iterate and call features, but when trying to get it's input schema (or json_encode feature), it throws an exception (this one was while trying to get inputs schema from "Query posts" feature):

Schema exceeds maximum allowed properties (0) in C:\xampp\htdocs\wp-astro\wp-content\plugins\wp-feature-api\includes\class-wp-feature-schema-adapter.php:424
Stack trace:
#0 C:\xampp\htdocs\wp-astro\wp-content\plugins\wp-feature-api\includes\class-wp-feature-schema-adapter.php(211): WP_Feature_Schema_Adapter->rule_max_properties('max_properties', Array)
#1 C:\xampp\htdocs\wp-astro\wp-content\plugins\wp-feature-api\includes\class-wp-feature.php(340): WP_Feature_Schema_Adapter->transform()
#2 C:\xampp\htdocs\wp-astro\wp-content\plugins\my-test\my-test.php(46): WP_Feature->get_input_schema()
#3 C:\xampp\htdocs\wp-astro\wp-includes\class-wp-hook.php(324): {closure}('')
#4 C:\xampp\htdocs\wp-astro\wp-includes\class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#5 C:\xampp\htdocs\wp-astro\wp-includes\plugin.php(517): WP_Hook->do_action(Array)
#6 C:\xampp\htdocs\wp-astro\wp-includes\general-template.php(3208): do_action('wp_footer')
#7 C:\xampp\htdocs\wp-astro\wp-content\themes\kadence\foo in C:\xampp\htdocs\wp-astro\wp-content\plugins\wp-feature-api\includes\class-wp-feature-schema-adapter.php on line 424

Environment info :

  • OS: Win 10
  • PHP: 7.4.33 (Xampp)
  • WP: 6.8.1

In addition, here is my test plugin

<?php
/*
Plugin Name: My Test Plugin
Description: A simple test plugin using the Feature API.
Version: 1.0
Author: tole
*/

// Register a new feature
add_action('init', function() {
    if (function_exists('register_feature')) {
        register_feature('my_custom_feature', [
            'title' => 'My Custom Feature',
            'description' => 'This is a custom feature for testing purposes.',
        ]);
    }
});

// Use the Feature API to find and execute a feature
add_action('wp', function() {
    if (function_exists('wp_find_feature')) {
        $feature = wp_find_feature('resource-myplugin/site-title');
        
        if ($feature) {
            $title = $feature->call();
            if (!is_wp_error($title)) {
                add_action('wp_footer', function() use ($title) {
                    echo '<p>Site Title Feature: ' . esc_html($title) . '</p>';
                });
            }
        }
    }
});

// Query multiple features
add_action('wp', function() {
    if (function_exists('wp_get_features')) {
        $features = wp_get_features(array(
            'type' => array('resource'),
            'categories' => array('core', 'post')
        ));
        
        foreach ($features as $feature) {
            add_action('wp_footer', function() use ($feature) {
                echo '<p>Feature Name: ' . esc_html($feature->get_name()) . '</p>';
				echo '<p>Feature Schema: ' . esc_html($feature->get_input_schema()) . '</p>';
            });
        }
    }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions