Jump to content

Recommended Posts

Posted

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!

Posted

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.

  • Like 3

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...