43

Have the same with Magento CE 1.8 and 1.9

After update php from 5.5.16 to 5.6.0 on my VPS I got this 2 errors in [magento]/var/log/system.log:

ERR (3): Deprecated functionality: iconv_set_encoding(): Use of iconv.internal_encoding is deprecated  in [magento]/lib/Zend/Locale/Format.php on line 311
ERR (3): Deprecated functionality: iconv_set_encoding(): Use of iconv.internal_encoding is deprecated  in [magento]/lib/Zend/Locale/Format.php on line 472

I was find this info https://github.com/zendframework/zf1/pull/347 But all variations in php.ini changes not work for me (I was restarted php-fpm service after each changes in php.ini, of course).

Here https://github.com/zendframework/zf1/pull/347/files#r14075423 I read suggested changes exactly in this lines (313 and 474) but I don't want use any hacks to Magento Core files.

In frontend and backend I don't see any problems with encoding - all looks fine (I have Russian localizations - frontend and admin panel).

May I ignore this ERR in system.log or not? What the right way to correct this error?

1
  • This should be addressed in 1.9.2+ where various lib/Zend files test for PHP version 5.6 and above to use the new method. May 24, 2016 at 4:36

9 Answers 9

18

I don't think you are supposed to use Magento with php 5.6 yet.
I assume there will be an official statement when Magento will support php 5.6 and an offical patch if necessary.

1
  • 6
    Since this is the accepted answer, I thought I'd point out that the answer from Alex below (magento.stackexchange.com/a/82410/2142) helped me patch a Magento EE 1.13.1 site to not throw those errors when using PHP 5.6 Oct 28, 2015 at 17:12
55

You can use the following patch:

It is from the full Github-Gist:

Bugfix for Zend Framework 1 in Magento (>= 1.7..) + PHP 5.6

https://gist.github.com/renttek/29beaaa1e90909639501

6
  • 15
    Worked like a charm, save the file to Magento root and run this command patch -p1 < 0001-BUGIFX-Magento-Zend-Framework-1-PHP5.6.patch kudos to @mautz-et-tong May 16, 2016 at 20:51
  • I missed the "p1" parameter - thanks for that
    – cljk
    Sep 28, 2016 at 10:27
  • I ran this successfully, but the error persists. Jun 14, 2017 at 16:24
  • 1
    @ol'bobdole Which error? Did you use compilation? you might need to compile again.
    – Alex
    Jun 15, 2017 at 11:07
  • @Alex Good point! I believe this is it. Jun 15, 2017 at 11:56
17

You need to change lib/Zend/Validate/Hostname.php and replace the internal_encoding related calls with ini_get('default_encoding') and all the other occurences in the Zend framework also...

3
  • This become very helpful for me - when I try to install old 1.4.0.1 version to dev server for migration to never version. Thanks! Oct 29, 2014 at 10:48
  • The problem itself is not Magento + PHP 5.6 but Zend Framework that is coming with magento + PHP 5.6 Nov 3, 2014 at 7:02
  • 4
    In here there is a gist for an easy replacement with sed on the commandline gist.github.com/nhp/326c2b03b2e88ff48d20 Jul 6, 2015 at 12:37
5

PHP 5.6 deprecated a few functions, especially the one Zend is using: http://de1.php.net/manual/en/migration56.deprecated.php#migration56.deprecated.iconv-mbstring-encoding

If I understand this correctly, you just have to set default_encoding, then the call of the method is not needed anymore.

1
  • 1
    Yes, I was try set default_encoding to "UTF-8" and comment all 3 strings (iconv.*) in php.ini but this error still exist. Think that need back to php 5.5.16 and wait for Magento support php 5.6 (as Marius suggested). Thanks. Aug 29, 2014 at 9:26
1

You can run this shell script from your Magento root directory to get rid of this message if you're running OSX: https://gist.github.com/jayelkaake/34109641e5489e3e7e30

Note that it will modify some files in your lib/ folder, so any updates to Magento will overwrite them (though I really hope Magento fixes the bug and adds official PHP 5.6.9 compatibility in their next version).

3
  • For which Magento Version did you try this? Does not seem to work for me.
    – Alex
    Sep 9, 2015 at 8:18
  • v1.9 - it only works on OSX though. This one should work for non-OSX unix machines. Sep 9, 2015 at 19:27
  • I just think it needs more than this replace.see the patch I linked in my answer.
    – Alex
    Sep 9, 2015 at 20:52
1

For me, the system encoding php.ini was already set to UTF-8, so in lib/Zend/Locale/Format.php I added:-

if($oenc != 'UTF-8') iconv_set_encoding('internal_encoding', 'UTF-8');
....
if($oenc != 'UTF-8') iconv_set_encoding('internal_encoding', $oenc);

And the same thing in lib/Zend/Validate/Hostname.php

In you php.ini file, make sure the value default_charset="UTF-8" even on Windows.

1

This helped me:

  1. Create the following folders:

    • /app/code/local/Zend/Locale
    • /app/code/local/Zend/Service
    • /app/code/local/Zend/Validate
    • /app/code/local/Zend/XmlRpc
  2. Copy the following files from /lib/Zend/ to /app/code/local/Zend/:

    • Locale/Format.php
    • Service/Audioscrobbler.php
    • Service/Technorati.php
    • Validate/Hostname.php
    • Validate/StringLength.php
    • XmlRpc/Client.php
  3. Open the files from /app/code/local/Zend/ in a text editor and search for "internal_encoding" and replace them with "default_charset". Before doing this, make sure that the “internal_encoding” string is a parameter of an iconv related function. Don’t replace "mb_internal_encoding", "$internal_encoding" or any other non iconv related stuff, because it will break the code.

Source: https://www.code007.ro/how-to-fix-php-5-6-deprecated-messages-in-magento/

-2

If you need quick fix you can replace in index.php line (about 40):

error_reporting(E_ALL | E_STRICT);

with:

error_reporting((E_ALL | E_STRICT) ^ E_DEPRECATED);

This should "hide" notifications/errors about deprecated functions.

Notice: This is not a real fix, this is just hiding notice/information about this problem with iconv_set_encoding()

Worked for me on Magento 1.8.1.0

-3

just install php gd library using relevant command

sudo apt-get install php5.6-gd of php5-gd

or say for the RehHat

sudo yum install php56-gd or php5-gd

and now restart the apache and you are good to go with as usual.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.