Interceptors - Buffer

I’ve found strange behavoir about the Interceptors and their buffer.
If more than one module observes the same event (in our case cbui_beforeHeadEnd) all methods will be executed, but the Buffer for the output is at the second module empty, there is no concatination for the output. The once exception were this works fine is at the reload of framework (fwreinit in url).


Hi Matthias,

Yeah I have seen this a few times now, and can say there is something going on. Normally I have found that if you use the $htmlhead() this can cause these issues.

Do you have an example of what you are doing, replace all sensitive text with some dummy text. Will help us better help you here.

Hi Andrew,

on the event “cbui_beforeHeadEnd” there is the google analytics module which creates output for the -Element. This is a standard event and a standard listener.
On the same event we’ve implemented an interceptor which should be create additional output for the -Element. The function cbui_beforeHeadEnd in our module will be executed firstly, the output buffer is filled with our data. The next step is to execute the cbui_beforeHeadEnd method in the google analytics module. If in url fwreinit is set, the output buffer is filled with the data of the first module, the output is correctly in the -element. If the parameter is not set, the output buffer is at the second listener empty, the data is dropped. We’ve no idea what’s the reason. It’s independent of the kind of output in our module.

Ok I wouldn’t use the fwreinit, as you really should be using the different options in the dashboard like reload application / reload site and kill cache etc.

There are times when I still find the things cached, and I sometimes have to change the Application name, or even restart ColdFusion.

Now you mention cbui_beforeHeadEnd which I am assuming is in two different interceptors with two different names.

Google Analytics was the first module I wrote and can be found on ForgeBox, it nothing special but I know it works as I run it on my own blog.

Now you haven’t given us any clue on how you are doing the addition to the page, so maybe some code for those events to see if there is anything you may be doing wrong.

I have seen this behavior as I stated, and it usually boils down to $htmlhead ussage, but I need to see what else you might be doing that could be causing this.

Our Module: akibase
Interceptor: CBRequest.cfc in modules/akibase/interceptor

public void function cbui_beforeHeadEnd(event, interceptData) {
var rc = event.getCollection();
if(structKeyExists(rc,‘pageSlug’) and rc.pageslug eq ‘en’)
siteid= ‘en’;
siteid = ‘de’;
savecontent variable=“scripts” {

appendToBuffer( scripts );

This function will always executed if cb.event(“cbui_beforeHeadEnd”) is called. This function will be executed before the ga-module. But if the cbui_beforeHeadEnd function of the ga-module is called, the output buffer is empty, if url.fwreinit is not set.

Ok well you have a problem right there, might not be the exact problem but you are open to a race condition or non thread safe variables.

Unless you have it in your code, then you really must var scope the scripts to the local variables scope for the function.

Now I am guessing that this is the one that is failing, and the reason it might be failing will actually be in the previous interceptor. So what is in there that might be causing it?

Hm what about caching, is that on for the pages. It might be it runs once only

Luis Majano
Ortus Solutions, Corp
Toll Free/Fax: 1-888-557-8057
Direct: 909-248-3408
Twitter: @lmajano, @ortussolutions

I will also add that when I was experiencing this, the one thing that also helped my insanity was using the logger.

For example I had two interceptors using the same interception point, so with logging information to a log file I was able to see that the interceptor was actually being run, and it was always the interceptor that was being run prior to the one that was failing.

In my case it was always when using the $htmlhead() to place certain code there that was causing the issue. Even by logging the data that should be outputted, to prove that the appendBuffer should be working.

But yours might be different, and by logging the information you can track the flow a bit easier.