Try the Demo

Magento

eCommerce Software for Online Growth

Magento Forum

Our new hosted solution for small & emerging businesses
   
Google Cache & Zend Locale
 
gabrielk
Sr. Member
 
Avatar
Total Posts:  83
Joined:  2007-11-30
 

It almost looks like Zend Locale isn’t able to tell where the Google Cache bot is located and therefore throws an error.  It’s a big ol’ footprint for anyone looking for Magento installs.  It’s not isolated.

exception 'Zend_Locale_Exception' with message 'Autodetection of Locale has been failed!' in /path/to/magento/lib/Zend/Locale.php:122
Stack trace
:
#0 /path/to/magento/lib/Zend/Locale.php(913): Zend_Locale->__construct()
#1 /path/to/magento/lib/Zend/Locale/Data.php(256): Zend_Locale::isLocale('en_US')
#2 /path/to/magento/lib/Zend/Locale.php(756): Zend_Locale_Data::getContent('en_US', 'currencyname', 'EUR')
#3 /path/to/magento/app/code/core/Mage/Directory/Block/Currency.php(46): Zend_Locale->getTranslation('EUR', 'currency')
#4 /path/to/magento/app/code/core/Mage/Directory/Block/Currency.php(36): Mage_Directory_Block_Currency->getCurrencies()
#5 /path/to/magento/app/design/frontend/default/default/template/directory/currency.phtml(28): Mage_Directory_Block_Currency->getCurrencyCount()
#6 /path/to/magento/app/code/core/Mage/Core/Block/Template.php(116): include('/home/username/www...')
#7 /path/to/magento/app/code/core/Mage/Core/Block/Template.php(143): Mage_Core_Block_Template->fetchView('frontend/defaul...')
#8 /path/to/magento/app/code/core/Mage/Core/Block/Template.php(188): Mage_Core_Block_Template->renderView()
#9 /path/to/magento/app/code/core/Mage/Core/Block/Text/List.php(38): Mage_Core_Block_Template->toHtml()
#10 /path/to/magento/app/code/core/Mage/Core/Block/Abstract.php(437): Mage_Core_Block_Text_List->toHtml()
#11 /path/to/magento/app/code/core/Mage/Core/Block/Abstract.php(415): Mage_Core_Block_Abstract->_getChildHtml('left', true)
#12 /path/to/magento/app/design/frontend/default/default/template/page/3columns.phtml(63): Mage_Core_Block_Abstract->getChildHtml('left')
#13 /path/to/magento/app/code/core/Mage/Core/Block/Template.php(116): include('/home/username/www...')
#14 /path/to/magento/app/code/core/Mage/Core/Block/Template.php(143): Mage_Core_Block_Template->fetchView('frontend/defaul...')
#15 /path/to/magento/app/code/core/Mage/Core/Block/Template.php(188): Mage_Core_Block_Template->renderView()
#16 /path/to/magento/app/code/core/Mage/Core/Model/Layout.php(401): Mage_Core_Block_Template->toHtml()
#17 /path/to/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(303): Mage_Core_Model_Layout->getOutput()
#18 /path/to/magento/app/code/core/Mage/Catalog/controllers/CategoryController.php(54): Mage_Core_Controller_Varien_Action->renderLayout()
#19 /path/to/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(326): Mage_Catalog_CategoryController->viewAction()
#20 /path/to/magento/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(147): Mage_Core_Controller_Varien_Action->dispatch('view')
#21 /path/to/magento/app/code/core/Mage/Core/Controller/Varien/Front.php(164): Mage_Core_Controller_Varien_Router_Standard->match(Object(Zend_Controller_Request_Http))
#22 /path/to/magento/app/Mage.php(378): Mage_Core_Controller_Varien_Front->dispatch()
#23 /path/to/magento/index.php(28): Mage::run('base')
#24 {main}

Of course a live server would benefit from just turning off error reporting, but I’m more curious as to what’s causing this error and how to “fix” it.  The part of the Magento code that throws this error is Mage_Directory_Block_Currency->getCurrencies() it seems, stemming from an underlying error in Zend_Locale.  Is the googlebot reaching a filesize limit and stopping, causing the page to incompletely load thus the error?  Is Zend Locale having trouble finding the location of the googlebot?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mark_Kimsal
Sr. Member
 
Total Posts:  186
Joined:  2007-09-12
Michigan, USA
 

heh… ZF…

The default behavior is to inspect the browser’s headers and determine a locale from the ‘Accept-Language’ HTTP header.  Most spiders don’t bother sending this header as it is optional.  ZF requires it by default, when it’s not found, they feel that it’s good to throw an exception.  Magento doesn’t catch this exception, and thus you see the error on the screen.

