2580 Posts in 695 Topics by 540 members
Data Model Questions
SilverStripe Forums » Data Model Questions » Why is onBeforeWrite() called several times?
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba
|
Page:
1
|
Go to End | |
| Author | Topic: | 473 Views |
-
Why is onBeforeWrite() called several times?

26 February 2011 at 3:00am
this:
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.
-
Re: Why is onBeforeWrite() called several times?

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?"
-
Re: 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.
| 473 Views | ||
|
Page:
1
|
Go to Top |



