[Bps-public-commit] rtx-calendar branch multiple-days-events-2 updated. 1.05-20-g8b28a35

BPS Git Server git at git.bestpractical.com
Fri Nov 3 18:10:23 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rtx-calendar".

The branch, multiple-days-events-2 has been updated
       via  8b28a35ec32be1d0fc1e8b41ae0621125a6b59b0 (commit)
       via  552a281e157fd5d75b66a4cb56035f9b2994a1fb (commit)
      from  7e24fe3c1f57eba397d8f2bea4c4de35d44351c9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8b28a35ec32be1d0fc1e8b41ae0621125a6b59b0
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Fri Nov 3 15:09:11 2023 -0300

    Prevent infinite loops when rendering multiple days events
    
    This patch prevents infinite or long loops when rendering multiple days
    events if user set end date to a date many years in the future.

diff --git a/lib/RTx/Calendar.pm b/lib/RTx/Calendar.pm
index 46eeec1..be2486b 100644
--- a/lib/RTx/Calendar.pm
+++ b/lib/RTx/Calendar.pm
@@ -140,7 +140,11 @@ sub FindTickets {
 
             my $end_date = $ends_date->ISO( Time => 0, Timezone => 'user' );
             my $first_day = 1;
-            while ( $current_date->ISO( Time => 0, Timezone => 'user' ) le $end_date )
+            # We want to prevent infinite loops if user for some reason
+            # set a future date for year 3000 or something like that
+            my $prevent_infinite_loop = 0;
+            while ( ( $current_date->ISO( Time => 0, Timezone => 'user' ) le $end_date )
+                && ( $prevent_infinite_loop++ < 10000 ) )
             {
                 my $dateindex = $current_date->ISO( Time => 0, Timezone => 'user' );
 

commit 552a281e157fd5d75b66a4cb56035f9b2994a1fb
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Fri Nov 3 15:02:53 2023 -0300

    Fix bug multiple days events not showing correctly
    
    The loop on the code that was checking if an event had multiple days had
    a minor bug because it was adding one day to each loop but using
    unixtime to check if the event had the next day ahead. That was causing
    the last day of the event to be disconnected from the rest if it was
    starting at a time lower than the start time of the event.

diff --git a/lib/RTx/Calendar.pm b/lib/RTx/Calendar.pm
index d37cae8..46eeec1 100644
--- a/lib/RTx/Calendar.pm
+++ b/lib/RTx/Calendar.pm
@@ -138,9 +138,9 @@ sub FindTickets {
                 Value => $starts_date->Unix,
             );
 
-            my $end_date_unix = $ends_date->Unix;
+            my $end_date = $ends_date->ISO( Time => 0, Timezone => 'user' );
             my $first_day = 1;
-            while ( $current_date->Unix <= $end_date_unix )
+            while ( $current_date->ISO( Time => 0, Timezone => 'user' ) le $end_date )
             {
                 my $dateindex = $current_date->ISO( Time => 0, Timezone => 'user' );
 

-----------------------------------------------------------------------

Summary of changes:
 lib/RTx/Calendar.pm | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
rtx-calendar


More information about the Bps-public-commit mailing list