Magicento icon indicating copy to clipboard operation
Magicento copied to clipboard

Magicento even shows a rewrite conflict when the modules have a clear ordering using <depend>

Open audaki opened this issue 10 years ago • 3 comments

Magicento even shows a rewrite conflict when the modules have a clear ordering using

Example

module A_Catalog rewrites and extends Mage_Catalog_Model_Product, so we have:

# app/code/community/A/Catalog/Model/Product.php
A_Catalog_Model_Product extends Mage_Catalog_Model_Product

and

# app/code/community/A/Catalog/etc/config.xml
<rewrite><catalog_product>A_Catalog_Model_Product</catalog_product></rewrite>

But now we write module B_Catalog, so we depend on A_Catalog in module.xml:

# app/etc/modules/B_Catalog.xml
<modules><B_Catalog>[...]<depends><A_Catalog></depends></B_Catalog></modules>

Due to this depends we have a clear ordering of XML config merging. So the rewrite in config is not a conflict, it is a guaranteed overwrite:

# app/code/community/B/Catalog/etc/config.xml
<rewrite><catalog_product>B_Catalog_Model_Product</catalog_product></rewrite>

And you can also see this in the model, that we actually extend the model of module A_Catalog

# app/code/community/B/Catalog/Model/Product.php
B_Catalog_Model_Product extends A_Catalog_Model_Product

Why is this a problem? There is no way to mark this rewrite as intentional with any phpdoc or alike, so every coder has to ignore dozens of those "rewrite conflicts". I'd suggest that in the case of modules where one depends on the other those rewrites are not marked as conflict.

rgds, Kira

audaki avatar Jan 28 '15 10:01 audaki

You can mark the class as solved very easily, just use ALT+M > Add to solved rewrite conflict list and Magicento won't warn about that.

enriquepiatti avatar Jan 28 '15 18:01 enriquepiatti

I know that that's possible, but if you have a big project where you have dozens of those rewrites and dozens of coders everyone has to do that again... So that's a lot of work for a bigger team. and in the described case the rewrites are not in a conflict, since they are well ordered, that's kinda a bug

audaki avatar Jan 29 '15 17:01 audaki

Yes you are right, I will add code to make the rewrite conflicts detector a bit smarter. Thanks !!

enriquepiatti avatar Jan 30 '15 01:01 enriquepiatti