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';