[wp-trac] [WordPress Trac] #41457: WP_REST_Comments_Controller::check_read_post_permission() counts an uncountable value

WordPress Trac noreply at wordpress.org
Fri Jul 28 13:49:30 UTC 2017


#41457: WP_REST_Comments_Controller::check_read_post_permission() counts an
uncountable value
------------------------------------------+-----------------------
 Reporter:  johnbillion                   |       Owner:
     Type:  defect (bug)                  |      Status:  new
 Priority:  normal                        |   Milestone:  4.9
Component:  Comments                      |     Version:  4.7
 Severity:  normal                        |  Resolution:
 Keywords:  needs-patch needs-unit-tests  |     Focuses:  rest-api
------------------------------------------+-----------------------

Comment (by ayeshrajans):

 The warnings thrown from this particular `count()` call is `count():
 Parameter must be an array or an object that implements Countable`.
 Build log: https://travis-ci.org/WordPress/wordpress-
 develop/jobs/258395218 (find for `/home/travis/build/WordPress/wordpress-
 develop/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-
 controller.php:1514`). There are 30 instances of it.

 The patch above fixes those issues.
 Build log: https://travis-ci.org/Ayesh/wordpress-develop/jobs/258563149
 The build still fails because of the other errors, but all the 39 errors
 reported for this `count()` call are gone.
 As for the unit tests,
 `\WP_Test_REST_Comments_Controller::test_get_items_with_password_with_multiple_post`
 covers a case of multiple post ID REST call with a password. I'm not sure
 if we can write a more meaningful test, but I think we can check if
 Boolean, arrays with wrong-password post IDs, and other misc variable
 types work (it should throw a 401 or 400 error).

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41457#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list