72

I have Ubuntu 16.04 LTS running with PHP7 and phpmyadmin installed. However, I get a lot of deprecation notices like:

Deprecation Notice in ./../php/php-gettext/streams.php#48  
Methods with the same name as their class will not be constructors in a future version of PHP; StringReader has a deprecated constructor

Backtrace  
./../php/php-gettext/gettext.inc#41: require()  
./libraries/select_lang.lib.php#477: require_once(./../php/php-gettext/gettext.inc)  
./libraries/common.inc.php#569: require(./libraries/select_lang.lib.php)  
./index.php#12: require_once(./libraries/common.inc.php)

Is this a problem? How can I get rid of these notices (they pop up each time a page is loaded or action is performed)?

nik_m
  • 11,825
  • 4
  • 43
  • 57
yoano
  • 1,466
  • 2
  • 16
  • 20
  • 2
    This happens on standard, fresh installed 16.04 with repository version of phpmyadmin. @David Curry's answer of reinstall is easy and works, other approaches here don't solve the problem as simply. – Henry's Cat Mar 14 '17 at 14:36

20 Answers20

113

I had this problem and solved it with a simple reinstall of phpmyadmin and its dependencies. Run the following commands:

sudo apt-get remove --purge phpmyadmin php-gettext php-mbstring -y
sudo apt-get autoremove -y
sudo apt-get update
sudo apt-get install phpmyadmin php-gettext php-mbstring -y

Once reinstalled, you should be good as new!

David Curry
  • 1,318
  • 1
  • 9
  • 2
  • 7
    Worked for me. Note: I chose 'no' at the installation prompts regarding removing/replacing the db common database configuration, to keep the existing config settings. No other setup was needed. – jwinn Apr 02 '17 at 01:49
  • 16
    This worked for me initially. However, about two weeks later, the deprecation notices started coming back. – electrophile May 21 '17 at 05:12
  • 14
    While accepted, this answer did not work for me. The link provided to [this answer](https://askubuntu.com/a/796705/305040) (originally provided by *user123943*) confirms that this *really is caused by a bug* in `php-gettext` and that the Deprecation Notices are just informing you about this. Reinstalling won't work until `php-gettext` is updated to be use class constructors compatible with PHP 7.0. – Free Radical Aug 10 '17 at 09:01
  • 10
    + sudo services apache2 restart ;) – Jean Paul CP Jan 25 '18 at 01:05
  • Don't forget to back up or make a snapshot of your disk in case something goes wrong. It almost scared the crap out of me when found out I couldn't access my sites and was praying that sudo service apache2 restart solves the issue. My prays were heard. – Andres Ramos Jan 27 '18 at 02:36
  • 3
    `services`? just `service` : `sudo service apache2 restart` or `sudo systemctl restart apache2.service` to refresh apache server. – B. Shea Feb 16 '18 at 18:04
  • 2
    as @FreeRadical said this doesn't work and SHOULD NOT be the accepted answer - it's only a short/temp fix. Yes, it MAY clean it up for first session login, but later you will get same notices. Try logging out/close browser - restart session. Doh. Think about it: the problem isn't phpmyadmin: it's php-gettext/ - this answer simple reinstalls same deprecated php-gettext – B. Shea Apr 11 '18 at 14:21
  • 1
    Tried this method on my Amazon lightsail VPS. Only got rid of the messages for a day then came back. – Edward B. Sep 11 '18 at 19:32
  • Is it possible to update phmyadmin php-gettext php-mbstring without removing phmyadmin? – Ghanshyam Nakiya May 16 '19 at 11:32
  • It is only working for some time and then the message comes back.. – Hike Nalbandyan Feb 01 '20 at 16:46
81

The way I fixed this problem was by following the askubuntu instructions at depreciation notice error in phpmyadmin with 16.04. It involves changing three lines in /usr/share/php/php-gettext/streams.php and one line in /usr/share/php/php-gettext/gettext.php.

