问题说明
我看到了问题!此错误消息是 phpPgAdmin 代码中的错误,该代码显然具有在 PHP 7.x 发布之前编写的旧代码。
如果您最近下载了包含所有最新版本的 PHP、PostGreSQL 和 phpPgAdmin 的技术堆栈,则会出现 phpPgAdmin 中的错误。例如...今天(2019 年 2 月)的最新版本是:
- PHP 7.3.1
- PostGreSQL 版本 11
- phpPgAdmin 5.6(2018 年 11 月 12 日)
PHP.net 在他们的Constructors and Destructors 页面中解释了问题:
警告旧式构造函数在 PHP 7.0 中已弃用,并将被
在未来的版本中删除。您应该始终使用 __construct()
新代码。
他们的示例在该页面的此部分中:
命名空间类中的示例 #2 构造函数
<?php
namespace Foo;
class Bar {
public function Bar() { <- This is an older style of creating a constructor.
For PHP 7.x, it should be changed to "__construct" instead of "Bar".
// treated as constructor in PHP 5.3.0-5.3.2
// treated as regular method as of PHP 5.3.3
}
}
?>
现在我们知道了问题所在,下面是如何解决它。
解决方案
查看您的网络服务器上的/phpPgAdmin/ 文件夹。您应该在/classes/ 子文件夹中找到以下文件:
- ArrayRecordSet.php function ArrayRecordSet 替换为
function __construct
- class.select.php function XHtmlSimpleElement 替换为
function __construct
- Gui.php function GUI 替换为
function __construct
- Misc.php function Misc() 替换为
function __construct
- Plugin.php function __construct
- PluginManager.php function __construct
编辑这些文件并将任何构造函数名称(显示为重复的类名称)更改为 __construct。
当您保存这些文件并在浏览器中重新加载 phpPgAdmin 时,您将看到“未找到对象”消息将消失。然后它将显示一个服务器名称。
瞧!最新版 phpPgAdmin 5.6 可与最新版 PHP 7.3.1 和最新版 PostGreSQL 11 一起使用!
如果您想检查左侧树的 XML 内容,只需将其附加到您的网站,因为这是 URL 的其余部分,它正在使用:/phppgadmin/servers.php?action=tree。这将有助于更轻松地调试 phpPgAdmin 代码。
您还可以删除action=tree 查询字符串参数。或者在 phpMyAdmin 代码中搜索。
错误报告
我将了解如何提交带有此页面链接的phpPgAdmin bug report。希望有人会在 phpPgAdmin 代码库中修复此错误。
享受使用最新版本的 phpPgAdmin、PHP 和 PostGreSQL 的乐趣!