phpmyadmin 16.04 中的“弃用通知”错误

tse*_*ard 11 php phpmyadmin

在 16.04 中启动 phpmyadmin 时出现错误:

Deprecation Notice in ./../php/php-gettext/streams.php#48

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)
Run Code Online (Sandbox Code Playgroud)

它继续这些以及与上面相同的回溯:

Deprecation Notice in ./../php/php-gettext/streams.php#84
Deprecation Notice in ./../php/php-gettext/streams.php#145
Deprecation Notice in ./../php/php-gettext/gettext.php#36
Run Code Online (Sandbox Code Playgroud)

我已经更新并验证我使用的是最新的 gettext 和 mbstring。关于解决的任何想法?

小智 29

这取决于你是否足够冒险。如果您理解错误,则意味着您的 PHP 有一些旧的类构造函数。

旧的 PHP 类构造函数

Class myclassname {

    function myclassname() {
      //This is a constructor
    }
Run Code Online (Sandbox Code Playgroud)

新的 PHP 类构造函数

Class myclassname {
    function __construct() {
      //this is the new constructor using __construct instead of the same function name as class name.
}
Run Code Online (Sandbox Code Playgroud)

所以我所做的是进入/usr/share/php/php-gettext/stream.php/usr/share/php/php-gettext/gettext.php(或您的错误中说明的任何文件),转到文件并更改function myclassname()function __construct.

该函数myclassname应与 CLASSmyclassname声明相同。

如果您在使用最新 gettext 的 ubuntu 16.04 上,您应该会看到大约 4 个错误。我只是改变它,它对你的系统没有害处。这是一种过时的编程语法,如果您将来升级,也不会遇到任何问题。我会说这是一个安全的编辑。

这不是真正的重大变化或任何事情,只是语法更新。如果你从 apt-get 包安装,除非你自己编译,否则你真的别无选择。

sudo nano /usr/share/php/php-gettext/streams.php
Run Code Online (Sandbox Code Playgroud)

第 48 行 StringReader 错误。

转到第 52 行并更改

function StringReader ($str='') {
Run Code Online (Sandbox Code Playgroud)

function __construct($str='') {
Run Code Online (Sandbox Code Playgroud)

第 84 行 FileReader 错误

转到第 90 行并更改

function FileReader($filename) {
Run Code Online (Sandbox Code Playgroud)

function __construct($filename) {
Run Code Online (Sandbox Code Playgroud)

第 145 行 CacheFileReader 错误

转到第 146 行并更改

function CachedFileReader($filename) {
Run Code Online (Sandbox Code Playgroud)

function __construct($filename) {
Run Code Online (Sandbox Code Playgroud)

使用sudo nano /usr/share/php/php-gettext/gettext.php.

第 36 行gettext_reader {错误

我想你现在明白要点了,转到第 101 行并更改

function gettext_reader($Reader, $enable_cache = true) {
Run Code Online (Sandbox Code Playgroud)

function __construct($Reader, $enable_cache = true) {
Run Code Online (Sandbox Code Playgroud)

  • 应该看到:`sudo nano /usr/share/php/php-gettext/gettext.php` 和 `sudo nano /usr/share/php/php-gettext/streams.php` (2认同)

小智 8

由于我还没有足够的声誉来评论有人特别的好答案,我只会回复。

以下是执行建议编辑的单行命令:

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


小智 5

您可以为 phpmyadmin 使用另一个 PPA。这是PPA 链接

sudo add-apt-repository ppa:nijel/phpmyadmin
sudo apt update
sudo apt install phpmyadmin
Run Code Online (Sandbox Code Playgroud)

由于它只是临时解决方案或不是最佳解决方案,直到ubuntu repos中的phpmyadmin包重建。