1
votes

Google has been able to crawl to my website, but it is not able to index anything.

When I fetch as Google to my website, I get an error message:

Fatal Error: Call to a member function getcookieshouldbereceived() on a non-object in /var/www/magento/app/code/core/mage/core/controller/varien/action.php on line 497

I then opened action.php file to see what's wrong. In the file action.php line 497 is this :

if ($session->getCookieShouldBeReceived()) {

The paragraph containing line 497 is: /** * Retrieve action method name * * @param string $action * @return string */ public function getActionMethodName($action) { return $action . 'Action'; }

/**
 * Dispatch event before action
 *
 * @return void
 */
public function preDispatch()
{
    if (!$this->getFlag('', self::FLAG_NO_CHECK_INSTALLATION)) {
        if (!Mage::isInstalled()) {
            $this->setFlag('', self::FLAG_NO_DISPATCH, true);
            $this->_redirect('install');
            return;
        }
    }

    // Prohibit disabled store actions
    if (Mage::isInstalled() && !Mage::app()->getStore()->getIsActive()) {
        Mage::app()->throwStoreException();
    }

    if ($this->_rewrite()) {
        return;
    }

    if (!$this->getFlag('', self::FLAG_NO_START_SESSION)) {
        $checkCookie = in_array($this->getRequest()->getActionName(), $this->_cookieCheckActions)
            && !$this->getRequest()->getParam('nocookie', false);
        $cookies = Mage::getSingleton('core/cookie')->get();
        /** @var $session Mage_Core_Model_Session */
        $session = Mage::getSingleton('core/session', array('name' => $this->_sessionNamespace))->start();

        if (empty($cookies)) {
            if ($session->getCookieShouldBeReceived()) {
                $this->setFlag('', self::FLAG_NO_COOKIES_REDIRECT, true);
                $session->unsCookieShouldBeReceived();
                $session->setSkipSessionIdFlag(true);
            } elseif ($checkCookie) {
                if (isset($_GET[$session->getSessionIdQueryParam()]) && Mage::app()->getUseSessionInUrl()
                    && $this->_sessionNamespace != Mage_Adminhtml_Controller_Action::SESSION_NAMESPACE
                ) {
                    $session->setCookieShouldBeReceived(true);
                } else {
                    $this->setFlag('', self::FLAG_NO_COOKIES_REDIRECT, true);
                }
            }
        }

Could you help me figure out what is wrong ?

Thanks !!

1
Did you manage to resolve this? I'm having the same issue - Javier Villanueva

1 Answers

0
votes

i had same problem. I think when a bot visit the site, $session object is NULL, not react like a normal browser. I modified;

if ($session->getCookieShouldBeReceived()) {

to

if (is_object($session) && $session->getCookieShouldBeReceived()) {

and my problem is solved. Google indexed my site normally.I know, its not a good thing to modifying core code but i'm new about magento. Is someone know how to make this change whithout change core code?