Node editing can't be saved when the read_time field is configured

Created on 7 April 2025, about 1 month ago

Problem/Motivation

Hello, I'm facing an issue inside a node configured with paragraphs, on Drupal 10.4.
As I've used the README.md field to use the module, I've added the read_time field type, the configured node is saving well.
The Readme file says the estimated time is processed on the node save action.

But when I edit an existing node, and save it, it returns a white page "The website encountered an unexpected error. Try again later.". The node can't save and there is no log to return the real cause.

I'm available this week to answer to all your questions if you need any additional information.
Regards,

πŸ› Bug report
Status

Active

Version

1.2

Component

Miscellaneous

Created by

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

Comments & Activities

  • Issue created by @fabrondeau
  • πŸ‡ΊπŸ‡ΈUnited States mtalt Maryland

    @fabrondeau Can you confirm you are on version 1.2 of the module? Are you able to get the error from the PHP, webserver, or Drupal's logs? If you are unable to get the error, can you provide replication steps on a fresh Drupal install? I'm not aware of any issues with paragraphs, so I would need to be able to replicate a setup that causes the issue.

  • @mtalt,
    My aim is to estimate the read time for a node which is built by paragraphs. The main one is the parent of paragraphs of texts.
    There is no direct text field in the node. The node is the parent of multiple paragraphs.
    So I'm expecting that the field I have created in the node can process all the texts paragraphs it can find in its children to add them. The node would save the total. Maybe it isn't the goal of this module, then you might let me know if another would suit to my case ?
    I confirm that I'm using the 1.2 version of estimated_read_time module.

    To reproduce:
    - install the drupal/paragraphs module: composer require drupal
    - enable the module: drush en paragraphs
    - create a paragraph type "texts"
    - In the texts paragraph type, add a field of type formatted long, multiple instances
    - save the paragraph type
    - create a node type "my_node"
    - add a field of type paragraph field_paragraphs, multiple, select the type "texts"
    - add a field of type estimated read time field_estimated_read_time, showed in the form and in the display.
    - save the node type.
    - create a content of type "my_node"
    - add texts paragraphs with false texts (lorem ipsum generated by online, example: https://www.faux-texte.com/)
    - add a title
    - save the node

    Result: the node can't be saved.
    Looking at the code, it seems that $estimation can't be processed in the function doEstimate().

    Please let me know if you can reproduce the case. Thank you by advance.

  • πŸ‡ΊπŸ‡ΈUnited States mtalt Maryland

    @fabrondeau This module should support your use-case. It calculates the read time based on the words present in a view mode. Can you let me know what the values for $viewMode and $wordsPerMinute are on this line?

  • Hello @mtalt
    The view mode is default.

  • πŸ‡ΊπŸ‡ΈUnited States mtalt Maryland

    @fabrondeau I setup a new content type with a paragraph as you described, but I was unable to replicate. Are you able to determine what part of doEstimate() is causing the error? One idea is that an error is occurring when attempting to render the default view mode. Also, can you check that your $wordsPerMinute is a positive integer?

  • Hello @mtalt.
    Thank you for your tests. I've created a single content type with paragraphs and it works. The trouble seems to come from my website content type or special fields, I have to investigate. So you can close this ticket. I will create another one if I find the real cause of my trouble.
    Otherwise, I will process the fields in a preprocess.
    Regards.

  • πŸ‡ΊπŸ‡ΈUnited States mtalt Maryland
  • Debugging the modules seems to show that it fails at $content = (string) $this->renderer->renderInIsolation($build);
    ...
    Dblog told about an error with quickedit.
    The node saved after I uninstalled the Quickedit module :-).
    So this should work after fixing it.

Production build 0.71.5 2024