Skip to content
Snippets Groups Projects
Verified Commit 49ecf1d7 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3331059 by quietone, Wongjn, ameymudras, smustgrave, xjm, alexpott,...

Issue #3331059 by quietone, Wongjn, ameymudras, smustgrave, xjm, alexpott, larowlan: Properly check for block content type in BlockPluginId process plugin
parent f91e76e5
No related branches found
No related tags found
41 merge requests!8528Issue #3456871 by Tim Bozeman: Support NULL services,!8323Fix source code editing and in place front page site studio editing.,!6278Issue #3187770 by godotislate, smustgrave, catch, quietone: Views Rendered...,!54479.5.x SF update,!5022Issue #3394406: FileUploadHandler::handleExtensionValidation does not have fallback for sites still using file_validate_extensions,!3878Removed unused condition head title for views,!38582585169-10.1.x,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3668Resolve #3347842 "Deprecate the trusted",!3651Issue #3347736: Create new SDC component for Olivero (header-search),!3546refactored dialog.pcss file,!3531Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!3502Issue #3335308: Confusing behavior with FormState::setFormState and FormState::setMethod,!3452Issue #3332701: Refactor Claro's tablesort-indicator stylesheet,!3451Issue #2410579: Allows setting the current language programmatically.,!3355Issue #3209129: Scrolling problems when adding a block via layout builder,!3226Issue #2987537: Custom menu link entity type should not declare "bundle" entity key,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3147Issue #3328457: Replace most substr($a, $i) where $i is negative with str_ends_with(),!3146Issue #3328456: Replace substr($a, 0, $i) with str_starts_with(),!3133core/modules/system/css/components/hidden.module.css,!31312878513-10.1.x,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2614Issue #2981326: Replace non-test usages of \Drupal::logger() with IoC injection,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2334Issue #3228209: Add hasRole() method to AccountInterface,!2062Issue #3246454: Add weekly granularity to views date sort,!1255Issue #3238922: Refactor (if feasible) uses of the jQuery serialize function to use vanillaJS,!1105Issue #3025039: New non translatable field on translatable content throws error,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!844Resolve #3036010 "Updaters",!673Issue #3214208: FinishResponseSubscriber could create duplicate headers,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #36985 passed
Pipeline: drupal

