I get the following error everytime I import an album from discogs. Please note the import is successful, but the error happens every time.

warning: mysql_real_escape_string() expects parameter 1 to be string, array given in [path]/htdocs/includes/database.mysql.inc on line 330.

E.g.
Discogs.com import

warning: mysql_real_escape_string() expects parameter 1 to be string, array given in /usr/local/pem/vhosts/169594/webspace/siteapps/120590/htdocs/includes/database.mysql.inc on line 330.

Discography release Vimana has been created.

Comments

strawberrybrick’s picture

Version: 6.x-1.x-dev » 6.x-1.0-beta1
strawberrybrick’s picture

actually using beta1

Karlheinz’s picture

I don't know why Drupal isn't auto-generating the -dev (HEAD) version... I assumed it had something to do with the Git migration, but now I'm not sure...

In any case, that's an odd error. I've never run across it before. It sounds like Discogs is passing Drupal an array for something like artist or title or something.

Which album were you importing? It might help me track that bug down.

Also, is this with every album, or just one or two?

strawberrybrick’s picture

/every/ album I import.

fwiw, I tried importing the album on another installation of drupal, same error:

warning: mysqli_real_escape_string() expects parameter 2 to be string, array given in [path]drupal/includes/database.mysqli.inc on line 330.

Karlheinz’s picture

Assigned: Unassigned » Karlheinz
Priority: Normal » Major

Dammit. OK, I'll take a look at it. Hopefully I should have a patch later today.

That's a pretty serious issue, so I changed the priority to "major."

Karlheinz’s picture

I cannot for the life of me recreate this bug. The errors are happening in db_escape_string(), but I'm not calling that function in my code. I'm sure it happens somewhere when Drupal writes data to the database... but the API page doesn't have the call hierarchy, so I can't follow it back to where it's going wrong.

I'm going to need a lot more info from you, I'm afraid.

  • What image handler are you using? Does switching image handlers fix the issue?
  • Does this happen only when importing albums, or also when you create albums by hand?
  • When did you first start getting the error?
  • Have you applied any of the patches from this issue queue?
  • What other modules are installed? Activated?
  • I'd like any info you can give me about the environment - exact Drupal version, OS of the webserver, etc.

Any clues you can give me would be helpful. Frankly, I'm stumped.

strawberrybrick’s picture

StatusFileSize
new2.49 KB

- What image handler are you using?
ImageAPI GD2

- Does this happen only when importing albums, or also when you create albums by hand?
Manual creation has NO errors. This error is only when importing albums.

- When did you first start getting the error?
Since I installed the discogs module.

- Have you applied any of the patches from this issue queue?
No.

- What other modules are installed? Activated?
See attached.

- I'd like any info you can give me about the environment - exact Drupal version, OS of the webserver, etc.
Drupal core 6.20
MySQL database 5.0.83
PHP 5.2.9

Karlheinz’s picture

I'm betting that this issue is related to #1152738: label, catalog field import issue. Funny that I never ran across it before, though.

Details are in that issue... I'm not entirely sure it's the same cause, though. I'll try to fix that issue, and we'll see if it fixes this one as well. If it does, I'll mark this one as a duplicate.

Karlheinz’s picture

Version: 6.x-1.0-beta1 » 6.x-1.x-dev
Status: Active » Needs review

I fixed the other issue, #1152738: label, catalog field import issue. The fix is in HEAD, and there's a patch in the other thread. I believe, but don't know for sure, that it should fix this issue as well.

Can you test and confirm? I was never able to replicate this bug.

strawberrybrick’s picture

Using 6.x-1.x-dev, here's the errors:

warning: mysqli_real_escape_string() expects parameter 2 to be string, array given in /var/www/drupal/includes/database.mysqli.inc on line 329.
warning: trim() expects parameter 1 to be string, array given in /var/www/drupal/sites/all/modules/date/date/date_token.inc on line 40.

Karlheinz’s picture

I still can't replicate this bug at all, so I'm kind of in the dark here.

The only thing I can think of is a change to _discogs_trim. I added code to make sure the string was actually a string and not an array.

I just pushed it to 6.x-1.x-dev, but it probably won't show up here for a while (patches can take 24 hours to propagate). In the meantime, I've provided a patch.

Still, I'm not entirely convinced this is the problem, as this function is mostly called when you're adding a release by hand. The only other place I could see this happening is in theme_discogs_forminfo, which uses check_plain and check_markup. However, I have code there to double-check that those are not arrays.

If that's where it was happening, the error would occur whenever you're seeing a checkbox-list of the albums, artists, etc. to import. Is that where it's occurring?

strawberrybrick’s picture

Switched to "master" with git, and was able to apply the patch successfully. However, still have the following (non-fatal) warning when importing releases:

warning: mysqli_real_escape_string() expects parameter 2 to be string, array given in /var/www/drupal/includes/database.mysqli.inc on line 329.
warning: trim() expects parameter 1 to be string, array given in /var/www/drupal/sites/all/modules/date/date/date_token.inc on line 40.

Note that second warning is new with beta2 and the patch, so I would guess trim doesn't help matters.

Karlheinz’s picture

Okay, I did some work on the two functions that I suspect were causing problems. I've included a patch. Please test this and see if it works.

I also changed the function to trim fields to length. If anything is different now because of that, please let me know. It shouldn't be, so if there is something different, that might be a clue as to why it's throwing those errors.

Karlheinz’s picture

Status: Needs review » Fixed

After re-writing for Discogs API v.2, I'm closing this issue as fixed. Re-open if it happens again.

Status: Fixed » Closed (fixed)

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