Comments

znerol’s picture

Status: Active » Needs review
StatusFileSize
new12.03 KB

Status: Needs review » Needs work

The last submitted patch, 1: 2225605-use-request-stack-in-form-builder.diff, failed testing.

znerol’s picture

Status: Needs work » Postponed

postponing this until we got rid of the request service injected into the url generator.

znerol’s picture

StatusFileSize
new11 KB
new478 bytes

Reroll after #2229223: RequestStack is not persisted across kernel rebuilds. Also push the request stack in core/authorize.php.

I cannot reproduce the test failures from #1 locally, so perhaps we're lucky and the test-bot also agrees.

znerol’s picture

Status: Postponed » Needs review

Status: Needs review » Needs work

The last submitted patch, 5: 2225605-use-request-stack-in-form-builder-5.diff, failed testing.

znerol’s picture

Status: Needs work » Needs review
StatusFileSize
new11.84 KB
new856 bytes

Ok, seems like unit-tests are failing, let's try the trick from #2229223: RequestStack is not persisted across kernel rebuilds

Update, this is the trick from #2228341-78: Objectify session management functions + remove session.inc to make DUTB pass.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

perfect!

znerol’s picture

Status: Reviewed & tested by the community » Postponed

Because the fix introduced in #8 is actually taken from #2228341: Objectify session management functions + remove session.inc, I'd like to postpone this on the session.inc issue. The latter is way more important and I'd rather avoid getting in the way of it.

znerol’s picture

Status: Postponed » Needs review
StatusFileSize
new11 KB

This is not blocked anymore, reroll.

dawehner’s picture

+++ b/core/lib/Drupal/Core/Form/FormBuilder.php
@@ -1240,7 +1248,10 @@ public function setErrorByName($name, array &$form_state, $message = '') {
+    $request = $this->requestStack->getCurrentRequest();
+    if ($request) {

@@ -1254,7 +1265,10 @@ public function getErrors(array $form_state) {
+    $request = $this->requestStack->getCurrentRequest();
+    if ($request) {

We could merge the assignment and the if into one line. btw. what is the reason we do need this here? Maybe we should document that and otherwise return FALSE in the later function.

znerol’s picture

StatusFileSize
new10.94 KB
new963 bytes

Re #12: I think that the condition was necessary before when neither installer nor update.php cared to populate the request-stack. Meanwhile we have it around anywhere, therefore they can be removed I guess.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Perfect!

tim.plunkett’s picture

Component: base system » forms system

Didn't see this (wrong component!) but it looks good.

tim.plunkett’s picture

webchick’s picture

Status: Reviewed & tested by the community » Fixed
+++ b/core/core.services.yml
@@ -122,9 +122,7 @@ services:
-    calls:

+++ b/core/scripts/run-tests.sh
@@ -389,6 +389,7 @@ function simpletest_script_bootstrap() {
   $container->set('request', $request, 'request');
+  $container->get('request_stack')->push($request);

It seems like it's super easy to forget that new line since one might reasonably expect that when you change something in the request, it'd handle pushing it onto the stack for you. Asked Tim about this and he noted that drupal_handle_request() does that for you in most instances, but run-tests.sh and authorize.php are different entry points that boot a slimmed down Drupal so they need extra handling.

Apart from that, this looks pretty straight-forward, soooo...

Committed and pushed to 8.x. Thanks!

  • Commit 340a0fa on 8.x by webchick:
    Issue #2225605 by znerol: Use request stack in form builder.
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.