不能使用'Object作为类名,因为已保留Cake 2.2.x [英] Cannot use 'Object as class name as it is reserved Cake 2.2.x

查看:248
本文介绍了不能使用'Object作为类名,因为已保留Cake 2.2.x的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试建立我们正在运行的网站的测试副本时遇到问题,我在Mint VM下安装了文件和应用程序,当我将apache指向目录时,出现500错误和以下错误-

  [2018年10月25日星期四15:09:39.714201 2018年[php7:error] [pid 8945] [客户端192.168.0.14 :52237] PHP致命错误:无法在第30行
的/home/jamesmcgrath/Documents/dashboard/lib/Cake/Core/Object.php中保留 Object作为类名,因为[b 10月25日,星期四:09:39.714547 2018] [php7:错误] [pid 8945] [客户端192.168.0.14:52237] PHP致命错误:未捕获的错误:在/ home / jamesmcgrath / Documents / dashboard / lib / Cake /中找不到类'Controller' Error / ExceptionRenderer.php:174\nStack跟踪: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-> __ constr uct(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,'无法使用'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,数组)\n#5 /home/jamesmcgrath/Documents/dashboard/lib/Cake/Core/App.php(906):App :: _ checkFatalError()\n#6 [内部函数] :位于第174行的/home/jamesmcgrath/Documents/dashboard/lib/Cake/Error/ExceptionRenderer.php中的App :: shutdow

奇怪的是,我们直接从网络服务器上剥离了文件,该服务器运行正常。第一个错误使我相信这是由于php或apache版本因我在其他地方所读的内容而异(工作的Web服务器是7.1.10,测试的是7.2.10,我无法确定该版本是什么)

我不确定这两个错误是否相关,我仍然习惯于这种环境,因此进展缓慢



任何帮助都将不胜感激。

解决方案

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



对象在PHP 7.2 ,从PHP 7.0 开始被软保留。为了获得适当的PHP 7.2 兼容性,请将CakePHP依赖项至少升级到最新的 2.10.x 版本。



如果您使用内置加密,则还必须切换到OpenSSL(请参见 Security.useOpenSsl 配置选项),或者如果您的应用程序使用的加密不兼容,请通过PECL安装Mcrypt,或使用 phpseclib / mcrypt_compat



如果您目前无法升级CakePHP,那么您将拥有将您的PHP安装降级到 7.1.x 或更早的版本。



另请参见




I'm having an issue trying to set up a testing copy of a site we have running, I have the files and applications installed under a Mint VM and when I point apache at the directory I get a 500 error and the following-

[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

The weird thing is we've ripped the files straight from the webserver, which is functioning correctly. The first error makes me believe that it's due to the php or apache versions being different based on what I've read elsewhere (the working webserver is 7.1.10 and the testing one is 7.2.10, I can't determine what version of apache the webserver is running).

I'm not sure if the two errors are related, I'm still getting used to this environment so progress is slow picking up this stuff.

Any help at all would be greatly appreciated.

解决方案

The latter error is caused by the problem that causes former error, and the former error should be rather self-explantory, the name Object is reserved and cannot be used as class name anymore.

Object has become a hard-reserved name in PHP 7.2, after being soft-reserved as of PHP 7.0. For proper PHP 7.2 compatibility, upgrade your CakePHP dependency to at least the latest 2.10.x release.

If you are using the built-in encryption, you'll also have to either switch to OpenSSL (see the Security.useOpenSsl configuration option), or if the encryption that your app is using isn't compatible, install Mcrypt via PECL, or use a polyfill like phpseclib/mcrypt_compat.

If you cannot upgrade CakePHP at this moment, then you'll have to downgrade your PHP installation to 7.1.x or earlier.

See also

这篇关于不能使用'Object作为类名,因为已保留Cake 2.2.x的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