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?

  • 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. – Fiasco Labs May 24 '16 at 4:36
16

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.

  • 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 – Erik Hansen Oct 28 '15 at 17:12
51

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

  • 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 – nick.graziano May 16 '16 at 20:51
  • I missed the "p1" parameter - thanks for that – cljk Sep 28 '16 at 10:27
  • I ran this successfully, but the error persists. – ol'bob dole Jun 14 '17 at 16:24
  • 1
    @ol'bobdole Which error? Did you use compilation? you might need to compile again. – Alex Jun 15 '17 at 11:07
  • @Alex Good point! I believe this is it. – ol'bob dole Jun 15 '17 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...

  • 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! – Andriy Gonchar Oct 29 '14 at 10:48
  • The problem itself is not Magento + PHP 5.6 but Zend Framework that is coming with magento + PHP 5.6 – Nils Preuß Nov 3 '14 at 7:02
  • 4
    In here there is a gist for an easy replacement with sed on the commandline gist.github.com/nhp/326c2b03b2e88ff48d20 – Nils Preuß Jul 6 '15 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
    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. – Andriy Gonchar Aug 29 '14 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).

  • For which Magento Version did you try this? Does not seem to work for me. – Alex Sep 9 '15 at 8:18
  • v1.9 - it only works on OSX though. This one should work for non-OSX unix machines. – Jay El-Kaake Sep 9 '15 at 19:27
  • I just think it needs more than this replace.see the patch I linked in my answer. – Alex Sep 9 '15 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.