Skip to content

Settings Get: Honor a comma-separated fields filter - #1161

Closed
maheshbohara wants to merge 4 commits into
WordPress:developfrom
maheshbohara:fix/1160-settings-get-csv-fields
Closed

maheshbohara wants to merge 4 commits into
WordPress:developfrom
maheshbohara:fix/1160-settings-get-csv-fields

Conversation

@maheshbohara

@maheshbohara maheshbohara commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What?

Closes #1160

Makes core/settings-get honor a comma-separated fields filter when the ability is executed directly.

Why?

The input schema declares fields as an array of strings, and schema validation accepts a comma-separated string for an array. execute_get_settings() only read an array, so "blogname,siteurl" passed validation, was dropped without an error, and every exposed setting was returned. Details and commands are in #1160.

The REST route is not affected, because the REST layer turns the string into an array before the ability runs. The problem shows for in-process callers: PHP, WP-CLI, or anything that calls execute() itself.

How?

  • execute_get_settings() reads fields with wp_parse_list() and keeps the string items, the same way core/content-query reads its list inputs (parse_list_input() in Content.php).
  • A value that is neither a string nor an array is still treated as "no filter".
  • One integration test for a comma-separated fields value. It fails on develop.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus
Used for: Investigation, implementation, tests, manual testing, and PR wording. I reviewed the changes and the test results, and I take responsibility for the contribution.

Testing Instructions

  1. Enable the Custom Abilities experiment under Settings > AI, which registers core/settings-get.
  2. Run:
    wp eval 'wp_set_current_user( 1 ); echo count( wp_get_ability( "core/settings-get" )->execute( array( "fields" => "blogname,siteurl" ) ) );'
    
    It prints 2. On develop it prints the number of all exposed settings (19 on my site).
  3. The array form array( "fields" => array( "blogname", "siteurl" ) ) still prints 2, and an empty input still returns every setting.

Results on my site (WordPress 7.1.3, wp-env, PHP 8.3) with this branch:

csv string:       2 (blogname, siteurl)
csv with spaces:  2 (blogname, siteurl)
array:            2 (blogname, siteurl)
no filter:        19
group + csv:      1 (posts_per_page)

Automated:

  • npm run test:php passes (1903 tests), including the new test.
  • composer lint and PHPStan pass.
  • No JS changed, so I did not run the e2e suite locally.

Changelog Entry

Fixed - Settings Get: a comma-separated fields filter is honored when the ability is executed directly.

Open WordPress Playground Preview

Schema validation accepts a comma-separated string for the `fields` list, but execute_get_settings() only read an array. A string filter was dropped without an error and every exposed setting was returned when the ability was executed directly.

The filter is now read with wp_parse_list(), as core/content-query reads its list inputs.

See WordPress#1160.
@maheshbohara
maheshbohara requested a review from a team October 12, 2026 06:07
@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: maheshbohara <maheshbohara@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@codecov

codecov Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.18%. Comparing base (26322c3) to head (4df392d).

Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #1161   +/-   ##
==========================================
  Coverage      82.17%   82.18%           
- Complexity      3399     3400    +1     
==========================================
  Files            136      136           
  Lines          13187    13189    +2     
==========================================
+ Hits           10837    10839    +2     
  Misses          2350     2350           
Flag Coverage Δ
unit 82.18% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@maheshbohara

Copy link
Copy Markdown
Contributor Author

@dkotter removed the comment in 2a0c614.

The failing checks are the "WP trunk" jobs only, on three tests in Show_In_AbilitiesTest that this PR doesn't touch. Other open PRs have been failing the same way since Oct 12, so it looks like a WordPress trunk change rather than this branch.

@maheshbohara
maheshbohara requested a review from dkotter October 13, 2026 06:13
@jeffpaul jeffpaul added this to the 1.5.0 milestone Oct 14, 2026
@jeffpaul jeffpaul mentioned this pull request Oct 28, 2026
31 of 46 tasks
@gziolo

gziolo commented Oct 29, 2026

Copy link
Copy Markdown
Member

@jorgefilipecosta, where did we land at supporting comma-separated fields in WP core? I have an impression it's supported across all core abilties. If not, let's make sure to fix it with this patch and sync into WP core.

@gziolo

gziolo commented Oct 29, 2026

Copy link
Copy Markdown
Member

If I follow the code correctly, it's been patched in both WP core and AI plugin:

$input = rest_sanitize_object( $input );
$group = isset( $input['group'] ) && is_string( $input['group'] ) ? $input['group'] : '';
$fields = rest_sanitize_array( $input['fields'] ?? array() );

@gziolo

gziolo commented Oct 29, 2026

Copy link
Copy Markdown
Member

I confirmed that it had been superseded by #1206. We also want to go one step further and coerce the input on the Abilties API level to mirror how REST API does it with WordPress/wordpress-develop#14882.

@gziolo gziolo closed this Oct 29, 2026
@gziolo

gziolo commented Oct 29, 2026

Copy link
Copy Markdown
Member

@maheshbohara, thank you for the report and the fix proposed.

@jeffpaul jeffpaul removed this from the 1.5.0 milestone Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Settings Get: a comma-separated fields filter is ignored when the ability is executed directly

4 participants