Drupal requires that mbstring must be disabled to run properly. Actually, if you have it enabled, you will have the following message on your setting page:

Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini mbstring.http_input setting. Please refer to the PHP mbstring documentation for more information.

I was wondering, as it is a requirement, why not force it to the required values in the settings.php file, together with the other "ini_set" entries. Just like this:

ini_set('mbstring.http_input', 'pass');
ini_set('mbstring.http_output', 'pass');

Well... I'm not aware of any side effect of it, but maybe I'm wrong.

Regards,
Frederico Caldeira Knabben
----
http://www.fckeditor.net
"Support Open Source Software"

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Steven’s picture

These values must be set before PHP is started... we could htaccess to set them. But that would only help people with htaccess ability. Feel free to make a patch. We also need to disable function overloading.

FredCK’s picture

Status: Active » Needs work

Ok, the htaccess patch would be much better. Just add the following lines to the root htaccess of Drupal for each PHP related "IfModule" block:

php_value mbstring.http_input pass
php_value mbstring.http_output pass

The following lines could also be added to the settings.php for those without htaccess:

// mbstring must be disable. It is done by default using the htaccess file.
// If you can't use htaccess, the better solution would be setting it in the
// php.ini file.
// The last solution is uncommenting the following lines.
//ini_set('mbstring.http_input', 'pass');
//ini_set('mbstring.http_output', 'pass');

But Steven said "These values must be set before PHP is started"... so, these changes settings.php will not be areal fix, right? Is there any explanation?

Well... I can't provide a patch for it, but the above lines will make it easy to implement it.

Thanks again.

netbjarne’s picture

As this problem showed its face in 4.7.3, I was helped by these lines in settings.php on my 3 drupal sites:

ini_set('mbstring.http_input','pass');
ini_set('mbstring.http_output','pass');

Now, that I'm testing the CVS version of Drupal 5.0, I am presented with the error:

Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini mbstring.http_input setting. Please refer to the PHP mbstring documentation for more information. (Currently using Unicode library Error)

Again the two lines mentioned, put into settings.php, saved my day.

If this is the most correct sollution, I suggest its implemented in the shipping settings.php. If its NOT the correct sollution, I would also like to now, especially why it isn't, why I shouldn't use it, and what I should to insted. I don't think most users have access to the php.ini file on their host, so I expect this issue to affect quite some people if being ignored.

Best regards
Bjarne

Steven’s picture

http_input affects how data such as GET and POST is processed. By the time PHP starts executing, $_GET and $_POST have already been created, and will not magically change just by calling ini_set(). All you do is trick Drupal into believing the problem is not there.e

FredCK’s picture

I agree with Steven's comment... this is why I believe the htaccess patch would be nice. In this way those with htaccess support will be ok with it right out of the box... for the others, the php.ini advice is ok.

authentictech’s picture

Well, I have access to the .htaccess file in the root directory of the Drupal installation but the fix as described by FredCK - adding the suggested lines for each PHP related "IfModule" block - did not work for me. I added the suggested lines to settings.php which at least removed the error message if not fixed the problem.

coreb’s picture

Version: x.y.z » 6.x-dev

Moving out of the "x.y.z" queue to a real queue.

notsleepy’s picture

None of these worked for me as there is one more setting mbstring.encoding_translation that needs to be overridden to continue with Drupal 5.0 installation. Place these three lines in a new .htaccess file in the root to get around this problem at install:

php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0

markj’s picture

This didn't work for me. I'm running Drupal 5 on FC5 (ppc), PHP 5.1.6, apache 2.2.3.

Steven’s picture

Title: Disable mbstring in settings.php » Disable mbstring in .htaccess

Changing title to match the issue.

To those testing the values: make sure AllowOverride is set in your Apache configuration. If you can turn on Clean URLs, you can be sure it works.

markj’s picture

Confirming that on my setup, AllowOverride is set to All (I can't test clean URLs because I can't install Drupal. The following error occurs when I hit install.php :

Incompatible environment
The following error must be resolved before you can continue the installation process:
Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini mbstring.encoding_translation setting. Please refer to the PHP mbstring documentation for more information. (Currently using Unicode library Error)

moshe weitzman’s picture

Assigned: Unassigned » moshe weitzman
Status: Needs work » Reviewed & tested by the community
FileSize
0 bytes

those 3 settings resolved my client's problem too. here is a patch. since it has worked for several people already, i set to RTBC.

i think this should be backported after commit to HEAD.

moshe weitzman’s picture

FileSize
1.28 KB

now, with a patch

dmetzcher’s picture

Category: feature » bug

Forgive me if this question seems stupid. This is the first time that I am attempting to install Drupal, and I got this error. I see that Moshe has posted a patch, but, frankly, I have no idea what to do with it. Is there a tutorial where I can find more information on this subject, or can someone describe exactly what to do with this patch. I attempted to create an .htaccess file at the root of my site with the contents of the patch file, but I get a server error when I attempt to visit my site. Removing the .htaccess file gets rid of the server error.

Any help that can be provided would be very greatly appreciated.

Thanks!

dmetzcher’s picture

Nevermind...
I added this to .htaccess and got it working.

php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0

wmmead’s picture

Version: 6.x-dev » 5.1
Component: base system » install system
Category: bug » support
Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

I was also able to get Drupal to install by changing my .htaccess file with the info listed in comment #15. However, I am concerned about what sorts of problems will crop up in the future with this sort of solution. Can anyone tell me what else I need to do, or what other problems I might encounter by doing this?

This installation of Drupal is for a client on their shared hosting site, so I doubt I will get any access to php.ini file

underpressure’s picture

none of the methods listed worked for me all I get is an error that say "zero file size"

my host said try a custom php.ini file but I have no idea whaty to place in the file.

moshe weitzman’s picture

Status: Postponed (maintainer needs more info) » Reviewed & tested by the community

no sense in holding this back. there are no drawbacks that i know of for the .htaccess solution. doing this in settings.php can be a bad idea, as mentioned earlier.

underpressure’s picture

Ok, I haven't tried the settings.php solution because of the mentioned problems. But the other solution (none of them) have worked for me. Can someone give a detailed explanation or show a copy of their .htaccess

drumm’s picture

Version: 5.1 » 6.x-dev
paulitikill’s picture

This drove me crazy, so for those out there that couldn't get the above to work in 5.1, placing the following AT THE TOP of your appropriate .htaccess section seems to work:

  php_flag mbstring.encoding_translation Off
  php_value mbstring.http_input pass
  php_value mbstring.http_output pass 
usera’s picture

editing the .htaccess files did not solve my problem. continued to give me the problem till i created a php.ini file... Question is do I need to put this in every directory or just the root directory? my php.ini file only works in the folder it's located in.

Steven’s picture

Version: 6.x-dev » 5.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

This is a good safeguard and should have no side-effects elsewhere. Tested locally, and seems to work fine.

Committed to HEAD. Should probably be backported too.

Steven’s picture

Category: support » feature
drumm’s picture

Status: Patch (to be ported) » Fixed

Committed to 5.

Anonymous’s picture

Status: Fixed » Closed (fixed)
DynV’s picture

Version: 6.x-dev » 5.x-dev
Assigned: saiedar » moshe weitzman
Category: task » feature
Priority: Critical » Normal

Warning

Here's the drawback from not paying attention to the following warning:

Operations on Unicode strings are emulated on a best-effort basis. Install the PHP mbstring extension for improved Unicode support.

Quoted from this comment in "Unicode library" in Status report?:

VeryMisunderstood

the mbstring extension has to do with multibyte characters in internationalization of Drupal. In other words languages. What will using it give you ? The ability to internationalize your site.

WHat risk do you run if you don't install it ? you site wont work with internationalization. In other words as the internet moves forward with multi language sites to reach a larger target audience, you will be left behind as your site will only work 100% properly in English.

Not so good workaround

Here's the drawback from using the settings.ini ini_set('mbstring.http_input','pass');ini_set('mbstring.http_output','pass'); workaround from the first two comments from Drupal 5.X Installation problems 'mbstring' error:

VeryMisunderstood

yes you can live without clean urls, however, you may find other serious limitations on a "free" host. They are typically more restricting then a shred host.

rosgar

If you're using imagecache module.

'Imagecache will not operate properly if Clean URLs is not enabled on your site.'

Solution

Do as the warning stated and demand your host to install the library. Some hosts might feel entitled to their conservative ways but there's some that will be happy to accommodate you and you can use this for leverage if the demand is not met.

I also documented this on my website: http://williamcarrier.com/en/page/mbstring-warning

lias’s picture

My techark host tech pointed me here and I'm assuming techark hosting will have this installed. This setting should set register_globals off for techark - I'll try this solution and after this one http://drupal.org/node/280724#comment-1048260

Actually, I'm not sure what part of this topic applies to turning off register_globals, techark is being quite vague in their support answers.

saiedar’s picture

Version: 5.x-dev » 6.x-dev
Assigned: moshe weitzman » saiedar
Category: feature » task
Priority: Normal » Critical

add those two line and it will work perfectly ....
ini_set('mbstring.http_input','pass');
ini_set('mbstring.http_output','pass');
:)

sbrattla’s picture

Version: 5.x-dev » 6.x-dev
Assigned: moshe weitzman » saiedar
Category: feature » task
Priority: Normal » Critical

For unknown reasons, my server just doesn't know how to parse the default .htaccess file. Even though the default .htaccess file has all settings and their values neatly aligned, the server i am on doesn't accept space/tab between the setting and its value. After having struggled for a long while, i discovered that there could only be a single space character between "php_value mbstring.http_input" and "pass". Adding extra space/tab to align all values caused the server to skip parsing that setting.

So, if you experience that some of the settings in your .htaccess file gets ignored, try to remove all uneccesary space and tab characters.

Swooperz’s picture

I can confirm that simply adding the two lines to the settings.php file worked flawlessly for me on php5 and apache:

ini_set('mbstring.http_input','pass');
ini_set('mbstring.http_output','pass');

Add it below the other similar lines and hopefully it will work for you too. ;)

chandanasl’s picture

I had the same problems. Tried to include the stuff to .htaccess file. Did not work.
But your method to adding these lines to settings.php in sites/default/settings.php worked we.. Yes of course. It worked. Thanks.

sistematico’s picture

Version: 6.x-dev » 7.12
Component: install system » base system
Assigned: saiedar » sistematico
Category: task » bug
Status: Closed (fixed) » Active

I have the same problem, none of the above worked.

marcingy’s picture

Priority: Critical » Normal
matiaslezin’s picture

#8 worked for me on Drupal 7.15.

nabuzant’s picture

On my shared host, I had to create a php.ini file in public_html with the following content:

mbstring.http_input=pass
mbstring.http_output=pass
extension=pdo.so
extension=pdo_mysql.so
EddyMS’s picture

Assigned: sistematico » Unassigned
FileSize
39.62 KB

I have this same problem in Drupal 7
---------------------
Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini mbstring.http_input setting. Please refer to the PHP mbstring documentation for more information.
---------------------

#8 doesn't work for me in Drupal 7

I don't see the php.ini file,

Is this issue resolve yet? any recommendation ?

hotpowerz’s picture

Issue summary: View changes

#36 solved my problem!

JimJS’s picture

Drupal kept telling me that mbstring.http_input needed to be disabled. However the value was set to pass. The problem I was having was not mbstring.http_input it was actually not having a value for mbstring.http_output. Setting php.ini as follows worked for me. (I am on a local install)

mbstring.http_input = pass
mbstring.http_output = pass

SolidSnakeGr’s picture

Hello, I am running Drupal 7.31 on Debian Jessie testing release, my PHP version is 5.6.0RC4 (cli) and I was getting this error.

Adding the following two lines in my /sites/default/settings.php solved the issue :

ini_set('mbstring.http_input', 'pass');
ini_set('mbstring.http_output', 'pass');

