Hi.

I get this error in Drupal Log whenever cron tries to upload a document to the server.

htmlspecialchars() [<a href='function.htmlspecialchars'>function.htmlspecialchars</a>]: Invalid multibyte sequence in argument in /html/drupal/sites/all/modules/apachesolr/SolrPhpClient/Apache/Solr/Service.php in Zeile 760.

Any Ideas what the cause of this could be?

Drupal 6.16

Thx
JThan

CommentFileSizeAuthor
#7 htmlspecialchars.png10.35 KBrainbow4711

Comments

jpmckinney’s picture

Status: Active » Postponed (maintainer needs more info)

Are you implementing any apachesolr hooks? Like hook_apachesolr_update_index? If you're using functions like substr in that hook, you may want to switch to drupal_substr.

jax’s picture

This error appears when running cron and context is sent to solr for indexing. It isn't related to implementing custom hooks. I'm having the same issue.

jax’s picture

The error only happens in the production environment. On my dev machine the error doesn't appear. Everything seems to work correctly in dev and in prod though.

jpmckinney’s picture

If it's the same code and the same database in dev and prod, but the error occurs in only one, then the bug is probably with your software stack, not with this module.

Anyway, hook_apachesolr_update_index is relevant, because it helps prepare the content that is sent to Solr on cron runs. If you mess up the content in that hook, you will experience errors.

Anonymous’s picture

I'm getting this error since I've done an update to drupal version 6.17 on my website. Also this happens only when I run cron. The only difference is that I get this error in

htmlspecialchars() [<a href='function.htmlspecialchars'>function.htmlspecialchars</a>]: Invalid multibyte sequence in argument in /var/www/vhosts/DOMAIN/httpdocs/includes/bootstrap.inc on line 840.

xandeadx’s picture

#5
me to, only 6.17, default language - russian

rainbow4711’s picture

StatusFileSize
new10.35 KB

Disable the cache in Perfomance Settings.Then clear the Cache 2 times and then the error is gone.

jpmckinney’s picture

I assume you can re-enable the cache afterwards?

yakker’s picture

Alrighty - giving that a shot. Disabled cache. Cleared cache twice. Re-enabled cache. Will update shortly...

UPDATE:

Did not work - error still persists - thanks for the idea though!

JThan’s picture

EDIT: I have solved this for me. The full text is still attached so others can follow my steps. Hopefully it helps someone.

I still have this error. I cannot find the reason :(
#7 did not help.

I have no Substring Methods or anything like that in hook_apachesolr_update_index. I tried to use mb_convert_encoding($value, 'UTF-8', mb_detect_encoding($value)); to make sure the charset is correct, but this did not help.

I have put a watchdog message in "drupal/sites/all/modules/apachesolr/SolrPhpClient/Apache/Solr/Service.php" just before "Line 760" to get the charset with mb_detect_encoding. The strings are all UTF8 or ASCII. Both should work with htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8'); as far as I know.

Every Time just before the error &value seems to be "Status: F". This is for every error of this kind. I do not know where that "Status: F" is coming from and why that Fails (it is UTF8).

Okay, now I found the solution: In my own content type module I had a template for that Content Type. This was not encoded as UTF8 somehow. Changed that, uploaded again and now it works.

Here are the steps that helped me to track this down (My error message was about Line 760, did not try for error message in other lines):
1) Just before the line of the error message add a watchdog message like this:
watchdog(mb_detect_encoding($value), $value);
2) Run cron and check what comes right before the error message.
3) Think about it: Where can that come from?
4) Make sure encoding of the files you thought of is set correctly
5) Put the code of the apachesolr module back as it was!!

I do not mark this as solved as I do not knwo if this works for the error on other lines!

jpmckinney’s picture

Thanks for the update, JThan! So, are you saying that the tpl.php template file for the content type wasn't encoded as UTF-8, and that uploading a new version encoded as UTF-8 fixed the problem?

Anonymous’s picture

I had this problem too, and first thought it was caused by my FileZilla FTP program. I re-upload my theme with a different ftp client, and the problem went away. I made no changes, it must have been the file system encoding of the theme tpl.php file.

But then the issue came back on another index run. This problem doesnt occur on my local machine. Running Ubuntu 8.04, PHP 5, Apache 2.

ikeigenwijs’s picture

subscribe

JThan’s picture

@jpmckinney #11: Yes, I just had to re-upload the template file as utf8 encoded.

beautifulmind’s picture

I have not installed solr but I still get errors on all my drupal production sites. I can see them on report page.

Regards.

jpmckinney’s picture

Status: Postponed (maintainer needs more info) » Fixed

I think the solution is for all files to be properly encoded. Not much the apachesolr module can do.

Status: Fixed » Closed (fixed)

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