Skip to content

Conversation

@dlh01
Copy link

@dlh01 dlh01 commented Nov 13, 2025

@github-actions
Copy link

github-actions bot commented Nov 13, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props dlh, westonruter, mamaduka.

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

@Mamaduka
Copy link
Member

The fix makes sense.

The unit tests are failing with following error:

Parse error: syntax error, unexpected ')' in /var/www/tests/phpunit/tests/rest-api/rest-posts-controller.php on line 2795

@github-actions
Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@dlh01
Copy link
Author

dlh01 commented Nov 13, 2025

Fixed!


if ( rest_is_field_included( 'class_list', $fields ) ) {
$data['class_list'] = get_post_class( array(), $post->ID );
$data['class_list'] = array_values( get_post_class( array(), $post->ID ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to rather put this in get_post_class()? So the function can return with this change:

- return array_unique( $classes );
+ return array_values( array_unique( $classes ) );

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would work too. My reason for putting it here is that it's the API's responsibility to ensure that the value is, at this instant, a list, whether it comes from get_post_class() or somewhere else. But I don't feel too strongly about it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think get_post_class() makes more sense because it will just avoid this being a problem for some other caller.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alrighty, done in 2167441.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My reason for putting it here is that it's the API's responsibility to ensure that the value is, at this instant, a list

That was my thinking as well, but I don't have a strong opinion. Patching the get_post_class works as well.

pento pushed a commit that referenced this pull request Nov 19, 2025
This avoids the REST API erroneously returning an object in the `class_list` property returned by `WP_REST_Posts_Controller::prepare_item_for_response()`.

Developed in #10515

Props dlh, mamaduka, westonruter.
Fixes #64247.


git-svn-id: https://develop.svn.wordpress.org/trunk@61269 602fd350-edb4-49c9-b593-d223f7449a82
@github-actions
Copy link

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 61269
GitHub commit: 6e91abe

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions bot closed this Nov 19, 2025
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Nov 19, 2025
This avoids the REST API erroneously returning an object in the `class_list` property returned by `WP_REST_Posts_Controller::prepare_item_for_response()`.

Developed in WordPress/wordpress-develop#10515

Props dlh, mamaduka, westonruter.
Fixes #64247.

Built from https://develop.svn.wordpress.org/trunk@61269


git-svn-id: http://core.svn.wordpress.org/trunk@60581 1a063a9b-81f0-0310-95a4-ce76da25c4cd
github-actions bot pushed a commit to gilzow/wordpress-performance that referenced this pull request Nov 19, 2025
This avoids the REST API erroneously returning an object in the `class_list` property returned by `WP_REST_Posts_Controller::prepare_item_for_response()`.

Developed in WordPress/wordpress-develop#10515

Props dlh, mamaduka, westonruter.
Fixes #64247.

Built from https://develop.svn.wordpress.org/trunk@61269


git-svn-id: https://core.svn.wordpress.org/trunk@60581 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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.

3 participants