Skip to content
Snippets Groups Projects
Commit 2aa1ba7e authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

VM4.2: Workaround for broken VM model

VirtueMartModelState::getStates and VirtueMartModelCountry::getCountries changes the internal cache ->_data, but does NOT modify ->_id...
The proper fix would be in VM's model classes to set the id to -1.

However, as a workaround we can call setId twice to ensure the cache is always invalidated and getData returns the proper object
parent ba590165
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@ BASE=rules_shipping
BASE_ADV=rules_shipping_advanced
PLUGINTYPE=vmshipment
ZIPBASE=opentools_vm2
VERSION=4.1
VERSION=4.2
PLUGINFILES=$(BASE).php $(BASE)_base.php $(BASE).script.php $(BASE).xml index.html
PLUGINFILES_ADV=$(BASE_ADV).php $(BASE)_base.php $(BASE_ADV).script.php $(BASE_ADV).xml index.html
......
File added
File added
......@@ -6,7 +6,7 @@
<authorUrl>http://www.open-tools.net</authorUrl>
<copyright>Copyright (C) 2013-2014, Reinhold Kainhofer</copyright>
<license>GPL v3+</license>
<version>4.1</version>
<version>4.2</version>
<description>VMSHIPMENT_RULES_DESC</description>
<files>
<filename plugin="rules_shipping">rules_shipping.php</filename>
......
......@@ -6,7 +6,7 @@
<authorUrl>http://www.open-tools.net</authorUrl>
<copyright>Copyright (C) 2013-2014, Reinhold Kainhofer</copyright>
<license>GPL v3+</license>
<version>4.1</version>
<version>4.2</version>
<description>VMSHIPMENT_RULES_ADV_DESC</description>
<files>
<filename plugin="rules_shipping_advanced">rules_shipping_advanced.php</filename>
......
......@@ -558,8 +558,13 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin {
$countriesModel = VmModel::getModel('country');
if (isset($address['virtuemart_country_id'])) {
$data['countryid'] = $address['virtuemart_country_id'];
// The following is a workaround to make sure the cache is invalidated
// because if some other extension meanwhile called $countriesModel->getCountries,
// the cache will be modified, but the model's id will not be changes, so the
// getData call will return the wrong cache.
$countriesModel->setId(0);
$countriesModel->setId($address['virtuemart_country_id']);
$country = $countriesModel->getData();
$country = $countriesModel->getData($address['virtuemart_country_id']);
if (!empty($country)) {
$data['country'] = $country->country_name;
$data['country2'] = $country->country_2_code;
......@@ -570,8 +575,13 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin {
$statesModel = VmModel::getModel('state');
if (isset($address['virtuemart_state_id'])) {
$data['stateid'] = $address['virtuemart_state_id'];
// The following is a workaround to make sure the cache is invalidated
// because if some other extension meanwhile called $countriesModel->getCountries,
// the cache will be modified, but the model's id will not be changes, so the
// getData call will return the wrong cache.
$statesModel->setId(0);
$statesModel->setId($address['virtuemart_state_id']);
$state = $statesModel->getData();
$state = $statesModel->getData($address['virtuemart_state_id']);
if (!empty($state)) {
$data['state'] = $state->state_name;
$data['state2'] = $state->state_2_code;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment