Skip to content

Commit d03c582

Browse files
committed
Merge tag '2.4.1'
Hotfix release 2.4.1 - Fix tree picker at parent view
2 parents d0f21ee + 6b2846f commit d03c582

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

src/BaseConfigRegistry.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ private function addParentFilter(ModelIdInterface $idParent, ConfigInterface $co
148148
* @param ModelIdInterface|null $parentId The parent to use.
149149
*
150150
* @return ConfigInterface
151+
*
152+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
151153
*/
152154
private function buildBaseConfig(?ModelIdInterface $parentId): ConfigInterface
153155
{
@@ -165,7 +167,7 @@ private function buildBaseConfig(?ModelIdInterface $parentId): ConfigInterface
165167
$additional = $definition->getBasicDefinition()->getAdditionalFilter();
166168

167169
// Custom filter common for all modes.
168-
if (\is_array($additional)) {
170+
if (\is_array($additional) && [] !== $additional) {
169171
$config->setFilter($additional);
170172
}
171173

@@ -184,10 +186,11 @@ private function buildBaseConfig(?ModelIdInterface $parentId): ConfigInterface
184186
if (null === $input) {
185187
throw new DcGeneralRuntimeException('Input provider not set.');
186188
}
187-
$pid = $input->getParameter('pid');
188-
$pidDetails = ModelId::fromSerialized($pid);
189-
190-
$this->addParentFilter($pidDetails, $config);
189+
$pid = $input->getParameter('pid');
190+
if (null !== $pid) {
191+
$pidDetails = ModelId::fromSerialized($pid);
192+
$this->addParentFilter($pidDetails, $config);
193+
}
191194
}
192195

193196
return $config;

src/Contao/View/Contao2BackendView/TreePicker.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,17 @@ public function formatModel(ModelInterface $model, $treeMode = true)
14331433
$arguments = [];
14341434
foreach ($formatter->getPropertyNames() as $propertyName) {
14351435
if ($properties->hasProperty($propertyName)) {
1436-
$arguments[$propertyName] = (string) $model->getProperty($propertyName);
1436+
$propertyValue = $model->getProperty($propertyName);
1437+
/** @psalm-suppress RedundantCast */
1438+
$arguments[$propertyName] = match (true) {
1439+
\is_bool($propertyValue),
1440+
\is_int($propertyValue),
1441+
\is_float($propertyValue),
1442+
\is_string($propertyValue),
1443+
=> (string) $propertyValue,
1444+
1445+
default => '-'
1446+
};
14371447
} else {
14381448
$arguments[$propertyName] = '-';
14391449
}
@@ -1490,7 +1500,7 @@ private function prepareLabelWithDisplayedProperties(
14901500
$labelList[] = [
14911501
'colspan' => 1,
14921502
'class' => 'tl_file_list col_' . $j . (($propertyName === $firstSorting) ? ' ordered_by' : ''),
1493-
'content' => ('' !== $arguments[$propertyName]) ? $arguments[$propertyName] : '-'
1503+
'content' => ('' !== ($arguments[$propertyName] ?? '')) ? $arguments[$propertyName] : '-'
14941504
];
14951505
}
14961506
}

0 commit comments

Comments
 (0)