Repository navigation
Conversation
GenericLinkProvider only de-duplicates by object identity, so preloading the same asset twice (for example from two modules) put the same entry into the Link header twice. link() now skips a link whose URI, relations and attributes equal those of a link the provider already holds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 of Changes
GenericLinkProviderde-duplicates links by object identity only, andPreloadManager::link()creates a newLinkobject on every call. Preloading the same asset twice — typical when several modules or plugins add the same file — therefore puts the same entry into theLinkheader twice (preload('/a.css', ['as' => 'style'])twice → two identical entries), which grows the header needlessly towards server/proxy header-size limits.link()now skips a link whose URI, relations and attributes (compared strictly, independent of order) equal those of a link the provider already holds, including links that were already in a custom provider passed tosetLinkProvider(). Links that differ in any attribute value are still added.The finding also mentioned an optional cap on the number of links; that is not part of this PR, as there is no obvious limit that fits every server and the duplicates were the actual source of growth.
Testing Instructions
php vendor/bin/phpunit. New tests inPreloadManagerTest: identical links (also with attributes in a different order, and vialink()) are stored once; links differing in URI, relation or attributes are all kept; a link already in a custom provider is not added again. Before the changetestIdenticalLinkIsAddedOnceandtestLinkAlreadyInProviderIsNotAddedAgainfail.Documentation Changes Required
docs/classes/PreloadManager.md, section "Adding links": describes the de-duplication.The owner's docs PR #12 says in
docs/overview.md("Things to know before you build on this" → No deduplication and no limit.) that identical entries are produced twice; that paragraph needs adjusting (the missing limit still applies) when the second of the two PRs is merged.🤖 Generated with Claude Code