Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E_ERROR: Call to a member function hasLastUrl() on null #36

Open
aingham opened this issue Apr 19, 2017 · 3 comments
Open

E_ERROR: Call to a member function hasLastUrl() on null #36

aingham opened this issue Apr 19, 2017 · 3 comments

Comments

@aingham
Copy link

aingham commented Apr 19, 2017

Hi,

Recently we've been getting the above error using vsn 1.5.0 of Recaptcha. Error is coming from line 67 of Helper/Redirect.php, and looks as though it's not checking that $this->_session actually exists before accessing its hasLastUrl() method. I checked in latest 1.5.7 code and doesn't look as though any recent changes in this area.

I'd be happy to submit a code change to address this, but not sure how to create a unit test for it.

Andy Ingham

@philipcofc
Copy link

Same issue here with respect to review pages. Looks like using the defined getter getSession in Studioforty9_Recaptcha_Helper_Redirect::getUrl() and Studioforty9_Recaptcha_Helper_Redirect::getRequestUri() would resolve the issue.

Just in case it's helpful, here's the stack trace:

E_ERROR: Call to a member function hasLastUrl() on null
in Studioforty9_Recaptcha_Helper_Redirect::getUrl called at app/code/community/Studioforty9/Recaptcha/Helper/Redirect.php (67)
in Studioforty9_Recaptcha_Helper_Redirect::getUrl called at app/code/community/Studioforty9/Recaptcha/Model/Observer.php (54)
in Studioforty9_Recaptcha_Model_Observer::onPostPreDispatch called at app/code/core/Mage/Core/Model/App.php (1339)
in Mage_Core_Model_App::_callObserverMethod called at app/code/core/Mage/Core/Model/App.php (1318)
in Mage_Core_Model_App::dispatchEvent called at app/Mage.php (448)
in Mage::dispatchEvent called at app/code/core/Mage/Core/Controller/Varien/Action.php (527)
in Mage_Core_Controller_Varien_Action::preDispatch called at app/code/core/Mage/Core/Controller/Front/Action.php (64)
in Mage_Core_Controller_Front_Action::preDispatch called at app/code/core/Mage/Review/controllers/ProductController.php (46)
in Mage_Review_ProductController::preDispatch called at app/code/core/Mage/Core/Controller/Varien/Action.php (407)
in Mage_Core_Controller_Varien_Action::dispatch called at app/code/core/Mage/Core/Controller/Varien/Router/Standard.php (254)
in Mage_Core_Controller_Varien_Router_Standard::match called at app/code/core/Mage/Core/Controller/Varien/Front.php (172)
in Mage_Core_Controller_Varien_Front::dispatch called at app/code/core/Mage/Core/Model/App.php (354)
in Mage_Core_Model_App::run called at app/Mage.php (684)
in Mage::run called at /index.php (95)

Also happy to submit a PR if requested.

Swahjak added a commit to Swahjak/Recaptcha that referenced this issue Jun 27, 2017
@Swahjak
Copy link

Swahjak commented Jun 27, 2017

Got the same error. Created a pull request to fix the issue.

@Swahjak
Copy link

Swahjak commented Jun 27, 2017

(Temporary) Solution:

Add the following query parameter to the request url:

Mage_Core_Controller_Front_Action::PARAM_NAME_BASE64_URL => Mage::helper('core/url')->getCurrentBase64Url()

This will be caught in Studioforty9_Recaptcha_Helper_Redirect::_getRefererUrl

    /**
     * Identify referer url via all accepted methods: 
     *  - HTTP_REFERER
     *  - Regular
     *  - base64-encoded request param
     *
     * @return string
     */
    protected function _getRefererUrl()
    {
        $request = Mage::app()->getRequest();
        
        $refererUrl = $request->getServer('HTTP_REFERER');
        if ($url = $request->getParam(Mage_Core_Controller_Front_Action::PARAM_NAME_REFERER_URL)) {
            $refererUrl = $url;
        }
        if ($url = $request->getParam(Mage_Core_Controller_Front_Action::PARAM_NAME_BASE64_URL)) {
            $refererUrl = Mage::helper('core')->urlDecode($url);
        }
        if ($url = $request->getParam(Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED)) {
            $refererUrl = Mage::helper('core')->urlDecode($url);
        }
        
        return $refererUrl;
    }

hnsr added a commit to ho-nl-fork/magento1-StudioForty9_Recaptcha that referenced this issue Aug 4, 2017
Fixes studioforty9-dev#36. Replaced _session with getSession(), removed some whitespace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants