VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: balai on October 06, 2016, 14:04:47 PM

Title: Datatypes of router's queries
Post by: balai on October 06, 2016, 14:04:47 PM
It could happen that another extension is using the same variable names in it's server requests.
Also it is possible that these variables have different format.

In that case, if there is a virtuemart module published in the output page, the VM router produces some notices like (Type x to string conversion).

Checking the router i found out that the query variables are submitted as they are in other functions with out any type validation or conversion.
Some examples:
$categoryRoute = $helper->getCategoryRoute($query['virtuemart_category_id']);
could become:
$virtuemart_category_id=$query['virtuemart_category_id'];
if(is_array($virtuemart_category_id)) {
        $virtuemart_category_id=reset($query['virtuemart_category_id']);
}
$virtuemart_category_id=(int)$virtuemart_category_id;
$categoryRoute = $helper->getCategoryRoute($virtuemart_category_id);


Something similar happens with the manufacturers.

It's up to you how you will implement this but i suggest either not going further or changing the data format in these cases
Title: Re: Datatypes of router's queries
Post by: Milbo on October 07, 2016, 09:26:39 AM
But to use the first option would be also just a guess, or?
I think it is better to disable SEF for this link in this cases, on the other hand, without SEF it may not work as expected also, because the SEF does more than just making the link nice. Hmmm, but interesting problem, indeed.
Title: Re: Datatypes of router's queries
Post by: balai on October 07, 2016, 13:41:28 PM
QuoteBut to use the first option would be also just a guess, or?
Partially yes. But through the url you can pass either a scalar variable or an array. Hence this covers all the cases i suppose.