Verified Commit a3af6101 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
By: larowlan
By: catch
parent e2df17e7
Loading
Loading
Loading
Loading
+15 −0
Changes for core/modules/system/src/Hook/SystemRequirementsHooks.php: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -1519,6 +1519,21 @@ public function checkRequirements(string $phase): array {
          }
        }
      }

      if (!\Drupal::moduleHandler()->moduleExists('text_with_summary')) {
        $config_storage = \Drupal::service('config.storage');
        foreach ($config_storage->listAll('field.storage.') as $config_name) {
          $config = $config_storage->read($config_name);
          if (($config['type'] ?? NULL) === 'text_with_summary') {
            $requirements['text_with_summary'] = [
              'title' => $this->t('Missing text_with_summary field type'),
              'description' => $this->t("The text_with_summary field type has been moved to a contributed module. Install it before updating by running 'composer require drupal/text_with_summary' and then enable the text_with_summary module."),
              'severity' => RequirementSeverity::Error,
            ];
            break;
          }
        }
      }
    }

    // Add warning when twig debug option is enabled.
+36 −0
Changes for core/modules/system/tests/fixtures/update/add-text-with-summary-storage.php: 36 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

/**
 * @file
 * Adds a text_with_summary field storage to the fixture database.
 */

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();
+55 −0
Changes for core/modules/system/tests/src/Functional/Update/TextWithSummaryUpdatePathTest.php: 55 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

namespace Drupal\Tests\system\Functional\Update;

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

/**
 * Tests the update path for the removed text_with_summary field type.
 */
#[Group('Update')]
#[RunTestsInSeparateProcesses]
#[IgnoreDeprecations]
class TextWithSummaryUpdatePathTest extends UpdatePathTestBase {

  /**
   * {@inheritdoc}
   */
  protected $checkFailedUpdates = FALSE;

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

  /**
   * Tests the update requirement for the missing field type.
   */
  public function testUpdateRequirements(): void {
    $this->writeSettings([
      'settings' => [
        'update_free_access' => (object) [
          'value' => TRUE,
          'required' => TRUE,
        ],
      ],
    ]);
    $this->drupalGet($this->updateUrl, ['external' => TRUE]);

    $this->assertSession()->pageTextContains('Missing text_with_summary field type');
    $this->assertSession()->pageTextContains('The text_with_summary field type has been moved to a contributed module.');
    $this->assertSession()->pageTextContains('composer require drupal/text_with_summary');
    $this->assertSession()->pageTextContains('enable the text_with_summary module');
  }

}