Skip to content

Commit

Permalink
[RELEASE] Version 12.5.3 with some small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dhoffmann1979 committed Aug 26, 2024
2 parents 9b1829b + 9c62195 commit 1ef0953
Show file tree
Hide file tree
Showing 31 changed files with 806 additions and 360 deletions.
1 change: 1 addition & 0 deletions .project/docker/docker-compose.darwin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ services:
- ./:/app/:cached
- ./:/packages/in2publish_core/:cached
- /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock
- /var/run/docker.sock:/var/run/docker.sock
- ${SQLDUMPSDIR}:/${SQLDUMPSDIR}:cached
env_file:
- .env
Expand Down
3 changes: 2 additions & 1 deletion .project/docker/local-php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ RUN usermod -u $USER_ID app \
&& mkdir -m 700 -p /home/app/.ssh/ \
&& curl -fsSL https://get.docker.com | sh \
&& usermod -aG docker app \
&& usermod -aG systemd-journal app
&& usermod -aG systemd-journal app \
&& usermod -aG root app
COPY id_ed25519 id_ed25519.pub /home/app/.ssh/
RUN chmod 400 /home/app/.ssh/id* \
&& chown -R $USER_ID:$GROUP_ID /home/app/
Expand Down
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,36 @@
# In2publish Core Change Log

12.5.3:

- [CODESTYLE] Make qa happy
- [BUGFIX] Add make target for installing qa tools
- [FEATURE] Adds Support for MM-Records to excluded Tables
- [BUGFIX] Make Processor for inputLink work properly
- [BUGFIX] Fixes finding missing records
- [BUGFIX] Enable Logging in Command on foreign
- [BUGFIX] Resolve images uploaded in RTE
- [TESTING] Harden a test
- [TEST] Align structure of artifacts with in2publish
- [TESTING] Align Tests
- [DEV] Add composer update & install to makefile
- [DEV] Add Cache Clearing Commands to Makefile
- [DEV] Align Makefiles between in2publish and in2publish_core
- [TESTING] Make Sleep Time configurable
- [BUGFIX] Activate Screencasts on Mac
- [TESTING] Make Tests also work on macs
- [TEST] Add workaround for loading pagetree
- [REFACTOR] Adopt new StackTest Structure
- [CODESTYLE] Make qa happy

12.5.2:

- [DOCS] Add known issue to explain missing (orphaned) MM records in the record tree
- [BUGFIX] Discard the table portion of a joined row if the joined record does not exist
- [META] Exclude compile-sass from archive
- [BUGFIX] Cast pageuid to integer to build the preview URL

12.5.1:

- [BUGFIX] Correct evaluation of publishing state
- [BUGFIX] Fixes Databender for Redirects

Expand Down
40 changes: 40 additions & 0 deletions Classes/Component/Core/Demand/Type/MmDemand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

declare(strict_types=1);

namespace In2code\In2publishCore\Component\Core\Demand\Type;

use In2code\In2publishCore\Component\Core\Record\Model\Node;

class MmDemand implements Demand
{
use UniqueRecordKeyGenerator;

protected string $from;
protected string $property;
/** @var mixed */
protected $value;
protected Node $record;

/**
* @param mixed $value
*/
public function __construct(string $from, string $property, $value, Node $record)
{
$this->from = $from;
$this->property = $property;
$this->value = $value;
$this->record = $record;
}

public function addToDemandsArray(array &$demands): void
{
$uniqueRecordKey = $this->createUniqueRecordKey($this->record);
$demands[$this->from][$this->property][$this->value][$uniqueRecordKey] = $this->record;
}

public function addToMetaArray(array &$meta, array $frame): void
{
$meta[$this->from][$this->property][] = $frame;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,21 @@ protected function findMissingTableRecords(JoinRowCollection $joinRowCollection)
$missingIdentifiers['local'] ?? [],
$joinRowCollection,
$this->localRepository,
'local'
);
$this->findMissingTableRecordsOnSide(
$missingIdentifiers['foreign'] ?? [],
$joinRowCollection,
$this->foreignRepository,
'foreign'
);
}

