Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/8.3' into bugfix/ui-3184/proper-…
Browse files Browse the repository at this point in the history
…cache-invalidation-on-discard
  • Loading branch information
mhsdesign committed Apr 25, 2024
2 parents c99cd8b + 6841c68 commit 21ed60f
Show file tree
Hide file tree
Showing 65 changed files with 8,769 additions and 810 deletions.
4 changes: 4 additions & 0 deletions Neos.ContentRepository/Classes/Domain/Model/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,10 @@ public function getProperty($propertyName, bool $returnNodesAsIdentifiers = fals
}

try {
/**
* In case the value is a value object it _will_ already be deserialized due to the feature in flow_json_array
* {@see \Neos\Flow\Persistence\Doctrine\DataTypes\JsonArrayType::deserializeValueObject}
*/
return $this->propertyMapper->convert($value, $expectedPropertyType);
} catch (\Neos\Flow\Property\Exception $exception) {
throw new NodeException(sprintf('Failed to convert property "%s" of node "%s" to the expected type of "%s": %s', $propertyName, $this->getIdentifier(), $expectedPropertyType, $exception->getMessage()), 1630675703, $exception);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ function (Workspace $workspace) {
// Find the position of the workspace, a smaller value means more priority
$workspacePosition = array_search($node->getWorkspace()->getName(), $workspaceNames);
if ($workspacePosition === false) {
throw new Exception\NodeException(sprintf('Node workspace "%s" not found in allowed workspaces (%s), this could result from a detached workspace entity in the context.', $node->getWorkspace()->getName(), implode($workspaceNames, ', ')), 1413902143);
throw new Exception\NodeException(sprintf('Node workspace "%s" not found in allowed workspaces (%s), this could result from a detached workspace entity in the context.', $node->getWorkspace()->getName(), implode(', ', $workspaceNames)), 1413902143);
}

// Find positions in dimensions, add workspace in front for highest priority
Expand Down
20 changes: 16 additions & 4 deletions Neos.Fusion/Classes/Core/Cache/ParserCacheFlusher.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/

use Neos\Flow\Cache\CacheManager;
use Neos\Flow\Monitor\ChangeDetectionStrategy\ChangeDetectionStrategyInterface;

/**
* Helper around the ParsePartials Cache.
Expand Down Expand Up @@ -50,10 +51,21 @@ public function flushPartialCacheOnFileChanges($fileMonitorIdentifier, array $ch

$identifiersToFlush = [];
foreach ($changedFiles as $changedFile => $status) {
// flow already returns absolute file paths from the file monitor, so we don't have to call realpath.
// attempting to use realpath can even result in an error as the file might be removed and thus no realpath can be resolved via file system.
// https://github.com/neos/neos-development-collection/pull/4509
$identifiersToFlush[] = $this->getCacheIdentifierForAbsoluteUnixStyleFilePathWithoutDirectoryTraversal($changedFile);
// flow returns linux style file paths without directory traversal from the file monitor.
// As discovered via https://github.com/neos/neos-development-collection/issues/4915 the paths will point to symlinks instead of the actual file.
// Thus, we still need to invoke `realpath` as the cache invalidation otherwise would not work (due to a different hash)
// But attempting to use realpath on removed/moved files fails because it surely cannot be resolved via file system.
if ($status === ChangeDetectionStrategyInterface::STATUS_DELETED) {
// Ignoring removed files means we cannot flush removed files, but this is a compromise for now.
// See https://github.com/neos/neos-development-collection/issues/4415 as reminder that flushing is disabled for deleted files
continue;
}
$fusionFileRealPath = realpath($changedFile);
if ($fusionFileRealPath === false) {
// should not happen as we ignored deleted files beforehand.
throw new \RuntimeException("Couldn't resolve realpath for: '$changedFile'", 1709122619);
}
$identifiersToFlush[] = $this->getCacheIdentifierForAbsoluteUnixStyleFilePathWithoutDirectoryTraversal($fusionFileRealPath);
}

if ($identifiersToFlush !== []) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ private function getCacheIdentifierForDslCode(string $identifier, string $code):
* - /Users/marc/Code/neos-project/Packages/Neos
*
* its crucial that the path
* - is absolute
* - is absolute (starting with /)
* - the path separator is in unix style: forward-slash /
* - doesn't contain directory traversal /../ or /./
* - is not a symlink
*
* to be absolutely sure the path matches the criteria, {@see realpath} can be used.
*
Expand Down
7 changes: 5 additions & 2 deletions Neos.Fusion/Classes/FusionObjects/Helpers/LazyReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ public function deref(): mixed
}

$this->isLocked = true;
$this->value = ($this->calculateValueCallback)();
$this->hasBeenDereferenced = true;
try {
$this->value = ($this->calculateValueCallback)();
} finally {
$this->hasBeenDereferenced = true;
}

return $this->value;
}
Expand Down
4 changes: 0 additions & 4 deletions Neos.Media.Browser/Classes/Controller/AssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1032,15 +1032,11 @@ private function forwardWithConstraints(string $actionName, string $controllerNa
private function checkForMaliciousContent(AssetProxyInterface $assetProxy): bool
{
if ($assetProxy->getMediaType() == 'image/svg+xml') {
// @todo: Simplify again when https://github.com/darylldoyle/svg-sanitizer/pull/90 is merged and released.
$previousXmlErrorHandling = libxml_use_internal_errors(true);
$sanitizer = new Sanitizer();

$resource = stream_get_contents($assetProxy->getImportStream());

$sanitizer->sanitize($resource);
libxml_clear_errors();
libxml_use_internal_errors($previousXmlErrorHandling);
$issues = $sanitizer->getXmlIssues();
if ($issues && count($issues) > 0) {
return true;
Expand Down
Loading

0 comments on commit 21ed60f

Please sign in to comment.