Get Tokens function is broken.

Created on 6 October 2023, about 1 year ago
Updated 17 September 2024, about 2 months ago

Problem/Motivation

Steps to reproduce

When I visit URL /yoast_seo/tokens I get PHP warnings.

Warning: foreach() argument must be of type array|object, null given in /app/web/modules/contrib/yoast_seo/src/Controller/YoastSeoController.php on line 46
[]

The same warning is logged every time to the logs when I write something to the body field. With every character, I get one line in the logs.

For the fix, I added not empty if to the code to fix it but then I got the next error.
This is the fix I tried to do:

    if (!empty($tokens)) {
      // Retrieve the tokens values.
      // Use the metatag token service, which use either core or token module
      // regarding if this one is installed.
      foreach ($tokens as $token) {
        $token_values[$token] = $metatag_token->replace($token, $data);
      }
    }

This is the next error I got.
Symfony\Component\HttpKernel\Exception\BadRequestHttpException: Input value "tokens" contains a non-scalar value. in Symfony\Component\HttpKernel\HttpKernel->handle() (line 83 of /app/vendor/symfony/http-kernel/HttpKernel.php).

Drupal 10.1.4
PHP 8.1.18

🐛 Bug report
Status

Active

Version

1.8

Component

Code

Created by

🇪🇪Estonia mikkmiggur

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024