Problem

After fixing the profile view router on https://www.drupal.org/node/2659474 I got this error:

LogicException: You are not allowed to use drupal_add_html_head_link in #attached. in Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAttachments() (line 150 of /var/www/phto/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php).

It seems there is a problem on ProfileViewController::view on $build['#attached']

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gremy created an issue. See original summary.

gremy’s picture

Assigned: gremy » Unassigned
Status: Active » Needs review
FileSize
1.07 KB

Fixed $build['#attached'] on ProfileViewController::view

gremy’s picture

mariancalinro’s picture

Status: Needs review » Reviewed & tested by the community

Patch tested manually, it fixes the error on the profile page.

dakala’s picture

     // Set the profile path as the canonical URL to prevent duplicate content.
-      $build['#attached']['drupal_add_html_head_link'][] = [
-        [
+      $build['#attached']['html_head_link'][] = array(
+        array(

It works but I think just changing the array key from 'drupal_add_html_head_link' to 'html_head_link' would suffice here. The short array square bracket syntax, [] doesn't have to be changed to array().

mglaman’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/src/Controller/ProfileViewController.php
@@ -28,17 +28,17 @@ public function view(EntityInterface $profile, $view_mode = 'full', $langcode =
+      $build['#attached']['html_head_link'][] = array(
+        array(
...
+        ),
...
+      );

Let's put this back to short array syntax.

  • mglaman committed 005bc8c on 8.x-1.x authored by gremy
    Issue #2659510 by gremy, mglaman: Error: You are not allowed to use...
mglaman’s picture

Status: Needs work » Fixed

I just made the change and committed. Thanks for patch!

Status: Fixed » Closed (fixed)

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