News:

Support the VirtueMart project and become a member

Main Menu

Error: PHP Warning: Division by zero

Started by Greystoke, April 27, 2017, 16:03:31 PM

Previous topic - Next topic

Greystoke

Hi,

Upgraded to Joomla 3.7.0
PHP 5.6
VirtueMart 3.2.1

I am see this error since I upgraded Joomla to 3.7.0:

PHP Warning:  Division by zero in /components/com_virtuemart/sublayouts/categories.php on line 33
PHP Warning:  Division by zero in /components/com_virtuemart/sublayouts/categories.php on line 57

jenkinhill

Probably another J3.7 issue. Was there a warning with J3.6.5?  If the front end still looks OK then you can suppress the php warning with php.ini settings or possibly by setting  Error Reporting
to none in Joomla global config/server - I have not checked if warning suppression still works after a Joomla update.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Greystoke

Hi,

The error was in the error log.

When I upgrade PHP to 7.0 virtuemart no longer works at all.

I get this error on all pages:


Jörgen

Are You using a custom template ? Because others are using Joomla 3.7.0 without this issue. Not saying that VM doesn´t have issues with 3.7.0, but probably not this for most other users.

regards

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Greystoke

I changed the Template to the Joomla default:

Beez3 - Default

Error:


I removed the lines that where giving errors and virtuemart works with PHP 7.0
PHP Warning:  Division by zero in /components/com_virtuemart/sublayouts/categories.php on line 33
PHP Warning:  Division by zero in /components/com_virtuemart/sublayouts/categories.php on line 57  (REMOVED LINES 57-61 AS IT WAS AN IF STATEMENT)

Jörgen

Please show the code for the lines that are faulting. You may have some settings in number of columns maybe that is giving trouble.

This should be easy to fix in the template file :)

regards

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

jenkinhill

Both those calculation lines include the number of set categories per row.

I have a J3.7 VM3.2.1 running just fine on PHP7.0.18 using Beez and VM default templates. With full debug turned on there is no division by zero reported.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Greystoke

It looks like it is just this link that is the problem.

index.php?option=com_virtuemart&view=category&virtuemart_category_id=0&virtuemart_manufacturer_id=0&Itemid=557

It is the Menu link to the Shop, created using the Menu Item Type : Category Layout.

Select a Category is set to: Top Level Category.
Select a Manufacturer is set to: "Please Select". ( I am not using Manufacturers, so none to select )


Jörgen

#8
Just curious. Do You have categories per row set to 0 somewhere  in Virtuemart under configuration templates?

This would explain the issue. The following code would be nice to include in sublayouts/categories.php

after line 39
$categories_per_row = VmConfig::get ( 'categories_per_row', 3 );

insert a test for categories == 0
// JH 2017-04-28 Prevents division by 0
if ($categories_per_row == 0) {
  $categories_per_row = 3:}



regards

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Greystoke

I have Default number of categories in a row set to 3

Is there anywhere else this could be set.

jenkinhill

Cats per row can be set in three places: 
the Joomla menu link to VM category view on the Virtuemart Category View Settings tab
in VM Configuration/Templates
and for each category on the Virtuemart category view settings
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Milbo

or just

if(empty($categories_per_row)) $categories_per_row = 3;
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/