public function findMissingTableRecordsOnSide(
array $missingIdentifiers,
JoinRowCollection $joinRowCollection,
SingleDatabaseRepository $repository
SingleDatabaseRepository $repository,
string $side
): void {
foreach ($missingIdentifiers as $table => $joinTables) {
$identifiers = [];
Expand All @@ -102,7 +105,7 @@ public function findMissingTableRecordsOnSide(
foreach ($rows as $uid => $row) {
foreach ($identifiers[$uid] as $joinTable => $mmIds) {
foreach ($mmIds as $mmId) {
$joinRowCollection->amendRow($joinTable, $table, $mmId, 'foreign', $row);
$joinRowCollection->amendRow($joinTable, $table, $mmId, $side, $row);
}
}
}
Expand Down
64 changes: 64 additions & 0 deletions Classes/Component/Core/DemandResolver/Mm/MmDemandResolver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace In2code\In2publishCore\Component\Core\DemandResolver\Mm;

use Doctrine\DBAL\Exception;
use In2code\In2publishCore\Component\Core\Demand\CallerAwareDemandsCollection;
use In2code\In2publishCore\Component\Core\Demand\Demands;
use In2code\In2publishCore\Component\Core\Demand\Type\MmDemand;
use In2code\In2publishCore\Component\Core\DemandResolver\DemandResolver;
use In2code\In2publishCore\Component\Core\DemandResolver\Exception\InvalidDemandException;
use In2code\In2publishCore\Component\Core\Record\Factory\RecordFactoryInjection;
use In2code\In2publishCore\Component\Core\RecordCollection;
use In2code\In2publishCore\Component\Core\RecordIndexInjection;
use In2code\In2publishCore\Component\Core\Repository\DualDatabaseRepositoryInjection;
use In2code\In2publishCore\Component\Core\Repository\ForeignSingleDatabaseRepositoryInjection;
use In2code\In2publishCore\Component\Core\Repository\LocalSingleDatabaseRepositoryInjection;

class MmDemandResolver implements DemandResolver
{
use RecordFactoryInjection;
use RecordIndexInjection;
use DualDatabaseRepositoryInjection;
use LocalSingleDatabaseRepositoryInjection;
use ForeignSingleDatabaseRepositoryInjection;

public function resolveDemand(Demands $demands, RecordCollection $recordCollection): void
{
foreach ($demands->getDemandsByType(MmDemand::class) as $mmTable => $fields) {
foreach ($fields as $field => $valueMaps) {
try {
$rows = $this->dualDatabaseRepository->findMmByProperty(
$mmTable,
$field,
array_keys($valueMaps)
);
} catch (Exception $exception) {
if ($demands instanceof CallerAwareDemandsCollection) {
$callers = $demands->getMeta(MmDemand::class, $mmTable, $field);
$exception = new InvalidDemandException($callers, $exception);
}
throw $exception;
}
foreach ($rows as $mmId => $recordInfo) {
$mmRecord = $this->recordIndex->getRecord($mmTable, $mmId);
if (null === $mmRecord) {
$mmRecord = $this->recordFactory->createMmRecord(
$mmTable,
$mmId,
$recordInfo['local'] ?? [],
$recordInfo['foreign'] ?? [],
);
if (null === $mmRecord) {
continue;
}
}
$mapValue = $mmRecord->getProp($field);
foreach ($valueMaps[$mapValue] as $parent) {
$parent->addChild($mmRecord);
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use In2code\In2publishCore\Component\Core\Resolver\GroupMultiTableResolver;
use In2code\In2publishCore\Component\Core\Resolver\GroupSingleTableResolver;
use In2code\In2publishCore\Component\Core\Resolver\Resolver;
use In2code\In2publishCore\Component\Core\Resolver\SelectStandaloneMmResolver;
use In2code\In2publishCore\Component\Core\Resolver\StaticJoinResolver;
use In2code\In2publishCore\Utility\DatabaseUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand Down Expand Up @@ -39,6 +40,10 @@ class GroupProcessor extends AbstractProcessor
'uploadfolder',
];

/**
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function additionalPreProcess(string $table, string $column, array $tca): array
{
$internalType = $tca['internal_type'] ?? 'db';
Expand All @@ -57,12 +62,12 @@ protected function additionalPreProcess(string $table, string $column, array $tc
}

$allowedTables = GeneralUtility::trimExplode(',', $allowed);
if (['pages'] === $allowedTables) {
if (empty($tca['MM']) && ['pages'] === $allowedTables) {
return ['TCA relations to pages are not resolved.'];
}

$allowedTables = $this->excludedTablesService->removeExcludedTables($allowedTables);
if (empty($allowedTables)) {
if (empty($tca['MM']) && empty($allowedTables)) {
return ['All tables of this relation (' . $allowed . ') are excluded.'];
}

Expand All @@ -76,6 +81,10 @@ protected function additionalPreProcess(string $table, string $column, array $tc
return $reasons;
}

/**
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function buildResolver(string $table, string $column, array $processedTca): ?Resolver
{
$foreignTable = $processedTca['allowed'];
Expand Down Expand Up @@ -109,6 +118,12 @@ protected function buildResolver(string $table, string $column, array $processed
$additionalWhere = $matches['where'];
}

if ('pages' === $foreignTable || $this->excludedTablesService->isExcludedTable($foreignTable)) {
$resolver = $this->container->get(SelectStandaloneMmResolver::class);
$resolver->configure($mmTable, $selectField);
return $resolver;
}

if (!$isSingleTable) {
$resolver = $this->container->get(GroupMmMultiTableResolver::class);
$resolver->configure($tables, $mmTable, $column, $selectField, $additionalWhere);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use In2code\In2publishCore\Component\Core\Resolver\InlineMultiValueResolver;
use In2code\In2publishCore\Component\Core\Resolver\InlineSelectResolver;
use In2code\In2publishCore\Component\Core\Resolver\Resolver;
use In2code\In2publishCore\Component\Core\Resolver\SelectStandaloneMmResolver;
use In2code\In2publishCore\Component\Core\Resolver\StaticJoinResolver;
use In2code\In2publishCore\Utility\DatabaseUtility;

Expand Down Expand Up @@ -37,7 +38,7 @@ class InlineProcessor extends AbstractProcessor
protected function additionalPreProcess(string $table, string $column, array $tca): array
{
$foreignTable = $tca['foreign_table'] ?? null;
if (null !== $foreignTable && $this->excludedTablesService->isExcludedTable($foreignTable)) {
if (empty($tca['MM']) && null !== $foreignTable && $this->excludedTablesService->isExcludedTable($foreignTable)) {
return ['The table ' . $foreignTable . ' is excluded from publishing'];
}
return [];
Expand All @@ -55,6 +56,12 @@ protected function buildResolver(string $table, string $column, array $processed

$additionalWhere = $this->processMmMatchFields($processedTca);

if ('pages' === $foreignTable || $this->excludedTablesService->isExcludedTable($foreignTable)) {
$resolver = $this->container->get(SelectStandaloneMmResolver::class);
$resolver->configure($mmTable, $selectField);
return $resolver;
}

/** @var StaticJoinResolver $resolver */
$resolver = $this->container->get(StaticJoinResolver::class);
$resolver->configure($mmTable, $foreignTable, $additionalWhere, $selectField);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
class InputProcessor extends TextProcessor
{
protected string $type = 'input';
protected array $required = [];

protected function additionalPreProcess(string $table, string $column, array $tca): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use In2code\In2publishCore\Component\Core\Resolver\Resolver;
use In2code\In2publishCore\Component\Core\Resolver\SelectMmResolver;
use In2code\In2publishCore\Component\Core\Resolver\SelectResolver;
use In2code\In2publishCore\Component\Core\Resolver\SelectStandaloneMmResolver;
use In2code\In2publishCore\Utility\DatabaseUtility;

use function array_filter;
Expand Down Expand Up @@ -58,11 +59,11 @@ protected function additionalPreProcess(string $table, string $column, array $tc
// Skip relations to table "pages", except if it's the page's transOrigPointerField
$foreignTable = $tca['foreign_table'] ?? null;
$transOrigPointerField = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] ?? null;
if ('pages' === $foreignTable && ('pages' !== $table || $column !== $transOrigPointerField)) {
if (empty($tca['MM']) && 'pages' === $foreignTable && ('pages' !== $table || $column !== $transOrigPointerField)) {
return ['TCA relations to pages are not resolved.'];
}

if (null !== $foreignTable && $this->excludedTablesService->isExcludedTable($foreignTable)) {
if (empty($tca['MM']) && null !== $foreignTable && $this->excludedTablesService->isExcludedTable($foreignTable)) {
return ['The table ' . $foreignTable . ' is excluded from publishing'];
}

Expand Down Expand Up @@ -91,6 +92,12 @@ protected function buildResolver(string $table, string $column, array $processed
$foreignTableWhere = DatabaseUtility::stripLogicalOperatorPrefix($foreignTableWhere);
$foreignTableWhere = $this->tcaEscapingMarkerService->escapeMarkedIdentifier($foreignTableWhere);

if ('pages' === $foreignTable || $this->excludedTablesService->isExcludedTable($foreignTable)) {
$resolver = $this->container->get(SelectStandaloneMmResolver::class);
$resolver->configure($mmTable, $selectField);
return $resolver;
}

/** @var SelectMmResolver $resolver */
$resolver = $this->container->get(SelectMmResolver::class);
$resolver->configure($foreignTableWhere, $column, $mmTable, $foreignTable, $selectField);
Expand Down
8 changes: 8 additions & 0 deletions Classes/Component/Core/Repository/DualDatabaseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,12 @@ public function findByWhere(string $table, string $andWhere): array

return $this->mergeRowsByIdentifier($localRows, $foreignRows);
}

public function findMmByProperty(string $table, string $property, array $values): array
{
$localRows = $this->localRepository->findMmByProperty($table, $property, $values);
$foreignRows = $this->foreignRepository->findMmByProperty($table, $property, $values);

return $this->mergeRowsByIdentifier($localRows, $foreignRows);
}
}
26 changes: 26 additions & 0 deletions Classes/Component/Core/Repository/SingleDatabaseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public function findByProperty(
/**
* @throws DBALException
* @throws Exception
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function findByPropertyWithJoin(
string $mmTable,
Expand Down Expand Up @@ -209,4 +210,29 @@ public function findByWhere($table, string $andWhere): array
$result = $query->executeQuery();
return array_column($result->fetchAllAssociative(), null, 'uid');
}

public function findMmByProperty(string $table, string $property, array $values): array
{
$query = $this->connection->createQueryBuilder();
$query->getRestrictions()->removeAll();
$query->select('*')
->from($table)
->where(
$query->expr()->in(
$property,
$query->createNamedParameter($values, DbalConnection::PARAM_STR_ARRAY),
),
);

$result = $query->executeQuery();
$rows = [];
foreach ($result->fetchAllAssociative() as $row) {
$mmIdentityProperties = [
$row['uid_local'],
$row['uid_foreign'],
];
$rows[hash('sha1', json_encode($mmIdentityProperties, JSON_THROW_ON_ERROR))] = $row;
}
return $rows;
}
}
Loading

0 comments on commit 1ef0953

Please sign in to comment.