Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#3 | notify-db_insert-3203496-3.patch | 838 bytes | gisle |
Comments
Comment #2
gisleI am going to upload a patch soon.
Comment #3
gisleHere is the patch. Please review.
Comment #4
gisleUpdated summary.
Comment #5
gisleFixed in latest 2.0.x-dev snapshot.