News:

Looking for documentation? Take a look on our wiki

Main Menu

Router problem VM3.0.18.7

Started by ptrouw, January 22, 2017, 17:34:55 PM

Previous topic - Next topic

ptrouw

Using: VM 3.0.18.7, J 3.6.5, no cache, no compression and no script/css merges

It seems that the router is doing strange things. If I follow a Google search and follow the link the fist time it loads the product page is gives a 404 error, the second time I click on the same google link, the product is showing!
It seems the VM router has problems the first time it hits the website finding the right category and product.
The is the response in the Apache log file. 1st line is unsuccessful and showing a 404. the 2nd time is successfully showing the product!

94.xxx - - [22/Jan/2017:17:08:32 +0100] "GET /nl/shop/opel/mokka-2012/opel-mokka-2012-achterbumper-protector-rvs-detail.html HTTP/1.1" 302 380 "https://www.google.nl/" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0"
94.xxx - - [22/Jan/2017:17:08:47 +0100] "GET /nl/shop/opel/mokka-2012/opel-mokka-2012-achterbumper-protector-rvs-detail.html HTTP/1.1" 200 20833 "https://www.google.nl/" "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0"

The search string within Google is right: 1st line is the Google URL, the 2nd is the product URL, both the same:

https://www.google.nl/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&ved=0ahUKEwj65bvAkdbRAhUCnRoKHcS4CSwQjhwIBQ&url=https%3A%2F%2Fwww.carparts-expert.com%2Fnl%2Fshop%2Fopel%2Fmokka-2012%2Fopel-mokka-2012-achterbumper-protector-rvs-detail.html&bvm=bv.144686652,d.d2s&psig=AFQjCNFdRGcrafafeQpQoYXqECk98eyS7w&ust=1485187631580755&cad=rjt

https://www.carparts-expert.com/nl/shop/opel/mokka-2012/opel-mokka-2012-achterbumper-protector-rvs-detail.html

Last comment, I double checked all the Joomla article links of the same website in Google, and they all show up fine! So my conclusion is that the Joomla router is fine!

jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

ptrouw

#2
Thx for the advice, but testserver is not indexed by google, so difficult to test!
I did the upgrade, but seem to have different problem now, related with SEO -detail.html behind the product URL in multi lingual environment!

Can it somehow perhaps be related to all the category (template) changes?

It seems that the default English languages URLs are fine, the problem is with all URLS with the language (SEF) in between, like /nl/shop/, /fr/shop/ etc.

ptrouw

#3
I did so more testing, I am getting crazy :(

I have changed back to the router from 3.0.16. Makes no difference.
Also it isn't related to multi lingual, I have problems with English as well.
First time you click on a link from for instance google (https://www.carparts-expert.com/nl/shop/toyota/yaris-iii-2011/toyota-yaris-iii-2014--3d-5d-achterbumper-protector-rvs-detail.html), it opens the highest parent category level.
If I do a refresh, the right product detail page is shown.

It is a production site, and google shopping is used a lot! Any ideas?

Got this messages in Apache error.log. They seem to be related or not?
[Sun Jan 22 22:53:58.880651 2017] [lsapi:error] [pid 739503:tid 140038505293568] [client zyx] [host www.carparts-expert.com] Error receiving response header (lsphp is killed?): ReceiveResponseHeader: receive pkg hdr failed: ReceivePkgHdr: nothing to read from backend socket, referer: https://www.carparts-expert.com/nl/shop/mercedes-benz/cla-c117-2013/mercedes-benz-cla-c117-2013--4d-coupe-kofferbakmat-anti-slip-pe-tpe-detail.html
[Sun Jan 22 22:54:07.175168 2017] [lsapi:error] [pid 739503:tid 140038736070400] [client abc] [host www.carparts-expert.com] Error receiving response header (lsphp is killed?): ReceiveResponseHeader: receive pkg hdr failed: ReceivePkgHdr: nothing to read from backend socket, referer: https://www.google.de/

stAn99

hello friends, after spending 5 hours at Paul's demo site i located the problem which can be replicated this way:

within any system plugin (in our example it's vmdropshipping.php) initialize Virtuemart with loadconfig before the class initialization OR within the onAfterInitialize event OR within the system plugin contructor.

example of a real plugin - this is a very common way to initiaze Virtuemart from system plugins:


<?php
/*------------------------------------------------------------------------
# plg_vmdropshipping - Virtuemart Drop Shiiping 
# ------------------------------------------------------------------------
# author    WebKul software private limited 
# copyright Copyright (C) 2010 webkul.com. All Rights Reserved.
# @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Websites: http://webkul.com
# Technical Support:  Forum - http://webkul.com/ticket
-------------------------------------------------------------------------*/
// no direct access
defined'_JEXEC' ) or die( 'Restricted access' ); 
jimport'joomla.plugin.plugin' ); 

//loading vmConfig
if (!class_exists'VmConfig' )) require(JPATH_ADMINISTRATOR.DIRECTORY_SEPARATOR .'components' .DIRECTORY_SEPARATOR.'com_virtuemart'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'config.php');
VmConfig::loadConfig();

