-
Notifications
You must be signed in to change notification settings - Fork 90
Deprecation warning #87
Comments
That's my concern. Now there is no implementation of ServiceLocatorAwareInterface so why this warning? |
@metanav |
I think, the warning is good, but message is wrong. |
I agree with you regarding the message. But could you please explain the logic behind triggering this warning when you have a method setServiceLocator in your controller? Suppose I have controller and factory like this:
|
With a factory you do not need the Service Locator in your controller. |
Hi, we also encounter this problem, sorry to complain again but this is the third problem we have in one week with the ZF 2 updates :( Could this be fixed quickly ? |
In all my controllers appear as message: " Deprecated: ServiceLocatorAwareInterface is deprecated and will be removed in version 3.0 [...]" :( and now!? |
same here - i recognized multiple changes in the past weeks, which will break here or there some things (example: bjyoungblood/BjyAuthorize#304). its like, working with an apple nowadays.. please provide some informations what to do, to clear the deprecated issue |
" Deprecated: ServiceLocatorAwareInterface is deprecated and will be removed in version 3.0, along with the ServiceLocatorAwareInitializer. " I am getting this error all over my application controller. Can anyone help? |
The message is good and important for all developers! For you production system you should use a different |
Sorry, but this is, at least for me, inacceptable. This will do the trick: in "composer.json" |
Still the issue exists. I had given error_reporting(0); in my controller function. But it is not working as i expected. Is it possible for me to change the version of Zend service Manager to Previous? |
This is correct. Therefore I wrote:
|
This is too late! |
IMO doing this triggers the warning. class MyController extends AbstractActionController {} So here using the API normally (i.e as explained in the ZF 2 docs) triggers a Warning. So I do not agree with you because a warning should be displayed if an API is used with abnormal calls and manipulations (which is definitly not the case here). |
Ok thanks. Its work for me right now. When I put it on the global.php file in Config folder. But need a better solution. |
This is only a warning for deprecation. Nothing more or less. |
This is the normal way for |
@froschdesign I understand what you mean and I don't have any issue with E_USER_DEPRECATED or any such kind of error reporting messages, they are really helpful. But they are useful only when they are meaningful and in appropriate places. The first case when a developer implements 'ServiceLocatorAwareInterface' it MUST be triggered but not for the other case when only 'setServiceLocator' is defined in the class or any parent class. |
Right!
The error message is wrong, but the hint for this "old" standard method is correct. In version 3.0 this messages will removed. It's only a small migration step in 2.7 to 3.0. |
Do you mean we should never inject a service locator or have a setServiceLocator method in a controller class because it is an anti-pattern? If yes, I think this is fine and only thing is the message should be changed for the other case. |
You get it! 👍 |
Ok, but |
See |
@froschdesign I know about it. But I think that should be other way to do that (refactor something). zend-mvc shouldn't trigger warnings by default, only my bad usage. |
I think @snapshotpl has a good point. This way we can get rid of setServiceLocator() method and also it will be BC/FC. |
Or add option to disable |
If |
@froschdesign Why is it necessary to throw an error when the method setServiceLocator exists? I know we should use a factory to inject dependencies, but what if I want to use that method name for something else? |
@dymen1 |
@snapshotpl |
Do not check if ServiceLocatorAwareInterface exists, as that will skip the initializer when it does, but the instance does not implement it and *does* fit duck typing rules.
@froschdesign I understand that it's for easier migration, the only issue right now is that \Zend\Mvc\Controller\AbstractController has a setServiceLocator method. This results in most Controller classes throwing the deprecation error. |
Right! But:
|
@froschdesign It is not a matter of right or wrong. By throwing a warning across the system, you are seriously interfering day to day operation of many developers. In real life I have to explain to other developers why we should use Zend Framework, and my best argument so far was enterprise friendly mature framework. The recent hiatus in Zend Development made me seriously doubt about that assessment. Developers are seeing this warning NOT in the production system, but in their development system where they turned on all warnings. It is good to let developers know about coming changes, but it should not be by intentionally break develop apps. It is very bad idea to turn off any of warnings in develop machines, including deprecation warning. So your warning is doing much more harm than any good. Please publish a fix as soon as possible. |
If you want to use the latest version in your development, than you can turn off only the
If you follow ZF on Github or Twitter you can jump in before these changes we merged into the master branch: https://twitter.com/zfdevteam/status/704448443519873024 Yes, help is needed! |
@ all |
I'm just waking up now and seeing this. I have a few ideas on how to proceed, and will be implementing then as soon as I have a chance. In the meantime, I'll be locking the thread; we have more than enough information to proceed with at this time. |
A patch is ready in #88; I'm waiting for Travis to run before merging and tagging. If anybody wants to test, add the following to your "repositories": [
{"type": "vcs", "url": "https://github.com/weierophinney/zend-mvc.git"}
], and add a requirement for zend-mvc as follows: "zendframework/zend-mvc": "dev-hotfix/deprecations as 2.7.1" and then run |
I am getting following warning after upgrading zend-mvc:
ServiceLocatorAwareInterface is deprecated and will be removed in version 3.0, along with the ServiceLocatorAwareInitializer. Please update your class My\Controller\MyController to remove the implementation, and start injecting your dependencies via factory instead.
I have read the CHANGELOG and I understand why this warning is coming. But none of the controller classes is implementing ServiceLocatorAwareInterface in my application. I think due to extending AbstractController class which has setServiceLocator() method I am getting this warning. I know if I need I can inject it through factory. I would prefer to see this warning only if any classes is implementing ServiceLocatorAwareInterface, not for merely defining a method setServiceLocator() which can be there even if we inject it using setters in factory instead of constructor injection.
The text was updated successfully, but these errors were encountered: