Skip to content

Commit 1305bc4

Browse files
committed
fixed import of old game exports
1 parent c4b79d4 commit 1305bc4

File tree

12 files changed

+135
-21
lines changed

12 files changed

+135
-21
lines changed

composer.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

composer.patches.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
22
"patches": {
3+
"drupal/hal": {
4+
"2904423 - Translated field denormalization creates duplicate values": "https://www.drupal.org/files/issues/2023-04-05/2904423-90.patch",
5+
"3517446 - Cached relation IDs are broken": "https://www.drupal.org/files/issues/2025-04-04/3517446.patch"
6+
}
37
}
48
}

vendor/composer/installed.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,7 +1524,7 @@
15241524
"source": {
15251525
"type": "git",
15261526
"url": "https://git.drupalcode.org/project/default_content_deploy.git",
1527-
"reference": "f4f8a6fccee4f9619f21d89972078e702865f58d"
1527+
"reference": "d52cf833263a24d10cfff2d0e34bdcd3d9ace8b9"
15281528
},
15291529
"require": {
15301530
"drupal/core": "^10.3 || ^11.0",
@@ -1546,8 +1546,8 @@
15461546
"dev-2.2.x": "2.2.x-dev"
15471547
},
15481548
"drupal": {
1549-
"version": "2.2.0-beta1+3-dev",
1550-
"datestamp": "1745834090",
1549+
"version": "2.2.0-beta2+2-dev",
1550+
"datestamp": "1747149066",
15511551
"security-coverage": {
15521552
"status": "not-covered",
15531553
"message": "Dev releases are not covered by Drupal security advisories."
@@ -1618,6 +1618,10 @@
16181618
"status": "covered",
16191619
"message": "Covered by Drupal's security advisory policy"
16201620
}
1621+
},
1622+
"patches_applied": {
1623+
"2904423 - Translated field denormalization creates duplicate values": "https://www.drupal.org/files/issues/2023-04-05/2904423-90.patch",
1624+
"3517446 - Cached relation IDs are broken": "https://www.drupal.org/files/issues/2025-04-04/3517446.patch"
16211625
}
16221626
},
16231627
"installation-source": "dist",

