Warning: Attempt to read property "error"

Created on 14 February 2023, over 1 year ago
Updated 13 February 2024, 5 months ago

Problem/Motivation

The OpenagendaConnector::getData & OpenagendaConnector::getAgendaSettings will throw warnings as attempting accessing object property error on an array.

Warning: Attempt to read property "error" on array in Drupal\openagenda\OpenagendaConnector->getData() (line 71 of modules/contrib/openagenda/src/OpenagendaConnector.php).

Steps to reproduce

  1. Install the module and configure a working API Key
  2. Create a new node "Open Agenda" with a working UID
  3. Access the previously created open agenda page.
    The page will now display two PHP Warning.

Proposed resolution

Fix the PHP code. When using Drupal\Component\Serialization\Json::decode method, the return value is an array not an object. Then access to element as array instead of object.

Remaining tasks

  • review by the community
  • merge

User interface changes

When then error dimension i populated, will not display a PHP Warning and will create a log - as expected.

API changes

none

Data model changes

none

πŸ› Bug report
Status

RTBC

Version

3.4

Component

Code

Created by

πŸ‡¨πŸ‡­Switzerland wengerk Lausanne

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024