How do I disable Multibyte string input conversion in PHP? - php

I am attempting to install Drupal 7 on my local debian jessie machine, and it is telling me the following:
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.
Ok, so I head over to the php documentation linked in that message and it provides me with a lot of (helpful, I am sure) information not at all related to disabling "Multibyte string input conversion". If it's there, I didn't find it.
I googled and came up with a thread on drupal.org, which claims:
Since Drupal made it mandatory to disable mbstring.http_input and its
'relatives', a lot complaints regarding Drupal installation was raised
everywhere in cyberspace. It's not a problem if you own your own
server, and there's a lot of workaround.
And provides a link to a page that I add the following to my .htaccess file:
php_value mbstring.http_input pass
php_value mbstring.http_output pass
So I had a look in my .htaccess file and found this:
# 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>
Right, so now what?
EDIT: Just added the following line to my php.ini file:
mbstring.http_input = pass ; No conversion.
and ran service apache2 reload. No effect.

Added the following to my php.ini file:
mbstring.http_input = pass ;
mbstring.http_output = pass ;
then I ran
sudo service apache2 reload
And then I could install drupal manually, however, if I try using drush I still get the error, so this is really just half a solution...

Instead you can edit your site's .htaccess file or settings.php file to do so.
This way there will not be any conflict between your site and your drush configuration. And in case you changed your server's php version in the future, you don't have to re-do the same changes to the new php version's php.ini file.
Via .htaccess:
php_value mbstring.http_input pass
php_value mbstring.http_output pass
Or via settings.php:
ini_set('mbstring.http_input', 'pass');
ini_set('mbstring.http_output', 'pass');

To disable mbstring function overloading without disabling mbstring, you have to use
mbstring.func_overload = 0
This can be set in the php.ini file, and if not set there, in the vhost setting or .htaccess.
If it does not work, try looking for an mbstring.ini file, for example in /etc/php.d/mbstring.ini. This gets loaded after php.ini, and will override any value set there.
You may also need to add the following, however this is already set in Drupal's htaccess file, so if this file is being loaded correctly there should be no change.
php_value mbstring.http_input pass
php_value mbstring.http_output pass

For me, installing php-mbstring module helped to resolve this error.

the same error here with the installation of a drupal demo
but I realised that the site has no .htaccess file
I copied one into the site
and the problem disappeared

Uncomment extension=php_mbstring.dll in php.ini file and restart apache

Drupal is asking you to enable the mbstring (multibyte string), but your default php settings has this option disabled. If you can change your php.ini file to enable this, then your problem will be fixed, but sometimes we don't have access to that file.
Instead, we can set drupal to enable this option only for this particular site. On your sites/default/settings.php file (or the respective copy you may be using), add this:
ini_set('mbstring.http_input', 'pass');
ini_set('mbstring.http_output', 'pass');
and reload your php
This will set the mbstring option for this particular drupal site. If this still fails, it may be possible that your server's php does not have mbstring installed at all. Run phpinfo() in your browser and search for a mbstring section. If you don't find it at all, then you need to install it or ask a server administrator to do it for you

Related

phpinfo shows allow_url_fopen is Off. It is On in php.ini

I'm trying to run a php website with nginx using php8.1 and php8.1-fpm, in a Ubuntu 20.04 vps.
phpinfo reports that the config file in use is: /etc/php/8.1/fpm/php.ini
It also reports that allow_url_fopen is Off (both Local Value and Master Value).
Examining /etc/php/8.1/fpm/php.ini shows:
allow_url_fopen = On
I suppose that's the default setting. But I need this value to reflect in phpinfo and I can't get that to work.
I've tried changing the value, restarting nginx and fpm, changing it back and restarting again, but nothing works. Feels like phpinfo is getting its values elsewhere. I've checked all files in /etc/php/8.1/fpm/conf.d (the config folder reported by phpinfo) and there is no allow_url_fopen in any of those.
How do I get allow_url_fopen to be On?
Type “php --ini” command to find the location of the PHP configuration file.
On the above server, you can see that the PHP configuration file is in location “/usr/local/lib/php.ini”
Edit the php.ini file to enable allow_url_fopen.
root#server [~]# vi /usr/local/lib/php.ini
allow_url_fopen = On
Change the line “allow_url_fopen = Off” to “allow_url_fopen = On”
Save the php.ini file after changing allow_url_fopen to On.
Restart the apache service after enabling allow_url_fopen.
Now, allow_url_fopen is enabled globally for all domains on your Server. allow_url_include = On
On some systems there's a file /etc/php.d/security.ini or /etc/php/8.1/fpm/conf.d/99-security.conf in which allow_url_fopen is turned of. If present it overrides the settings in php.ini system wide.
Unfortunately this file isn't listed by php_ini_scanned_files().

