Skip to content

Commit

Permalink
Upmerges from 8.2 to 8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ahaeslich committed Dec 12, 2023
2 parents b1bce9b + 3191d01 commit 60cfffe
Show file tree
Hide file tree
Showing 27 changed files with 190 additions and 58,877 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['8.0', '8.1', '8.2']
php-versions: ['8.0', '8.1', '8.2', '8.3']
dependencies: ['highest']
composer-arguments: [''] # to run --ignore-platform-reqs in experimental builds
static-analysis: ['no']
Expand Down
5 changes: 3 additions & 2 deletions Neos.Media/Classes/Domain/Repository/AssetRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,9 @@ protected function addAssetCollectionToQueryConstraints(QueryInterface $query, A
return;
}

$constraints = $query->getConstraint();
$query->matching($query->logicalAnd([$constraints, $query->contains('assetCollections', $assetCollection)]));
$query->getQueryBuilder()->andWhere(
$query->contains('assetCollections', $assetCollection)
);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion Neos.Media/Classes/Domain/Service/AssetService.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,9 @@ public function replaceAssetResource(AssetInterface $asset, PersistentResource $
$variant->refresh();
foreach ($variant->getAdjustments() as $adjustment) {
if (method_exists($adjustment, 'refit') && $this->imageService->getImageSize($originalAssetResource) !== $this->imageService->getImageSize($resource)) {
$adjustment->refit($asset);
if ($asset instanceof ImageInterface && $asset->getWidth() !== null && $asset->getHeight() !== null) {
$adjustment->refit($asset);
}
}
}
$this->getRepository($variant)->update($variant);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
* information, please view the LICENSE file which was distributed with this
* source code.
*/

use Doctrine\Common\Collections\ArrayCollection;
use Neos\Flow\Persistence\Doctrine\PersistenceManager;
use Neos\Media\Domain\Model\AssetCollection;
use Neos\Media\Domain\Model\Image;
use Neos\Media\Domain\Model\ImageVariant;
use Neos\Media\Domain\Repository\AssetCollectionRepository;
use Neos\Utility\Files;
use Neos\Media\Domain\Model\Asset;
use Neos\Media\Domain\Model\Tag;
Expand All @@ -34,6 +40,11 @@ class AssetRepositoryTest extends AbstractTest
*/
protected $assetRepository;

/**
* @var AssetCollectionRepository
*/
protected $assetCollectionRepository;

/**
* @var TagRepository
*/
Expand All @@ -52,6 +63,7 @@ public function setUp(): void
$this->prepareResourceManager();

$this->assetRepository = $this->objectManager->get(AssetRepository::class);
$this->assetCollectionRepository = $this->objectManager->get(AssetCollectionRepository::class);
$this->tagRepository = $this->objectManager->get(TagRepository::class);
}

Expand Down Expand Up @@ -147,4 +159,91 @@ public function findBySearchTermAndTagsReturnsFilteredResult()
$asset->getResource()->getSha1();
}
}

/**
* @test
*/
public function testAddAssetVariantFilterClauseWithoutAssetCollection()
{
$resource1 = $this->resourceManager->importResource(__DIR__ . '/../../Fixtures/Resources/417px-Mihaly_Csikszentmihalyi.jpg');
$resource2 = $this->resourceManager->importResource(__DIR__ . '/../../Fixtures/Resources/640px-Goodworkteam.jpg');

$image1 = new Image($resource1);
$image1->setTitle('asset for homepage');
$this->assetRepository->add($image1);

$imageVariant1 = new ImageVariant($image1);
$image1->addVariant($imageVariant1);

$image2 = new Image($resource2);
$image2->setTitle('asset for homepage');
$this->assetRepository->add($image2);

$imageVariant2 = new ImageVariant($image2);
$image2->addVariant($imageVariant2);

$this->persistenceManager->persistAll();
$this->persistenceManager->clearState();

$assets = $this->assetRepository->findAll();

self::assertCount(2, $assets);
foreach ($assets as $asset) {
self::assertInstanceOf(Image::class, $asset);
self::assertNotInstanceOf(ImageVariant::class, $asset);
}

// This is necessary to initialize all resource instances before the tables are deleted
foreach ($this->assetRepository->findAll() as $asset) {
$asset->getResource()->getSha1();
}
}

