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

CommentFileSizeAuthor
#2 3330050-2.patch969 bytes_pratik_

Comments

SteveWilson created an issue. See original summary.

_pratik_’s picture

StatusFileSize
new969 bytes

Created patch for it.
Please check
thanks

stevewilson’s picture

Apologies for the delayed response - I've been away.

Thanks for the patch. I lack the knowledge (and possibly the necessary development set-up) to check whether the patch applies cleanly, but I can see that it precisely reflects my proposed fix - so it looks good to me.

I guess the maintainers need to decide whether this is an appropriate fix and whether it should be committed? I also appreciate that the Date iCal README,txt file will need updating if and when a fresh version of the iCalcreator library is made available.

stevewilson’s picture

Status: Active » Needs review
joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

Totally works, I applied it to a patch as I have it in composer:

"kigkonsult/icalcreator": {
      "#3330050 iCalcreator.class.php (2.20.4) reports deprecations in PHP 8.1": "https://www.drupal.org/files/issues/2022-12-30/3330050-2.patch"
    }

Thanks @_pratik_ Maybe we should provide it to the upstream fork maintainer?

stevewilson’s picture

It would be good to have a fresh release of the iCalcreator library fork but I am nevertheless encouraged that my proposed fix has belatedly garnered some support.

joseph.olstad’s picture

I believe we need an upstream request to have this fixed in kigkonsult/icalcreator

Assuming this is on github somewhere? has anyone pushed a pull request or made a fork?

stevewilson’s picture

iCalcreator was forked to https://github.com/lkmorlan/iCalcreator/releases/tag/v2.20.4 by Liam Morland to address issue #2707373: PHP 7 support with iCalcreator class. Do we need Liam to update that fork?

joseph.olstad’s picture

Hi @SteveWilson , Liam Morland is quite active, I'm sure that if someone created a pull request on github, he would merge it and tag a release.

joseph.olstad’s picture

I created a pull request for Liam Morlands repo
https://github.com/lkmorlan/iCalcreator/pull/1

Alternatively, someone could use my fork instead: https://github.com/joejoseph00/iCalcreator/releases/tag/v2.20.6

joseph.olstad’s picture

Status: Reviewed & tested by the community » Fixed

I updated the drupal.org project page for ical to refer to the new build, my fork that has the above mentioned changes.

https://github.com/joejoseph00/iCalcreator/archive/refs/tags/v2.20.6.zip

joseph.olstad’s picture

Status: Fixed » Needs review

  • joseph.olstad committed ef22cd6c on 7.x-3.x
    Issue #3330050 by _pratik_, SteveWilson, joseph.olstad, joelpittet:...

  • joseph.olstad committed 78b74445 on 7.x-3.x
    Issue #3330050 by _pratik_, SteveWilson, joseph.olstad, joelpittet:...
joseph.olstad’s picture

Status: Needs review » Fixed

https://www.drupal.org/project/date_ical/releases/7.x-3.12
Updated README.txt
also updated project page to rever to the new library release.

stevewilson’s picture

Status: Fixed » Needs work

This seems only to incorporate only the first change, not that at line 4872?

liam morland’s picture

I have merged the pull request referred-to in #10.

joseph.olstad’s picture

@SteveWilson, thanks for catching that, I pushed that into my fork with the pull request for Liam Morlands fork and he merged it also.

I updated the project page with a link to my forks latest release that has the entire fix.

https://github.com/joejoseph00/iCalcreator/archive/refs/tags/v2.20.6.zip

The README.txt for date_ical has been updated to refer to my fork.

The date_ical project page is now referring to my forks release that includes the fix, v2.20.6

version v2.20.6 or higher to get this fix.

joseph.olstad’s picture

Status: Needs work » Fixed
liam morland’s picture

@joseph.olstad since you also maintain this and I don't use this any more, I will leave it to you to maintain the fork of iCalcreator. Thanks

joseph.olstad’s picture

Sounds good, ya that's what I was thinking, thanks for the followup! With that said, you might as well tag a release in case someone is still looking at your fork.

stevewilson’s picture

Thanks @joseph.olstad, all working well now.

Status: Fixed » Closed (fixed)

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