Issue with increase local memory_limit [duplicate]

I have a clean install of a CentOs with php 5.2.13.
In php.ini that is loaded and present in the header of phpinfo() I have
safe_mode=off
in the phpinfo() information I have
// local value - safe_mode: On
// master value - safe_mode: off
the php file has only a phpinfo() function.
I am still looking for vhost file to see if any directives are there overwriting this, but still then any sugggestions?
Look for "Additional ini files parsed" in phpinfo() output. This setting can also be changed in the Apache config (including .htaccess files).
"Master Value" (from php.ini) could be overridden with "Local Value" in httpd.conf, .htaccess or other Apache configuration with php_value directive.
I found the problem/solution to be in the extra config file that is added in the vhosts folder.
The file is named httpd.include and it has this line
php_admin_flag safe_mode on
PS. I really hate when other systems create files on the fly like this, especially with values they want.

Can't disable multibyte string input conversion for Drupal 8 install

I've installed a lot of Drupal sites and never had this problem before. On attempting to install 8.1.2 I get an error that says:
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.
The .htaccess file that comes with Drupal already has a section that should disable this:
# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
php_value assert.active 0
php_flag session.auto_start off
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_flag mbstring.encoding_translation off
# PHP 5.6 has deprecated $HTTP_RAW_POST_DATA and produces warnings if this is
# not set.
php_value always_populate_raw_post_data -1
</IfModule>
I've tested and this .htaccess file is used. The server is running a new installation of CentOS 7 with cPanel/WHM. I also changed the PHP settings (using WHM) to:
; http input encoding.
mbstring.http_input = pass
; http output encoding. mb_output_handler must be
; registered as output buffer to function
mbstring.http_output = pass
Though I don't think that's notably different than what the defaults were. I checked that this was the actual php.ini file used. I have restarted Apache.
The solution was to enable the mbstring extension.

PHP mbstring.func_overload ignored in .user.ini

I have mbstring.func_overload = 7 in my php.ini, and I need to have it set to 0 for one directory. I have found out I cannot use .htaccess when using PHP via mod_fcgid as I do in my Debian installation.
I have created a .user.ini in the directory where I want this setting set to 0 and I also placed a test.php containing a phpinfo(); line inside the same directory, to see if this .user.ini takes effect.
Beside of the setting above that I WANT to change I also put some other PHP settings in this .user.ini files which I will not keep there, they are just to notice if something actually changes.
My .user.ini:
post_max_size = 12M
upload_max_filesize = 128M
[Date]
date.timezone = "UTC"
[mbstring]
mbstring.language = German
mbstring.func_overload = 0
The strange thing is: all the above settings are accepted and shown as they are in my .user.ini when requesting the test.php file, as "local" settings, except one: mbstring.func_overload is still 7 both for local and global configuration.
Any hints why mbstring.func_overload is ignored while other PHP settings in my .user.ini work perfectly?
I have same problem. I can change any mbstrings-settings in .user.ini, but not mbstring.func_overload.
UPD: I found a reason - mbstring.func_overload can't be redefined in .user.ini, because have status PHP_INI_SYSTEM.
This setting can only be changed from the php.ini file.
Solution. Add follow lines into nginx.conf:
`
location ~ \.php$ {
fastcgi_param PHP_VALUE "date.timezone='Europe/Berlin'
mbstring.func_overload=2
memory_limit=1024M";
...another fastcgi-options...
}
`

phpinfo() difference between master and local value

I have a clean install of a CentOs with php 5.2.13.
In php.ini that is loaded and present in the header of phpinfo() I have
safe_mode=off
in the phpinfo() information I have
// local value - safe_mode: On
// master value - safe_mode: off
the php file has only a phpinfo() function.
I am still looking for vhost file to see if any directives are there overwriting this, but still then any sugggestions?
Look for "Additional ini files parsed" in phpinfo() output. This setting can also be changed in the Apache config (including .htaccess files).
"Master Value" (from php.ini) could be overridden with "Local Value" in httpd.conf, .htaccess or other Apache configuration with php_value directive.
I found the problem/solution to be in the extra config file that is added in the vhosts folder.
The file is named httpd.include and it has this line
php_admin_flag safe_mode on
PS. I really hate when other systems create files on the fly like this, especially with values they want.

Categories