#90330Wrong publicUrl for FAL files in non-public storages generated from CLI
Description
In at least TYPO3 9.5.13 fetching the public url of a FAL \TYPO3\CMS\Core\Resource\File located in a non-public storage using $file->getPublicUrl() from the commandline in a Symfony command returns
http:///var/www/example.org/www/typo3/sysext/core/bin/index.php?eID=dumpFile&t=f&f=[fileUid]&token=[token]
Using $file->getPublicUrl(TRUE) returns
../../../../http://var/www/example.org/www/typo3/sysext/core/bin/index.php?eID=dumpFile&t=f&f=[fileUid]&token=[token]
Last changes to that area were done in
https://review.typo3.org/c/Packages/TYPO3.CMS/+/57240/11/typo3/sysext/core/Classes/Resource/ResourceStorage.php#1304
https://review.typo3.org/c/Packages/TYPO3.CMS/+/53140/8/typo3/sysext/core/Classes/Resource/ResourceStorage.php#1297
https://review.typo3.org/c/Packages/TYPO3.CMS/+/53789/5/typo3/sysext/core/Classes/Resource/ResourceStorage.php#1304
This should be a valid URL not mangling local file paths with eID-GET-Parameters.
For TYPO3 9+ it probably should take site configuration in account, otherwise it would even help if at least just the relative path
/index.php?eID=dumpFile&t=f&f=[fileUid]&token=[token]
would be returned
Reviews 1
Related issues 2
History 913
-
Stephan Großberndt commented <span data-processor="relativetime" data-value="2020-02-05T17:13:32+00:00" > 02/05/20, 17:13 </span>
-
Georg Ringer changed status
NewAccepted <span data-processor="relativetime" data-value="2020-02-06T07:14:33+00:00" > 02/06/20, 07:14 </span> -
Stephan Großberndt commented <span data-processor="relativetime" data-value="2023-06-14T15:47:04+00:00" > 06/14/23, 15:47 </span>
This issue is still present in TYPO3 v12, here
$file->getPublicUrl()and$file->getPublicUrl(TRUE)both returnhttp://bin/index.php?eID=dumpFile&t=f&f=2096&token=bd6e0cc99d3c2a7a6745416bff82d61ce87d44dd
-
Stephan Großberndt changed Related to #100361 <span data-processor="relativetime" data-value="2023-09-13T07:47:57+00:00" > 09/13/23, 07:47 </span>
-
Georg Ringer changed Sprint Focus On Location Sprint <span data-processor="relativetime" data-value="2025-04-16T14:07:37+00:00" > 04/16/25, 14:07 </span>
-
Gerrit Code Review pushed patch set 1 for main to change 91366 status
AcceptedUnder Review <span data-processor="relativetime" data-value="2025-10-30T13:24:37+00:00" > 10/30/25, 13:24 </span> -
Gerrit Code Review pushed patch set 2 for main to change 91366 <span data-processor="relativetime" data-value="2025-10-30T13:26:15+00:00" > 10/30/25, 13:26 </span>
-
Gerrit Code Review pushed patch set 3 for main to change 91366 <span data-processor="relativetime" data-value="2025-10-30T15:23:28+00:00" > 10/30/25, 15:23 </span>
-
Georg Ringer changed Sprint Focus
On Location Sprint<span data-processor="relativetime" data-value="2026-08-06T15:48:12+00:00" > 08/06/26, 15:48 </span> -
Gerrit Code Review pushed patch set 4 for main to change 91366 <span data-processor="relativetime" data-value="2026-09-25T01:31:41+00:00" > 09/25/26, 01:31 </span>
-
Benni Mack changed Related to #109548 <span data-processor="relativetime" data-value="2026-09-25T01:32:59+00:00" > 09/25/26, 01:32 </span>
-
Benni Mack commented <span data-processor="relativetime" data-value="2026-09-25T01:33:11+00:00" > 09/25/26, 01:33 </span>
This was fixed with #109548 but we add tests now
-
Anonymous commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2026-09-25T07:00:10+00:00" > 09/25/26, 07:00 </span>Applied in changeset commit:ceebf222c966ce8290de1e022b4b9264a2bdc324.
My current workaround:
/** * Cached public URL * * @var string */ private $publicSiteUrl = ''; /** * Cached wrong local path from File::getPublicUrl() * * @var string * @link https://forge.typo3.org/issues/90330 */ private $publicUrlLocalPath = ''; /** * Workaround for "Wrong publicUrl for FAL files in non-public storages generated from CLI" * * @param File $file * @return string * @throws SiteNotFoundException * @link https://forge.typo3.org/issues/90330 */ protected function getPublicUrl(File $file): string { if (empty($this->publicUrlLocalPath)) { $this->publicUrlLocalPath = 'http://' . Environment::getPublicPath() . '/typo3/sysext/core/bin/'; } if (empty($this->publicSiteUrl)) { $siteFinder = GeneralUtility::makeInstance(SiteFinder::class); $this->publicSiteUrl = $siteFinder->getSiteByIdentifier('identifier-of-my-site')->getBase(); } $publicUrl = $file->getPublicUrl(); if (substr($publicUrl, 0, 8) === 'http:///') { $publicUrl = str_replace($this->publicUrlLocalPath, $this->publicSiteUrl, $publicUrl); } return $publicUrl; }