Problem/Motivation

When saving a node that isn't set to use "read time", I am getting this error:
Warning: Trying to access array offset on value of type null in Drupal\node_read_time\Plugin\Field\NodeReadTime->computeValue() (line 27 of /var/www/html/web/modules/contrib/node_read_time/src/Plugin/Field/NodeReadTime.php) ]

I am trying to figure out if our installation has had it enabled for this node type before and then disabled, as I'm not entirely sure why it's still trying to compute the value, but thought I'd fix it anyway just to suppress the warnings.

Steps to reproduce

Save a node that hasn't got node read time enabled.

Proposed resolution

Add an isset to check the array key exists.

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

littlepixiez created an issue. See original summary.

littlepixiez’s picture

Status: Active » Needs review

Ah, just reviewing this - I think our problem is that our content type was created AFTER the node_read_time was set up, so it didn't have a value in the config. This patch fixes the error though. :) Thanks for the great module!

  • yivanov committed 2573b4d8 on 8.x-1.x authored by littlepixiez
    Issue #3347611: Warning on content type updates excluded from read time
    
yivanov’s picture

Thanks a lot, @littlepixiez, for reporting and fixing this issue :)

yivanov’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

joshahubbers’s picture

StatusFileSize
new837 bytes

Patch-version of this patch to be included in composer patches.

joshahubbers’s picture

kalpanajaiswal’s picture

StatusFileSize
new705 bytes

A patch has been created to fix the warning issue.