Verified Commit 88187a5e authored by Dave Long's avatar Dave Long
Browse files

task: #3580877 Remove updates added prior to 11.3.0 from 12.x

By: catch
By: quietone
By: smustgrave
By: dcam
parent 42f62b89
Loading
Loading
Loading
Loading
Loading
−12
Changes for core/.phpstan-baseline.php: 0 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -10945,12 +10945,6 @@
	'count' => 1,
	'path' => __DIR__ . '/modules/block/tests/src/Functional/BlockUiTest.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Tests\\\\block\\\\Functional\\\\BlockWeightUpdateTest\\:\\:testRunUpdates\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/modules/block/tests/src/Functional/BlockWeightUpdateTest.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Tests\\\\block\\\\Functional\\\\Views\\\\DisplayBlockTest\\:\\:assertBlockAppears\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
@@ -22465,12 +22459,6 @@
	'count' => 1,
	'path' => __DIR__ . '/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Tests\\\\search\\\\Functional\\\\Update\\\\SearchBlockPageIdUpdatePathTest\\:\\:testRunUpdates\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/modules/search/tests/src/Functional/Update/SearchBlockPageIdUpdatePathTest.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Tests\\\\search\\\\Kernel\\\\SearchMatchTest\\:\\:getText\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
+2 −37
Changes for core/modules/block/block.post_update.php: 2 added lines, 37 removed lines.
Original line number Diff line number Diff line
@@ -5,9 +5,6 @@
 * Post update functions for Block.
 */

use Drupal\block\BlockInterface;
use Drupal\Core\Config\Entity\ConfigEntityUpdater;

/**
 * Implements hook_removed_post_updates().
 */
@@ -17,39 +14,7 @@ function block_removed_post_updates(): array {
    'block_post_update_disabled_region_update' => '9.0.0',
    'block_post_update_fix_negate_in_conditions' => '9.0.0',
    'block_post_update_replace_node_type_condition' => '10.0.0',
    'block_post_update_make_weight_integer' => '12.0.0',
    'block_post_update_set_menu_block_depth_to_null_if_zero' => '12.0.0',
  ];
}

/**
 * Ensures that all block weights are integers.
 */
function block_post_update_make_weight_integer(array &$sandbox = []): void {
  \Drupal::classResolver(ConfigEntityUpdater::class)
    ->update($sandbox, 'block', function (BlockInterface $block): bool {
      $weight = $block->getWeight();
      if (!is_int($weight)) {
        $block->setWeight($weight);
        return TRUE;
      }
      return FALSE;
    });
}

/**
 * Updates the `depth` setting to NULL if it is 0 in any menu blocks.
 */
function block_post_update_set_menu_block_depth_to_null_if_zero(array &$sandbox = []): void {
  \Drupal::classResolver(ConfigEntityUpdater::class)
    ->update($sandbox, 'block', function (BlockInterface $block): bool {
      if ($block->getPlugin()->getBaseId() === 'system_menu_block') {
        $settings = $block->get('settings');
        // Use `empty()` to account for either integer 0, or '0'.
        if (empty($settings['depth'])) {
          $settings['depth'] = NULL;
        }
        $block->set('settings', $settings);
        return TRUE;
      }
      return FALSE;
    });
}
−47
Changes for core/modules/block/src/BlockConfigUpdater.php: 0 added lines, 47 removed lines.
Original line number Diff line number Diff line
@@ -35,51 +35,4 @@ public function setDeprecationsEnabled(bool $enabled): void {
    $this->deprecationsEnabled = $enabled;
  }

  /**
   * Performs the required update.
   *
   * @param \Drupal\block\BlockInterface $block
   *   The block to update.
   *
   * @return bool
   *   Whether the block was updated.
   */
  public function updateBlock(BlockInterface $block): bool {
    $changed = FALSE;
    if ($this->needsInfoStatusSettingsRemoved($block)) {
      $settings = $block->get('settings');
      unset($settings['info'], $settings['status']);
      $block->set('settings', $settings);
      $changed = TRUE;
    }
    return $changed;
  }

  /**
   * Checks if the block contains deprecated info and status settings.
   *
   * @param \Drupal\block\BlockInterface $block
   *   The block to update.
   *
   * @return bool
   *   TRUE if the block has deprecated settings.
   */
  public function needsInfoStatusSettingsRemoved(BlockInterface $block): bool {
    if (!str_starts_with($block->getPluginId(), 'block_content')) {
      return FALSE;
    }
    $settings = $block->get('settings');
    if (!isset($settings['info']) && !isset($settings['status'])) {
      return FALSE;
    }

    $deprecations_triggered = &$this->triggeredDeprecations['3426302'][$block->id()];
    if ($this->deprecationsEnabled && !$deprecations_triggered) {
      $deprecations_triggered = TRUE;
      @trigger_error('Block content blocks with the "status" and "info" settings is deprecated in drupal:11.3.0 and will be removed in drupal:12.0.0. They were unused, so there is no replacement. Profile, module and theme provided configuration should be updated. See https://www.drupal.org/node/3499836', E_USER_DEPRECATED);
    }

    return TRUE;
  }

}
−26

File deleted.

−59

File deleted.

Loading