However, now I'm getting this warning for which according to what I've googled there is no solution yet :

  • Deprecated function: ini_set(): Use of mbstring.http_input is deprecated in include_once() (line [] of [drupal folder]/sites/default/settings.php).
  • Deprecated function: ini_set(): Use of mbstring.http_output is deprecated in include_once() (line [] of [drupal folder]/sites/default/settings.php).

Has anyone figured out another way to bypass the mbstring error on my setup?

Any help would be much appreciated!
Thanks in advance!

SOLVED EDIT:
Since there has been no reply yet and I have solved my problem, I'll simply edit my post to share what I did.
There are 2 ways to disable the mbstring.input and mbstring.output as said in the previous posts.

1. To add the lines :

ini_set('mbstring.http_input', 'pass');
ini_set('mbstring.http_output', 'pass');

..at the end of the file : [drupal folder]/sites/default/settings.php
This however is causing the warning I described in my post, regarding using the deprecated "ini_set" function (in the latest versions of Drupal), and therefore is not the acceptable solution.

2. The second way is to edit the .htaccess (hidden) file located at the root directory of Drupal.

However to make this work we must let apache2 server know that this file exists and that it should be used.
Previously I was editing the file normally but still mbstring.input and mbstring.output were not being disabled.

To do this you need to change some settings on the apache configuration file.
In my case it was located at : /etc/apache2/apache2.conf

This is what you need to make sure looks like this :

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

( Note : This step takes for granted that your Drupal root directory is within /var/www/. if not please change it accordingly)
And also make sure that this setting follows below it :

AccessFileName .htaccess

To load the new settings you need to reload (to avoid any downtime) or if on local setup restart the apache2 server :

sudo /etc/init.d/apache2 reload

Now it's time to check the .htaccess file in your Drupal root directory. It is a hidden file so you can see it for example using "ls -a".

Here's what needs to be checked :

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
  php_flag magic_quotes_gpc                 off
  php_flag magic_quotes_sybase              off
  php_flag register_globals                 off
  php_flag session.auto_start               off
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_flag mbstring.encoding_translation    off
</IfModule>

and also a bit lower than that :

<IfModule mod_rewrite.c>
  RewriteEngine on

These should do the trick..
Btw, a simple way to check if the .htaccess is used by apache2 server at all would be to add a garbage line at the end of it and try to open the site to see if that breaks. Example :

This is a garbage line.. !@#$%^&*()_+

Make sure you remove this line immediately afterwards..

hkoosha’s picture

Unfortunately solution #40 php_value mbstring.http_output ...... only works if using mod_php which is not the case for fastcgi I'm using with apache 2.4.
I think nginx users would have the same problem too.

Berdir’s picture

jordilopezamat’s picture

#40 worked for me in a local Debian Jessie scenario :-)

TwoD’s picture

For automatic crosslinking...

TwoD’s picture

Forgot to hide a few old and now irrelevant patches...

TBH, I think this is a duplicate of #2332295: Unicode requirements check not working with PHP 5.6 as I don't see this issue at all after applying that patch, even under FPM/FastCGI, though I haven't confirmed with an older PHP version in FastCGI mode.

eshaan’s picture

Status: Active » Fixed

#21 by @paulitikill worked perfectly, thanks!

Status: Fixed » Closed (fixed)

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

Abbass’s picture

#36 WORKED FOR ME ON AN ONLINE HOST!!!

goviedo’s picture

Thank you very much to solution #40. Works like a charm. It is not neccesary the ini_set lines on settings.php

  • PHP Version of My System: PHP Version 5.6.24-0+deb8u1
  • Version Drupal en GIT: HEAD detached at 7.51
djassie’s picture

Version: 7.12 » 10.1.x-dev

For lando -

For .lando.yml put PHP-5.6

name: drutest1
recipe: drupal7
config:
  webroot: .
  php: 5.6

And then lando rebuild -y

Now, it will work as intended, without much hiccups.

If you want to - install older Drupal versions, sometimes - you may need to copy petty files like .htacess to make it work.

In Drupal 7.23even after lando rebuild it gave mbstring error, requires to copy the htacess file