3093 Posts in 875 Topics by 654 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 291 Views |
-
SS3 onAfterWrite Browser Hangs

18 July 2012 at 3:45pm
I am doing something pretty simple
public function onAfterWrite( ){
$pageID = $this->LinkPageID;
if($pageID){
$LinkedPage = Page::get()->filter(array('ID'=>$pageID))->first();
$LinkedPage->LinkPageID = $this->ID;
$LinkedPage->write();
parent::onAfterWrite();
}
}I can see the update in the database so its working and sometimes it goes though just fine but most of the time the browser just hangs and then gets a 500 error. The fact that sometimes it works fine and that I can see the updates in the database has me boggled.
-
Re: SS3 onAfterWrite Browser Hangs

18 July 2012 at 8:02pm
It isn't stuck in a loop is it? i.e LinkedPage->write() triggers a new onBeforeWrite() which then fires a new onBeforeWrite.
-
Re: SS3 onAfterWrite Browser Hangs

19 July 2012 at 4:05am
Ok so I created a test were it created new records instead of just changing info and it was creating 5 new records so it is looping. I am using onAfterWrite here and not onBeforeWrite.
So how do I update new information without creating the loop? I tried all sorts of things but always got the loop. So I upon saving the current page updating information on another page as well is what I am trying to accomplish.
-
Re: SS3 onAfterWrite Browser Hangs

19 July 2012 at 5:43pm
Try not calling write() as that will trigger the loops again. You can use something like a direct DB::query() to update your database rather than using the ORM.
| 291 Views | ||
|
Page:
1
|
Go to Top |


