Skip to content

Commit

Permalink
Revert "Add ability to compare revision dates for import updates"
Browse files Browse the repository at this point in the history
This reverts commit 758988f.
  • Loading branch information
Blanca-Esqueda committed Dec 14, 2022
1 parent 0c4e035 commit effc466
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 40 deletions.
7 changes: 2 additions & 5 deletions src/Commands/ContentSyncCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,7 @@ public function import($label = NULL, array $options = [
'entity-types' => '',
'uuids' => '',
'actions' => '',
'skiplist' => FALSE,
'compare-dates' ]) {
'skiplist' => FALSE ]) {

//Generate comparer with filters.
$storage_comparer = new ContentStorageComparer($this->contentStorageSync, $this->contentStorage, $this->configManager);
Expand All @@ -222,9 +221,7 @@ public function import($label = NULL, array $options = [
foreach ($collections as $collection){
if (!empty($options['uuids'])){
$storage_comparer->createChangelistbyCollectionAndNames($collection, $options['uuids']);
} elseif ($options['compare-dates']) {
$storage_comparer->createChangelistbyCollection($collection, TRUE);
} else {
}else{
$storage_comparer->createChangelistbyCollection($collection);
}
if (!empty($options['actions'])){
Expand Down
37 changes: 2 additions & 35 deletions src/Content/ContentStorageComparer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class ContentStorageComparer extends StorageComparer {
/**
* {@inheritdoc}
*/
public function createChangelistbyCollection($collection, $use_dates = FALSE) {
public function createChangelistbyCollection($collection) {
$this->changelist[$collection] = $this->getEmptyChangelist();
$this->getAndSortConfigData($collection);
$this->addChangelistCreate($collection);
$use_dates ? $this->addChangelistUpdateByDate($collection) : $this->addChangelistUpdate($collection);
$this->addChangelistUpdate($collection);
$this->addChangelistDelete($collection);
// Only collections that support configuration entities can have renames.
if ($collection == StorageInterface::DEFAULT_COLLECTION) {
Expand Down Expand Up @@ -74,37 +74,4 @@ protected function getAndSortContentDataByCollectionAndNames($collection, $names
}
return false;
}

/**
* Creates the update changelist with revision date comparison.
*
* The list of updates is sorted so that dependencies are created before
* configuration entities that depend on them. For example, field storages
* should be updated before fields.
*
* @param string $collection
* The storage collection to operate on.
*/
protected function addChangelistUpdateByDate($collection)
{
$recreates = [];
foreach (array_intersect($this->sourceNames[$collection], $this->targetNames[$collection]) as $name) {
$source_data = $this->getSourceStorage($collection)->read($name);
$target_data = $this->getTargetStorage($collection)->read($name);
if ($source_data !== $target_data) {
if (isset($source_data['uuid']) && $source_data['uuid'] !== $target_data['uuid']) {
// The entity has the same file as an existing entity but the UUIDs do
// not match. This means that the entity has been recreated so config
// synchronization should do the same.
$recreates[] = $name;
} else {
if (strtotime($source_data['revision_timestamp'][count($source_data['revision_timestamp']) - 1]['value']) >
strtotime($target_data['revision_timestamp'][count($target_data['revision_timestamp']) - 1]['value']))
{
$this->addChangeList($collection, 'update', [$name]);
}
}
}
}
}
}

0 comments on commit effc466

Please sign in to comment.