News:

Looking for documentation? Take a look on our wiki

Main Menu

ps_session.php: it does not work correctly

Started by MiRcOv, December 13, 2008, 14:09:34 PM

Previous topic - Next topic

MiRcOv

Hi, i'm found a bad way of work of the file administration/components/com_virtuemart/classes/ps_session.php

Infact it passes bad itemsid. This is not onlyu a my problem but a general bug. I've found a lot of discussion about this.

Now i'm working on the bug.

For now the problem seems caused by the following functions:

getShopItemid
purl
url

In my first case the problem there was in shop.browse. Infact the Itemid passed was ever the same, also if i was in another menu branch. I solved partially by adding an else to the getShopItemid function (see http://forum.virtuemart.net/index.php?topic=42931.0).

Now there is a similar problem in the user area, using a virtuemart menu item setted only in the "page parameter" as account.index. In this page i have two link: "account info" and "shipping info". In the "account info" link there is a bad itemid insead of the "shipping info" link that have the correct itemid. As told i'm working on the problem. If someone of the VirtueMart developers likes to see the bug working, please contact me via pm. Bye bye.

MiRcOv

#1
Ok, it seems i've solved the bug. The problem was in the getShopItemid function.
This is the old function code


/**
     * Gets the Itemid for the com_virtuemart Component
     * and stores it in a global Variable
     *
     * @return int Itemid
     */
function getShopItemid() {

if( empty( $_REQUEST['shopItemid'] )) {
$db = new ps_DB;
$db->query( "SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND published=1");
if( $db->next_record() ) {
$_REQUEST['shopItemid'] = $db->f("id");
}
else {
if( !empty( $_REQUEST['Itemid'] )) {
$_REQUEST['shopItemid'] = intval( $_REQUEST['Itemid'] );
}
else {
$_REQUEST['shopItemid'] = 1;
}
}
}

return intval($_REQUEST['shopItemid']);

}


This is my edited function getShopItemid


/**
* Gets the Itemid for the com_virtuemart Component
* and stores it in a global Variable
*
* @return int Itemid
*/
function getShopItemid() {

if( !empty( $_REQUEST['Itemid'] )) {
// I have a good Itemid and i use it
$_REQUEST['shopItemid'] = $_REQUEST['Itemid'] ;
} else {
// Itemid is empty: i've to find
// a new value for $_REQUEST['shopItemid']

// I query the db to retrieve a valid Itemid
$db = new ps_DB;
$db->query( "SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND published=1");

// I read the values: if one i valorize
// $_REQUEST['shopItemid'] with it
if( $db->next_record() ) {
$_REQUEST['shopItemid'] = $db->f("id");
} else {
// I haven't find a good value in the db.
// I valorize $_REQUEST['shopItemid'] with
// a predefined value (=1)
$_REQUEST['shopItemid'] = 1;
}
}

// Now i can retrieve the correct shopItemid
return intval( $_REQUEST['shopItemid'] ) ;
}


If something isn't clear please replt to this post.

Below there are the other info:

VirtueMart 1.1

Joomla 1.5.8

Bugtracker task #:
Enter the bugtracker task #/url when submitted.

System info:
PHP 5.2.6
Apache
MySQL 5.0.67
Linux

MiRcOv

Hi, there is an edit in this file in the 1.1.3 version of virtue mart but this bug isn't still fixed :( The method is still the same and i've edited it another time. But is a bug! The itemid is not correct!