Clarify storeWebhook with static:: and cover custom webhook_model (refs #253)#254
Closed
freekmurze wants to merge 1 commit into
Closed
Clarify storeWebhook with static:: and cover custom webhook_model (refs #253)#254freekmurze wants to merge 1 commit into
freekmurze wants to merge 1 commit into
Conversation
storeWebhook() already respects a configured custom webhook_model: the self::create() call is a forwarding static call, so Eloquent's __callStatic (which uses new static) resolves to the configured model and its table/connection. Switch to static:: to make that intent explicit and add a regression test storing through a custom model on its own table. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Member
Author
|
Closing: based on a stale local checkout that diverged from current |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
Issue #253 reports that
WebhookCall::storeWebhook()usesself::create(...)and therefore "ignores the configured webhook_model class context," storing/validating against the wrong connection/table.After investigation, the reported bug does not actually reproduce.
WebhookProcessorcalls$this->config->webhookModel::storeWebhook(...), and inside that methodself::create(...)is a forwarding static call. PHP preserves the late-static-binding scope across forwarding calls, and Eloquent'sModel::__callStatic()doesreturn (new static)->$method(...). Sostaticresolves to the configured custom model and the row is created against that model's table/connection.A standalone proof:
There are no hardcoded
WebhookCall::references insrc/, so nothing in the package actually exhibits the reported problem.Changes
self::calls instoreWebhook()(and its static helpers) tostatic::. This is a no-op behaviorally, but makes the intent explicit and matches the existingstatic::where(...)inprunable().webhook_modelmapped to its own table (custom_webhook_calls) and asserts the row lands in that table and the returned instance is the custom model.Testing
All 29 tests pass locally (
vendor/bin/pest).