问题
s0o many deprecated error?
How to fixed this one?
Deprecated (16384): Cake\Cache\Cache::config() is deprecated. Use setConfig()/getConfig() instead. - E:\xampp\htdocs\cakephp\config\bootstrap.php, line: 136 [CORE\src\Core\functions.php, line 305] Deprecated (16384): Cake\Datasource\ConnectionManager::config() is deprecated. Use setConfig()/getConfig() instead. - E:\xampp\htdocs\cakephp\config\bootstrap.php, line: 137 [CORE\src\Core\functions.php, line 305] Deprecated (16384): Use Cake\Mailer\Email instead of Cake\Network\Email\Email. - E:\xampp\htdocs\cakephp\vendor\composer\ClassLoader.php, line: 444 [CORE\src\Core\functions.php, line 305] Deprecated (16384): Email::configTransport() is deprecated. Use Email::setConfigTransport() or Email::getConfigTransport() instead. - E:\xampp\htdocs\cakephp\config\bootstrap.php, line: 138 [CORE\src\Core\functions.php, line 305] Deprecated (16384): Cake\Mailer\Email::config() is deprecated. Use setConfig()/getConfig() instead. - E:\xampp\htdocs\cakephp\config\bootstrap.php, line: 139 [CORE\src\Core\functions.php, line 305] Deprecated (16384): Cake\Log\Log::config() is deprecated. Use setConfig()/getConfig() instead. - E:\xampp\htdocs\cakephp\config\bootstrap.php, line: 140 [CORE\src\Core\functions.php, line 305] Deprecated (16384): Security::salt() is deprecated. Use Security::getSalt()/setSalt() instead. - E:\xampp\htdocs\cakephp\config\bootstrap.php, line: 141 [CORE\src\Core\functions.php, line 305] Deprecated (16384): Use Cake\Http\ServerRequest instead of Cake\Network\Request. - E:\xampp\htdocs\cakephp\vendor\composer\ClassLoader.php, line: 444 [CORE\src\Core\functions.php, line 305] Deprecated (16384): ServerRequest::createFromGlobals() is deprecated. Use
Cake\Http\ServerRequestFactory
instead. - E:\xampp\htdocs\cakephp\webroot\index.php, line: 35 [CORE\src\Core\functions.php, line 305] Deprecated (16384): Use Cake\Http\Response instead of Cake\Network\Response. - E:\xampp\htdocs\cakephp\vendor\composer\ClassLoader.php, line: 444 [CORE\src\Core\functions.php, line 305] Deprecated (16384): Dispatcher is deprecated. You should update your application to use the Http\Server implementation instead. - E:\xampp\htdocs\cakephp\webroot\index.php, line: 37 [CORE\src\Core\functions.php, line 305] Deprecated (16384): ActionDispatcher::addFilter() is deprecated. This is only available for backwards compatibility with DispatchFilters - E:\xampp\htdocs\cakephp\vendor\cakephp\cakephp\src\Http\ActionDispatcher.php, line: 61 [CORE\src\Core\functions.php, line 305] Deprecated (16384): ActionDispatcher::addFilter() is deprecated. This is only available for backwards compatibility with DispatchFilters - E:\xampp\htdocs\cakephp\vendor\cakephp\cakephp\src\Http\ActionDispatcher.php, line: 61 [CORE\src\Core\functions.php, line 305] Deprecated (16384): ActionDispatcher::addFilter() is deprecated. This is only available for backwards compatibility with DispatchFilters - E:\xampp\htdocs\cakephp\vendor\cakephp\cakephp\src\Http\ActionDispatcher.php, line: 61 [CORE\src\Core\functions.php, line 305] Deprecated (16384): ActionDispatcher::addFilter() is deprecated. This is only available for backwards compatibility with DispatchFilters - E:\xampp\htdocs\cakephp\vendor\cakephp\cakephp\src\Http\ActionDispatcher.php, line: 61 [CORE\src\Core\functions.php, line 305] Deprecated (16384): ServerRequest::addParams() is deprecated. UsewithParam()
orwithAttribute("params", $params)
instead. - E:\xampp\htdocs\cakephp\vendor\cakephp\cakephp\src\Routing\Filter\RoutingFilter.php, line: 59 [CORE\src\Core\functions.php, line 305] Deprecated (16384): ServerRequest::session() is deprecated. Use getSession() instead. The setter part will be removed. - E:\xampp\htdocs\cakephp\src\Controller\AppController.php, line: 120 [CORE\src\Core\functions.php, line 305] Deprecated (16384): App\Model\Table\UsersTable::table() is deprecated. Use setTable()/getTable() instead. - E:\xampp\htdocs\cakephp\src\Model\Table\UsersTable.php, line: 27 [CORE\src\Core\functions.php, line 305] Deprecated (16384): App\Model\Table\UsersTable::displayField() is deprecated. Use setDisplayField()/getDisplayField() instead. - E:\xampp\htdocs\cakephp\src\Model\Table\UsersTable.php, line: 37 [CORE\src\Core\functions.php, line 305] Deprecated (16384): App\Model\Table\UsersTable::primaryKey() is deprecated. Use setPrimaryKey()/getPrimaryKey() instead. - E:\xampp\htdocs\cakephp\src\Model\Table\UsersTable.php, line: 38 [CORE\src\Core\functions.php, line 305] Deprecated (16384): Response::send() will be removed in 4.0.0 - E:\xampp\htdocs\cakephp\vendor\cakephp\cakephp\src\Routing\Dispatcher.php, line: 72 [CORE\src\Core\functions.php, line 305] Deprecated (16384): Will be removed in 4.0.0 - E:\xampp\htdocs\cakephp\vendor\cakephp\cakephp\src\Http\Response.php, line: 494 [CORE\src\Core\functions.php, line 305] Deprecated (16384): Will be removed in 4.0.0 - E:\xampp\htdocs\cakephp\vendor\cakephp\cakephp\src\Http\Response.php, line: 495 [CORE\src\Core\functions.php, line 305] Deprecated (16384): Response::body() is deprecated. Mutable response methods are deprecated. UsewithBody()
andgetBody()
instead. - E:\xampp\htdocs\cakephp\vendor\cakephp\cakephp\src\Http\Response.php, line: 502 [CORE\src\Core\functions.php, line 305] Deprecated (16384): Will be removed in 4.0.0 - E:\xampp\htdocs\cakephp\vendor\cakephp\cakephp\src\Http\Response.php, line: 502 [CORE\src\Core\functions.php, line 305] Home About Services Contact Us . Notice (8): Undefined variable: flasharea [APP/Template\Layout\default.ctp, line 325]Deprecated (16384): App\Model\Table\WebsitesTable::table() is deprecated. Use setTable()/getTable() instead. - E:\xampp\htdocs\cakephp\src\Model\Table\WebsitesTable.php, line: 33 [CORE\src\Core\functions.php, line 305] Deprecated (16384): App\Model\Table\WebsitesTable::displayField() is deprecated. Use setDisplayField()/getDisplayField() instead. - E:\xampp\htdocs\cakephp\src\Model\Table\WebsitesTable.php, line: 34 [CORE\src\Core\functions.php, line 305] Deprecated (16384): App\Model\Table\WebsitesTable::primaryKey() is deprecated. Use setPrimaryKey()/getPrimaryKey() instead. - E:\xampp\htdocs\cakephp\src\Model\Table\WebsitesTable.php, line: 35 [CORE\src\Core\functions.php, line 305]
回答1:
- You didn't read the error message. It already tells you how to fix it.
- You didn't check the change log nor the migration guide and making an update over two version, jumping from 3.4 over to 3.6. This is pretty careless.
- You didn't bother to check the php manual for the deprecation warning. A simple Google search for "php 16384" would have brought you to this page.
- You didn't do a search here on SO about deprecation warnings
The php manual explains it:
User-generated warning message. This is like an E_DEPRECATED, except it is generated in PHP code by using the PHP function
E_DEPRECATED:
Run-time notices. Enable this to receive warnings about code that will not work in future versions.
Your conclusion should be that you should update your code to the new method calls that the warnings already suggest you to use. You should also consider that there might be code you don't have direct control over, like plugins, that might require the new version at some point. So make sure your dependency versions are setup in a way you won't get in trouble with.
For the future fix your personal workflow:
- Check google for error code / message if you don't understand it
- When doing updates that aren't minors check the change log and migration guide before even considering an update. Worst case is that an update will take you more time than you have, especially if you didn't bother to check what actually could or clearly will blow up because of changes
- Make sure dependencies will work with the new version as well
You can still disable the notices just for the framework via config:
// in config/app.php
'Error' => [
'errorLevel' => E_ALL ^ E_USER_DEPRECATED
]
Be aware, this won't make it work, it just hides the warnings!
When the deprecated methods get removed you're screwed. So plan ahead, allocate the time needed to update the code in your roadmap and do it when you have time before you don't have it and are forced to update for some reason.
回答2:
Either update the methods calls as clearly stated in the error message or disable reporting of deprecation warning by referring to https://book.cakephp.org/3.0/en/appendices/3-6-migration-guide.html#disabling-deprecation-warnings
来源:https://stackoverflow.com/questions/49877063/so-many-deprecated-after-updating-3-4-13-to-3-6-cakephp