For the last week I have been trying to find an issue, where captcha images where being cached. Luis was not able to reproduce this and I was not only able to reproduce it, but offer a solution below.
ContentBox now provides caching of CommentForms, not sure why but it does. Which means that if you are developing your own layouts with Custom themes, then this will apply to you as well.
In my theme I have a custom CommentForm that was doing this.
#getMyPlugin(plugin=“Captcha”, module=“contentbox”).display(message="")#
Which means that now the image actually gets cached, so when we go and look at how Luis has done this in his themes, we can see that he has now changed it to this.
<img src=’#event.buildLink( event.getValue( ‘cbEntryPoint’, ‘’, true) & ‘__captcha’)#’>
The problem was that for me, on 5 servers I tried this on. I got one of two issues. The first was my servers locally all came back with Bad Gateway, but in production I just got errors in my logs that stated that it couldn’t find a layout.
After many days of going back and forth with Luis, as well as my hosting provider, I then decided to search something else in the code and discovered that ContentBox has a critical bug in the code.
To fix this we have to make changes to the __captcha handler, located inside the contentbox-ui that looks like this.
/**
- Deliver Captcha
*/
function captcha(event,rc,prc){
var data = getMyPlugin(plugin=“Captcha”,module=“contentbox”).display();
var imgURL = arrayToList( reMatchNoCase( ‘src="([^"]*)"’, data ) );
imgURL = replace( replace( imgURL, “src=”, “” ) , ‘"’, “”, “all”);
// deliver image
getPageContext().forward( imgURL );
}
Which doesn’t look like a problem, but according to an article I found. One must use an abort after using the getPageContext().forward(), so that means the following should now work.
/**
- Deliver Captcha
*/
function captcha(event,rc,prc){
var data = getMyPlugin(plugin=“Captcha”,module=“contentbox”).display();
var imgURL = arrayToList( reMatchNoCase( ‘src="([^"]*)"’, data ) );
imgURL = replace( replace( imgURL, “src=”, “” ) , ‘"’, “”, “all”);
// deliver image
getPageContext().forward( imgURL );
abort;
}
Once we have reloaded the application from the admin dashboard, we now find that all the issues that had been occurring are now obsolete.
Anyway until Luis patches this change, I thought I would put it out there for everyone to patch now if you need it.