Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/7.3' into 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Feb 11, 2024
2 parents 3d0bc31 + 7507617 commit e0ae66c
Show file tree
Hide file tree
Showing 5 changed files with 263 additions and 158 deletions.
18 changes: 10 additions & 8 deletions Neos.Media.Browser/Resources/Private/Templates/Asset/Edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,16 @@ <h2>{neos:backend.translate(id: 'connectionError', package: 'Neos.Media.Browser'
</label>
</f:for>
</f:if>
<f:if condition="{assetCollections}">
<label>{neos:backend.translate(id: 'collections', package: 'Neos.Media.Browser')}</label>
<f:for each="{assetCollections}" as="assetCollection">
<label class="neos-checkbox neos-inline">
<m:form.checkbox property="assetCollections" multiple="TRUE" value="{assetCollection}" /><span></span> {assetCollection.title}
</label>
</f:for>
</f:if>
<f:security.ifAccess privilegeTarget="Neos.Media.Browser:ManageAssetCollections">
<f:if condition="{assetCollections}">
<label>{neos:backend.translate(id: 'collections', package: 'Neos.Media.Browser')}</label>
<f:for each="{assetCollections}" as="assetCollection">
<label class="neos-checkbox neos-inline">
<m:form.checkbox property="assetCollections" multiple="TRUE" value="{assetCollection}" /><span></span> {assetCollection.title}
</label>
</f:for>
</f:if>
</f:security.ifAccess>
</fieldset>
<fieldset>
<legend>{neos:backend.translate(id: 'metadata', package: 'Neos.Media.Browser')}</legend>
Expand Down
90 changes: 62 additions & 28 deletions Neos.Neos/Classes/Controller/Backend/MenuHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
* source code.
*/

use Neos\ContentRepository\Domain\Factory\NodeFactory;
use Neos\ContentRepository\Domain\Repository\NodeDataRepository;
use Neos\ContentRepository\Domain\Repository\WorkspaceRepository;
use Neos\ContentRepository\Domain\Utility\NodePaths;
use Neos\ContentRepository\Security\Authorization\Privilege\Node\NodePrivilegeSubject;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Http\Exception;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Flow\Mvc\Routing\Exception\MissingActionNameException;
use Neos\Flow\Security\Authorization\PrivilegeManagerInterface;
use Neos\Neos\Domain\Service\ContentContextFactory;
use Neos\Neos\Domain\Service\SiteService;
use Neos\Neos\Security\Authorization\Privilege\ModulePrivilege;
use Neos\Neos\Security\Authorization\Privilege\ModulePrivilegeSubject;
Expand Down Expand Up @@ -65,9 +68,21 @@ class MenuHelper

/**
* @Flow\Inject
* @var ContentContextFactory
* @var WorkspaceRepository
*/
protected $contextFactory;
protected $workspaceRepository;

/**
* @Flow\Inject
* @var NodeDataRepository
*/
protected $nodeDataRepository;

/**
* @Flow\Inject
* @var NodeFactory
*/
protected $nodeFactory;

/**
* @param array $settings
Expand All @@ -93,38 +108,57 @@ public function buildSiteList(ControllerContext $controllerContext): array
return [];
}

$context = $this->contextFactory->create();
$liveWorkspace = $this->workspaceRepository->findByIdentifier('live');

$domainsFound = false;
$sites = [];
foreach ($this->siteRepository->findOnline() as $site) {
$node = $context->getNode(\Neos\ContentRepository\Domain\Utility\NodePaths::addNodePathSegment(SiteService::SITES_ROOT_PATH, $site->getNodeName()));
if ($this->privilegeManager->isGranted(NodeTreePrivilege::class, new NodePrivilegeSubject($node))) {
$uri = null;
$active = false;
/** @var $site Site */
if ($site->hasActiveDomains()) {
$activeHostPatterns = $site->getActiveDomains()->map(static function ($domain) {
return $domain->getHostname();
})->toArray();

$active = in_array($requestUriHost, $activeHostPatterns, true);

if ($active) {
$uri = $contentModule['uri'];
} else {
$uri = $controllerContext->getUriBuilder()->reset()->uriFor('switchSite', ['site' => $site], 'Backend\Backend', 'Neos.Neos');
}
$granted = false;

$siteNodePath = NodePaths::addNodePathSegment(SiteService::SITES_ROOT_PATH, $site->getNodeName());
$siteNodesInAllDimensions = $this->nodeDataRepository->findByPathWithoutReduce($siteNodePath, $liveWorkspace);

$domainsFound = true;
foreach ($siteNodesInAllDimensions as $siteNodeData) {
$siteNodeContext = $this->nodeFactory->createContextMatchingNodeData($siteNodeData);
$siteNode = $this->nodeFactory->createFromNodeData($siteNodeData, $siteNodeContext);

// if the node exists, check if the user is granted access to this node
if ($this->privilegeManager->isGranted(NodeTreePrivilege::class, new NodePrivilegeSubject($siteNode))) {
$granted = true;
break;
}
}

// if no siteNode is accessible ignore this site
if (!$granted) {
continue;
}

$uri = null;
$active = false;
/** @var $site Site */
if ($site->hasActiveDomains()) {
$activeHostPatterns = $site->getActiveDomains()->map(static function ($domain) {
return $domain->getHostname();
})->toArray();

$active = in_array($requestUriHost, $activeHostPatterns, true);

if ($active) {
$uri = $contentModule['uri'];
} else {
$uri = $controllerContext->getUriBuilder()->reset()->uriFor('switchSite', ['site' => $site], 'Backend\Backend', 'Neos.Neos');
}

$sites[] = [
'name' => $site->getName(),
'nodeName' => $site->getNodeName(),
'uri' => $uri,
'active' => $active
];
$domainsFound = true;
}

$sites[] = [
'name' => $site->getName(),
'nodeName' => $site->getNodeName(),
'uri' => $uri,
'active' => $active
];
}

if ($domainsFound === false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,16 +470,18 @@ protected function computeChangesCount(Workspace $selectedWorkspace)
{
$changesCount = ['new' => 0, 'changed' => 0, 'removed' => 0, 'total' => 0];
foreach ($this->computeSiteChanges($selectedWorkspace) as $siteChanges) {
foreach ($siteChanges['documents'] as $documentChanges) {
foreach ($documentChanges['changes'] as $change) {
if ($change['node']->isRemoved()) {
$changesCount['removed']++;
} elseif ($change['isNew']) {
$changesCount['new']++;
} else {
$changesCount['changed']++;
};
$changesCount['total']++;
foreach ($siteChanges['documents'] as $dimensions) {
foreach ($dimensions as $documentChanges) {
foreach ($documentChanges['changes'] as $change) {
if ($change['node']->isRemoved()) {
$changesCount['removed']++;
} elseif ($change['isNew']) {
$changesCount['new']++;
} else {
$changesCount['changed']++;
};
$changesCount['total']++;
}
}
}
}
Expand Down Expand Up @@ -509,11 +511,15 @@ protected function computeSiteChanges(Workspace $selectedWorkspace)
// $document will be null if we have a broken root line for this node. This actually should never happen, but currently can in some scenarios.
if ($document !== null) {
$documentPath = implode('/', array_slice(explode('/', $document->getPath()), 3));

$dimensionValues = $document->getDimensions();
$documentDimension = Utility::sortDimensionValueArrayAndReturnDimensionsHash($dimensionValues);

$relativePath = str_replace(sprintf(SiteService::SITES_ROOT_PATH . '/%s/%s', $siteNodeName, $documentPath), '', $node->getPath());
if (!isset($siteChanges[$siteNodeName]['siteNode'])) {
$siteChanges[$siteNodeName]['siteNode'] = $this->siteRepository->findOneByNodeName($siteNodeName);
}
$siteChanges[$siteNodeName]['documents'][$documentPath]['documentNode'] = $document;
$siteChanges[$siteNodeName]['documents'][$documentDimension][$documentPath]['documentNode'] = $document;

$change = [
'node' => $node,
Expand All @@ -522,7 +528,7 @@ protected function computeSiteChanges(Workspace $selectedWorkspace)
if ($node->getNodeType()->isOfType('Neos.Neos:Node')) {
$change['configuration'] = $node->getNodeType()->getFullConfiguration();
}
$siteChanges[$siteNodeName]['documents'][$documentPath]['changes'][$relativePath] = $change;
$siteChanges[$siteNodeName]['documents'][$documentDimension][$documentPath]['changes'][$relativePath] = $change;
}
}
}
Expand All @@ -534,17 +540,21 @@ protected function computeSiteChanges(Workspace $selectedWorkspace)

ksort($siteChanges);
foreach ($siteChanges as $siteKey => $site) {
foreach ($site['documents'] as $documentKey => $document) {
$liveDocumentNode = $liveContext->getNodeByIdentifier($document['documentNode']->getIdentifier());
$siteChanges[$siteKey]['documents'][$documentKey]['isMoved'] = $liveDocumentNode && $document['documentNode']->getPath() !== $liveDocumentNode->getPath();
$siteChanges[$siteKey]['documents'][$documentKey]['isNew'] = $liveDocumentNode === null;
foreach ($document['changes'] as $changeKey => $change) {
$liveNode = $liveContext->getNodeByIdentifier($change['node']->getIdentifier());
$siteChanges[$siteKey]['documents'][$documentKey]['changes'][$changeKey]['isNew'] = is_null($liveNode);
$siteChanges[$siteKey]['documents'][$documentKey]['changes'][$changeKey]['isMoved'] = $liveNode && $change['node']->getPath() !== $liveNode->getPath();
foreach ($site['documents'] as $documentDimension => $documentsPerDimension) {
foreach ($documentsPerDimension as $documentKey => $document) {
$liveDocumentNode = $liveContext->getNodeByIdentifier($document['documentNode']->getIdentifier());
$siteChanges[$siteKey]['documents'][$documentDimension][$documentKey]['isMoved'] = $liveDocumentNode && $document['documentNode']->getPath() !== $liveDocumentNode->getPath();
$siteChanges[$siteKey]['documents'][$documentDimension][$documentKey]['isNew'] = $liveDocumentNode === null;
foreach ($document['changes'] as $changeKey => $change) {
$liveNode = $liveContext->getNodeByIdentifier($change['node']->getIdentifier());
$siteChanges[$siteKey]['documents'][$documentDimension][$documentKey]['changes'][$changeKey]['isNew'] = is_null($liveNode);
$siteChanges[$siteKey]['documents'][$documentDimension][$documentKey]['changes'][$changeKey]['isMoved'] = $liveNode && $change['node']->getPath() !== $liveNode->getPath();
}
}
}
ksort($siteChanges[$siteKey]['documents']);
foreach ($siteChanges[$siteKey]['documents'] as $key => $document) {
ksort($siteChanges[$siteKey]['documents'][$key]);
}
}
return $siteChanges;
}
Expand Down
57 changes: 57 additions & 0 deletions Neos.Neos/Documentation/Appendixes/ChangeLogs/7319.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
`7.3.19 (2024-01-15) <https://github.com/neos/neos-development-collection/releases/tag/7.3.19>`_
================================================================================================

Overview of merged pull requests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

`BUGFIX: Check SVG files for malicious code before providing original asset url links <https://github.com/neos/neos-development-collection/pull/4812>`_
-------------------------------------------------------------------------------------------------------------------------------------------------------

This adds a check in the preview of assets in the media module and checks for malicous content in svgs. If detected, the direct links to the original url get removed from the preview pages and a warning is shown.

!`image <https://github.com/neos/neos-development-collection/assets/13046100/bb8a2b73-a251-499e-926a-1e6b866bbc87>`_

Fixes https://github.com/neos/flow-development-collection/issues/3248

* Packages: ``Neos`` ``Media.Browser``

`BUGFIX: Resolve StyleCI issues <https://github.com/neos/neos-development-collection/pull/4820>`_
-------------------------------------------------------------------------------------------------



* Packages: ``Neos`` ``Fusion``

`BUGFIX: node:repair fails with could not be converted to string <https://github.com/neos/neos-development-collection/pull/4795>`_
----------------------------------------------------------------------------------------------------------------------------------

Fixes the following crash during node:repair

```shell
./flow node:repair --dry-run --only removeBrokenEntityReferences
Dry run, not committing any changes.
Checking for broken entity references ...
Object of class Neos\\Flow\\Persistence\\Doctrine\\Proxies\\__CG__\\Neos\\Media\\Domain\\Model\\ImageVariant could not be converted to string
Type: Error
File: Data/Temporary/Development/SubContextWbWeb/Cache/Code/Flow_Object_Classes/Neos_ContentRepository_Command_NodeCommandControllerPlugin.php
Line: 836
```

resolved `#4794 <https://github.com/neos/neos-development-collection/issues/4794>`_

**Upgrade instructions**

- [x] Code follows the PSR-2 coding style
- ~~Tests have been created, run and adjusted as needed~~
- There are not tests in place and I added none.
- [x] The PR is created against the `lowest maintained branch <https://www.neos.io/features/release-roadmap.html>`_ -> 7.3
- [ ] Reviewer - PR Title is brief but complete and starts with ``FEATURE|TASK|BUGFIX``
- [ ] Reviewer - The first section explains the change briefly for change-logs
- [ ] Reviewer - Breaking Changes are marked with ``!!!`` and have upgrade-instructions

* Packages: ``Neos`` ``ContentRepository``

`Detailed log <https://github.com/neos/neos-development-collection/compare/7.3.18...7.3.19>`_
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Loading

0 comments on commit e0ae66c

Please sign in to comment.