Skip to content

Commit fadab95

Browse files
committed
2 parents 9d6ec4a + 12465b6 commit fadab95

File tree

8 files changed

+64
-16
lines changed

8 files changed

+64
-16
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# In2publish Core Change Log
22

3+
10.2.6:
4+
- [META] Set the EM conf version number to 10.2.6
5+
- [BUGFIX] Use correct key "foreign" to index a row from Foreign
6+
- [BUGFIX] Support resolving related redirects with query URL parts
7+
- [BUGFIX] Show undecoded message line if it could not be decoded
8+
- [BUGFIX] Throw an exception if the file to retrieve does not exist
9+
- [BUGFIX] Do not try to publish files that neither exist on local nor foreign
10+
- [RELEASE] Version 10.2.5 with non-empty bulk inserts
11+
312
10.2.5:
413

514
- [META] Set the EM conf version number to 10.2.5

Classes/Domain/Factory/FileIndexFactory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ public function updateFileIndexInfo(
158158
$record->setLocalProperties($localFileInfo);
159159
$record->setForeignProperties($foreignFileInfo);
160160
$record->setDirtyProperties()->calculateState();
161+
} else {
162+
$record->addAdditionalProperty('fileState', 'missing');
161163
}
162164
}
163165

Classes/Domain/Service/Publishing/FilePublisherService.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ protected function transferTemporaryFile(int $storage, string $fileIdentifier):
148148
protected function getLocalReadableFilePathForIdentifier(int $storage, string $fileIdentifier): string
149149
{
150150
$resourceStorage = $this->resourceFactory->getStorageObject($storage);
151-
$file = $resourceStorage->getFile($fileIdentifier);
152-
return $file->getForLocalProcessing(false);
151+
if (!$resourceStorage->hasFile($fileIdentifier)) {
152+
throw new FileMissingException($fileIdentifier);
153+
}
154+
return $resourceStorage->getFile($fileIdentifier)->getForLocalProcessing(false);
153155
}
154156
}

