News:

Looking for documentation? Take a look on our wiki

Main Menu

router bug Object set as index!

Started by Studio 42, November 09, 2017, 01:15:43 AM

Previous topic - Next topic

Studio 42

VM 3.2.4
Check your code arround line 1314 in router.php file :               
} else {
static $msg = array();
if(empty($msg[$item])){
vmdebug('my item with empty $link["view"]',$item);
$msg[$item] = 1;
}

$item used to set index is an object ! Lucky, it not break all the online shops.
And adding a static in the else ? I think this not really clear and can give trouble in next releases.

The message i have is :
QuoteWarning: Illegal offset type in isset or empty in /homepages/38/d323638701/htdocs/habitat-ecologique/Joomla3/components/com_virtuemart/router.php on line 1316

Warning: Illegal offset type in /homepages/38/d323638701/htdocs/habitat-ecologique/Joomla3/components/com_virtuemart/router.php on line 1318
Each time the router is called when i'm on PHP debug mode.
Why none control the code with PHP debug mode set to maximum? This is then directly visible.
When you log this errors in php log, you have a 100mo file each day because this.

Studio 42

changing $item to $item->id remove the bug, but static should be moved in the begin of function.
} else {
static $msg = array();
if(empty($msg[$item->id])){
vmdebug('my item with empty $link["view"]',$item);
$msg[$item->id] = 1;
}

Milbo

Thank you.

Actually it is a kind of "error" message. The static is created here, just to prevent that we see the debug message more than one time. So the creation of the static here is correct imho, even it is dirty.
But setting the object of course is wrong. My suggestion is:

static $msg = array();
$id = empty($item->id)? '0': $item->id;
if(empty($msg[$id])){
vmdebug('my item with empty $link["view"]',$item);
$msg[$id] = 1;
}
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/