PHP 7 with phpmyadmin gives lots of Deprecation Notices
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)?
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!
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) {
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.
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.
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