【问题标题】:Cannot use 'Object as class name as it is reserved Cake 2.2.x不能使用'对象作为类名,因为它是保留的 Cake 2.2.x
【发布时间】:2018-10-25 04:30:46
【问题描述】:

我在尝试设置我们正在运行的站点的测试副本时遇到问题,我在 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 网络服务器正在运行)。

我不确定这两个错误是否相关,我还在习惯这种环境,所以处理这些东西的进度很慢。

任何帮助都将不胜感激。

【问题讨论】:

  • 由于错误状态 Object 是保留关键字。您不能将它用于您的课程。您必须为您的班级使用其他名称。只需将您的类名更改为其他名称即可解决此错误。
  • 我遇到了第一个错误,因为错误的php版本。第二个,还没有。

标签: php cakephp php-7.2 cakephp-2.2 cakephp-2.x


【解决方案1】:

后一个错误是由导致前一个错误的问题引起的,前一个错误应该是不言自明的,名称Object是保留的,不能再用作类名。

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

如果您使用的是内置加密,您还必须切换到 OpenSSL(请参阅Security.useOpenSsl 配置选项),或者如果您的应用使用的加密不兼容,请通过以下方式安装 Mcrypt PECL,或者使用像 phpseclib/mcrypt_compat 这样的 polyfill。

如果您此时无法升级 CakePHP,那么您必须将您的 PHP 安装降级到 7.1.x 或更早版本。

另见

【讨论】:

  • 谢谢!降级 PHP 版本很有效,结果发现运行 web 服务器的 PHP 版本与 apache 使用的不同(5.6.something),所以一旦我们恢复到它一切都很好!
猜你喜欢
  • 2023-03-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-11-08
  • 1970-01-01
  • 2015-07-01
  • 1970-01-01
  • 2017-11-08
相关资源
最近更新 更多