feed-me icon indicating copy to clipboard operation
feed-me copied to clipboard

craft\helpers\Db::escapeParam(): Argument #1 ($value) must be of type string, array given when using a URL field as the unique field value

Open jamesmacwhite opened this issue 11 months ago • 2 comments
trafficstars

Description

When mapping a URL field/value as the unique field to match on Feed Me throws the following error:

craft\helpers\Db::escapeParam(): Argument #1 ($value) must be of type string, array given, called in /var/www/html/vendor/craftcms/feed-me/src/base/Element.php on line 170 - Db.php: 472

Match existing element with data {"webUrl":{"value":"https://spotthestation.nasa.gov/sightings/view.cfm?country=United_Kingdom&region=England&city=Nottingham&ss=83D8CB58-4263-457E-86C99174259184FD","type":"url","label":null,"target":null}}

I believe this is because the URL field is passed with it's JSON serialised value, where the value intending to be checked is the value key.

I believe this did work until a recent version.

Steps to reproduce

  1. Create a feed using a URL field as the unique field value
  2. Attempt to import the feed
  3. craft\helpers\Db::escapeParam() triggers an error preventing items being imported.

Additional info

  • Craft version: 5.5.5
  • PHP version: 8.3
  • Database driver & version: MySQL 8
  • Plugins & versions: 6.6.1

jamesmacwhite avatar Dec 11 '24 10:12 jamesmacwhite

Hi @jamesmacwhite, could I please get you to share a screenshot of your field mapping? Is the URL field the native Link field that was introduced in 5.3?

tommysvr avatar May 07 '25 10:05 tommysvr

Hi @tommysvr

Yes, this is the Craft CMS native link field introduced in 5.3. It appears specific the context of using it as the unique identifier field. Or at least, a case where it can be triggered.

I believe the field type itself worked, but an update in Feed Me then triggers the error.

The workaround was to use a different unique field which was not a URL field.

jamesmacwhite avatar May 07 '25 17:05 jamesmacwhite

@tommysvr @jamesmacwhite

We are also experiencing this issue in Craft 5.8.17, trying to use a native Link field for the unique identifier ( combined with entry title and a date field)

Image
Admission - Travel Schedule - Google Sheets: Match existing element with data
    {
        "title":"Visit with Broadview Heights High School",
        "externalLink":{
            "value":"https:\/\/example.com\/register\/?id=335d9f27-1f87-4eb4-84dc-d1ccb85ba81e",
            "type":"url"},
        "eventStartDate":"2025-10-23T16:30:00.000000Z"
    }.
↳ Admission - Travel Schedule - Google Sheets: craft\helpers\Db::escapeParam():
    Argument #1 ($value) must be of type string, array given, called in /chroot/home/redacted/vendor/craftcms/feed-me/src/base/Element.php on line 171 - Db.php: 472.
↳ Admission - Travel Schedule - Google Sheets: Starting processing of node #2 in batch 1.

Admission - Travel Schedule - Google Sheets: craft\helpers\Db::escapeParam():
    Argument #1 ($value) must be of type string, array given, called in /chroot/home/redacted/vendor/craftcms/feed-me/src/base/Element.php on line 171 - Db.php: 472.
↳ Admission - Travel Schedule - Google Sheets: Match existing element with data
    {
        "title":"Grandview Preparatory School",
        "externalLink":{
            "value":"https:\/\/example.com\/register\/?id=48734792-7b04-44a8-8f99-90a1fd8eef74",
            "type":"url"},
        "eventStartDate":"2025-10-21T16:30:00.000000Z"
    }.
↳ Admission - Travel Schedule - Google Sheets: Starting processing of node #1 in batch 1.
Image

beckycsolomon avatar Oct 03 '25 21:10 beckycsolomon