lochmueller / calendarize

📆 Best TYPO3 Calendar ever 📆
http://typo3.org/extensions/repository/view/calendarize
74 stars 84 forks source link

cal migration wizard breaks #725

Closed rteitge closed 1 year ago

rteitge commented 1 year ago

When migrating from cal records to calendarize the wizard breaks at https://github.com/lochmueller/calendarize/blob/master/Classes/Updates/CalMigrationUpdate.php#L976

Here is the output of the related variables:

calByday: 'th', recurrence: ''  
calByday: 'th', recurrence: ''  
calByday: 'th', recurrence: ''  
calByday: 'th', recurrence: ''  
calByday: '4we', recurrence: '4'  
calByday: '2we,4we', recurrence: '2we,4'  
calByday: 'sa', recurrence: ''  
calByday: '2sa', recurrence: '2'  
calByday: 'tu', recurrence: ''  
calByday: '1tu,2tu,3tu,4tu,5tu', recurrence: '1tu,2tu,3tu,4tu,5'  
calByday: '1we,3we', recurrence: '1we,3'  
calByday: 'tu', recurrence: ''  
calByday: 'fr', recurrence: ''  
calByday: 'th', recurrence: ''  
calByday: 'tu', recurrence: ''  
calByday: 'we', recurrence: ''  
calByday: '1th,3th', recurrence: '1th,3'  
calByday: '2sa', recurrence: '2'  
calByday: 'we', recurrence: ''  
calByday: '3sa', recurrence: '3'  
calByday: 'we', recurrence: ''  
calByday: '4th', recurrence: '4'  
calByday: 'fr', recurrence: ''  
calByday: '-1sa', recurrence: '-1'  
calByday: 'th', recurrence: ''  
calByday: 'th', recurrence: ''  
calByday: '-1sa', recurrence: '-1'  
calByday: 'sa', recurrence: ''  
calByday: 'fr', recurrence: ''  
calByday: '2sa', recurrence: '2'  
calByday: '2sa', recurrence: '2'  
calByday: 'th', recurrence: ''  
calByday: 'th', recurrence: ''  
calByday: 'fr', recurrence: ''  
calByday: 'fr', recurrence: ''  
calByday: 'tu', recurrence: ''  
calByday: 'tu', recurrence: ''  
calByday: '4', recurrence: ''  

The last one causes the exception: array_key_exists(): The first argument should be either a string or an integer

T3 v10.4-latest PHP 7.4-latest calendarize 12.4-latest

rteitge commented 1 year ago

In substr PHP < 8 returns false when length is greater than string length, since PHP 8 it returns "". https://www.php.net/manual/en/function.substr.php

$rest = substr("abcdef", 4, -4);  // returns ""; prior to PHP 8.0.0, false was returned
lochmueller commented 1 year ago

Hey @rteitge should a simple string cast fix this problem alá $recurrence = (string)substr($calByday, 0, -2);? Regards, Tim

rteitge commented 1 year ago

Hi @lochmueller,

thank you for your hint, the cast seems to solve the problem. The script runs now. 👍

Best regards, Roman