Skip to content
Snippets Groups Projects

Issue #3420857: Division by 0 when max_slots is 0

Open Issue #3420857: Division by 0 when max_slots is 0
1 unresolved thread
Open Reinhard Hutter requested to merge issue/bookable_calendar-3420857:2.2.x into 2.2.x
1 unresolved thread

Fixes #3420857: Division by 0 when max_slots is 0

Merge request reports

Members who can merge are allowed to add commits.

Merge request contains no changes

Use merge requests to propose changes to your project and discuss them with your team. To make changes, use the Code dropdown list above, then test them with CI/CD before merging.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
136 136 ];
137 137 $slots_available = $instance->slotsAvailable();
138 138 $max_slots = $instance->maxSlotsAvailable();
139 $remaining_percent = $slots_available / $max_slots;
139 if ($max_slots > 0) {
140 $remaining_percent = $slots_available / $max_slots;
141 }
142 else {
143 $remaining_percent = 0;
  • I need to test this, but if $max_slots is 0 that would mean there is no limit so we should set $remaining_percent to 100 right? Otherwise we will not allow new people to register.

  • Author Contributor

    IMHO 0 should not mean unlimited. Empty (unset, NULL,...) should mean unlimited, but the number 0 should mean nothing left.

  • Not saying you're wrong but Drupal uses 0 to mean unlimited when setting amount of values allowed in a field and other places like that.

  • Ok, maybe it actually uses -1 to mean unlimited, maybe I could switch to that.

  • Author Contributor

    I think in the context of instance booking slots both 0 and unlimited are meaningful valid (and different) values.

    So I'd be in favor of dedicated three-way logic umlimited + 0 + more than zero

  • Please register or sign in to reply
Please register or sign in to reply
Loading