Context variable objects are silently converted to arrays

Created on 14 February 2023, almost 2 years ago
Updated 7 March 2023, over 1 year ago

Problem/Motivation

I learnt it the hard way: None of my object getters seemed to work in a component. After hours of debugging i found that objects are converted to arrays. (As this is a deep conversion, wrapping in an array is no workaround.)

Dumping this module and using theme functions again was the only solution i could find.

Debug details

FTR:

The render array:

^ array:3 [▼
  "#type" => "sdc"
  "#component" => "untrack_email_storage:ute-result"
  "#context" => array:2 [▼
    "result" => Geeks4change\UntrackEmailAnalyzer\Analyzer\Result\FullResult {#1477 ▶}
    "isUteAdmin" => true
  ]
]
^ array:5 [▼
  "result" => array:4 [▶]
  "isUteAdmin" => true
  "clAttributes" => Drupal\Core\Template\Attribute {#1970 ▶}
  "clMeta" => array:6 [▶]
]
$schema: https://git.drupalcode.org/project/sdc/-/raw/1.x/src/metadata.schema.json
name: "Ute Result"
description: "The result from the unspy.email analyzer."
schemas:
  props:
    type: object
    properties:
      result:
        type: Geeks4change\UntrackEmailAnalyzer\Analyzer\AnalyzerResult\FullResult | \Geeks4change\UntrackEmailAnalyzer\Analyzer\AnalyzerResult\FullResult
        title: "Result"
      isUteAdmin:
        type: bool
        title: Is admin

Proposed resolution

Do not convert objects.
Could not find the code for that on first sight though.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇩🇪Germany geek-merlin Freiburg, Germany

Live updates comments and jobs are added and updated live.
  • DrupalWTF

    Worse Than Failure. Approximates the unpleasant remark made by Drupal developers when they first encounter a particular (mis)feature.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024