#2102125: Big Local Task Conversion changed \Drupal\Core\EventSubscriber\ViewSubscriber::onHtml() so that it no longer allows controllers to return string content, as it tries to use array access on it.

CommentFileSizeAuthor
#7 drupal_2121461_7.patch963 bytesxano
#7 interdiff.txt874 bytesxano
#1 drupal_2121461_1.patch833 bytesxano

Comments

xano’s picture

Assigned: xano » Unassigned
Status: Active » Needs review
StatusFileSize
new833 bytes
dawehner’s picture

Can we have some fix test?

Crell’s picture

This is all being changed entirely by #2068471: Normalize Controller/View-listener behavior with a Page object anyway, and is going to conflict with that (as does everything, it seems). Since it's not failing any tests now, should we just let that issue fix it?

xano’s picture

I have some contrib tests that fail, because Views apparently returns a string instead of an array. I'll look up the exact code later.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

This is all being changed entirely by #2068471: Normalize Controller/View-listener behavior with a Page object anyway, and is going to conflict with that (as does everything, it seems). Since it's not failing any tests now, should we just let that issue fix it?

That patch will just exist for ever, so we ensure that there is constant effort with rerolls.

But yeah this is throwing a notice on every views screen.

webchick’s picture

Status: Reviewed & tested by the community » Needs work

Yeah, agreed with getting this in to fix the bug for now. But one small point...

+++ b/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php
@@ -175,6 +175,11 @@ public function onHtml(GetResponseForControllerResultEvent $event) {
     // If no title was returned fall back to one defined in the route.
+    if (!is_array($page_callback_result)) {
+      $page_callback_result = array(
+        '#markup' => $page_callback_result,
+      );
+    }
     if (!isset($page_callback_result['#title'])) {

This comment is no longer accurate for what the code is doing. Should be moved below. I'd just do that myself, except I don't understand exactly what this is testing for. Is it something like:

// Some page callbacks might return strings rather than arrays. If so, convert it to a render array?
xano’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new874 bytes
new963 bytes
dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Let's get it in, for real.

tim.plunkett’s picture

Priority: Normal » Critical
Issue tags: +PHP 5.4
Parent issue: » #1498574: [policy, no patch] Require PHP 5.4

This is a blocker for 5.4

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 021452d and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

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