/**
* @test
*/
public function testAddAssetVariantFilterClauseWithAssetCollection()
{
$resource1 = $this->resourceManager->importResource(__DIR__ . '/../../Fixtures/Resources/417px-Mihaly_Csikszentmihalyi.jpg');
$resource2 = $this->resourceManager->importResource(__DIR__ . '/../../Fixtures/Resources/640px-Goodworkteam.jpg');

$assetCollection1 = new AssetCollection('test-1');
$this->assetCollectionRepository->add($assetCollection1);

$collections1 = new ArrayCollection();
$collections1->add($assetCollection1);

$image1 = new Image($resource1);
$image1->setTitle('asset for homepage');
$image1->setAssetCollections($collections1);
$assetCollection1->addAsset($image1);

$imageVariant1 = new ImageVariant($image1);
$image1->addVariant($imageVariant1);

$assetCollection2 = new AssetCollection('test-2');
$this->assetCollectionRepository->add($assetCollection2);

$collections2 = new ArrayCollection();
$collections2->add($assetCollection2);

$image2 = new Image($resource2);
$image2->setTitle('asset for homepage');
$image2->setAssetCollections($collections2);
$assetCollection2->addAsset($image2);

$this->persistenceManager->persistAll();
$this->persistenceManager->clearState();

$assets = $this->assetRepository->findAll($assetCollection1);
self::assertCount(1, $assets);
self::assertInstanceOf(Image::class, $assets->getFirst());
self::assertNotInstanceOf(ImageVariant::class, $assets->getFirst());
self::assertNotInstanceOf(ImageVariant::class, $assets->getFirst());

// This is necessary to initialize all resource instances before the tables are deleted
foreach ($this->assetRepository->findAll() as $asset) {
$asset->getResource()->getSha1();
}
}
}
13 changes: 11 additions & 2 deletions Neos.Neos/Classes/Fusion/ConvertUrisImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Neos\Flow\Annotations as Flow;
use Neos\Neos\Domain\Exception;
use Neos\Neos\Fusion\Helper\CachingHelper;
use Neos\Neos\Service\LinkingService;
use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\Fusion\FusionObjects\AbstractFusionObject;
Expand Down Expand Up @@ -56,6 +57,12 @@ class ConvertUrisImplementation extends AbstractFusionObject
*/
protected $linkingService;

/**
* @Flow\Inject
* @var CachingHelper
*/
protected $cachingHelper;

/**
* Convert URIs matching a supported scheme with generated URIs
*
Expand Down Expand Up @@ -97,11 +104,13 @@ public function evaluate()
switch ($matches[1]) {
case 'node':
$resolvedUri = $linkingService->resolveNodeUri($matches[0], $node, $controllerContext, $absolute);
$this->runtime->addCacheTag('node', $matches[2]);
$cacheTagIdentifier = sprintf('%s_%s', $this->cachingHelper->renderWorkspaceTagForContextNode($node->getContext()->getWorkspaceName()), $matches[2]);
$this->runtime->addCacheTag('node', $cacheTagIdentifier);
break;
case 'asset':
$resolvedUri = $linkingService->resolveAssetUri($matches[0]);
$this->runtime->addCacheTag('asset', $matches[2]);
$cacheTagIdentifier = sprintf('%s_%s', $this->cachingHelper->renderWorkspaceTagForContextNode($node->getContext()->getWorkspaceName()), $matches[2]);
$this->runtime->addCacheTag('asset', $cacheTagIdentifier);
break;
default:
$resolvedUri = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{namespace neos=Neos\Neos\ViewHelpers}
<f:for each="{roles}" as="role" iteration="iteration">
<span class="neos-label" title="{f:render(section: 'tooltip', arguments: {role: role})}" data-neos-toggle="tooltip" data-placement="right" data-html="true">
{role.name}
{f:if(condition: role.label, then: role.label, else: role.name)}
</span>
</f:for>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ <h2>{neos:backend.translate(id: 'user.new.subtitle', value: 'Create a new user',
<div class="neos-controls">
<label for="roles-{rolesIteration.cycle}" class="neos-checkbox" title="{role.packageKey}" data-neos-toggle="tooltip" data-placement="right">
<f:form.checkbox name="roleIdentifiers" multiple="true" value="{role.identifier}" id="roles-{rolesIteration.cycle}" /><span></span>
{role.name}
{f:if(condition: role.label, then: role.label, else: role.name)}
</label>
</div>
</f:for>
Expand Down

0 comments on commit 60cfffe

Please sign in to comment.