Warning Illegal string offset in unique_field_ajax_validate_unique()

Created on 5 June 2023, over 1 year ago

Problem/Motivation

Somehow I'm getting this error while using unique on Entity Reference fields. I have content types set up with fields using Entity Reference which are set to be "Unique". They were working for the past few months on my dev site. Today all of the sudden, the unique constrain stopped working, and user are able to create new content with the same unique field value. I'm getting this (or similar) error in the status log and PHP log. My specific error is "Warning: Illegal string offset 'target_id' in unique_field_ajax_validate_unique() (line 572 of ...../modules/contrib/unique_field_ajax/unique_field_ajax.module)"

Running Drupal 9.5.9 and Unique Field Ajax 2.1.2

Not sure if this could've caused the issue: my server is still running PHP 7.4 due to current site is on D7.

Steps to reproduce

  • Create a Content Type with a Entity Reference field, such as a Taxonomy terms field
  • Make the field "Unique"
  • Create a node with the Content Type and set a Term value, save the node.
  • Create another node with the same Content Type and set the Term value SAME as the last one. You will still be able to save the node even though the "Unique" setting should stop you from doing it.
  • Check php error and drupal "Recent log" and you will see the Warning on unique_field_ajax_validate_unique()

** commented this on a related issue but not getting any response, so posting as an issue **

πŸ› Bug report
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jmouse888

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

Comments & Activities

Production build 0.71.5 2024