不能使用“对象作为类名,因为它是蛋糕 2.2.x 的保留”

问题描述 投票:0回答:2

我在尝试设置我们正在运行的站点的测试副本时遇到问题,我在 Mint VM 下安装了文件和应用程序,当我将 apache 指向该目录时,我收到 500 错误和以下内容 -

[Thu Oct 25 15:09:39.714201 2018] [php7:error] [pid 8945] [client 192.168.0.14:52237] PHP Fatal error:  Cannot use 'Object' as class name as it is reserved in /home/jamesmcgrath/Documents/dashboard/lib/Cake/Core/Object.php on line 30
[Thu Oct 25 15:09:39.714547 2018] [php7:error] [pid 8945] [client 192.168.0.14:52237] PHP Fatal error:  Uncaught Error: Class 'Controller' not found in /home/jamesmcgrath/Documents/dashboard/lib/Cake/Error/ExceptionRenderer.php:174\nStack trace:\n#0 /home/jamesmcgrath/Documents/dashboard/lib/Cake/Error/ExceptionRenderer.php(92): ExceptionRenderer->_getController(Object(InternalErrorException))\n#1 /home/jamesmcgrath/Documents/dashboard/lib/Cake/Error/ErrorHandler.php(126): ExceptionRenderer->__construct(Object(InternalErrorException))\n#2 /home/jamesmcgrath/Documents/dashboard/lib/Cake/Error/ErrorHandler.php(284): ErrorHandler::handleException(Object(InternalErrorException))\n#3 /home/jamesmcgrath/Documents/dashboard/lib/Cake/Error/ErrorHandler.php(213): ErrorHandler::handleFatalError(64, 'Cannot use 'Obj...', '/home/jamesmcgr...', 30)\n#4 /home/jamesmcgrath/Documents/dashboard/lib/Cake/Core/App.php(933): ErrorHandler::handleError(64, 'Cannot use 'Obj...', '/home/jamesmcgr...', 30, Array)\n#5 /home/jamesmcgrath/Documents/dashboard/lib/Cake/Core/App.php(906): App::_checkFatalError()\n#6 [internal function]: App::shutdow in /home/jamesmcgrath/Documents/dashboard/lib/Cake/Error/ExceptionRenderer.php on line 174

奇怪的是,我们直接从网络服务器中提取文件,该服务器运行正常。第一个错误让我相信这是由于 php 或 apache 版本根据我在其他地方读到的内容而有所不同(工作网络服务器是 7.1.10,测试服务器是 7.2.10,我无法确定哪个版本apache 网络服务器正在运行)。

我不确定这两个错误是否相关,我还在适应这个环境,所以拾取这些东西的进度很慢。

任何帮助将不胜感激。

php cakephp php-7.2 cakephp-2.2 cakephp-2.x
2个回答
8
投票

后一个错误是由导致前一个错误的问题引起的,前一个错误应该是不言自明的,名称

Object
被保留,不能再用作类名。

自 PHP

Object

 起软保留后,
7.2
已成为 PHP
7.0
中的硬保留名称。为了获得正确的 PHP
7.2
兼容性,请将 CakePHP 依赖项至少升级到最新的
2.10.x
版本。

如果您使用内置加密,您还必须切换到 OpenSSL(请参阅

Security.useOpenSsl
配置选项),或者如果您的应用程序使用的加密不兼容,请通过 PECL 安装 Mcrypt,或者使用像phpseclib/mcrypt_compat这样的polyfill。

如果此时无法升级 CakePHP,则必须将 PHP 安装降级到

7.1.x
或更早版本。

另请参阅


0
投票

您必须将班级

Object
重命名为例如
Cake_Object
(以及其中的
function CakeObject()
)。

还有所有出现的

extends Object

extends Cake_Object

还可以更改

的出现次数
if (!class_exists('Object')) {
    uses('object');
}

if (!class_exists('Cake_Object')) {
    uses('object');
}
© www.soinside.com 2019 - 2024. All rights reserved.