bernhard Posted May 30, 2016 Share Posted May 30, 2016 hi, i had a really strange bug today! szenario: user can book an event user gets invoice via mail admin can create new invoices the problem: $page->created was empty on mail-invoices whereas it was properly filled on admin-creation difference between those two events from the code-perspective: nothing both are triggered via $page->createInvoice(); public function renderAddressSection($event) { $page = $event->object; $eventpage = $page->getEventPage(); if($page->template != "booking") return; // shows 0 $page->created; // shows 1462893271 wire('pages')->get($page->id)->created; any ideas what could cause this odd behaviour?? all other fields work well. of course in both cases the booking is already saved. that was my first guess, but in both cases there was a proper id for the page... a quick test if "created" was not available in hooks in general showed, that it SHOULD work as i expected: $this->addHookProperty('Page::test', $this, 'test'); public function test($event) { $page = $event->object; $event->return = $page->created; } $page = $pages->get(3505); $page->of(false); echo $page->created . ' ' . $page->test; // shows 1462893271 1462893271 thank you for your help! Link to comment Share on other sites More sharing options...
LostKobrakai Posted May 30, 2016 Share Posted May 30, 2016 You're probably triggering the hook on the newly created page object. The created timestamp is (probably) not part of that object by then and won't be available until the page is loaded from the db for the first time. 3 Link to comment Share on other sites More sharing options...
bernhard Posted May 31, 2016 Author Share Posted May 31, 2016 thanks lostkobrakai, that seems to be the case! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now