Closed addison74 closed 3 years ago
I suggest the following change into the code:
Replace
$e->prepareForward('index', 'error', 'honeyspam');
with
$e->prepareRedirect('honeyspam/error');
I have tested and it is working as expected.
It shouldn't work 🤔 😂 Because Magento has still a bug in their prepareRedirect
method:
public function prepareRedirect($path, $arguments = array())
{
$this->_resultCallback = self::RESULT_REDIRECT;
$this->_resultCallbackParams($path, $arguments);
return $this;
}
$this->_resultCallbackParams($path, $arguments);
needs to be
$this->_resultCallbackParams = array($path, $arguments);
I'm heavily wondering why this works.
But imho is that the way to go. Extend Mage_Core_Controller_Varien_Exception
, fix the bug in prepareRedirect
and then prepareRedirect()
and throw
this new implemented exception
@ADDISON74 Thanks fir digging into this!
I checked a lot of posts over the years related to prepareForward issue. In most of the cases the solution was the one I mentioned in the first post, but I checked the core code to understand what means Forward and Redirect.
Probably it worked in my case without changing the core code because there were no arguments in the method. I will check if OpenMage team has fixed the issue you mentioned.
Yes they did 😅 If you are using OpenMage, this explains the working <3
You guessed right. I made the change in OpenMage. It is a blessing the M1 project is led before that kind team.
You can make a change in the code without extending any class. If it is Magento by default then you use the code from the first post (or other more elegant). If it is OpenMage then the redirection made through a line of code works like a charm.
In order to generate a SPAM event in frontend fill up honeyspam input text box with a value and an email address. Check the URL of the page after redirection. The extension redirects to /newsletter/subscriber/new instead of /honeyspam/error. I got the same results testing with Magento 1.9.2.4, 1.3,9.10, 1.9.4.5 and OpenMage 20.0.4.
This issue is coming from prepareForward method used in Observer.php file. Here is one example:
I did a change in the code as follows in order to get honeyspam URL:
Any thougths?