Skip to content

Commit 58b05b1

Browse files
authored
Merge branch '4.6' into IBX-10116_ibexa_render_does_not_use_decorated_fragment_renders
2 parents 284fad4 + d24854c commit 58b05b1

File tree

14 files changed

+213
-23
lines changed

14 files changed

+213
-23
lines changed

phpstan-baseline-7.4.neon

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,18 @@ parameters:
528528
count: 3
529529
path: tests/integration/Core/Repository/RoleServiceTest.php
530530

531+
-
532+
message: '#^Parameter \#1 \$class of class ReflectionProperty constructor expects object\|string, class\-string\|false given\.$#'
533+
identifier: argument.type
534+
count: 4
535+
path: tests/integration/Core/Repository/SearchServiceLocationTest.php
536+
537+
-
538+
message: '#^Parameter \#1 \$class of class ReflectionProperty constructor expects object\|string, class\-string\|false given\.$#'
539+
identifier: argument.type
540+
count: 4
541+
path: tests/integration/Core/Repository/SearchServiceTest.php
542+
531543
-
532544
message: '#^Parameter \#1 \$str of function md5 expects string, int\<1, max\> given\.$#'
533545
identifier: argument.type

phpstan-baseline.neon

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,6 @@ parameters:
342342
count: 1
343343
path: src/bundle/Core/Command/ReindexCommand.php
344344

345-
-
346-
message: '#^Parameter \#2 \$subject of function preg_match expects string, string\|false given\.$#'
347-
identifier: argument.type
348-
count: 1
349-
path: src/bundle/Core/Command/ReindexCommand.php
350-
351345
-
352346
message: '#^Parameter \#2 \$subject of function preg_match_all expects string, string\|false given\.$#'
353347
identifier: argument.type
@@ -2556,12 +2550,6 @@ parameters:
25562550
count: 1
25572551
path: src/bundle/Core/EventListener/PreviewRequestListener.php
25582552

2559-
-
2560-
message: '#^Method Ibexa\\Bundle\\Core\\EventListener\\RejectExplicitFrontControllerRequestsListener\:\:onKernelRequest\(\) has no return type specified\.$#'
2561-
identifier: missingType.return
2562-
count: 1
2563-
path: src/bundle/Core/EventListener/RejectExplicitFrontControllerRequestsListener.php
2564-
25652553
-
25662554
message: '#^Method Ibexa\\Bundle\\Core\\EventListener\\RequestEventListener\:\:__construct\(\) has parameter \$defaultSiteAccess with no type specified\.$#'
25672555
identifier: missingType.parameter

src/bundle/Core/DependencyInjection/IbexaCoreExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,12 +861,12 @@ private function configurePlatformShSetup(ContainerBuilder $container): void
861861
$container->setParameter(
862862
'dfs_database_url',
863863
sprintf(
864-
'%s://%s:%s:%d@%s/%s',
864+
'%s://%s:%s@%s:%d/%s',
865865
$endpoint['scheme'],
866866
$endpoint['username'],
867867
$endpoint['password'],
868-
$endpoint['port'],
869868
$endpoint['host'],
869+
$endpoint['port'],
870870
$endpoint['path']
871871
)
872872
);

src/bundle/Core/EventListener/RejectExplicitFrontControllerRequestsListener.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,25 @@ public static function getSubscribedEvents(): array
2828
];
2929
}
3030

