Getting this error with 8.x-3.x-dev, and rendering of the whole regions/blocks wrappers are broken and not working

Warning: Invalid argument supplied for foreach() in ds_preprocess_ds_layout() (line 366 of modules/contrib/ds/ds.module).
ds_preprocess_ds_layout(Array, 'ds_lmc_card_image_overlay', Array) (Line: 287)
...
SNIP
...

After Investigation i found out that there is no longer $variables['settings']; and now is at $variables['content']['settings']; Works perfectly now.

See also https://github.com/sameronline/drupalprojects-ds/commit/0480815d87937e8f...

Comments

samerali created an issue. See original summary.

samerali’s picture

samerali’s picture

Issue summary: View changes
samerali’s picture

Priority: Normal » Critical
swentel’s picture

Status: Active » Postponed (maintainer needs more info)

Is layout_plugin still enabled or not ?

Because DS 8.x-3.x is dependant on core 8.3.x which includes the layout discovery module now and not compatible anymore with contrib layout_plugin.

Other than that, still need the upgrade hook for it anyway, so we could potentially use this issue for it. The patch itself seems weird as this works fine (at least in tests).

samerali’s picture

No layout_plugin is not enabled, we can't enable both layout_plugin & layout_discovery modules on D8.3

this is what my composer dependencies looks like anyway:

    "require": {
        "composer/installers": "^1.2",
        "drupal-composer/drupal-scaffold": "^2.2",
        "cweagans/composer-patches": "~1.0",
        "drupal/core": "~8.3",
        "drupal/console": "~1.0",
        "drupal/bootstrap_barrio": "^4.3",
        "drupal/styleguide": "1.*",
        "twbs/bootstrap": "4.0.0-alpha.6",
        "drupal/page_manager": "1.x-dev",
        "drupal/ds": "^3.0",
        "eduardoboucas/include-media": "^1.4",
        "drupal/field_group": "^1.0@RC",
        "drupal/admin_toolbar": "^1.18",
        "drupal/paragraphs": "^1.0",
        "drupal/bootstrap_layouts": "~5.0",
        "drupal/name": "^1.0@beta",
        "drupal/deploy": "1.x-dev",
        "drupal/relaxed": "1.x-dev",
        "drupal/restui": "^1.13",
        "drupal/workspace": "1.x-dev"
    },
swentel’s picture

Priority: Critical » Major
Status: Postponed (maintainer needs more info) » Needs review

That's weird .. I don't get why DS core isn't failing on this. I have a feeling something external is messing with those settings.
Let's put the patch on needs review and see what the bot thinks.

Status: Needs review » Needs work

The last submitted patch, 2: 2860490-ds_preprocess_ds_layout-settings-fix.patch, failed testing.

swentel’s picture

So , the entities fail test is probably due to something unrelated.

But other than than that, the patch seems to be fine. I'm baffled :)
Has something changed the last 10 hours in core or so ? :)

samerali’s picture

@swentel I'm myself surprised that this works lol.

Actually without it. the whole thing and rendering is broken (since the templates would no longer have their wrapper and attr settings set)

Regarding if anything changed in core at the last 10hours. I don't think so. I have no idea lol

samerali’s picture

swentel’s picture

