Unverified Commit 89b938b4 authored by Alex Pott's avatar Alex Pott
Browse files

fix: #2863785 Avoid PHP notice when comparing config without uuid

By: alexpott
By: neclimdul
By: john cook
By: claudiu.cristea
By: smustgrave
(cherry picked from commit c8bda45c)
(cherry picked from commit 23a4af78)
parent b6e28b8d
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -300,7 +300,7 @@ protected function addChangelistUpdate($collection) {
      $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']) {
        if (isset($source_data['uuid']) && $source_data['uuid'] !== ($target_data['uuid'] ?? NULL)) {
          // 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.
+39 −0
Original line number Diff line number Diff line
@@ -291,6 +291,45 @@ public function testDifferentCollections(): void {
    }
  }

  /**
   * @legacy-covers ::createChangelist
   */
  public function testChangelistUuidMissMatch(): void {
    $target_data = $source_data = $this->getConfigData();
    unset($target_data['views.view.test_view']['uuid']);
    $target_data['field.storage.node.body']['uuid'] = (new Php())->generate();

    $this->sourceStorage->expects($this->once())
      ->method('listAll')
      ->willReturn(array_keys($source_data));
    $this->targetStorage->expects($this->once())
      ->method('listAll')
      ->willReturn(array_keys($target_data));
    $this->sourceStorage->expects($this->once())
      ->method('readMultiple')
      ->willReturn($source_data);
    $this->targetStorage->expects($this->once())
      ->method('readMultiple')
      ->willReturn($target_data);
    $this->sourceStorage->expects($this->once())
      ->method('getAllCollectionNames')
      ->willReturn([]);
    $this->targetStorage->expects($this->once())
      ->method('getAllCollectionNames')
      ->willReturn([]);

    $this->storageComparer->createChangelist();
    $recreate_expected = [
      'field.storage.node.body',
      'views.view.test_view',
    ];
    // Recreating these because of uuid differences. This shows up as a create
    // and delete operation.
    $this->assertEqualsCanonicalizing($recreate_expected, $this->storageComparer->getChangelist('create'));
    $this->assertEqualsCanonicalizing($recreate_expected, $this->storageComparer->getChangelist('delete'));
    $this->assertEquals([], $this->storageComparer->getChangelist('update'));
  }

  /**
   * Generate random data in a config storage.
   *