Problem/Motivation

After upgrading to PHP 8.2, I get several deprecation warnings in the log about dynamic creation of properties in the ICalItem class. These are the different variables that it is warning about: $organizer, $attendee, $additionalProperties, $duration, $dtend_tz, $dtstart_tz, $last_modified.

Steps to reproduce

I think this would happen on any calendar feed import, but in case it matters:

We are pulling from a Microsoft 365 shared calendar.

We are extending the ICalItem class for our own custom feed parsing to do a little massaging of the data for a custom entity. But I don't think this part throwing the warnings is in our code.

Proposed resolution

I've encountered similar in a couple other modules already and the solution is to explicitly declare the protected properties. I tested that same idea here:

protected $organizer, $attendee, $additionalProperties, $duration, $dtend_tz, $dtstart_tz, $last_modified;

That's not up to the Drupal coding standards (each should have a var declaration with its type), but the concept seemed to work.

Issue fork feeds_ical-3445551

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

ryanrobinson_wlu created an issue. See original summary.

ben.hamelin’s picture

Assigned: Unassigned » ben.hamelin

Thanks @ryanrobinson_wlu! This was at least partially introduced in 2.2.0 with the "Add additionalProperties to IcalParser" fix.
I've added the missing properties you identified, as well as an exception to the additionalProperties logic to hopefully avoid these moving forward.

I also looked at the docs for " #[AllowDynamicProperties]" in https://php.watch/versions/8.2/dynamic-properties-deprecated but that just feels like hiding a potential issue.

ryan-l-robinson’s picture

Thank you! The bit I looked into #[AllowDynamicProperties] I got the same impression: maybe there are some situations where it is necessary, but the proper solution usually is to declare the properties.

ryan-l-robinson’s picture

Status: Active » Reviewed & tested by the community

ben.hamelin’s picture

Can you take a look at the MR? If this fix works for you I'll merge it in and tag 2.2.1 as the latest release.
Thanks!

ryan-l-robinson’s picture

The changes work in my tests, no more deprecation warnings in the logs.

ben.hamelin’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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