Recoverable fatal error: Object of class Drupal\Core\Url could not be converted to string in Drupal\Component\Utility\SafeMarkup::isSafe() (line 94 of core/lib/Drupal/Component/Utility/SafeMarkup.php).

CommentFileSizeAuthor
views.patch1.14 KBdevpreview
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Issue tags: +Needs tests, +VDC

The fix looks great, but I fear we need some form of test coverage here.

jibran’s picture

+++ b/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php
@@ -147,8 +147,8 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
-            '@create' => Url::fromRoute('views_ui.add'),
-            '@existing' => Url::fromRoute('entity.view.collection'),
+            '@create' => Url::fromRoute('views_ui.add')->toString(),
+            '@existing' => Url::fromRoute('entity.view.collection')->toString(),

This is a shame we can't use Url object as a placeholder. I made this mistake a lot of times.

dawehner’s picture

This is a shame we can't use Url object as a placeholder. I made this mistake a lot of times.

It used to work, but if an exception is thrown inside the magic __toString(), good luck!

dawehner’s picture