Problem/Motivation

On install
the value assigned to "section" is not a valid section

Steps to reproduce

Given that Varbase started to Install
And the option of Varbase Layout Builder module was in the default components
And the "Varbase Landing Page (Layout Builder)" was enabled too
Then the following error will show up

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /dev/varbase8c2/docroot/core/install.php?rewrite=ok&profile=varbase&langcode=en&id=3&op=do_nojs&op=do
StatusText: OK
ResponseText: InvalidArgumentException: Value assigned to "section" is not a valid section in Drupal\layout_builder\Plugin\DataType\SectionData->setValue() (line 34 of /var/www/html/dev/varbase8c2/docroot/core/modules/layout_builder/src/Plugin/DataType/SectionData.php).

The out put of tail -f /var/log/apache2/error.log

[Wed Dec 02 14:39:51.579795 2020] [php7:notice] [pid 23280] [client ::1:42816] InvalidArgumentException: Value assigned to "section" is not a valid section in /var/www/html/dev/varbase8c2/docroot/core/modules/layout_builder/src/Plugin/DataType/SectionData.php on line 34 #0 /var/www/html/dev/varbase8c2/docroot/modules/contrib/default_content/src/Normalizer/ContentEntityNormalizer.php(257): Drupal\\layout_builder\\Plugin\\DataType\\SectionData->setValue(Array)\n#1 /var/www/html/dev/varbase8c2/docroot/modules/contrib/default_content/src/Normalizer/ContentEntityNormalizer.php(184): Drupal\\default_content\\Normalizer\\ContentEntityNormalizer->setFieldValues(Object(Drupal\\node\\Entity\\Node), 'layout_builder_...', Array)\n#2 /var/www/html/dev/varbase8c2/docroot/modules/contrib/default_content/src/Importer.php(225): Drupal\\default_content\\Normalizer\\ContentEntityNormalizer->denormalize(Array)\n#3 /var/www/html/dev/varbase8c2/docroot/modules/contrib/default_content/default_content.module(15): Drupal\\default_content\\Importer->importContent('enabled_varbase...')\n#4 [internal function]: default_content_modules_installed(Array, false)\n#5 /var/www/html/dev/varbase8c2/docroot/core/lib/Drupal/Core/Extension/ModuleHandler.php(403): call_user_func_array('default_content...', Array)\n#6 /var/www/html/dev/varbase8c2/docroot/core/lib/Drupal/Core/Extension/ModuleInstaller.php(347): Drupal\\Core\\Extension\\ModuleHandler->invokeAll('modules_install...', Array)\n#7 /var/www/html/dev/varbase8c2/docroot/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php(83): Drupal\\Core\\Extension\\ModuleInstaller->install(Array, false)\n#8 /var/www/html/dev/varbase8c2/docroot/profiles/varbase/varbase.profile(442): Drupal\\Core\\ProxyClass\\Extension\\ModuleInstaller->install(Array, false)\n#9 /var/www/html/dev/varbase8c2/docroot/core/includes/batch.inc(295): varbase_install_component('enabled_varbase...', Array)\n#10 /var/www/html/dev/varbase8c2/docroot/core/includes/batch.inc(137): _batch_process()\n#11 /var/www/html/dev/varbase8c2/docroot/core/includes/batch.inc(93): _batch_do()\n#12 /var/www/html/dev/varbase8c2/docroot/core/includes/install.core.inc(665): _batch_page(Object(Symfony\\Component\\HttpFoundation\\Request))\n#13 /var/www/html/dev/varbase8c2/docroot/core/includes/install.core.inc(570): install_run_task(Array, Array)\n#14 /var/www/html/dev/varbase8c2/docroot/core/includes/install.core.inc(118): install_run_tasks(Array, NULL)\n#15 /var/www/html/dev/varbase8c2/docroot/core/install.php(44): install_drupal(Object(Composer\\Autoload\\ClassLoader))\n#16 {main}, referer: http://localhost/dev/varbase8c2/docroot/core/install.php?rewrite=ok&profile=varbase&langcode=en&id=3&op=start


Proposed resolution

In Drupal core
core/modules/layout_builder/src/Plugin/DataType/SectionData.php

<?php

namespace Drupal\layout_builder\Plugin\DataType;

use Drupal\Core\TypedData\TypedData;
use Drupal\layout_builder\Section;

/**
 * Provides a data type wrapping \Drupal\layout_builder\Section.
 *
 * @DataType(
 *   id = "layout_section",
 *   label = @Translation("Layout Section"),
 *   description = @Translation("A layout section"),
 * )
 *
 * @internal
 *   Plugin classes are internal.
 */
class SectionData extends TypedData {

  /**
   * The section object.
   *
   * @var \Drupal\layout_builder\Section
   */
  protected $value;

  /**
   * {@inheritdoc}
   */
  public function setValue($value, $notify = TRUE) {
    if ($value && !$value instanceof Section) {
      throw new \InvalidArgumentException(sprintf('Value assigned to "%s" is not a valid section', $this->getName()));
    }
    parent::setValue($value, $notify);
  }

}

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

Comments

RajabNatshah created an issue. See original summary.

rajab natshah’s picture

rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Project: Varbase Layout Builder » Varbase Core

Moving the issue to Varbase Core

  • RajabNatshah committed 03e1ee5 on 8.x-8.x
    Issue #3186010: Fix Value assigned to "section" is not a valid section
    
rajab natshah’s picture

Assigned: rajab natshah » mohammed j. razem
Status: Active » Needs review
Issue tags: +varbase-8.8.8, +varbase-9.0.0, +varbase-9.0.0-rc1
rajab natshah’s picture

Assigned: mohammed j. razem » Unassigned
rajab natshah’s picture

Status: Needs review » Fixed

  • RajabNatshah committed 20ee74a on 9.0.x
    Issue #3186010: Fix Value assigned to "section" is not a valid section
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.