This is a follow-up for #2973615: Add Section delta as extra data on filtered block definitions. $delta is passed as a string but should be passed as a integer.

i.e.

+++ b/core/modules/layout_builder/src/Controller/ChooseBlockController.php
@@ -63,8 +63,13 @@ public function build(SectionStorageInterface $section_storage, $delta, $region)
+    // Currently delta is passed as a string, so we'll explicitily convert it
+    // to a integer.
+    $delta = (int) $delta;
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

johndevman created an issue. See original summary.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jdleonard’s picture

Note that the patch in #3038981: Inline blocks missing section delta extra data on filtered block definitions adds an analogous cast in function inlineBlockList() of the same class.

tim.plunkett’s picture

Issue tags: +Blocks-Layouts

Tagging

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Falco010’s picture

Status: Active » Needs review
Issue tags: +Amsterdam2019
FileSize
5.08 KB

Just tested and debugged this, dynamic route parameters always are a string.

Even after trying to add the Regular Expression on the route parameter, still receive it as a string.

layout_builder.choose_block:
  path: '/layout_builder/choose/block/{section_storage_type}/{section_storage}/{delta}/{region}'
  defaults:
    _controller: '\Drupal\layout_builder\Controller\ChooseBlockController::build'
    _title: 'Choose a block'
  requirements:
    _layout_builder_access: 'view'
    delta: \d+ .  <---------
  options:
    _admin_route: TRUE
    parameters:
      section_storage:
        layout_builder_tempstore: TRUE

As @tim.plunkett mentioned earlier in:
https://www.drupal.org/project/drupal/issues/2973615

This would be the solution, but it does not work for PHP 5.

-  public function build(SectionStorageInterface $section_storage, $delta, $region) {
+  public function build(SectionStorageInterface $section_storage, int $delta, $region) {

However, the official documentation is stating that we don't support PHP 5.x anymore:
https://www.drupal.org/docs/8/system-requirements/php-requirements

So attaching a patch for the integer casting in the parameters of the functions.

tbsiqueira’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
FileSize
234.58 KB

Tested, it is working fine, the delta is now one integer.

tim.plunkett’s picture

Version: 8.9.x-dev » 9.0.x-dev

Unfortunately, this is a BC-breaking change in versions before PHP 7.2, which means it won't be allowed in Drupal 8.
https://3v4l.org/kRYDG

The good news is that Drupal 9 requires PHP 7.2, so this sort of change can safely be made!
See https://wiki.php.net/rfc/covariant-returns-and-contravariant-parameters

I'm not sure if there's a D8 safe fix available, or what the current policy is for D9 only fixes. But leaving this at RTBC for now.

  • catch committed 7acaffe on 9.0.x
    Issue #2984509 by Falco010, tbsiqueira, tim.plunkett, johndevman,...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 7acaffe and pushed to 9.0.x. Thanks!

Status: Fixed » Closed (fixed)

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