processwire-issues icon indicating copy to clipboard operation
processwire-issues copied to clipboard

Table field name method results ignoring fields in the selector when called inside hook

Open adrianbj opened this issue 2 months ago • 0 comments

I have so far tested this with the User::changed hook (shown below), but also with Pages::saveReady so it seems to be universal with hooks

$wire->addHookAfter('User::changed(refund_test)', function($event) {
    $u = $event->object;
    bd($u->subscriptions('amount_paid>0, limit=1, sort=-date')->last());
});

will return the last row of the table, completing ignoring the amount_paid>0 condition.

However, this (using in-memory find on the table) works as expected:

$wire->addHookAfter('User::changed(refund_test)', function($event) {
    $u = $event->object;
    bd($u->subscriptions->find('amount_paid>0, limit=1, sort=-date')->last());
});

Outside of a hook, the method approach works as expected.

adrianbj avatar Oct 25 '25 15:10 adrianbj