Skip to content

Commit 64b721e

Browse files
committed
[RELEASE] Version 9.0.1 with stability improvements
2 parents 48c0521 + 77634df commit 64b721e

13 files changed

+566
-15
lines changed

CHANGELOG.md

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

3+
9.0.1:
4+
5+
- [META] Set the EM conf version number to 9.0.1
6+
- [BUGFIX] Add page records to pages again
7+
- [BUGFIX] Add missing type hints for BackendUtility::getDomainFromPageIdentifier
8+
- [BUGFIX] Pass properties to be merged as strings to string functions
9+
- [BUGFIX] Ensure the returned uid of a sent envelope is always an int
10+
- [FEATURE] Add performance tests
11+
- [RELEASE] Version 9.0.0 with TYPO3 v10 compatiblity
12+
313
9.0.0:
414

515
- [META] Set the stability to stable

Classes/Communication/RemoteProcedureCall/Letterbox.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function sendEnvelope(Envelope $envelope)
9191
if (0 === $uid || 0 === $database->count('uid', static::TABLE, ['uid' => $uid])) {
9292
if (1 === $database->insert(static::TABLE, $envelope->toArray())) {
9393
if ($uid <= 0) {
94-
$uid = $database->lastInsertId();
94+
$uid = (int)$database->lastInsertId();
9595
$envelope->setUid($uid);
9696
}
9797
return $uid;

Classes/Domain/Model/Record.php

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -618,9 +618,11 @@ public function addRelatedRecord(RecordInterface $record)
618618
{
619619
if ($record->localRecordExists() || $record->foreignRecordExists()) {
620620
if (!$record->isParentRecordLocked()) {
621-
if ($this->tableName !== 'pages'
622-
|| $record->getTableName() !== 'pages'
623-
|| $record->getPageIdentifier() === $this->getPageIdentifier()
621+
// If both records are from 'pages' the added record must be directly attached to this record by `pid`.
622+
// Ignore the foreign `pid`. It differs only when the record was moved but the record will be shown
623+
// beneath its new parent anyway.
624+
if (!($this->isPagesTable() && $record->isPagesTable())
625+
|| $record->getSuperordinatePageIdentifier() === $this->getIdentifier()
624626
) {
625627
if (!$this->isParentDisabled) {
626628
$record->setParentRecord($this);
@@ -798,17 +800,20 @@ public function getMergedProperty($propertyName)
798800
if (is_array($localValue) || is_array($foreignValue)) {
799801
$value = array_merge((array)$localValue, (array)$foreignValue);
800802
} elseif (is_string($localValue) || is_string($foreignValue)) {
801-
if (strpos($localValue, ',') !== false || strpos($foreignValue, ',') !== false) {
802-
$localValueArray = explode(',', $localValue);
803-
$foreignValueArray = explode(',', $foreignValue);
803+
$localString = (string)$localValue;
804+
$foreignString = (string)$foreignValue;
805+
806+
if (strpos($localString, ',') !== false || strpos($foreignString, ',') !== false) {
807+
$localValueArray = explode(',', $localString);
808+
$foreignValueArray = explode(',', $foreignString);
804809
$value = implode(',', array_filter(array_merge($localValueArray, $foreignValueArray)));
805-
} elseif ($localValue === '0' && $foreignValue !== '0') {
810+
} elseif ($localString === '0' && $foreignString !== '0') {
806811
$value = $foreignValue;
807-
} elseif ($localValue !== '0' && $foreignValue === '0') {
812+
} elseif ($localString !== '0' && $foreignString === '0') {
808813
$value = $localValue;
809-
} elseif (strlen($localValue) > 0 && strlen($foreignValue) > 0) {
810-
$value = implode(',', [$localValue, $foreignValue]);
811-
} elseif (!$localValue && $foreignValue) {
814+
} elseif (strlen($localString) > 0 && strlen($foreignString) > 0) {
815+
$value = implode(',', [$localString, $foreignString]);
816+
} elseif (!$localString && $foreignString) {
812817
$value = $foreignValue;
813818
} else {
814819
$value = $localValue;
@@ -1165,6 +1170,22 @@ public function getPageIdentifier(): int
11651170
return 0;
11661171
}
11671172

1173+
/**
1174+
* @return int
1175+
*/
1176+
public function getSuperordinatePageIdentifier(): int
1177+
{
1178+
if ($this->isPagesTable() && $this->isTranslation()) {
1179+
return $this->getL10nParentIdentifier() ?? 0;
1180+
}
1181+
if ($this->hasLocalProperty('pid')) {
1182+
return (int)$this->getLocalProperty('pid');
1183+
} elseif ($this->hasForeignProperty('pid')) {
1184+
return (int)$this->getForeignProperty('pid');
1185+
}
1186+
return 0;
1187+
}
1188+
11681189
protected function getL10nParentIdentifier(): ?int
11691190
{
11701191
if ($this->isTranslation()) {

Classes/Domain/Model/RecordInterface.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,4 +348,14 @@ public function lockParentRecord();
348348
* @return int
349349
*/
350350
public function getPageIdentifier(): int;
351+
352+
/**
353+
* Returns the uid of the record this record is attached to:
354+
* * Record is a default language page: pid
355+
* * Record is a translated page: l10n_parent
356+
* * Record is not a page: pid
357+
*
358+
* @return int
359+
*/
360+
public function getSuperordinatePageIdentifier(): int;
351361
}

Classes/Domain/Service/DomainService.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,11 @@ protected function getFirstDomainInRootLineFromRelatedRecords(RecordInterface $r
196196
*
197197
* @SuppressWarnings(PHPMD.StaticAccess)
198198
*/
199-
public function getDomainFromPageIdentifier($identifier, $stagingLevel, bool $addProtocol = false): string
200-
{
199+
public function getDomainFromPageIdentifier(
200+
int $identifier,
201+
string $stagingLevel,
202+
bool $addProtocol = false
203+
): string {
201204
trigger_error(sprintf(static::DEPRECATION_METHOD, __METHOD__), E_USER_DEPRECATED);
202205
if (0 === $identifier) {
203206
return '';

Classes/Testing/Tests/Application/AbstractDomainTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,31 @@
44

55
namespace In2code\In2publishCore\Testing\Tests\Application;
66

7+
/*
8+
* Copyright notice
9+
*
10+
* (c) 2020 in2code.de and the following authors:
11+
* Oliver Eglseder <[email protected]>
12+
*
13+
* All rights reserved
14+
*
15+
* This script is part of the TYPO3 project. The TYPO3 project is
16+
* free software; you can redistribute it and/or modify
17+
* it under the terms of the GNU General Public License as published by
18+
* the Free Software Foundation; either version 3 of the License, or
19+
* (at your option) any later version.
20+
*
21+
* The GNU General Public License can be found at
22+
* http://www.gnu.org/copyleft/gpl.html.
23+
*
24+
* This script is distributed in the hope that it will be useful,
25+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
26+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27+
* GNU General Public License for more details.
28+
*
29+
* This copyright notice MUST APPEAR in all copies of the script!
30+
*/
31+
732
use Doctrine\DBAL\Driver\Statement;
833
use Exception;
934
use In2code\In2publishCore\Testing\Tests\TestResult;
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace In2code\In2publishCore\Testing\Tests\Performance;
6+
7+
/*
8+
* Copyright notice
9+
*
10+
* (c) 2020 in2code.de and the following authors:
11+
* Oliver Eglseder <[email protected]>
12+
*
13+
* All rights reserved
14+
*
15+
* This script is part of the TYPO3 project. The TYPO3 project is
16+
* free software; you can redistribute it and/or modify
17+
* it under the terms of the GNU General Public License as published by
18+
* the Free Software Foundation; either version 3 of the License, or
19+
* (at your option) any later version.
20+
*
21+
* The GNU General Public License can be found at
22+
* http://www.gnu.org/copyleft/gpl.html.
23+
*
24+
* This script is distributed in the hope that it will be useful,
25+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
26+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27+
* GNU General Public License for more details.
28+
*
29+
* This copyright notice MUST APPEAR in all copies of the script!
30+
*/
31+
32+
use In2code\In2publishCore\Testing\Tests\TestCaseInterface;
33+
use In2code\In2publishCore\Testing\Tests\TestResult;
34+
use TYPO3\CMS\Core\Utility\GeneralUtility;
35+
36+
use function array_unshift;
37+
use function fclose;
38+
use function fgets;
39+
use function fopen;
40+
use function function_exists;
41+
use function fwrite;
42+
use function microtime;
43+
use function random_bytes;
44+
use function register_shutdown_function;
45+
use function unlink;
46+
use function xdebug_is_enabled;
47+
48+
class DiskSpeedPerformanceTest implements TestCaseInterface
49+
{
50+
protected const THRESHOLD = [
51+
'read' => [
52+
TestResult::OK => 0.03,
53+
TestResult::WARNING => 0.04,
54+
],
55+
'write' => [
56+
TestResult::OK => 0.06,
57+
TestResult::WARNING => 0.08,
58+
],
59+
];
60+
61+
public function run(): TestResult
62+
{
63+
$canaryFile = GeneralUtility::tempnam('tx_contentpublisher_test_');
64+
register_shutdown_function(
65+
function () use ($canaryFile) {
66+
unlink($canaryFile);
67+
}
68+
);
69+
$targetFile = GeneralUtility::tempnam('tx_contentpublisher_test_');
70+
register_shutdown_function(
71+
function () use ($targetFile) {
72+
unlink($targetFile);
73+
}
74+
);
75+
76+
$canaryTarget = fopen($canaryFile, 'w');
77+
for ($i = 0; $i < 10; $i++) {
78+
$bytes = random_bytes(1024 * 1024);
79+
fwrite($canaryTarget, $bytes);
80+
}
81+
fclose($canaryTarget);
82+
83+
// Read speed
84+
$canaryTarget = fopen($canaryFile, 'r');
85+
$start = microtime(true);
86+
while (fgets($canaryTarget, 1024)) {
87+
// Do nothing with the read content
88+
}
89+
$readTime = microtime(true) - $start;
90+
fclose($canaryTarget);
91+
92+
// Write speed
93+
$canarySource = fopen($canaryFile, 'r');
94+
$canaryTarget = fopen($targetFile, 'w');
95+
$start = microtime(true);
96+
while ($bytes = fgets($canarySource, 1024)) {
97+
fwrite($canaryTarget, $bytes);
98+
}
99+
$readAndWriteTime = microtime(true) - $start;
100+
$writeTime = $readAndWriteTime - $readTime;
101+
102+
$messages[] = 'Read: ' . $readTime . ' msec';
103+
$messages[] = 'Write: ' . $writeTime . ' msec';
104+
105+
$severity = TestResult::ERROR;
106+
if ($readTime < self::THRESHOLD['read'][TestResult::OK]) {
107+
$severity = TestResult::OK;
108+
} elseif ($readTime < self::THRESHOLD['read'][TestResult::WARNING]) {
109+
$severity = TestResult::WARNING;
110+
}
111+
if ($severity === TestResult::OK) {
112+
if ($writeTime < self::THRESHOLD['write'][TestResult::OK]) {
113+
$severity = TestResult::OK;
114+
} elseif ($writeTime < self::THRESHOLD['write'][TestResult::WARNING]) {
115+
$severity = TestResult::WARNING;
116+
} elseif ($writeTime >= self::THRESHOLD['write'][TestResult::WARNING]) {
117+
$severity = TestResult::ERROR;
118+
}
119+
}
120+
if ($severity !== TestResult::OK) {
121+
array_unshift($messages, 'performance.fs_io.slow_help');
122+
}
123+
if (function_exists('xdebug_is_enabled') && xdebug_is_enabled()) {
124+
$severity = TestResult::WARNING;
125+
array_unshift($messages, 'performance.fs_io.xdebug_enabled');
126+
}
127+
128+
return new TestResult(
129+
'performance.fs_io.rw_time',
130+
$severity,
131+
$messages,
132+
[(string)$readAndWriteTime]
133+
);
134+
}
135+
136+
public function getDependencies(): array
137+
{
138+
return [];
139+
}
140+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace In2code\In2publishCore\Testing\Tests\Performance;
6+
7+
/*
8+
* Copyright notice
9+
*
10+
* (c) 2020 in2code.de and the following authors:
11+
* Oliver Eglseder <[email protected]>
12+
*
13+
* All rights reserved
14+
*
15+
* This script is part of the TYPO3 project. The TYPO3 project is
16+
* free software; you can redistribute it and/or modify
17+
* it under the terms of the GNU General Public License as published by
18+
* the Free Software Foundation; either version 3 of the License, or
19+
* (at your option) any later version.
20+
*
21+
* The GNU General Public License can be found at
22+
* http://www.gnu.org/copyleft/gpl.html.
23+
*
24+
* This script is distributed in the hope that it will be useful,
25+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
26+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27+
* GNU General Public License for more details.
28+
*
29+
* This copyright notice MUST APPEAR in all copies of the script!
30+
*/
31+
32+
use In2code\In2publishCore\Testing\Tests\Application\ForeignDatabaseConfigTest;
33+
use In2code\In2publishCore\Testing\Tests\TestCaseInterface;
34+
use In2code\In2publishCore\Testing\Tests\TestResult;
35+
use In2code\In2publishCore\Utility\DatabaseUtility;
36+
use ReflectionProperty;
37+
38+
use function array_sum;
39+
use function array_unshift;
40+
use function count;
41+
use function function_exists;
42+
use function microtime;
43+
use function sort;
44+
use function xdebug_is_enabled;
45+
46+
class ForeignDbInitializationPerformanceTest implements TestCaseInterface
47+
{
48+
protected const THRESHOLD = [
49+
TestResult::OK => 1200,
50+
TestResult::WARNING => 1900,
51+
];
52+
53+
public function run(): TestResult
54+
{
55+
$reflectionProperty = new ReflectionProperty(DatabaseUtility::class, 'foreignConnection');
56+
$reflectionProperty->setAccessible(true);
57+
58+
$times = [];
59+
60+
for ($i = 0; $i < 10; $i++) {
61+
$start = microtime(true);
62+
63+
$reflectionProperty->setValue(null);
64+
DatabaseUtility::buildForeignDatabaseConnection();
65+
66+
$times[] = (int)((microtime(true) - $start) * 1000000);
67+
}
68+
69+
$median = (array_sum($times) / count($times));
70+
$messages = [];
71+
sort($times);
72+
$messages[] = 'Fastest: ' . $times[0] . ' msec';
73+
$messages[] = 'Slowest: ' . $times[9] . ' msec';
74+
75+
$severity = TestResult::ERROR;
76+
if ($median < self::THRESHOLD[TestResult::OK]) {
77+
$severity = TestResult::OK;
78+
} elseif ($median < self::THRESHOLD[TestResult::WARNING]) {
79+
$severity = TestResult::WARNING;
80+
}
81+
if ($severity !== TestResult::OK) {
82+
array_unshift($messages, 'performance.db_init.slow_help');
83+
}
84+
if (function_exists('xdebug_is_enabled') && xdebug_is_enabled()) {
85+
$severity = TestResult::WARNING;
86+
array_unshift($messages, 'performance.db_init.xdebug_enabled');
87+
}
88+
89+
return new TestResult(
90+
'performance.db_init.init_time',
91+
$severity,
92+
$messages,
93+
[(string)$median]
94+
);
95+
}
96+
97+
public function getDependencies(): array
98+
{
99+
return [
100+
ForeignDatabaseConfigTest::class,
101+
];
102+
}
103+
}

0 commit comments

Comments
 (0)