Out of range value for column 'virtuemart_calc_id' VM 4.4.6

Started by carlos88, March 13, 2025, 23:23:50 PM

Previous topic - Next topic

carlos88

Hi,

I am testing an update from VM 4.2.18 to VM 4.4.6
Joomla 5.2.5
PHP 8.1

VM 4.2.18 works perfectly for me, but after updating to VM 4.4.6, I get the following error when completing a purchase:


vmError: vmTable store insertObject #__virtuemart_order_calc_rules Out of range value for column 'virtuemart_calc_id' at row 1 INSERT INTO `rek6z_virtuemart_order_calc_rules` (`virtuemart_calc_id`,`virtuemart_order_id`,`virtuemart_vendor_id`,`calc_rule_name`,`calc_kind`,`calc_amount`,`calc_result`,`calc_value`,`created_on`,`created_by`) VALUES ('-1','9374','1','None','payment','0','0','0','2025-03-13 22:04:32','866')
Do you have any idea what might be causing this issue?

Around line 2295 of the orders.php file:


This code is being executed:

if(empty($_cart->cartPrices['payment_calc_id'])){
    $orderCalcRules->virtuemart_calc_id = -1;
    $orderCalcRules->calc_value = 0.0;
    $orderCalcRules->calc_rule_name = vmText::_('COM_VIRTUEMART_NONE');
} else {

The value of $_cart->cartPrices['payment_calc_id'] is 0, but this value is incorrect.



Carlos.

hazael

Out of Range Value means that the value you are trying to save in the Virtuemart_Calc_id column is beyond the allowed range for this field in the database. Your result indicates -1. This is a negative value for the displayed item, which of course is illogical. The column can be UNSIGNED INT which means that it only accepts 0 and larger values.

if(empty($_cart->cartPrices['payment_calc_id'])){
    $orderCalcRules->virtuemart_calc_id = 0; // Instead of -1
    $orderCalcRules->calc_value = 0.0;
    $orderCalcRules->calc_rule_name = vmText::_('COM_VIRTUEMART_NONE');
} else {

carlos88

Looking a bit better through the forum, I found a thread discussing this topic and linking to a possible solution.

https://forum.virtuemart.net/index.php?topic=152301.0

It seems that the "virtuemart_calc_id" field in the "#__virtuemart_order_calc_rules" table can now be negative.

I wonder what the reason is or in which cases this happens.
Does anyone know?
Shouldn't the table update automatically?

Carlos.

Milbo

Great research guys,
You may also look here, there is my answer in english https://forum.virtuemart.net/index.php?msg=544153

Here is the link to the german forum with the image which shows which db table column must be changed https://forum.virtuemart.de/thread/4748-fehlermeldung-nach-update-4-4-6/?postID=20573#post20573
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/