tbar0970 / jethro-pmm

Jethro Pastoral Ministry Manager
GNU General Public License v3.0
36 stars 26 forks source link

Planned Absences cause errors to be logged when displaying attendance in 'Date Total's format #1050

Closed jefft closed 5 months ago

jefft commented 5 months ago

This bug doesn't affect end users, but generates error logs:

PHP message: A non well formed numeric value encountered - Line 485 of /srv/www/jethro/2.35.1/app/views/view_6_attendance__2_display.class.php', referer: https://jethro/?view=attendance__display

To replicate:

  1. Create a Planned Absence for someone, e.g. yourself. To do this, find your Person record, go to the Rosters tab and add a planned absence for the upcoming Sunday (23 June here): image

  2. Go to Attendance -> Record, select the upcoming Sunday as the date, and record yourself Absent: image

  3. Go to Attendance -> Display and verify that your record is (A) to denote a planned absence: image

  4. Change the format from Sequential to Date Totals and click 'Go'. Your record will have a 0 total, and an error will be logged.

jefft commented 5 months ago

The problem originated about a year ago, when getAttendances() output was modified to add * characters to indicate 'planned absence':

https://github.com/tbar0970/jethro-pmm/blob/f525298a798b7df136d36c5a1a02e86e22e89b38/db_objects/attendance_record_set.class.php#L761

The 'view attendance' code wasn't modified to take this into account, so $x would be 0* instead of 0 in this line: https://github.com/tbar0970/jethro-pmm/blob/f525298a798b7df136d36c5a1a02e86e22e89b38/views/view_6_attendance__2_display.class.php#L485

PHP is a YOLO language where 0 + '0*' evaluates to 0 and 0+'1*' evaluates to 1, so the code works but we get errors. See https://github.com/tbar0970/jethro-pmm/pull/1051 for suggested fix.