#36993

    Pipeline: drupal

    #36992

      Pipeline: drupal

      #36991

        +1
        ......@@ -28,7 +28,7 @@ class BlockPluginId extends ProcessPluginBase implements ContainerFactoryPluginI
        /**
        * The block_content entity storage handler.
        *
        * @var \Drupal\Core\Entity\EntityStorageInterface
        * @var \Drupal\Core\Entity\EntityStorageInterface|null
        */
        protected $blockContentStorage;
        ......@@ -41,12 +41,13 @@ class BlockPluginId extends ProcessPluginBase implements ContainerFactoryPluginI
        * The plugin ID.
        * @param array $plugin_definition
        * The plugin definition.
        * @param \Drupal\Core\Entity\EntityStorageInterface $storage
        * The block content storage object.
        * @param \Drupal\Core\Entity\EntityStorageInterface|null $storage
        * The block content storage object. NULL if the block_content module is
        * not installed.
        * @param \Drupal\migrate\MigrateLookupInterface $migrate_lookup
        * The migrate lookup service.
        */
        public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityStorageInterface $storage, MigrateLookupInterface $migrate_lookup) {
        public function __construct(array $configuration, $plugin_id, array $plugin_definition, ?EntityStorageInterface $storage, MigrateLookupInterface $migrate_lookup) {
        parent::__construct($configuration, $plugin_id, $plugin_definition);
        $this->blockContentStorage = $storage;
        $this->migrateLookup = $migrate_lookup;
        ......@@ -61,7 +62,7 @@ public static function create(ContainerInterface $container, array $configuratio
        $configuration,
        $plugin_id,
        $plugin_definition,
        $entity_type_manager->getDefinition('block_content') ? $entity_type_manager->getStorage('block_content') : NULL,
        $entity_type_manager->hasDefinition('block_content') ? $entity_type_manager->getStorage('block_content') : NULL,
        $container->get('migrate.lookup')
        );
        }
        ......
        <?php
        namespace Drupal\Tests\block\Kernel\Migrate\d7;
        use Drupal\block\Entity\Block;
        use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
        /**
        * Tests the migration of blocks without Block Content installed.
        *
        * @group block
        */
        class MigrateBlockNoBlockContentTest extends MigrateDrupal7TestBase {
        /**
        * {@inheritdoc}
        */
        protected static $modules = [
        'block',
        'views',
        'comment',
        'menu_ui',
        'node',
        'text',
        'filter',
        'path_alias',
        'user',
        ];
        /**
        * {@inheritdoc}
        */
        protected function setUp(): void {
        parent::setUp();
        // Install the themes used for this test.
        $this->container->get('theme_installer')->install(['olivero', 'claro']);
        $this->installConfig(static::$modules);
        // Set Olivero and Claro as the default public and admin theme.
        $config = $this->config('system.theme');
        $config->set('default', 'olivero');
        $config->set('admin', 'claro');
        $config->save();
        $this->executeMigrations([
        'd7_filter_format',
        'd7_user_role',
        'd7_block',
        ]);
        block_rebuild();
        }
        /**
        * Asserts various aspects of a block.
        *
        * @param string $id
        * The block ID.
        * @param string $plugin_id
        * The block's plugin ID.
        * @param array $roles
        * Role IDs the block is expected to have.
        * @param string $pages
        * The list of pages on which the block should appear.
        * @param string $region
        * The display region.
        * @param string $theme
        * The theme.
        * @param int $weight
        * The block weight.
        * @param string $label
        * The block label.
        * @param string $label_display
        * The block label display setting.
        * @param bool $status
        * Whether the block is expected to be enabled or disabled.
        *
        * @internal
        */
        public function assertEntity(string $id, string $plugin_id, array $roles, string $pages, string $region, string $theme, int $weight, string $label, string $label_display, bool $status = TRUE): void {
        $block = Block::load($id);
        $this->assertInstanceOf(Block::class, $block);
        /** @var \Drupal\block\BlockInterface $block */
        $this->assertSame($plugin_id, $block->getPluginId());
        $visibility = $block->getVisibility();
        if ($roles) {
        $this->assertSame($roles, array_values($visibility['user_role']['roles']));
        $this->assertSame('@user.current_user_context:current_user', $visibility['user_role']['context_mapping']['user']);
        }
        if ($pages) {
        $this->assertSame($pages, $visibility['request_path']['pages']);
        }
        $this->assertSame($region, $block->getRegion());
        $this->assertSame($theme, $block->getTheme());
        $this->assertSame($weight, $block->getWeight());
        $this->assertSame($status, $block->status());
        $config = $this->config('block.block.' . $id);
        $this->assertSame($label, $config->get('settings.label'));
        $this->assertSame($label_display, $config->get('settings.label_display'));
        }
        /**
        * Tests the block migration.
        */
        public function testBlockMigration(): void {
        $this->assertEntity('bartik_system_main', 'system_main_block', [], '', 'content', 'olivero', 0, '', '0');
        $this->assertEntity('bartik_search_form', 'search_form_block', [], '', 'content', 'olivero', -1, '', '0');
        $this->assertEntity('bartik_user_login', 'user_login_block', [], '', 'content', 'olivero', 0, 'User login title', 'visible');
        $this->assertEntity('bartik_system_powered_by', 'system_powered_by_block', [], '', 'footer_bottom', 'olivero', 10, '', '0');
        $this->assertEntity('seven_system_main', 'system_main_block', [], '', 'content', 'claro', 0, '', '0');
        $this->assertEntity('seven_user_login', 'user_login_block', [], '', 'content', 'claro', 10, 'User login title', 'visible');
        // Assert that disabled blocks (or enabled blocks whose plugin IDs could
        // be resolved) did not migrate.
        $non_existent_blocks = [
        'bartik_system_navigation',
        'bartik_system_help',
        'seven_user_new',
        'seven_search_form',
        'bartik_comment_recent',
        'bartik_node_syndicate',
        'bartik_node_recent',
        'bartik_shortcut_shortcuts',
        'bartik_system_management',
        'bartik_system_user-menu',
        'bartik_system_main-menu',
        'bartik_user_new',
        'bartik_user_online',
        'seven_comment_recent',
        'seven_node_syndicate',
        'seven_shortcut_shortcuts',
        'seven_system_powered-by',
        'seven_system_navigation',
        'seven_system_management',
        'seven_system_user-menu',
        'seven_system_main-menu',
        'seven_user_online',
        'bartik_blog_recent',
        'bartik_book_navigation',
        'bartik_locale_language',
        'bartik_forum_active',
        'bartik_forum_new',
        'seven_blog_recent',
        'seven_book_navigation',
        'seven_locale_language',
        'seven_forum_active',
        'seven_forum_new',
        'bartik_menu_menu-test-menu',
        'bartik_statistics_popular',
        'seven_menu_menu-test-menu',
        'seven_statistics_popular',
        'seven_block_1',
        ];
        $this->assertEmpty(Block::loadMultiple($non_existent_blocks));
        }
        }
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment