X Tutup
Skip to content

Creating a log without a name generates a revision that is unviewable #1002

@mstenta

Description

@mstenta

This is the convergence of three different things, so first some context:

The Log module has logic in it for automatically setting the log name if it is left blank.

https://git.drupalcode.org/project/log/-/blob/2bbb45e9c97dca0af0d07efd219733392327d3ad/src/LogStorage.php#L81

This happens after the log is saved so that the log ID is available for token replacement.

farmOS automatically adds setNewRevision(TRUE) whenever logs are saved, to ensure traceability of edits.

$entity->setNewRevision(TRUE);

This results in two revisions whenever a log is saved without a title. The first revision doesn't have a title, and the second does.

This has been an issue all along, it seems. It isn't ideal, but it didn't cause any errors, until recently...

Drupal 11 made a change to it's internal Html::escape() helper method, which requires that its only argument be a string type. In the case described above, the log title is NULL, which means if you click on one of the revisions without a title, you get a white screen (with "The website encountered an unexpected error. Try again later.") and the following error in server logs:

Uncaught PHP Exception TypeError: "Drupal\\Component\\Utility\\Html::escape(): Argument #1 ($text) must be of type string, null given, called in /opt/drupal/web/core/lib/Drupal/Component/Render/FormattableMarkup.php on line 238" at /opt/drupal/web/core/lib/Drupal/Component/Utility/Html.php line 433, referer: http://localhost/log/4/revisions

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup