iCalcreator.class.php (2.20.4) reports deprecations in PHP 8.1

Created on 28 December 2022, almost 2 years ago
Updated 16 November 2023, about 1 year ago

Problem/Motivation

With PHP 8.1, the following deprecations are reported in the dblog when downloading a .ics file:

Deprecated function: strtoupper(): Passing null to parameter #1 ($string) of type string is deprecated in vcalendar->_makeProdid() (line 220 of /home/techsoco/public_html/sites/all/libraries/iCalcreator/iCalcreator.class.php).

Deprecated function: trim(): Passing null to parameter #1 ($string) of type string is deprecated in calendarComponent->setConfig() (line 4872 of /home/techsoco/public_html/sites/all/libraries/iCalcreator/iCalcreator.class.php).

Steps to reproduce

Drupal core 7.94
Date iCal 7.x-3.10
PHP 8.1.
Create an iCal feed in Views using the iCal Fields plugin, as per the Date iCal documentation. I have Exclude Calendar Name
and Disable webcal:// ticked. Place a link to this feed in a node. Click the link to download the calendar entry. The calendar entry downloads correctly but the deprecations above are reported in dblog.

Note that this was working without deprecations using PHP 7.4.

Proposed resolution

I'm not a programmer but from what I've seen of solutions elsewhere I tried the following changes to iCalcreator.class.php:

- 220 $this->prodid = '-//'.$this->unique_id.'//NONSGML kigkonsult.se '.ICALCREATOR_VERSION.'//'.strtoupper( $this->language );
+ 220 $this->prodid = '-//'.$this->unique_id.'//NONSGML kigkonsult.se '.ICALCREATOR_VERSION.'//'.strtoupper( (string) $this->language );

- 4872 $value = trim( $value );
+ 4872 $value = trim( (string) $value );

This worked for me.

Remaining tasks

  1. Maintainer to review proposed solution
  2. Create a patch - sorry I'm not up to that
  3. Test
  4. Commit

User interface changes

None

API changes

Data model changes

None

🐛 Bug report
Status

Fixed

Version

3.0

Component

iCal Export

Created by

🇬🇧United Kingdom stevewilson

Live updates comments and jobs are added and updated live.
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