Problem/Motivation

In notify.module, the function function notify_comment_insert() contains the following code:

    \Drupal::database()->insert('notify_unpublished_queue')
      ->fields(array(
        'uid' => $comment->nid,
        'cid' => $comment->cid,
      ))
      ->execute();

This produces the following error:

Error: Object of class Drupal\Core\Field\FieldItemList could not be converted to string in PDOStatement->execute() (line 116 of core/lib/Drupal/Core/Database/StatementWrapper.php).>

Call stack:

PDOStatement->execute() (Line: 116)
Drupal\Core\Database\StatementWrapper->execute() (Line: 823)
Drupal\Core\Database\Connection->query() (Line: 97)
Drupal\Core\Database\Driver\mysql\Connection->query() (Line: 32)
Drupal\Core\Database\Driver\mysql\Insert->execute() (Line: 165)
notify_comment_insert()

Steps to reproduce

Take away the permission "Skip comment approval" from the authenticated user. Post a comment as an authenticated user (that comment will then by default be unpublished).

This triggers the error.

Proposed resolution

The error is caused by trying to access the fields nid and cid, which uses D7 code.

Remaining tasks

Review the patch in comment #3.

When RTBC, commit it.

CommentFileSizeAuthor
#3 notify-db_insert-3203496-3.patch838 bytesgisle
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gisle created an issue. See original summary.

gisle’s picture

Assigned: Unassigned » gisle

I am going to upload a patch soon.

gisle’s picture

Assigned: gisle » Unassigned
Status: Active » Needs review
FileSize
838 bytes

Here is the patch. Please review.

gisle’s picture

Issue summary: View changes

Updated summary.

gisle’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Status: Needs review » Fixed

Fixed in latest 2.0.x-dev snapshot.

Status: Fixed » Closed (fixed)

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