3237 Posts in 943 Topics by 684 members
|Go to End|
26 February 2011 at 3:00am
some time ago I realized that SilverStripe calls multiple times the same function. E.g.
Place a onBeforeWrite function to your Page class and put 'print('Hello World');' (or even mail()) in it and save.
Examining the response in firebug will reveal 'Hello World' at least 2 times in the server response. Why? I saved only once, so it should be onBeforeWrite once too. When pressing save & publish, 'Hello World' appears 3 times in the response. Is this by Design? It looks like a waste of resources if it's executed twice, instead of once.
2 March 2011 at 1:11am
I have no answer to your question but the title of your thread is not very helpful if you want someone to answer your question ;-).
How about "Why is onBeforeWrite() called several times?"
2 March 2011 at 10:43pm
Examining the response in firebug will reveal 'Hello World' at least 2 times in the server response
In your onBeforeWrite() you could log a backtrace. Looking at the backtrace you'll be able to work out whats calling it. I'm picking it'll be quite hard to avoid.
|Go to Top|