31-
public function onKernelRequest(RequestEvent $event)
31+
public function onKernelRequest(RequestEvent $event): void
3232
{
33-
if ($event->getRequestType() !== HttpKernelInterface::MASTER_REQUEST) {
33+
if ($event->getRequestType() !== HttpKernelInterface::MAIN_REQUEST) {
3434
return;
3535
}
3636

3737
$request = $event->getRequest();
3838

3939
// Not every symfony runtime provides SCRIPT_FILENAME
40-
if (!$request->server->has('SCRIPT_FILENAME')) {
40+
if (
41+
!$request->server->has('SCRIPT_FILENAME')
42+
|| empty($scriptFileName = $request->server->get('SCRIPT_FILENAME'))
43+
) {
4144
return;
4245
}
4346

44-
$scriptFileName = preg_quote(basename($request->server->get('SCRIPT_FILENAME')), '\\');
47+
$scriptFileName = preg_quote(basename($scriptFileName), '\\');
4548
// This pattern has to match with vhost.template files in meta repository
46-
$pattern = sprintf('<^/([^/]+/)?%s([/?#]|$)>', $scriptFileName);
49+
$pattern = sprintf('<^/([^/]+/)*?%s([/?#]|$)>', $scriptFileName);
4750

4851
if (1 === preg_match($pattern, $request->getRequestUri())) {
4952
// Trigger generic 404 error to avoid leaking backend technology details.

src/lib/FieldType/MapLocation/MapLocationStorage/Gateway/DoctrineStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function getFieldData(VersionInfo $versionInfo, Field $field)
146146
* @param int $fieldId
147147
* @param int $versionNo
148148
*
149-
* @return array|null
149+
* @return array|\ArrayAccess<string, float>|null
150150
*/
151151
protected function loadFieldData($fieldId, $versionNo)
152152
{

src/lib/Notification/Renderer/Registry.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,22 @@ public function hasRenderer(string $alias): bool
4141
{
4242
return isset($this->registry[$alias]);
4343
}
44+
45+
/**
46+
* @return array<string, string>
47+
*/
48+
public function getTypeLabels(): array
49+
{
50+
$labels = [];
51+
foreach ($this->registry as $type => $renderer) {
52+
if ($renderer instanceof TypedNotificationRendererInterface) {
53+
$labels[$type] = $renderer->getTypeLabel();
54+
}
55+
}
56+
ksort($labels);
57+
58+
return $labels;
59+
}
4460
}
4561

4662
class_alias(Registry::class, 'eZ\Publish\Core\Notification\Renderer\Registry');
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Ibexa\Core\Notification\Renderer;
10+
11+
interface TypedNotificationRendererInterface
12+
{
13+
public function getTypeLabel(): string;
14+
}

src/lib/Persistence/Legacy/Content/UrlAlias/Handler.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ class Handler implements UrlAliasHandlerInterface
4646
*/
4747
public const MAX_URL_ALIAS_DEPTH_LEVEL = 60;
4848

49+
/**
50+
* Match url alias id in form of `<parentId>-<textMD5>`.
51+
*
52+
* @var string
53+
*/
54+
public const URL_ALIAS_ID_PATTERN = '/^\d+-[a-f0-9]{32}$/';
55+
4956
/**
5057
* UrlAlias Gateway.
5158
*
@@ -620,6 +627,10 @@ public function lookup($url)
620627
*/
621628
public function loadUrlAlias($id)
622629
{
630+
if (!preg_match(self::URL_ALIAS_ID_PATTERN, $id)) {
631+
throw new NotFoundException('URLAlias', $id);
632+
}
633+
623634
list($parentId, $textMD5) = explode('-', $id);
624635
$data = $this->gateway->loadRow((int)$parentId, $textMD5);
625636

src/lib/Repository/Helper/RelationProcessor.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,11 @@ public function processFieldRelations(
145145
if ($relationType === Relation::FIELD || $relationType === Relation::ASSET) {
146146
foreach ($relationData as $fieldDefinitionId => $contentIds) {
147147
foreach (array_keys($contentIds) as $destinationContentId) {
148-
if (isset($mappedRelations[$relationType][$fieldDefinitionId][$destinationContentId])) {
148+
if (
149+
isset($mappedRelations[$relationType][$fieldDefinitionId]) &&
150+
is_array($mappedRelations[$relationType][$fieldDefinitionId]) &&
151+
isset($mappedRelations[$relationType][$fieldDefinitionId][$destinationContentId])
152+
) {
149153
unset($mappedRelations[$relationType][$fieldDefinitionId][$destinationContentId]);
150154
} else {
151155
$this->persistenceHandler->contentHandler()->addRelation(

tests/bundle/Core/DependencyInjection/IbexaCoreExtensionTest.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,51 @@ public function testLoadsTestServicesWhenParameterIsSpecified(): void
910910
$this->assertContainerBuilderHasService(QueryControllerContext::class);
911911
}
912912

913+
/**
914+
* @throws \JsonException
915+
*/
916+
public function testConfigurePlatformShDFS(): void
917+
{
918+
$dsn = 'mysql://dfs:dfs@localhost:3306/dfs';
919+
$parts = parse_url($dsn);
920+
921+
$relationship = [
922+
'dfs_database' => [
923+
[
924+
'host' => $parts['host'],
925+
'scheme' => $parts['scheme'],
926+
'username' => $parts['user'],
927+
'password' => $parts['pass'],
928+
'port' => $parts['port'],
929+
'path' => ltrim($parts['path'], '/'),
930+
'query' => [
931+
'is_master' => true,
932+
],
933+
],
934+
],
935+
];
936+
937+
$_SERVER['PLATFORM_RELATIONSHIPS'] = base64_encode(json_encode($relationship, JSON_THROW_ON_ERROR));
938+
$_SERVER['PLATFORMSH_DFS_NFS_PATH'] = '/';
939+
$_SERVER['PLATFORM_ROUTES'] = base64_encode(json_encode([], JSON_THROW_ON_ERROR));
940+
$_SERVER['PLATFORM_PROJECT_ENTROPY'] = '';
941+
942+
$this->container->setParameter('database_charset', 'utf8mb4');
943+
$this->container->setParameter('database_collation', 'utf8mb4_general_ci');
944+
$this->container->setParameter('kernel.project_dir', __DIR__ . '/../Resources');
945+
$this->load();
946+
947+
$this->assertContainerBuilderHasParameter('dfs_database_url');
948+
self::assertEquals($dsn, $this->container->getParameter('dfs_database_url'));
949+
950+
unset(
951+
$_SERVER['PLATFORM_RELATIONSHIPS'],
952+
$_SERVER['PLATFORMSH_DFS_NFS_PATH'],
953+
$_SERVER['PLATFORM_ROUTES'],
954+
$_SERVER['PLATFORM_PROJECT_ENTROPY']
955+
);
956+
}
957+
913958
/**
914959
* Prepare Core Container for compilation by mocking required parameters and compile it.
915960
*/

0 commit comments

Comments
 (0)