The issue has already been fixed.  It’s fixed in Magento 0.7 latest, I think it’s fixed in the latest release of ZF, not positive.

The core part of the issue is in the raw PHP function setlocale().  You can use it to “get” the current locale setting.  The only problem is if your apache has been launched from an environment where the locale variables are already set, LC_ALL, LC_CTYPE, whatever, then setlocale() returns a different format.  Normally it returns a list of key value pairs that you can split like:

LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;

But, if your environment has already set the LC_ALL, then setlocale() returns only the letter “C”, meaning that you can’t parse it up normally and get all the different variable settings.

So, php is goofy (we all know that), ZF is goofy (because it doesn’t know that PHP is goofy and because it throws an exception if “auto-detection” fails) and magento is goofy because it doesn’t catch the Exception thrown by ZF (but Mage is still beta).

If your system has an “old” ZF, maybe Mage is picking up that first before its own copy… Anyways, here’s the fix*:

Add this between lines 198 and 199 of lib/Zend/Locale.php (end of function getDefault())

if (!array_key_exists(self::$_Default$languages)) {
             $languages[self
::$_Default] 0.1;
        
}

Again, this is fixed on my install of 0.7 already.

(* i don’t really consider this a fix because it doesn’t apply any locale if you haven’t set a default one, it merely shoves an empty array key at the end of “languages”.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mark_Kimsal
Sr. Member
 
Total Posts:  186
Joined:  2007-09-12
Michigan, USA
 

Don’t take anything I say seriously.  I’m not entirely sure if PHP looks at apache’s environment for it’s default setting.  I can’t seem to change anything with setlocale(), so maybe my environment isn’t the best to test this with.

The rest of the explanation stands though.

 
Magento Community Magento Community
Magento Community
Magento Community
 
gabrielk
Sr. Member
 
Avatar
Total Posts:  83
Joined:  2007-11-30
 

Cool, that’s along the lines of what I was thinking.  Thanks for the fix, I’ll try that out! 

We’re working with a modified version of 0.6.something (I can’t wait to start upgrading… =P).

 
Magento Community Magento Community
Magento Community
Magento Community
 
gabrielk
Sr. Member
 
Avatar
Total Posts:  83
Joined:  2007-11-30
 

Unfortunately the above fix didn’t actually fix it.  However, it’s a known issue with Zend, and the latest release (1.5.0, currently listed as “unstable") DOES in fact fix it.

There are no real reported bugs with the two effected modules, so you can download the whole library and just replace the following files:
/lib/Zend/Currency/*
/lib/Zend/Currency.php
/lib/Zend/Locale/*
/lib/Zend/Locale.php

Grabbing the file with wget no longer shows these errors. :D

 
Magento Community Magento Community
Magento Community
Magento Community
 
Hadifarnoud
Sr. Member
 
Total Posts:  162
Joined:  2007-10-07
Guildford, Surrey, UK
 

@ gabrielk: should i replace xml files as well? i mean locale xml files (like en.xml or en_US.xml)
and current version is 1.0.3 but you said replace 1.5 version , is it OK ?

 Signature 

VIP Managed Hosting & Magento Development | Acamedium Ltd.

 
Magento Community Magento Community
Magento Community
Magento Community
 
gabrielk
Sr. Member
 
Avatar
Total Posts:  83
Joined:  2007-11-30
 

I didn’t find any real bug reports for the Currency & Locale modules that you’d be replacing on the Zend site.  I uploaded all the /Zend/Locale/Data xml files too, just to be on the safe side.  Zend 1.5 is still pre-release, but then so is Magento, right? wink

One bug this introduces is on the Admin panel, when you click on System Configuration, you get an error about ksort trying to sort a non-array.  I haven’t gotten a chance to look at this and find a fix, but it only appears to affect the “General” tab of system configuration on the admin panel.  The bug basically means no locations/timezones show up in the dropdown menu on that page; we’ve put this on our live site (http://www.shoebacca.com) and I haven’t seen any other errors or adverse effects.

 
Magento Community Magento Community
Magento Community
Magento Community
 
AnkaBiz
Jr. Member
 
Total Posts:  5
Joined:  2009-12-07
 

any idea why no cache in google for magento?

site: http://www.anka-bizuteria-sklep.pl

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
 
© Copyright Magento Inc.
Privacy Policy|Terms of Service
Magento Community Count
819302 users|754 users currently online|519712 forum posts