From that link, this are the changes you need to do (if you have ubuntu 16.04):

sudo nano /usr/share/php/php-gettext/streams.php

Line 48 StringReader Error.

Go to Line 52 and change

function StringReader ($str='') {

TO

function __construct($str='') {

Line 84 FileReader Error

Go to Line 90 and change

function FileReader($filename) {

to

function __construct($filename) {

Line 145 CacheFileReader error

Go to Line 146 and change

function CachedFileReader($filename) {

to

function __construct($filename) {

Using sudo nano /usr/share/php/php-gettext/gettext.php.

Line 36 gettext_reader { error

I think you get the gist now, go to line 101 and change

function gettext_reader($Reader, $enable_cache = true) {

To

function __construct($Reader, $enable_cache = true) {
PhoneixS
  • 10,574
  • 6
  • 57
  • 73
user123943
  • 948
  • 6
  • 5
  • 1
    indeed. upvoted. the php-gettext files had timestamps from 2010-12-25 - changing their 'class XYZ{ function XYZ(){} }' to 'class XYZ{ function __construct(){} }' styled code should fix the issue and any updates to the package should contain that fix anyway, so you should be safe from your fix being negated through an update, but keeping backups is just good style - always! – flowtron Jan 15 '18 at 10:07
  • 3
    Worked like a charm followed by `sudo service nginx restart`. Apache users replace _nginx_ with _apache2_ – Saif Mar 25 '18 at 15:20
  • 6
    Manually changing code in a package? This smells like a horrible hack. – alexw May 20 '18 at 23:30
  • @alexw true, but this is just a dependancy for for php my admin, that uses the old contructor (which i hostly perfer, dunno why php7 wants to deprecate it), So its its not really a major change. – Henrik Bøgelund Lavstsen Mar 22 '19 at 05:31
39

You can use another PPA for phpmyadmin.Here it is PPA Link

sudo add-apt-repository ppa:nijel/phpmyadmin
sudo apt update
sudo apt install phpmyadmin

As it is only a temporary solution or not a optimal one, till the package of phpmyadmin in ubuntu repos are rebuild.

Deepanshu Jain
  • 558
  • 4
  • 5
  • 1
    After doing this, what do we do to make sure this "temporary solution" doesn't end up permanent? – Buttle Butkus May 08 '17 at 06:00
  • 1
    i.e. should we remove the repo after installing `phpmyadmin` from it? Should we check regularly with the standard repos and reinstall once it is available from them? – Buttle Butkus May 09 '17 at 18:18
  • @ButtleButkus yes your point is right to remove this PPA and check with standard repo but as far as i am getting Ubuntu 16.04 repo are still not rebuild, so it will be better to keep it till offical repo are updated. – Deepanshu Jain May 10 '17 at 04:19
  • That PPA link no longer exists...is there are replacment? – user2662680 May 10 '19 at 15:08
24

You can do it easily from settings visit features form

http://<localhost>/phpmyadmin/prefs_forms.php?form=Features

select send error reports to NEVER

select send error reports to NEVER

Abhijeet Patil
  • 370
  • 2
  • 8
22

You should try in your php.ini to set error_reporting = ~E_DEPRECATED, this will remove deprecation errors. It should be similiar to error_reporting = ~E_DEPRECATED & E_ALL. Please let me know if it works.

  • 3
    @beniaminp There are two types deprecation notices [E_DEPRECATED](http://php.net/manual/en/errorfunc.constants.php#errorfunc.constants.errorlevels.e-deprecated-error) and [E_USER_DEPRECATED](http://php.net/manual/en/errorfunc.constants.php#errorfunc.constants.errorlevels.e-user-deprecated). In some configuration you may need to disable both to stop the warnings in PHPMyadmin. – Dom Nov 21 '16 at 20:56
  • 7
    Is suppressing the warning a solution or a workaround? After all the warnings have been added for some purpose. right? – BTR Naidu Dec 23 '16 at 14:21
  • @BTRNaidu The warnings are there because the code in the version of phpMyAdmin you are using is deprecated in PHP 7. So this is essentially a workaround until you upgrade to a newer version of phpMyAdmin where they have fixed their code to be PHP 7 comaptible. See other answers for that. – BadHorsie Jul 06 '17 at 11:00
  • It's a bit of a workaround, but if you're running on a production server, you probably want to disable deprecation errors anyway. – alexw Oct 13 '17 at 22:23
15

Dear @BeniaminPantiru your answer is correct but your solution is not solve the problem because you are telling the Apache to don't show the deprecation errors rather than fix the errors. but we can easily fix this error by upgrade the necessary security updates and packages. type the following command will solve the problem.

sudo apt-get dist-upgrade
Script47
  • 14,230
  • 4
  • 45
  • 66
Mohamed Haseem
  • 362
  • 3
  • 7
  • 1
    First : sudo apt-get update And after, sudo service apache2 restart – Mathieu G May 18 '17 at 16:54
  • Thanks Mathieu to reminder me.. I forget to tell, finally you want to restart Apache server to fix the errors completely for that you need sudo service apache2 restart let me know If you have difficulty to fix this error. – Mohamed Haseem May 20 '17 at 15:41
  • 5
    However: `sudo apt-get dist-upgrade` and its newer variant `sudo apt-get full-upgrade` are not for everybody. These commands are dangerous and may break your system (it did happen to me). Just my two cent's worth. – Free Radical Aug 10 '17 at 08:13
  • I was attempting this but everytime the session expired and had to log in again, the problem reappeared. Only installing phpmyadmin from nijel repo (ppa:nijel/phpmyadmin) fixed it for me. – Alberto Alexander Rodriguez Feb 11 '18 at 20:14
  • Goes without saying that you need to restart apache through `systemctl restart apache2`. This should be the accepted answer. – mutiemule Mar 10 '19 at 18:33
  • i have tried but not working for me – Naren Verma May 04 '23 at 13:14
15

For PHP 7.3+

Edit the following file : config.inc.php. It can be located in /etc/phpmyadmin/config.inc.php or in /usr/share/phpmyadmin/config.inc.php

/**
 * Whether or not to query the user before sending the error report to
 * the phpMyAdmin team when a JavaScript error occurs
 *
 * Available options
 * ('ask' | 'always' | 'never')
 * default = 'ask'
 */

$cfg['SendErrorReports'] = 'never';
Antoine Martin
  • 618
  • 8
  • 21
5

I had the same problem. I just wanted to mention that before purging phpmyadmin and reinstalling it. Try restarting Apache. In my case it was the simplest approach and I tried it first. I just wanted people to save time.

 sudo service apache2 restart
Mycodingproject
  • 1,031
  • 1
  • 9
  • 13
4

You didn't mention which version of phpMyAdmin you're using or from where it was installed, but it seems to either be the Ubuntu packaged version 4.5.4.1 or a rather old and unsupported version from source. Either way, I believe your issue was reported (and fixed) at https://github.com/phpmyadmin/phpmyadmin/issues/11462 -- if you're using the Ubuntu packaged version, the comments there suggest that the nijel PPA version should work better for you.

Of course, Beniamin Pantiru's accepted answer is good, too, and if you're running a production server you should reduce the number of warnings and errors displayed by PHP anyway as a standard best practice.

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
3

I had fixed by setting error reporting to the following in php.ini file path /etc/php/7.0

error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR

Common Values:

 E_ALL (Show all errors, warnings and notices including coding standards.)

 E_ALL & ~E_NOTICE  (Show all errors, except for notices)

 E_ALL & ~E_NOTICE & ~E_STRICT  (Show all errors, except for notices and coding standards warnings.)

 E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR  (Show only errors)

 Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
Ranjithkumar MV
  • 804
  • 8
  • 10
2

The problem is caused by outdated PHP Class Constructor syntax. To fix this issue run the following code on your terminal:

sed -ri.bak 's:function StringReader.*:function __construct($str=\x27\x27) {:' /usr/share/php/php-gettext/streams.php
sed -ri 's:function FileReader.*:function __construct($filename) {:' /usr/share/php/php-gettext/streams.php
sed -ri 's:function CachedFileReader.*:function __construct($filename) {:' /usr/share/php/php-gettext/streams.php
sed -ri.bak 's:function gettext_reader.*:function __construct($Reader, $enable_cache = true) {:' /usr/share/php/php-gettext/gettext.php
John Collins
  • 89
  • 1
  • 8
1

Updating the server worked for me with sudo apt-get dist-upgrade and then restarting apache.

I think that this issue is caused by not updating phpmyadmin frequently enough.

Trey Tyler
  • 273
  • 2
  • 10
1

Until it gets resolved in dependency itself (in your case the php-gettext) and you don't want to change global PHP settings so that your other stuff is not affected you may want to try to just customize PHPMyadmin's index.php by putting

error_reporting( ~E_DEPRECATED & E_ALL );

somewhere at the beginning or by using

php_value error_reporting 24575

in either .htdocs or virtual host configuration directive. I think the latter option is better.

Wojciech Fornal
  • 1,265
  • 11
  • 11
1

I do not want to mess with the php installations, therefore I just restarted my Apache and it worked perfectly for me.

"sudo service apache2 restart"
Gufran Hasan
  • 8,910
  • 7
  • 38
  • 51
0

I solved this issue differently in that i downloaded the official package from a newer Ubuntu:

https://packages.ubuntu.com/search?keywords=phpmyadmin

And then installed it:

sudo dpkg -i phpmyadmin_4.6.6-5_all.deb

Thus one doesn't have to use unofficial repositories and the package will simply be updated later on.

eitch
  • 317
  • 2
  • 10
0

"Deprecation Notice" message on login page of phpMyAdmin

Ok, this issue solved easily with editing /etc/php/7.0/apache2/php.ini

Change error_reporting value to:

error_reporting = ~E_DEPRECATED & E_ALL.   

By default it is on comment position, so uncomment it and change it.

Then restart Apache

systemctl restart apache2

OR Second Solution

apt-get purge phpmyadmin
apt-get install phpmyadmin

If require then install

apt-get install php7.0-mbstring

Then restart Apache

systemctl restart apache2

Well, the "Deprecation Notice" message no longer shows.

Eje
  • 354
  • 4
  • 8
0

Problem arises when there's a mismatch between the original PHP version you were running previously and your current PHP server version. Depending on your installed PHP version, this should be enough.

sudo apt-get update
sudo apt-get install phpmyadmin php7.0-gettext php7.0-mbstring -y
Chibueze Opata
  • 9,856
  • 7
  • 42
  • 65
0

I had the same problem and none of the solution proposed here worked.

My configuration was Ubuntu 16.04 and php 7.

I solved the issue reinstalling phpmyadmin to last version (5.02). The process is pretty simple. Backup your phpmyadmin folder ('/usr/share/phpmyadmin/' to '/usr/share/phpmyadmin.bak/') by renaming it, create another folder '/usr/share/phpmyadmin/', download the last version of phpmyadmin and copy files inside the newly created folder '/usr/share/phpmyadmin/'. Your version is now upgraded. In my case, deprecation notice vanished.

The process could raise a pair of other errors that you can get rid of by following this guide https://devanswers.co/manually-upgrade-phpmyadmin/

Sasha Grievus
  • 2,566
  • 5
  • 31
  • 58
-1

One more thing for the top answer; need to add

Include /etc/phpmyadmin/apache.conf

to

/etc/apache2/apache2.conf

and restart Apache:

/etc/init.d/apache2 restart
-7

restarting the server helped me

shutdown -r now
Moode Osman
  • 1,715
  • 18
  • 17