cancel
Showing results for 
Search instead for 
Did you mean: 

Propose to warn an administrator before installing an extension which uses the «preference»...

0 Kudos

Propose to warn an administrator before installing an extension which uses the «preference»...

Feature request from mage2pro, posted on GitHub Nov 20, 2015

As I understand, the preference should be avoided, and in 99% cases a usage of preference is an extension's developer fault (a lack of skill with plugins, observers, and other techniques) and in the remain 1% cases it is Magento 2 core fault (for example, if the problem core method is static or protected and there is no other way to change the system behaviour, see https://github.com/magento/magento2/issues/2265#issuecomment-154351312 and https://github.com/magento/magento2/issues/2202#issuecomment-151599087). Anyway, I think, the system should warn the administrator that the installation could break other extensions.

1 Comment
apiuser
New Member

Comment from alankent, posted on GitHub Nov 23, 2015

It is an interesting point. Using preferences is not wrong - if an extension is trying to replace functionality, that is what it should use. Early on we had debated pull all service contracts into separate modules, so someone could depend on either the service contract (showing they are abstract), or the implementation (showing they are bound to the implementation of the contract). After protracted debate, we did not split them until we learnt more. But splitting them may be a better solution to this problem - so it is explicit that a module depends on a particular implementation rather than the generic service contract definition.

It is not clear to me that warning about preferences is the right way to go. Often it is the right solution. I think the interesting one is not spotting the conflict automatically. I think that is a problem worth solving.