Verified Commit 642babcd authored by Lee Rowlands's avatar Lee Rowlands
Browse files

fix: #3621016 text_update_12001 fails to load text_with_summary

By: ptmkenny
By: longwave-bot
By: longwave
(cherry picked from commit d107690b)
parent a9aee65b
Loading
Loading
Loading
Loading
Loading
+38 −0
Changes for core/modules/text/tests/fixtures/update/add-unused-text-with-summary-storage.php: 38 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

/**
 * @file
 * Adds an unused text_with_summary field storage to the fixture database.
 *
 * @see https://www.drupal.org/project/drupal/issues/3621016
 */

use Drupal\Core\Database\Database;

$field_storage = [
  'uuid' => '61d16478-4c4a-467e-8829-5e7e8d1d720a',
  'langcode' => 'en',
  'status' => TRUE,
  'dependencies' => ['module' => ['node', 'text']],
  'id' => 'node.body',
  'field_name' => 'body',
  'entity_type' => 'node',
  'type' => 'text_with_summary',
  'settings' => [],
  'module' => 'text',
  'locked' => FALSE,
  'cardinality' => 1,
  'translatable' => TRUE,
  'indexes' => [],
  'persist_with_no_fields' => TRUE,
  'custom_storage' => FALSE,
];

Database::getConnection()->merge('config')
  ->keys(['collection' => '', 'name' => 'field.storage.node.body'])
  ->fields([
    'collection' => '',
    'name' => 'field.storage.node.body',
    'data' => serialize($field_storage),
  ])
  ->execute();
+41 −0
Changes for core/modules/text/tests/src/Functional/Update/TextWithSummaryUnusedStorageUpdatePathTest.php: 41 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

namespace Drupal\Tests\text\Functional\Update;

use Drupal\FunctionalTests\Update\UpdatePathTestBase;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;

/**
 * Tests installing text_with_summary for an unused field storage.
 */
#[Group('Update')]
#[RunTestsInSeparateProcesses]
#[IgnoreDeprecations]
class TextWithSummaryUnusedStorageUpdatePathTest extends UpdatePathTestBase {

  /**
   * {@inheritdoc}
   */
  protected function setDatabaseDumpFiles(): void {
    $this->databaseDumpFiles = [
      __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-11.3.0.bare.standard.php.gz',
      __DIR__ . '/../../../fixtures/update/add-unused-text-with-summary-storage.php',
    ];
  }

  /**
   * Tests text_with_summary installation for an unused field storage.
   */
  public function testRunUpdates(): void {
    $this->assertFalse(\Drupal::moduleHandler()->moduleExists('text_with_summary'));

    $this->runUpdates();

    $this->assertTrue(\Drupal::moduleHandler()->moduleExists('text_with_summary'));
  }

}
+5 −4
Changes for core/modules/text/text.install: 5 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -12,10 +12,11 @@ function text_update_11001(): void {
  if (\Drupal::moduleHandler()->moduleExists('text_with_summary')) {
    return;
  }
  $storages = \Drupal::entityTypeManager()
    ->getStorage('field_storage_config')
    ->loadByProperties(['type' => 'text_with_summary']);
  if ($storages !== []) {
  $storage_ids = \Drupal::entityQuery('field_storage_config')
    ->accessCheck(FALSE)
    ->condition('type', 'text_with_summary')
    ->execute();
  if ($storage_ids !== []) {
    \Drupal::service('module_installer')->install(['text_with_summary']);
  }
}