Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Error: Object of class Drupal\layout_builder\Section could not be converted to string #6125

Open
ivangrozni opened this issue Oct 2, 2024 · 0 comments

Comments

@ivangrozni
Copy link

Describe the bug

I'm trying to load a node with layout builder customized for that node in the drush console.

$ drush php
Psy Shell v0.11.0 (PHP 8.1.3 — cli) by Justin Hileman
Drush Site-Install (Drupal 10.2.8)
>>> $etm=\Drupal::entityTypeManager();
=> Drupal\Core\Entity\EntityTypeManager {#1248}
>>> $ns=$etm->getStorage('node');
=> Drupal\node\NodeStorage {#7630}
>>> $n35=$ns->load(35);
PHP Error:  Object of class Drupal\layout_builder\Section could not be converted to string in /app/vendor/drush/drush/src/Psysh/Caster.php on line 46

Expected behavior

Node is loaded.

Workaround

I edited drush/src/Psysh/Caster.php line 46.

                // Collapse single value'd field values.
                if (count($value[0] ?? []) === 1) {
                    $to_implode = array_filter(array_column($value, array_keys($value[0])[0]), fn ($v) => is_string($v));
                    $value = implode(', ', $to_implode);
                }

System Configuration

Q A
Drush version? 12.5.2 (please be specific, and try latest release)
Drupal version? 10.2.8
PHP version 8.1.3
OS? Linux

With layout builder enabled and made enabled for overrides per node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant