问题
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)?
回答1:
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!
回答2:
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) {
回答3:
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.
回答4:
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.
回答5:
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
回答6:
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.
回答7:
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
回答8:
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
回答9:
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.
回答10:
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.
回答11:
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
回答12:
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.
回答13:
"Deprecation Notice" message on login page of phpMyAdmin
Ok, this issue solved easily with editing the php.ini file :
file path: /etc/php/7.0/apache2/php.ini
Change error_reporting value to:
CODE: SELECT ALL
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.
回答14:
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
回答15:
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"
回答16:
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
回答17:
at last I solved this problem permanently.
Find your php.ini file in your server. It should be in /etc/php/7.0/apache2 folder
open it with nano
nano /etc/php/7.0/apache2/php.ini
Find (ctrl+w) upload_max_filesize = 2M (default) in php.ini file
change default value to 50M or 100M or 20M as you wish.
Save and restart apache2 service
service apache2 restart
and please tell me your satisfactions :-)
回答18:
restarting the server helped me
shutdown -r now
来源:https://stackoverflow.com/questions/37002494/php-7-with-phpmyadmin-gives-lots-of-deprecation-notices