Honour publish options with `AssetManager::$linkAssets` and add the `files` publish option #21150
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 648 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.387
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #21150"
general
weight: 0.35
terabytesoftw
| Q | A
| ------------- | ---
| Is bugfix? | ✔️
| New feature? | ✔️
| Breaks BC? | ❌ (behaviour change for
linkAssets+ filters, seeUPGRADE.md)| Fixed issues | -
Problem
With
AssetManager::$linkAssets = true,publishDirectory()symlinks the wholesourcePathand silently ignoresthese publish options:
only,except,caseSensitivebeforeCopy,afterCopy(fromAssetBundle::$publishOptionsand fromAssetManager::$beforeCopy/$afterCopy)forceCopyNo error and no warning are reported, and the docs don't mention it.
Security impact
publishOptionsis the documented way to publish only part of a package, and packages often ship server code nextto their client files. For example:
|
linkAssets| published || ------------ | --------------------------------------------------- |
|
false|assets/1a2b3c/{css,js,img,sounds}||
true|assets/1a2b3c -> vendor/studio-42/elfinder(all of it) |With
linkAssetsenabled,/assets/1a2b3c/php/*.phpbecomes reachable. A typical front controller config (.htaccess,nginx
try_files) serves existing files directly, so those PHP files can be executed outside the application'saccess control. The same applies to other filters:
linkAssetsis a global switch, often enabled only in some environments. Turning it on changes what every bundleexposes, far from the bundles that rely on the filters.
Solution
With
linkAssetsenabled:| publish options | result |
| ----------------------------------------------------------------------- | ------------------------------------------- |
| none | whole directory symlinked (unchanged) |
|
only/except/beforeCopy/afterCopy(bundle or manager) | tree recreated, one symlink per file that passes the filters (same files as when copying) || only
files(new) | each listed entry symlinked as a whole |New
filesoption, an alternative toonlyfor listing published entries explicitly:only(callbacks and the dotfile filter apply as usual).linkAssetsand no other filters,assets/1a2b3c/js -> vendor/.../js. Files added to a listed directory arepublished immediately.
only/except(InvalidConfigException). Entries are validated: relative, no..,existing, not overlapping.
Other details:
forceCopynow recreates the symlinks in the per-file andfilesmodes. It still has no effect when the wholedirectory is symlinked.
hashCallback, wherethe directory name survives the upgrade).
hash($src), sogetPublishedPath()/getPublishedUrl()keep working.Known limitation (same as copy mode): the directory name doesn't depend on the options, so a changed filter applies
after the published directory is removed or with
forceCopy. This is documented.Behaviour change: apps that use
linkAssetstogether with filters stop publishing files the filters exclude. TheCHANGELOG and
UPGRADE.mddescribe it.Summary by Sourcery
Honor asset publishing options when linking assets and add explicit file and directory selection for safer package publishing.
New Features:
filespublishing option for explicitly selecting files and directories to publish.Bug Fixes:
linkAssetsis enabled, preventing excluded files from being exposed.Enhancements:
forceCopyrefreshes and safe atomic replacement of published directories.Documentation:
filesoption, filtered symlink behavior, callback implications, and upgrade considerations.Tests:
filesvalidation, callbacks, force-copy behavior, and concurrent-safe publication.Chores:
linkAssetsconfigurations.