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
- Maintainer to review proposed solution
- Create a patch - sorry I'm not up to that
- Test
- Commit
User interface changes
None
API changes
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3330050-2.patch | 969 bytes | _pratik_ |
Comments
Comment #2
_pratik_Created patch for it.
Please check
thanks
Comment #3
stevewilson commentedApologies 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.
Comment #4
stevewilson commentedComment #5
joelpittetTotally works, I applied it to a patch as I have it in composer:
Thanks @_pratik_ Maybe we should provide it to the upstream fork maintainer?
Comment #6
stevewilson commentedIt 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.
Comment #7
joseph.olstadI 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?
Comment #8
stevewilson commentediCalcreator 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?
Comment #9
joseph.olstadHi @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.
Comment #10
joseph.olstadI 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
Comment #11
joseph.olstadI 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
Comment #12
joseph.olstadComment #15
joseph.olstadhttps://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.
Comment #16
stevewilson commentedThis seems only to incorporate only the first change, not that at line 4872?
Comment #17
liam morlandI have merged the pull request referred-to in #10.
Comment #18
joseph.olstad@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.
Comment #19
joseph.olstadComment #20
liam morland@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
Comment #21
joseph.olstadSounds 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.
Comment #22
stevewilson commentedThanks @joseph.olstad, all working well now.