DivisionByZeroError: Modulo by zero

Created on 29 July 2019, about 5 years ago
Updated 13 June 2024, 4 months ago

The getColSize() calculates the number of columns a grid will take given the size of a specific column.

  • col-md-4 will take 3 columns as 12/4 = 3
  • col-lg-12 will take 1 column as 12/12 = 1

But, extra small columns are in the form of col-4 and not col-xs-4. This means that the preg_match() call with the regular expression ~col-[a-z]{2}-([0-9]*)~ will always fail and return FALSE for extra small columns.

By adding an additional call to preg_match() with the regular expression ~col-([0-9]*)~ catches this scenario.

diff --git a/web/modules/contrib/views_bootstrap/src/ViewsBootstrap.php b/web/modules/contrib/views_bootstrap/src/ViewsBootstrap.php
index 4823816b..879ea23f 100644
--- a/web/modules/contrib/views_bootstrap/src/ViewsBootstrap.php
+++ b/web/modules/contrib/views_bootstrap/src/ViewsBootstrap.php
@@ -104,6 +104,9 @@ public static function getColSize($size) {
     if (preg_match('~col-[a-z]{2}-([0-9]*)~', $size, $matches)) {
       return 12 / $matches[1];
     }
+    if (preg_match('~col-([0-9]*)~', $size, $matches)) {
+      return 12 / $matches[1];
+    }

     return FALSE;
   }
πŸ› Bug report
Status

Fixed

Version

5.4

Component

Grid

Created by

πŸ‡±πŸ‡ΊLuxembourg paddy_deburca

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024