Problem/Motivation

With markdownify_metadata and schema_metatag both enabled, every request for the Markdown representation of an entity logs two PHP warnings:

Warning: Drupal\schema_metatag\SchemaMetatagManager::parseJsonld():
Argument #1 ($elements) must be passed by reference, value given in
Drupal\markdownify_metadata\MarkdownifyMetadataManager->buildFrontmatter()
Warning: Array to string conversion in
Drupal\markdownify_metadata\MarkdownifyMetadataManager->extractMetatags()

Both have the same origin: Schema.org metatags hold their JSON-LD as a nested array, while MarkdownifyMetadataManager treats every metatag value as a scalar.

The frontmatter itself is still produced correctly, so the impact is log noise on every Markdown request, which on a busy site buries genuine errors.

Steps to reproduce

  1. Install Drupal 11 with markdownify, markdownify_metadata, metatag and schema_metatag, plus a Schema.org submodule such as schema_article.
  2. Configure Schema.org metatag defaults for a content type.
  3. Request the Markdown representation of a node of that type, for example /node/1.md.
  4. Both warnings appear at /admin/reports/dblog on every request.
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

frouco created an issue. See original summary.

frouco’s picture

Assigned: frouco » Unassigned
Status: Active » Needs review

Ready to be reviewed

vinodhini.e’s picture

Status: Needs review » Needs work

Hi,

Tested this on Drupal 11.4.2 and was able to reproduce the issue following the steps provided in the issue summary.

I applied MR !39 and cleared caches, but the warnings are still being logged when accessing the Markdown representation of a node (/node/{nid}.md).

It appears that MR !39 does not fully resolve the issue on Drupal 11.4.2.

gillesbailleux’s picture

@vinodhini.e: on a Drupal 11.4.5 instance equipped with PHP 8.4.25, the issue occurs when visiting a node with an .md output which uses the schema_metatag module v.3.0.4

Warning : Drupal\schema_metatag\SchemaMetatagManager::parseJsonld(): Argument #1 ($elements) must be passed by reference, value given dans Drupal\markdownify_metadata\MarkdownifyMetadataManager->buildFrontmatter() (/home/petitefontaine/public_html/web/modules/contrib/markdownify/modules/metadata/src/MarkdownifyMetadataManager.php ligne 433)

tbcs’s picture

Tested MR !39 against a clean 1.2.0 on the exact combination reported in #5, and both warnings are gone for me:

- Drupal 11.4.5, PHP 8.4.20, markdownify 1.2.0, schema_metatag 3.0.4, metatag 2.2.0
- Applied the MR diff to a fresh copy of the module, drush cr
- Called MarkdownifyMetadataManager::buildFrontmatter() for a node with Schema.org WebPage/WebSite tags under an error handler that records every non-deprecation notice: none raised (unpatched: both warnings raised, every request). The schema: block in the front matter is unchanged.
- Confirmed over HTTP too, with error_level: verbose: a fresh /node/1.md request (cache-busting query string) renders no warning into the body and adds no rows of type php to watchdog; unpatched, the same request logs both.

A small suggestion on the MR itself:

Instead of the string-variable static call, import the class and call it directly:

use Drupal\schema_metatag\SchemaMetatagManager;
...
$items = SchemaMetatagManager::parseJsonld($elements);

A use statement never triggers autoloading, so the existing class_exists() guard keeps the dependency optional exactly as before, and it satisfies Drupal.Classes.FullyQualifiedNamespace (a fully qualified name inline fails phpcs). The variable-class form works, but hides the class from IDEs and static analysis for no gain.