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;
}
Comments
Comment #2
RabiaSajjad commentedSame error, applied change and works now.
Comment #3
Salez-Poivrez commentedSame problem. Call to preg_match() added. It's works fine for me.
Comment #4
drupgirl commented+1 RTBC manually patched and it worked. Thank you!
Comment #5
glynster commentedSame issue exists in version 8.x-3.5. I have back ported a patch and this resolves the issue as well. All credits to @paddy_deburca we use composer so we need patches :)
Comment #6
shelaneComment #7
komlenic commentedConfirming that the issue exists in 5.3.0 and that the patch in #5 fixes the issue in 8.x-3.5/5.3.0.
Does this need to be applied to the 5.3 and 5.4 branches?
Comment #8
chris matthews commentedI'm running into this issue on 5.3.0 (for Bootstrap 3). Any chance the patch in #5 can be committed to -dev?
Comment #9
shelaneI'm not sure how this would work for Bootstrap 3 as the columns are all in the form of col-sm-1, col-md-1, etc.
Comment #10
chris matthews commentedDrupal: 9.4.7
PHP: 8.1
Bootstrap: 8.x-3.25
Views Bootstrap: 5.3.0
Before applying the patch in #5, below was the php error I was getting. After applying the patch the error was resolved.
Message DivisionByZeroError: Modulo by zero in __TwigTemplate_5a297159902bd77452b3a32b195c7d9a->doDisplay() (line 117 of /tmp/rolling/live_418/twig/633b314f71e36_views-bootstrap-grid.html_gqQPANHLUWgn4Erd9IyZPPw_t/9JC_yaiygW3Zy9cotXsAi59lgI0UE5VlacmZZBmy4gQ.php)Comment #11
shelaneCan you share a screen shot of your settings that would enable me to recreate the error message?
Comment #12
chris matthews commented@shelane Would it be possible for the patch in #5 to be committed? I've been using on the 3.x branch for quite a while with no issues.
Comment #13
noonoos commentedJust did upgrade. " - Upgrading drupal/views_bootstrap (5.5.0-beta2 => 5.5.0-beta3): Extracting archive"
and I am now getting this error on one page (Home Page)
Comment #14
shelaneIf you are seeing this error after update to 5.5.0-beta, see related issue #3447965: 5.5.0-beta1 DivisionByZeroError: Modulo by zero and comments.
Comment #15
noonoos commentedJust did upgrade. " - Upgrading drupal/views_bootstrap (5.5.0-beta2 => 5.5.0-beta3): Extracting archive"
and I am now getting this error on one page (Home Page)
Issue resulted from the updated ViewsBootstrapCards.php plugin requiring extra data input than previous plugin causing the above error response.
Comment #21
shelane