From ba15a1fdb3e22dbbedf40f40766fd60de933e13b Mon Sep 17 00:00:00 2001 From: Noel Date: Tue, 12 May 2026 10:24:44 +0800 Subject: [PATCH] Prevent creating duplicate files if assets and public stream is in same path. --- src/Plugin/Usage/FileUsage.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Plugin/Usage/FileUsage.php b/src/Plugin/Usage/FileUsage.php index 640407ab..a2831e63 100644 --- a/src/Plugin/Usage/FileUsage.php +++ b/src/Plugin/Usage/FileUsage.php @@ -110,6 +110,11 @@ public function __construct( $this->wrappers[$key]['instance'] = $stream_wrapper_manager->getViaUri($key . '://'); } + // Ensure 'public' is processed before 'asset' in convertBasepathsToUris + // so base-path URIs resolve to public:// (the canonical form) and don't + // create duplicate file entities when both wrappers share the same path. + uksort($this->wrappers, fn($a, $b) => ($b === 'public') <=> ($a === 'public') ?: strcmp($a, $b)); + // This regex now handles spaces in filenames. $this->uriRegex = '/(?wrappers)) . '):\/\/(.*?)\.(.*?))([\s|:"*?<>|\\\\]|$)/m'; $this->mediaReferenceRegex = '/\[media-reference:file:(.*?)\]/m';