Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUGFIX: Replace baseUri in cache identifiers
Since Flow 6.0 the httpRequest.baseUri is gone and we need to replace it in the cache identifiers to avoid wrong cache behavior.
- Loading branch information
Showing
3 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
namespace Neos\Fusion\Eel; | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
use Neos\Eel\ProtectedContextAwareInterface; | ||
use Neos\Flow\Http\BaseUriProvider; | ||
use Neos\Flow\Http\Helper\RequestInformationHelper; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Psr\Http\Message\UriInterface; | ||
|
||
/** | ||
* This is a purely internal helper to provide baseUris for Caching. | ||
* It will be moved to a more sensible package in the future so do | ||
* not rely on the classname for now. | ||
* | ||
* @internal | ||
*/ | ||
class BaseUriHelper implements ProtectedContextAwareInterface | ||
{ | ||
/** | ||
* @Flow\Inject | ||
* @var BaseUriProvider | ||
*/ | ||
protected $baseUriProvider; | ||
|
||
/** | ||
* @param ServerRequestInterface|null $fallbackRequest | ||
* @return UriInterface | ||
* @throws \Exception | ||
*/ | ||
public function getConfiguredBaseUriOrFallbackToCurrentRequest(ServerRequestInterface $fallbackRequest = null): UriInterface | ||
{ | ||
try { | ||
$baseUri = $this->baseUriProvider->getConfiguredBaseUriOrFallbackToCurrentRequest(); | ||
} catch (\Exception $e) { | ||
// We are avoiding an exception here in favor of trying more fallback variants. | ||
} | ||
|
||
if (isset($baseUri)) { | ||
return $baseUri; | ||
} | ||
|
||
if ($fallbackRequest === null) { | ||
throw new \Exception('Could not determine baseUri for current process and no fallback HTTP request was given, maybe running in a CLI command.', 1581002260); | ||
} | ||
|
||
return RequestInformationHelper::generateBaseUri($fallbackRequest); | ||
} | ||
|
||
/** | ||
* @param string $methodName | ||
* @return bool | ||
*/ | ||
public function allowsCallOfMethod($methodName): bool | ||
{ | ||
return true; | ||
} | ||
} |
This file contains 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
This file contains 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