vendor/composer/installed.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
'name' => 'ppuc/web',
44
'pretty_version' => 'dev-main',
55
'version' => 'dev-main',
6-
'reference' => '6c3dd4f39ab1b04a4e47a3ae876d48ae45b1ad44',
6+
'reference' => 'c4b79d418d0b5e28049fddb758884e2dab6a79b2',
77
'type' => 'project',
88
'install_path' => __DIR__ . '/../../',
99
'aliases' => array(),
@@ -346,7 +346,7 @@
346346
'drupal/default_content_deploy' => array(
347347
'pretty_version' => 'dev-2.2.x',
348348
'version' => 'dev-2.2.x',
349-
'reference' => 'f4f8a6fccee4f9619f21d89972078e702865f58d',
349+
'reference' => 'd52cf833263a24d10cfff2d0e34bdcd3d9ace8b9',
350350
'type' => 'drupal-module',
351351
'install_path' => __DIR__ . '/../../web/modules/contrib/default_content_deploy',
352352
'aliases' => array(
@@ -579,7 +579,7 @@
579579
'ppuc/web' => array(
580580
'pretty_version' => 'dev-main',
581581
'version' => 'dev-main',
582-
'reference' => '6c3dd4f39ab1b04a4e47a3ae876d48ae45b1ad44',
582+
'reference' => 'c4b79d418d0b5e28049fddb758884e2dab6a79b2',
583583
'type' => 'project',
584584
'install_path' => __DIR__ . '/../../',
585585
'aliases' => array(),

web/modules/contrib/default_content_deploy/src/Importer.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -760,9 +760,11 @@ public function decodeFile(object $file): void {
760760
// Get parsed data.
761761
$parsed_data = file_get_contents($file->uri);
762762
// Backward compatibility for exports before 2.2.x.
763-
$parsed_data = preg_replace('@"href": "http[^"]+/rest\\\\/type\\\\/([^"]+)"@', '"href": "$1"', $parsed_data);
764-
$parsed_data = preg_replace('@"http[^"]+/rest\\\\/(relation[^"]+)"@', '"$1"', $parsed_data);
765-
763+
if (preg_match('@"href": "(http[^"]+)/rest\\\\/type\\\\/[^"]+"@', $parsed_data, $matches)) {
764+
$parsed_data = preg_replace('@"href": "http[^"]+/rest\\\\/type\\\\/([^"?]+).*?"@', '"href": "$1"', $parsed_data);
765+
$parsed_data = preg_replace('@"http[^"]+/rest\\\\/(relation[^"?]+).*?"@', '"$1"', $parsed_data);
766+
$parsed_data = preg_replace('@"href": "' . preg_quote($matches[1], '@') . '([^"?]+).*?"@', '"href": "_dcd$1"', $parsed_data);
767+
}
766768
// Decode.
767769
try {
768770
$decode = $this->serializer->decode($parsed_data, 'hal_json');
@@ -777,7 +779,7 @@ public function decodeFile(object $file): void {
777779
}
778780

779781
/**
780-
* Here we can edit data`s value before importing.
782+
* Here we can edit data's value before importing.
781783
*
782784
* @param object $file
783785
* The file object.

web/modules/contrib/default_content_deploy/src/Normalizer/ConfigurableContentEntityNormalizer.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,15 @@ public function denormalize($data, $class, $format = NULL, array $context = []):
168168
unset($data['_dcd_metadata']);
169169
}
170170

171+
if (isset($data['_embedded']) && !$this->metadataService->isCorrectionRequired($data['uuid'][0]['value'])) {
172+
foreach (array_keys($data['_embedded']) as $relation) {
173+
$field_ids = $this->linkManager->getRelationInternalIds($relation, $context);
174+
if (empty($field_ids)) {
175+
$this->metadataService->setCorrectionRequired($data['uuid'][0]['value'], TRUE);
176+
}
177+
}
178+
}
179+
171180
return parent::denormalize($data, $class, $format, $context);
172181
}
173182

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
This file was automatically generated by Composer Patches (https://github.com/cweagans/composer-patches)
2+
Patches applied to this directory:
3+
4+
2904423 - Translated field denormalization creates duplicate values
5+
Source: https://www.drupal.org/files/issues/2023-04-05/2904423-90.patch
6+
7+
8+
3517446 - Cached relation IDs are broken
9+
Source: https://www.drupal.org/files/issues/2025-04-04/3517446.patch
10+
11+

web/modules/contrib/hal/src/LinkManager/LinkManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public function getRelationUri($entity_type, $bundle, $field_name, $context = []
5555
/**
5656
* {@inheritdoc}
5757
*/
58-
public function getRelationInternalIds($relation_uri) {
59-
return $this->relationLinkManager->getRelationInternalIds($relation_uri);
58+
public function getRelationInternalIds($relation_uri, $context = []) {
59+
return $this->relationLinkManager->getRelationInternalIds($relation_uri, $context);
6060
}
6161

6262
/**

web/modules/contrib/hal/src/LinkManager/RelationLinkManagerInterface.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ public function getRelationUri($entity_type, $bundle, $field_name, $context = []
3030
*
3131
* @param string $relation_uri
3232
* Relation URI (or IANA link relation type) to transform into internal IDs.
33+
* @param array $context
34+
* (optional) Optional serializer/normalizer context.
3335
*
3436
* @return array
3537
* Array with keys 'entity_type_id', 'bundle' and 'field_name'.
3638
*/
37-
public function getRelationInternalIds($relation_uri);
39+
public function getRelationInternalIds($relation_uri, $context = []);
3840

3941
}

web/modules/contrib/hal/src/Normalizer/ContentEntityNormalizer.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ public function denormalize($data, $class, $format = NULL, array $context = []):
155155
break;
156156
}
157157
}
158-
// Remove the default langcode so it does not get iterated over below.
159-
unset($data[$default_langcode_key]);
160158
}
161159

162160
if ($entity_type->hasKey('bundle')) {
@@ -179,7 +177,7 @@ public function denormalize($data, $class, $format = NULL, array $context = []):
179177

180178
// Flatten the embedded values.
181179
foreach ($embedded as $relation => $field) {
182-
$field_ids = $this->linkManager->getRelationInternalIds($relation);
180+
$field_ids = $this->linkManager->getRelationInternalIds($relation, $context);
183181
if (!empty($field_ids)) {
184182
$field_name = $field_ids['field_name'];
185183
$data[$field_name] = $field;

0 commit comments

Comments
 (0)