//loading VirtuemartViewInvoice
if (!class_exists'VirtuemartViewInvoice' )) require(JPATH_SITE.DIRECTORY_SEPARATOR .'components' .DIRECTORY_SEPARATOR.'com_virtuemart'.DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.'invoice'.DIRECTORY_SEPARATOR.'view.html.php');

//loading shopFunctionsF
if (!class_exists'shopFunctionsF' )) require(JPATH_SITE.DIRECTORY_SEPARATOR .'components' .DIRECTORY_SEPARATOR.'com_virtuemart'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'shopfunctionsf.php');


class 
plgSystemVmdropshipping extends JPlugin
{


now at the
\components\com_virtuemart\router.php

which parses an URL into non-SEF variables
url example OF A PRODUCT DETAILS URL:

http://example.com/nl/shop/nissan/note-e12-2013/nissan-note-e12-2013--5d-instaplijst-set-4-delig-detail.html


to check for the current language you can debug like this in the router.php file:


public function getProductId($names,$catId = NULL, $seo_sufix = true ){

var_dump(VmConfig::$vmlang);


NOW CLEAR THE COOKIES AND HIT YOUR SEF URL
you'll see your default language such as "en_gb"

if you press F5/reload you'll see your own language "nl_nl"

clear the cookies, reload the page and you'll see "en_gb" again.

The fix for this is TO RELOAD VMCONFIG at a Joomla event which got all the Router parameters ready, and can recognize the language since the URL was already parsed.

i've created a patch for this:
https://www.rupostel.com/svn3/patch.1485197413.svn.txt

which looks like this:


locate this lines:


/* This function can be slower because is used only one time  to find the real URL*/
function virtuemartParseRoute($segments) {
$vars = array();


and change to:


/* This function can be slower because is used only one time  to find the real URL*/
function virtuemartParseRoute($segments) {

defined('DS') or define('DS', DIRECTORY_SEPARATOR);
if (!class_exists( 'VmConfig' )) require(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'helpers'.DS.'config.php');
$lang_code = JFactory::getApplication()->input->get('language', null);  //this is set by languageFilterPlugin
if (!empty($lang_code)) {  // by default it returns a full language tag such as nl-NL
VmConfig::loadConfig();    // this is needed in case VmConfig was not yet loaded before
VmConfig::setdbLanguageTag($lang_code); //this is needed if VmConfig was called in incompatible context and thus curret VmConfig::$vmlang IS INCORRECT
}

$vars = array();



the fix was done agains VM 3.0.18.7 to 3.0.18.9

best regards, stan, rupostel.com
----
RuposTel.com
www.rupostel.com
Your customized checkout solution for Virtuemart

stAn99

edit:
this fix works only on VM3.0.18.7 and a few versions before...

for 3.0.18.9 the "VmConfig::$vmlang" will not get changed with "VmConfig::setdbLanguageTag($lang_code);"

stan
----
RuposTel.com
www.rupostel.com
Your customized checkout solution for Virtuemart

stAn99

updated fix for some 3.0.18.9 versions:

replace whole function in your virtuemart's router.php


public static function getInstance(&$query = null) {

  if (!self::$_instance){

   $lang_code = JFactory::getApplication()->input->get('language', null);  //this is set by languageFilterPlugin
   if (!empty($lang_code)) {  // by default it returns a full language tag such as nl-NL
    if (!class_exists( 'VmConfig' )) require(JPATH_ROOT .'/administrator/components/com_virtuemart/helpers/config.php');
    VmConfig::loadConfig();    // this is needed in case VmConfig was not yet loaded before
    vmLanguage::setLanguageByTag($lang_code); //this is needed if VmConfig was called in incompatible context and thus current VmConfig::$vmlang IS INCORRECT
   }
   self::$_instance= new vmrouterHelper ($query);

   if (self::$limit===null){
    $mainframe = JFactory::getApplication(); ;
    $view = 'virtuemart';
    if(isset($query['view'])) $view = $query['view'];
    self::$limit= $mainframe->getUserStateFromRequest('com_virtuemart.'.$view.'.limit', VmConfig::get('list_limit', 20), 'int');
   }
  }
  self::$_instance->query = $query;
  if(!empty($query['Itemid']) and $query['Itemid']!=self::$_instance->Itemid){
   self::$_instance->Itemid = $query['Itemid'];
   self::$_instance->setMenuItemId();
  } else {
   //self::$_instance->Itemid = vRequest::get('Itemid',false);
   //vmTrace('No item id in query');
  }

  return self::$_instance;
}



this will get included in future VMs.

best regards, stan
----
RuposTel.com
www.rupostel.com
Your customized checkout solution for Virtuemart