Skip to content

Commit

Permalink
localized-landing-pages: Localized landing pages themed
Browse files Browse the repository at this point in the history
  • Loading branch information
gauravaxl committed Feb 29, 2024
1 parent c0eda5a commit 9fefc13
Show file tree
Hide file tree
Showing 14 changed files with 1,223 additions and 7 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@
"drupal/core": "-p2"
},
"patches": {
"drupal/core": {
"Error after saving node drupal 8.7 issue": "https://www.drupal.org/files/issues/2019-02-11/ignore_width_height_on_untranslatable_field_comparision_2941092_8.patch"
},
"drupal/migrate_plus": {
"XML Parser item_selector does not work properly with predicate": "https://www.drupal.org/files/issues/fix-ignored-predicate-2891964-2.patch"
},
Expand Down
15 changes: 15 additions & 0 deletions docroot/core/lib/Drupal/Core/Field/FieldItemList.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,21 @@ public function equals(FieldItemListInterface $list_to_compare) {
$non_computed_properties = array_filter($property_definitions, function (DataDefinitionInterface $property) {
return !$property->isComputed();
});

// in the specific case where this is an image field (as recognized by the
// array keys) we do not want the width and the height in the comparision
// because these are somehow calculated fields no matter what.
// @see https://www.drupal.org/node/2941092
if (is_array($non_computed_properties)
&& array_key_exists('target_id',$non_computed_properties)
&& array_key_exists('alt',$non_computed_properties)
&& array_key_exists('width',$non_computed_properties)
&& array_key_exists('height',$non_computed_properties)
) {
unset($non_computed_properties['width']);
unset($non_computed_properties['height']);
}

$callback = function (&$value) use ($non_computed_properties) {
if (is_array($value)) {
$value = array_intersect_key($value, $non_computed_properties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ protected function hasSynchronizedPropertyChanges(ContentEntityInterface $entity
return TRUE;
}
foreach ($items as $delta => $item) {
// The width & height properties on image fields should get recomputed
// on save when they are empty so can be ignored.
if (empty($items[$delta][$property]) && in_array($property, ['width', 'height'], TRUE) && $entity->getFieldDefinition($field_name)->getType() === 'image') {
continue;
}

// @todo This loose comparison is not fully reliable. Revisit this
// after https://www.drupal.org/project/drupal/issues/2941092.
if ($items[$delta][$property] != $original_items[$delta][$property]) {
Expand Down

0 comments on commit 9fefc13

Please sign in to comment.