PHP 7 with phpmyadmin gives lots of Deprecation Notices
Asked Answered
R

20

75

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)?

Rhombic answered 3/5, 2016 at 11:10 Comment(1)
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.Toole
V
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!

Vista answered 11/2, 2017 at 16:24 Comment(10)
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.Lenient
This worked for me initially. However, about two weeks later, the deprecation notices started coming back.Acting
While accepted, this answer did not work for me. The link provided to this answer (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.Daffie
+ sudo services apache2 restart ;)Ammunition
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.Tilt
services? just service : sudo service apache2 restart or sudo systemctl restart apache2.service to refresh apache server.Lignin
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-gettextLignin
Tried this method on my Amazon lightsail VPS. Only got rid of the messages for a day then came back.Azaria
Is it possible to update phmyadmin php-gettext php-mbstring without removing phmyadmin?Burmese
It is only working for some time and then the message comes back..Comatose
F
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) {
Frisket answered 15/3, 2017 at 20:0 Comment(4)
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!Stclair
Worked like a charm followed by sudo service nginx restart. Apache users replace nginx with apache2Nady
Manually changing code in a package? This smells like a horrible hack.Exciseman
@Exciseman 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.Fivepenny
B
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.

Banc answered 14/10, 2016 at 2:44 Comment(4)
After doing this, what do we do to make sure this "temporary solution" doesn't end up permanent?Sickroom
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?Sickroom
@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.Banc
That PPA link no longer exists...is there are replacment?Amphibrach
T
25

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

Tremblay answered 6/7, 2022 at 5:52 Comment(0)
B
21

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.

Bernadette answered 3/5, 2016 at 11:17 Comment(4)
@beniaminp There are two types deprecation notices E_DEPRECATED and E_USER_DEPRECATED. In some configuration you may need to disable both to stop the warnings in PHPMyadmin.Roband
Is suppressing the warning a solution or a workaround? After all the warnings have been added for some purpose. right?Yawmeter
@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.Frias
It's a bit of a workaround, but if you're running on a production server, you probably want to disable deprecation errors anyway.Exciseman
C
16

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';
Cirsoid answered 26/9, 2020 at 9:3 Comment(1)
is this the right way to do?Draco
K
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
Karylkarylin answered 25/8, 2016 at 14:6 Comment(6)
First : sudo apt-get update And after, sudo service apache2 restartCalci
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.Karylkarylin
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.Daffie
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.Germann
Goes without saying that you need to restart apache through systemctl restart apache2. This should be the accepted answer.Inspector
i have tried but not working for meDraco
S
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
Sox answered 5/8, 2018 at 21:58 Comment(0)
H
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.

Highstepper answered 4/5, 2016 at 17:40 Comment(0)
I
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
Insensibility answered 12/5, 2017 at 6:51 Comment(1)
That helps. But in my case, php.ini was at /etc/php/7.0/apache2/php.ini Thanks :-)Saied
A
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
Agronomy answered 11/7, 2018 at 8:49 Comment(0)
H
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.

Hemistich answered 8/12, 2017 at 3:54 Comment(0)
S
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.

Salenasalene answered 26/2, 2018 at 17:17 Comment(0)
M
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"
Mantegna answered 23/7, 2019 at 11:3 Comment(0)
U
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.

Unpolitic answered 1/5, 2018 at 8:50 Comment(0)
A
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.

Appreciate answered 17/7, 2018 at 13:40 Comment(0)
B
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
Blackmarket answered 6/3, 2019 at 10:43 Comment(0)
P
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/

Potman answered 2/9, 2020 at 10:44 Comment(0)
V
-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
Valoniah answered 21/9, 2017 at 1:3 Comment(2)
Why does this need to be added?Escort
The question doesn't say anything about using Apache specifically.Exciseman
B
-7

restarting the server helped me

shutdown -r now
Blaeberry answered 30/5, 2017 at 22:19 Comment(1)
This "fix" seems unrelated to the problem.Daffie

© 2022 - 2024 — McMap. All rights reserved.