Fix notice after submitting a node or comment

Created on 7 February 2024, 10 months ago

After submitting a new node/comment, we can see this notice :

Notice : Trying to access array offset on value of type bool dans anonymous_publishing_cl_node_presave() (/opt/www/drupal/web/modules/contrib/anonymous_publishing/modules/anonymous_publishing_cl/anonymous_publishing_cl.module line571)

This is due to an incorrect verification of the database result :

      $result = \Drupal::database()
        ->select('anonymous_publishing_emails')
        ->fields('anonymous_publishing_emails', [
          'email',
          'ipaddress',
          'blocked',
        ])
        ->condition('email', $node->anonymous_publishing_email)
        ->execute()
        ->fetchAssoc();

      if ($result['email']) {

$result can be a boolean so we need to test it correctly as it's been done in other place of this file.

      $result = \Drupal::database()
        ->select('anonymous_publishing')
        ->fields('anonymous_publishing')
        ->condition('nid', $node->id())
        ->execute()
        ->fetchAssoc();

      if (!empty($result) && !empty($result['email'])) {
🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇫🇷France tostinni

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024