|
| 1 | +<?php |
| 2 | +// Build-time source patches for plugins installed by composer. Each patch is an exact |
| 3 | +// string replacement that must match once; the build fails if upstream changes it. |
| 4 | +$patches = [ |
| 5 | + // libcalendaring 3.6.1: toDateTime() re-parses a recurrence's last occurrence with |
| 6 | + // createFromFormat, which can return false; the next line then dies with "Attempt to |
| 7 | + // assign property _dateonly on false" and the whole CalDAV sync of that calendar |
| 8 | + // aborts (seen on a Google calendar with ~800 events). Fall back to the timestamp, |
| 9 | + // and return false (no end) only when there is no date at all. |
| 10 | + '/usr/src/roundcubemail/plugins/libcalendaring/lib/libcalendaring_recurrence.php' => [[ |
| 11 | + <<<'OLD' |
| 12 | + if ($date instanceof DateTimeInterface) { |
| 13 | + $date = libcalendaring_datetime::createFromFormat( |
| 14 | + 'Y-m-d\\TH:i:s', |
| 15 | + $date->format('Y-m-d\\TH:i:s'), |
| 16 | + // Sabre will loose timezone on all-day events, use the event start's timezone |
| 17 | + $this->start->getTimezone() |
| 18 | + ); |
| 19 | + } |
| 20 | +
|
| 21 | + $date->_dateonly = $this->dateonly; |
| 22 | +OLD, |
| 23 | + <<<'NEW' |
| 24 | + if ($date instanceof DateTimeInterface) { |
| 25 | + $src = $date; |
| 26 | + $date = libcalendaring_datetime::createFromFormat( |
| 27 | + 'Y-m-d\\TH:i:s', |
| 28 | + $date->format('Y-m-d\\TH:i:s'), |
| 29 | + // Sabre will loose timezone on all-day events, use the event start's timezone |
| 30 | + $this->start->getTimezone() |
| 31 | + ); |
| 32 | + if (!$date) { |
| 33 | + $date = new libcalendaring_datetime('@' . $src->getTimestamp()); |
| 34 | + $date->setTimezone($this->start->getTimezone()); |
| 35 | + } |
| 36 | + } |
| 37 | +
|
| 38 | + if (!is_object($date)) { |
| 39 | + return false; |
| 40 | + } |
| 41 | +
|
| 42 | + $date->_dateonly = $this->dateonly; |
| 43 | +NEW, |
| 44 | + ]], |
| 45 | +]; |
| 46 | + |
| 47 | +foreach ($patches as $file => $list) { |
| 48 | + $src = file_get_contents($file); |
| 49 | + foreach ($list as [$old, $new]) { |
| 50 | + if (substr_count($src, $old) !== 1) { |
| 51 | + fwrite(STDERR, "patch does not apply to $file\n"); |
| 52 | + exit(1); |
| 53 | + } |
| 54 | + $src = str_replace($old, $new, $src); |
| 55 | + } |
| 56 | + file_put_contents($file, $src); |
| 57 | + echo "patched $file\n"; |
| 58 | +} |
0 commit comments