There is an error when viewing a node with Read time rendered which doesn't have calculated read time value. Wrong variable name is used in code to save calculated value to database ($read_time instead of $time on read_time.module@135).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

petersykora created an issue. See original summary.

petersykora’s picture

petersykora’s picture

jigarius’s picture

I tried the patches above, but still I get an error like:

The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">InvalidArgumentException</em>: $string (&quot;Read time: :read_time&quot;) must be a string. in <em class="placeholder">Drupal\Core\StringTranslation\TranslatableMarkup-&gt;__construct()</em> (line <em class="placeholder">132</em> of <em class="placeholder">core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php</em>).

I simply enabled the module and enabled read time on node.article.

valthebald’s picture

FileSize
436 bytes

$display argument that is passed to t(), can be either string or TranslatableMarkup. Second case must be explicitly casted to string.

valthebald’s picture

FileSize
354 bytes

Actually... it makes more sense to remove t() wrapper from read_time_defaults() - there is no need to double-wrap the display string with t()

a3hill’s picture

Used patch #2 but preferred to use https://www.drupal.org/project/read_time/issues/3068116 to address the issue in comment #4.

valthebald’s picture

valthebald’s picture

Status: Needs review » Closed (duplicate)
dqd’s picture

Status: Closed (duplicate) » Active

Sorry, but we have a D.O. recommendation following generally to close the newer issue in case of a duplicate.

@valthebald: what do you mean by "double" wrap? I do only see one t() wrapping here?

dqd’s picture

Status: Active » Needs review

https://www.drupal.org/files/issues/2019-07-08/3051696-6.patch applied cleanly but we need more opinions on if this is the right way to solve it.

dqd’s picture

Additionally we get A non-numeric value encountered error now when cron runs, so string is maybe still an issue...

Antonnavi’s picture

Hello all here!

I had A non-numeric value encountered .. error after #6 patch apply.
But a combination of #2 & #6 fixed the issue for me.
Combined patch is attached to the comment.

joco_sp credited jplana.

joco_sp credited mmjvb.

joco_sp credited s-jack.

joco_sp credited zanvidmar.

joco_sp’s picture

Status: Needs review » Fixed

Thank you all for the help. This will be finally available in the next release.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

dqd’s picture

This will be finally available in the next release.

Errm, ok, this is hard to follow from here. Why there is nothing committed?

joco_sp’s picture

I followed those instructions - https://www.drupal.org/project/read_time/git-instructions. Everything was deployed and it worked, so I didn't bother with this notification, because I used the suggested git commit command and I thought this will be done automatically. I see now that there are some new instruction on forking the project (Creating issue forks and merge requests). Will do that in the future. @diqidoq thank you for pointing that out.

FYI: It was committed to read_time 2.0.0-beta1 on 13 Nov 2021.