Classes/Features/PhysicalFilePublisher/Domain/Anomaly/PhysicalFilePublisher.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ protected function publishAuthoritativeRecord(
131131
string $identifier,
132132
string $combinedIdentifier
133133
): void {
134+
if ($record->getAdditionalProperty('fileState') === 'missing') {
135+
return;
136+
}
134137
switch ($record->getState()) {
135138
case RecordInterface::RECORD_STATE_MOVED_AND_CHANGED:
136139
$result = $this->replaceFileWithChangedCopy($record, $storage, $logData);

Classes/Features/RedirectsSupport/Domain/Repository/SysRedirectRepository.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,17 @@
3434
use TYPO3\CMS\Core\Database\Connection;
3535
use TYPO3\CMS\Core\Database\ConnectionPool;
3636
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
37+
use TYPO3\CMS\Core\Http\Uri;
3738
use TYPO3\CMS\Core\Utility\GeneralUtility;
3839
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
3940
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
4041
use TYPO3\CMS\Extbase\Persistence\Repository;
4142

4243
class SysRedirectRepository extends Repository
4344
{
45+
/**
46+
* @param array<Uri> $uris
47+
*/
4448
public function findRawByUris(Connection $connection, array $uris, array $exceptUid): array
4549
{
4650
$query = $connection->createQueryBuilder();
@@ -49,13 +53,18 @@ public function findRawByUris(Connection $connection, array $uris, array $except
4953
$predicates = [];
5054

5155
foreach ($uris as $uri) {
56+
$target = $uri->getPath();
57+
$queryPart = $uri->getQuery();
58+
if (!empty($queryPart)) {
59+
$target .= '?' . $queryPart;
60+
}
5261
if ($uri->getHost() === '*') {
5362
// If the "parent" redirect does not have a host it does not matter which host the redirect has, which
5463
// redirects to the host-less redirect. It just belongs.
55-
$predicates[] = $query->expr()->eq('target', $query->createNamedParameter($uri->getPath()));
64+
$predicates[] = $query->expr()->eq('target', $query->createNamedParameter($target));
5665
} else {
5766
$predicates[] = $query->expr()->andX(
58-
$query->expr()->eq('target', $query->createNamedParameter($uri->getPath())),
67+
$query->expr()->eq('target', $query->createNamedParameter($target)),
5968
$query->expr()->orX(
6069
$query->expr()->eq('source_host', $query->createNamedParameter($uri->getHost())),
6170
$query->expr()->eq('source_host', $query->createNamedParameter('*'))

Classes/Features/RedirectsSupport/PageRecordRedirectEnhancer.php

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ protected function findRedirectsByDynamicTarget(RecordInterface $record): array
141141
return $collected;
142142
}
143143

144+
/**
145+
* @param array<Uri> $uris
146+
* @param array<int, array{local?: array, foreign?: array}> $collected
147+
*/
144148
protected function collectRedirectsByUri(array $uris, array $collected, string $side, Connection $connection): array
145149
{
146150
$newRows = $this->repo->findRawByUris($connection, $uris, array_keys($collected));
@@ -152,9 +156,7 @@ protected function collectRedirectsByUri(array $uris, array $collected, string $
152156
$newUris = [];
153157
foreach ($newRows as $row) {
154158
$collected[$row['uid']][$side] = $row;
155-
$newUris[$row['uid']] = (new Uri())
156-
->withHost($row['source_host'] ?? '')
157-
->withPath($row['source_path'] ?? '');
159+
$newUris[$row['uid']] = $this->rowToUri($row);
158160
}
159161

160162
return $this->collectRedirectsByUri($newUris, $collected, $side, $connection);
@@ -193,6 +195,9 @@ protected function assignRedirects(Connection $connection, array $uids, int $pid
193195
->execute();
194196
}
195197

198+
/**
199+
* @param array<int, array{local?: array, foreign?: array}> $redirects
200+
*/
196201
protected function findMissingRowsByUid(array $redirects): array
197202
{
198203
$missingRows = ['local' => [], 'foreign' => []];
@@ -229,14 +234,10 @@ protected function findRedirectsByUri(RecordInterface $record): array
229234
$redirects = $this->getExistingRedirects($record);
230235
foreach ($redirects as $redirect) {
231236
if (!empty($redirect['local'])) {
232-
$row = $redirect['local'];
233-
$basicUris[] = (new Uri())->withHost($row['source_host'] ?? '')
234-
->withPath($row['source_path'] ?? '');
237+
$basicUris[] = $this->rowToUri($redirect['local']);
235238
}
236239
if (!empty($redirect['foreign'])) {
237-
$row = $redirect['foreign'];
238-
$basicUris[] = (new Uri())->withHost($row['source_host'] ?? '')
239-
->withPath($row['source_path'] ?? '');
240+
$basicUris[] = $this->rowToUri($redirect['foreign']);
240241
}
241242
}
242243

@@ -291,7 +292,9 @@ protected function createAndAddRecordsToRecord(RecordInterface $record, array $r
291292
}
292293
}
293294

294-
/** @return array<int, RecordInterface> */
295+
/**
296+
* @return array<int, array{local?: array, foreign?: array}>
297+
*/
295298
protected function getExistingRedirects(RecordInterface $record): array
296299
{
297300
$redirects = [];
@@ -302,10 +305,24 @@ protected function getExistingRedirects(RecordInterface $record): array
302305
$row['local'] = $redirectRecord->getLocalProperties();
303306
}
304307
if ($redirectRecord->foreignRecordExists()) {
305-
$row['local'] = $redirectRecord->getForeignProperties();
308+
$row['foreign'] = $redirectRecord->getForeignProperties();
306309
}
307310
$redirects[$redirectRecord->getIdentifier()] = $row;
308311
}
309312
return $redirects;
310313
}
314+
315+
/**
316+
* @param array{source_path?: string, source_host?: string} $row
317+
* @noinspection PhpRedundantDocCommentInspection
318+
* @noinspection RedundantSuppression
319+
*/
320+
protected function rowToUri(array $row): Uri
321+
{
322+
$uri = new Uri($row['source_path'] ?? '');
323+
if (!empty($row['source_host'])) {
324+
$uri = $uri->withHost($row['source_host']);
325+
}
326+
return $uri;
327+
}
311328
}

Classes/Features/SystemInformationExport/Exporter/LogsExporter.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@
3232
use TYPO3\CMS\Core\Database\ConnectionPool;
3333

3434
use function json_decode;
35+
use function json_last_error;
3536
use function sprintf;
3637
use function strftime;
3738
use function substr;
3839

40+
use const JSON_ERROR_NONE;
41+
3942
class LogsExporter implements SystemInformationExporter
4043
{
4144
/** @var ConnectionPool */
@@ -74,6 +77,9 @@ public function getInformation(): array
7477
$logData = $log['data'];
7578
$logDataJson = substr($logData, 2);
7679
$logsFormatted[$message] = json_decode($logDataJson, true);
80+
if (json_last_error() !== JSON_ERROR_NONE) {
81+
$logsFormatted[$message] = $logData;
82+
}
7783
}
7884
return $logsFormatted;
7985
}

ext_emconf.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
'title' => 'in2publish Core',
1010
'description' => 'Content publishing extension to connect stage and production server',
1111
'category' => 'plugin',
12-
'version' => '10.2.5',
12+
'version' => '10.2.6',
1313
'state' => 'stable',
1414
'uploadfolder' => 0,
1515
'createDirs' => '',

0 commit comments

Comments
 (0)