[wp-trac] [WordPress Trac] #39242: Add caching to count_user_posts()

WordPress Trac noreply at wordpress.org
Tue Jul 19 15:52:44 UTC 2022


#39242: Add caching to count_user_posts()
-------------------------------------------------+-------------------------
 Reporter:  johnjamesjacoby                      |       Owner:  whyisjake
     Type:  enhancement                          |      Status:  accepted
 Priority:  normal                               |   Milestone:  Future
                                                 |  Release
Component:  Users                                |     Version:  3.0
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch dev-feedback needs-unit-   |     Focuses:  rest-api,
  tests needs-testing                            |  performance
-------------------------------------------------+-------------------------

Comment (by johnregan3):

 Modified the code so that if an array is passed as the $post_type param,
 the cache key name will be generated correctly.

 I also composed initial Unit Tests.

 However, the tests currently come back as such:

 {{{
 There were 3 failures:

 1)
 Tests_Media::test_wp_get_attachment_image_should_use_wp_get_attachment_metadata
 Failed asserting that two strings are identical.
 --- Expected
 +++ Actual
 @@ @@
 -'<img width="999" height="999" src="http://example.org/wp-
 content/uploads/2022/07/test-image-testsize-999x999.jpg" class
 ="attachment-testsize size-testsize" alt="" decoding="async"
 loading="lazy" srcset="http://example.org/wp-content/uploads/2022/07/test-
 image-testsize-999x999.jpg 999w, http://example.org/wp-
 content/uploads/2022/07/test-image-large-150x150.jpg 150w" sizes="(max-
 width: 999px) 100vw, 999px" />'
 +'<img width="999" height="999" src="http://example.org/wp-
 content/uploads/2022/07/test-image-testsize-999x999.jpg" class
 ="attachment-testsize size-testsize" alt="" decoding="async"
 loading="lazy" srcset="http://example.org/wp-content/uploads/2022/07/test-
 image-testsize-999x999.jpg 999w, http://example.org/wp-
 content/uploads/2022/07/test-image-large-1-150x150.jpg 150w" sizes="(max-
 width: 999px) 100vw, 999px" />'

 /var/www/tests/phpunit/tests/media.php:2646

 2) WP_Test_REST_Users_Controller::test_get_item_published_author_pages
 Failed asserting that 401 is identical to 200.

 /var/www/tests/phpunit/tests/rest-api/rest-users-controller.php:3128
 /var/www/tests/phpunit/tests/rest-api/rest-users-controller.php:1152

 3) Tests_User::test_count_many_users_posts
 Failed asserting that '1' matches expected 2.

 /var/www/tests/phpunit/tests/user.php:573
 }}}

 I'll continue tracking down these issues, but feel free to jump in and add
 feedback or your own ideas.

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


More information about the wp-trac mailing list