@samerali So I've been wondering: is this a custom layout ?
It would be interesting also to know which class it's using in case it's custom (e.g. if you check ds.layouts.yml, all our layouts classes are \Drupal\ds\Plugin\DsLayout. Maybe that might give me a clue where the difference is coming from.

And on which entity type/bundle is it applied ?

swentel’s picture

Also checking template_preprocess_layout() in layout_discovery, that is actually using the check you are doing in the patch and assigning it to $variable['settings'] (which then in ds_preprocess_layout is picked up in most cases)

tim.plunkett’s picture

Issue summary: View changes

As mentioned, this means that template_preprocess_layout() is not being run at the correct time, or at all.
Can you post your *.layouts.yml entry?

bceyssens’s picture

We are experiencing the same error, can you review the code we are using?

In our *.layouts.yml

colli_teaser:
  label: Colli Teaser
  category: Display Suite
  class: '\Drupal\ds\Plugin\DsLayout'
  type: partial
  template: templates/layout/colli-teaser
  regions:
    left:
      label: Left
    right:
      label: Right
    bottom:
      label: Bottom

The template

<{{ outer_wrapper }}{{ attributes.addClass('node--type-colli', 'node--view-mode-teaser') }}>

    {{ title_suffix.contextual_links }}

    <div class="teaser-table">
        <div class="teaser-table-row">
            <{{ left_wrapper }}{{ left_attributes.addClass('group-left') }}>
                {{ left }}
            </{{ left_wrapper }}>

            <{{ right_wrapper }}{{ right_attributes.addClass('group-right') }}>
                {{ right }}
            </{{ right_wrapper }}>
        </div>
    </div>

    <{{ bottom_wrapper }}{{ bottom_attributes.addClass('group-bottom') }}>
        {{ bottom }}
    </{{ bottom_wrapper }}>
</{{ outer_wrapper }}>
aspilicious’s picture

The above code is added in a custom theme.

swentel’s picture

Oh, I think there's an issue somewhere that involves the registration of custom layouts in themes iirc, but can't find it right now, maybe that's the key.

swentel’s picture

So interestingly enough, it seems the one column layout has this problem too, this is very weird to say at the least.

aspilicious’s picture

I noticed all the fails are missing a library key...
Could that be the problem?

swentel’s picture

Not sure, but it's the first interesting clue to start debugging in a few days :)

swentel’s picture

Status: Needs work » Needs review
StatusFileSize
new406 bytes

Let's see what happens if entities test uses ds_1col (which has no library key)

Status: Needs review » Needs work

The last submitted patch, 21: 2860490-22.patch, failed testing.

swentel’s picture

I'm with stupid today, sorry .. one second

swentel’s picture

Status: Needs work » Needs review
StatusFileSize
new339 bytes

remove library key from stacked

aspilicious’s picture

Can we add a test for the 1col case first so that we have a failing test at least?

aspilicious’s picture

swentel’s picture

#2857972: Some content wrappers are not passed to display suite layouts overridden twig templates is simply about the wrapper not appearing, but I'm not getting the notices on my local machine, so we're back to square one regarding that.

aspilicious’s picture

Try to use the template we made in a test theme. Maybe that Will trigger a fail. The linked issue is also about layout in a theme and we had missing wrappers too, the above patch fixed everything at once but is obviously wrong.

tim.plunkett’s picture

It's a core bug, and it's definitely related to it being defined by a theme.

tim.plunkett’s picture

Okay here's what I'm seeing:
In \Drupal\Core\Theme\Registry::build() there are a bunch of calls to $this->processExtension() in a row.
During the first round it loops through each module, and once it gets to layout_discovery, that loads the theme implementation for each entry in every *.layouts.yml
Then it goes through base themes and stuff, which isn't relevant to this.

Then it calls it for the 'theme_engine' and for the 'theme' itself.

Of course, the theme doesn't have the layout in its hook_theme().

But the theme_engine is the problem.
It calls twig_theme(), which scans for *any* *.html.twig in a theme. It finds the colli-teaser.html.twig, and creates a dummy theme definition, and then uses that to overwrite the valid one.

This isn't unique to layouts or DS. I'll open a core issue for this later. But in the meantime, themes cannot safely provide layout definitions, unless they alter it with hook_theme_registry_alter() or provide a hook_theme() to add in the 'base hook' => 'layout'

aspilicious’s picture

In that case DS should add a theme registry alter workaround. I don't want to piss off the DS user base :). Sadly enough that workaround need to be copied to panels as well. Can't we have a workaround in the core module before 8.3 is releases? :S

aspilicious’s picture

And offcourse add a test theme.

tim.plunkett’s picture

tim.plunkett’s picture

StatusFileSize
new813 bytes

This should work? Still probably want a test though, things shouldn't break this bad.

swentel’s picture

StatusFileSize
new3.97 KB
new3.96 KB

Ok, with tests.

Thinks Tim for figuring this out!

swentel’s picture

StatusFileSize
new3.95 KB

Slightly better

The last submitted patch, 35: 2860490-35-fail.patch, failed testing.

swentel’s picture

Status: Needs review » Fixed

committed and pushed

  • swentel committed 840dd04 on 8.x-3.x
    Issue #2860490 by swentel, samerali, tim.plunkett: Invalid argument...

Status: Fixed » Closed (fixed)

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

dqd’s picture

Oops wrong issue ... deleted my comment