Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I was creating a form with an element that uses #ajax.
There are two ways core currently specifies callbacks (in this place, the method is called "statesAjax"):
1) 'callback' => '::statesAjax',
2) 'callback' => array(get_class($this), 'statesAjax'),
I accidentally mixed them up and specified array('::statesAjax') as the callback.
This gave me the completely unhelpful message:
Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\HttpException: "Internal Server Error" at core/modules/system/src/Controller/FormAjaxController.php line 102
Going to the class & line in question showed me the issue, but it would be better DX if the exception told me the exact cause right away.
Patch to follow...
Comment | File | Size | Author |
---|---|---|---|
#4 | 2399221-4-fix-callback-exception.patch | 771 bytes | bojanz |
#1 | 2399221-1-fix-callback-exception.patch | 774 bytes | bojanz |
Comments
Comment #1
bojanz CreditAttribution: bojanz commentedIt's possible that a test might need to be modified. Let's see what fails.
Comment #2
dawehnerIs there any reason on earth we have to translate this message?
Comment #3
bojanz CreditAttribution: bojanz commentedYeah, good point, most parts of core don't translate the exceptions. I'll remove that.
Comment #4
bojanz CreditAttribution: bojanz commentedIt actually passed. Here's a patch without the t().
Comment #5
dawehner+1
Comment #10
bojanz CreditAttribution: bojanz commentedGreen again.
Comment #11
alexpottStrings are not frozen in the beta. Committed f4a817a and pushed to 8.0.x. Thanks!