Repository navigation
v6 with adapter - compatibility - #102
Merged
Merged
Conversation
Amp-Thread-ID: https://ampcode.com/threads/T-01a1bb52-1bc2-7562-8c0c-c85c057b73a4 Co-authored-by: Amp <amp@ampcode.com>
- Pass sandboxed Twig templates the event’s properties as an array on Craft 6, whose sandbox no longer allows yii\base\Event objects - Push request jobs right away from console requests on Craft 6, which only triggers EVENT_AFTER_REQUEST for web requests - Convert Craft 6 components (Yiisoft\Arrays\ArrayableInterface) with toArray() so payload dates and extra attributes work - Suggest events for Craft 6 element classes, which aren’t yii\base\Component subclasses - Initialize CP scripts with Craft.whenReady() on bridged screens - Support <craft-switch> lightswitches on the Webhooks index page - Keep .hidden working for the filter pane and spinner - Update craftcms/url-validator in composer.lock to satisfy ^1.2 - Document the json_encode sandbox requirement for payload templates Amp-Thread-ID: https://ampcode.com/threads/T-01a1bb52-1bc2-7562-8c0c-c85c057b73a4 Co-authored-by: Amp <amp@ampcode.com>
New installs now create the url columns as mediumtext too, and the schema version bump makes Craft run the url length migration on update. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a1bb52-1bc2-7562-8c0c-c85c057b73a4
A webhook template that failed to render threw from the event handler, so it stopped the action that triggered it, such as saving an entry. On Craft 6, payload templates that use json_encode always fail, because the Twig sandbox doesn't allow it. Errors are now logged and the webhook is skipped, as in Webhooks 4. Allowing json_encode in the sandbox lets templates output public properties of objects the sandbox otherwise hides, so the README no longer suggests it. Its payload example writes the JSON out instead. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a1bb52-1bc2-7562-8c0c-c85c057b73a4
Craft 4 and 5 requirements are unchanged. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a1bb52-1bc2-7562-8c0c-c85c057b73a4
riasvdv
marked this pull request as ready for review
November 9, 2026 17:55
Craft 6 renders autosuggest inputs as comboboxes that ignore the
template's Vue methods, so Sender Class and Event Name listed nothing.
The controller now passes the suggestions in, and the Event Name list is
reloaded when the sender class changes.
The filter buttons used a "checkmark" icon that doesn't exist on any
version ("check" does), and Craft 6 doesn't style the ignore button's
status dot or align the buttons. Filter labels were centered by Craft 6's
table header styles.
Craft 6 slideouts have no padding and no $container property, so request
details were cut off and the Redeliver and Send now buttons were never
bound.
Craft 6-only styles are scoped to .cp-legacy-screen, so Craft 4 and 5
are unchanged.
Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a1bb52-1bc2-7562-8c0c-c85c057b73a4
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.
Description
Makes Webhooks 3.x work on Craft 6 through the
craftcms/yii2-adapterpackage, alongside Craft 4 and 5.#95 and #98 are merged in with their original commits, so they'll show as merged when this PR is. The schema version is now 2.4.1, so Craft runs #95’s migration on update.
Craft’s
Migration::archiveTableIfExists()truncates archived names to 10 characters on Craft 4 and 5 (webhookgroups→webhoo_old, thenwebhooks→webho_old1). The data is kept, but the names don’t say which table is which. That’s a core bug, fixed on 6.x in craftcms/cms87a3271, where they archive aswebhooks_oldand so on, and on 5.x in craftcms/cms#20484.Craft 6 always renders these templates in the Twig sandbox, which doesn’t allow
json_encode. The README’s payload example now writes the JSON out, escaping strings with|e('js'), and warns against allowingjson_encode: it can output properties of objects the sandbox otherwise hides, such as a relation field’s source element. A webhook whose template fails to render is now logged and skipped. Before, the error stopped the action that triggered it, such as saving an entry.The native Craft 6 release, without the adapter, is #108 (4.x).
Evidence
Run on craftcms/cms 6.x
2e1929fwith yii2-adapter6bbbf5e, against a local receiver (no external services):allowedPrivateHostsworks, and unknown events are rejected.afterSave,Elements::afterSaveElement, entryafterDelete(a GET to an env var URL) and userafterSavewebhooks fire, and draft filters work.maxAttempts, a redirect to169.254.169.254is blocked,$ENVheaders are parsed when sent, debounce merges requests, and garbage collection purges old ones.accessPlugin-webhooksgets 200 and one with onlyaccessCpgets 403. Settings save to project config.json_encodestill enabled, saving an entry now succeeds and logsUnable to trigger webhook “Failing”: Filter "json_encode" is not allowed. Before this change, the same save threw that error. The README’s new payload example deliveredapplication/jsonwith a title containing quotes, a backslash,</script>and an emoji intact.fd1763f:craft:upran Adds migration to increase length of url column #95’s migration and changed bothurlcolumns fromvarchar(255)totext. A 364-character URL saved from the CP, and the request reached the receiver with its query string intact (200). Running the install migration over a copy of the database kept all 5 webhooks, 19 requests and 1 group in archived tables, and the new tables accepted a webhook with a 300+ character URL.