Merged
Conversation
- Cache get_feeds() on User object to avoid duplicate term queries (called 3x in author-header.php) - Reuse known author in have_posts() loop instead of per-post wp_get_object_terms() lookups via get_post_author() - Add static cache to get_actor_metadata_from_attributed_to() to avoid repeated JSON parsing for the same actor across posts - Add lazy-loading to User/Subscription get_post_count_by_post_format() matching the pattern in the global version (return placeholders instead of running expensive queries synchronously)
Root cause: Remote_Actors::get_avatar_url() triggers the activitypub_remote_media_url filter which synchronously downloads avatar images via HTTP when not locally cached (2-3.5s per post). - Rewrite author_avatar_url filter to read icon directly from actor JSON (already in memory) instead of calling get_avatar_url() - Replace get_avatar_url() in get_actor_metadata_from_attributed_to() with get_icon() + object_to_uri() to avoid the same HTTP trap - Cache User/Subscription objects in get_post_author() to avoid recreating them for every post from the same author
Use the cached get_actor_metadata_from_attributed_to() which already calls get_actor() + get_icon() instead of duplicating the logic.
Removed the force fetching parameter from the get_post_count_by_post_format method and its related logic.
Removed the force fetching parameter from get_post_count_by_post_format method.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
get_feeds()on User object to avoid duplicate term queries (called 3x in author-header.php)have_posts()loop instead of per-postwp_get_object_terms()lookups viaget_post_author()get_actor_metadata_from_attributed_to()to avoid repeated JSON parsing for the same actor across postsget_post_count_by_post_format()matching the pattern in the global version (return...placeholders instead of running expensive COUNT queries synchronously)Context
The
ccda819commit added thefriends_author_avatar_urlfilter toheader.php, which triggers ActivityPub actor metadata lookups for every post in the loop (previously only status-format posts). Combined with existing N+1 patterns, this made author pages noticeably slow.Test plan
...initially and load correctly on subsequent visits (after transient is set)Test in WordPress Playground