Skip to content

Return value must be of type array, null returned #81

@kathi-at-datrycs

Description

@kathi-at-datrycs

PHP Version

8.2

Shopware Version

6.6.10.15

Plugin Version

3.0.1

Actual behaviour

I ran into the following error:

{
  "errors": [
    {
      "code": "0",
      "status": "500",
      "title": "Internal Server Error",
      "detail": "An exception has been thrown during the rendering of a template (\"Frosh\\DevelopmentHelper\\Component\\Profiler\\TwigDataCollector::getTemplateData(): Return value must be of type array, null returned\") in \"@FroshDevelopmentHelper/Collector/twig.html.twig\" at line 112.",
      "meta": {
        "trace": [ ... ]
      }
    }
  ]
}

Here's the full error trace: 500.json

The issue is that TwigDataCollector::getTemplateData() has to return an array

public function getTemplateData(): array
{
return $this->data['renders'];
}

but for whatever reasons returns null. Patched this locally simply with

return $this->data['renders'] ?? [];

what seems to work fine.

Expected behaviour

No 500 error :)

Steps to Reproduce?

Not sure ... I can reproduce it with lots of plugins installed, but likely not reproducible on a plain Shopware instance.
Happens in my case when opening the Twig tab in the Symfony profiler toolbar (Composer package symfony/web-profiler-bundle, example route /_profiler/29e7a3?panel=twig).

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions