if you have a field which has no value and you are using token for that field then this module will return token machine name

Created on 17 January 2023, almost 2 years ago

Problem/Motivation

Steps to reproduce

Proposed resolution

if you have a field which has no value and you are using token for that field then this module will return token machine name

Tokens do not and should not return anything if they do not have data. here is a patch

<?php
diff --git a/master/web/modules/contrib/autotitle/autotitle.module b/master/web/modules/contrib/autotitle/autotitle.module
index 359d4786..00a09578 100644
--- a/master/web/modules/contrib/autotitle/autotitle.module
+++ b/master/web/modules/contrib/autotitle/autotitle.module
@@ -211,7 +211,7 @@ function autotitle_node_presave(EntityInterface $entity) {
   }
   else {
     $title = $node_type->getThirdPartySetting('autotitle', 'fallback_title');
-    $title =  \Drupal::token()->replace($title, ['node' => $entity]);
+    $title =  \Drupal::token()->replace($title, ['node' => $entity], ['sanitize' => FALSE, 'clear' => TRUE]);
   }
 
   $entity->setTitle($title);

?>
📌 Task
Status

Needs review

Version

1.0

Component

Code

Created by

🇮🇳India Ali Rizvi

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Status changed to Needs review almost 2 years ago
Production build 0.71.5 2024