Community Forums

Conflicting OpenCart contributions

General discussion about OpenCart - Only post here if you can't place it on any other board.

Conflicting OpenCart contributions

Postby JNeuhoff » Sun Apr 25, 2010 9:01 pm

We used to discuss this in the past, but never came up with a working solution.

Problem:

There are 2 addons which were independently from each other created for OpenCart. In addition to providing new classes, they also happen to modify some of the same OpenCart core classes.

For example, both the Export/Import addon and the CMS addon modify the core files

admin/controller/common/header.php
admin/language/english/common/header.php
admin/view/template/common/header.tpl

Solution wanted:

At the the moment we are forced to manually merge the changes from each add-on to the core classes.

Ideally, I'd like to be able to keep an automatic track of all the add-ons in the form of a simple list stored e.g. as separate overwrite directories, and the core class is extended dynamically from that list.

For example, using a cascading overwrite directory named overwrite/<contrib-name>/ :

overwrite/export/admin/controller/common/header.php extends
overwrite/cms/admin/controller/common/header.php which in turn extends the core
/admin/controller/common/header.php

But how would I be able to have a PHP class whose parent class is dynamic? The language doesn't allow for such a feature, or at least I haven't found a solution yet for this.

Any ideas or suggestions are welcome.
J.Neuhoff - MHC Web Design

OpenCart Override Engine (Version 5.3)
allowing addons to override and modify core methods, language files and templates (see also FAQ)
User avatar
JNeuhoff
 
Posts: 2113
Joined: Tue Dec 04, 2007 7:38 pm

Re: Conflicting OpenCart contributions

Postby Xsecrets » Sun Apr 25, 2010 10:50 pm

yes there have been a few discussions about this, and I think it's going to be looked at closer in 1.5.0 or maybe 2.0 timeframe when it comes around to making major changes again, but I agree it would be nice to have some sort of solution to the admin header files sooner rather than later, as any contribution that wants to add a menu item will have to modify those three files.
Xsecrets
 
Posts: 5042
Joined: Sat Oct 24, 2009 7:51 pm
Location: FL US

Re: Conflicting OpenCart contributions

Postby Qphoria » Mon Apr 26, 2010 12:10 am

I've got this partially working in my dev

Basically its multiple parts:
1. Goto the Admin and choose "Package Manager" - DONE
2. Upload a zip file that contains a mod and it extracts to a temp folder - DONE
3. Copy all files to the correct path structure, making backups of any file that gets replaced to a backup folder. - DONE

After files are copied, there are cases like menus that can be file edited just like SMF and PHPBB do for their mods.
Using SMF's same xml syntax, you can find/replace code automatically. I have this working but have to add error handling. It also handles backups of edited files.

After all files copied and edits made, it zips all the backups and stores them in the backup folder.

To Do:
- Generate a list of files that are changing
- Pre-test the files to ensure they can be modded (i.e. find all the points of entry in existing file)
- Generate a list of installed mods and offer "rollback" options for them

There is also the idea of extending a class. I tried this once but there aren't enough dynamic hook points in the code to check for extended versions of files. This would take a bit more work and I'm still not sure that if we had
class cmsHeader extends ControllerCatalogHeader {

if 2 of the same functions were overridden by 2 different mods, it would still have a problem.

The SMF way seems to handle multiple mods by automatic file edit.

For now, the answer is to simply add a few manual edits to the readme. That is how I handle the CMS mod.. its 2 lines of code that need to be added to the header.tpl file
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18200
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: Conflicting OpenCart contributions

Postby Xsecrets » Mon Apr 26, 2010 3:32 am

yeah it's just a shame Daniel didn't want the dynamic admin menu's as it seems crazy to ask users who may not know what a text editor is to modify three files just to add an entry in the menu.
Xsecrets
 
Posts: 5042
Joined: Sat Oct 24, 2009 7:51 pm
Location: FL US

Re: Conflicting OpenCart contributions

Postby Qphoria » Mon Apr 26, 2010 5:21 am

Well I managed to make an automatic installer with Options Plus that handles all the modifies and it has surprisingly excellent and error-free results with the customers that have used it. So if I can get this standardized and working with all mods, then we should have fewer problems with that
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18200
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: Conflicting OpenCart contributions

Postby JNeuhoff » Mon Apr 26, 2010 9:14 am

Using SMF's same xml syntax, you can find/replace code automatically. I have this working but have to add error handling. It also handles backups of edited files.


Does this mean that SMF is capable of merging the code changes to core classes from different contributions fully automatically? Can it cope with different contributions trying to modify the sane core class, maybe even in the same method?
J.Neuhoff - MHC Web Design

OpenCart Override Engine (Version 5.3)
allowing addons to override and modify core methods, language files and templates (see also FAQ)
User avatar
JNeuhoff
 
Posts: 2113
Joined: Tue Dec 04, 2007 7:38 pm

Re: Conflicting OpenCart contributions

Postby Qphoria » Mon May 03, 2010 3:40 pm

Well SMF & PHPBB simply use a file edit method with a backup. It is just triggered by an xml script.

Example (this script adds a require_once config2.php to the index.php file)
Code: Select all
<modification>
   <file name="index.php">
      <operation>
         <search position="after"><![CDATA[
            require_once('config.php');
         ]]></search>
         <add><![CDATA[
            require_once('config2.php');
         ]]></add>
      </operation>
   </file>
</modification>


So the file "index.php"
gets backed up to "index.php_20100503_config2mod"
then a new index.php file is written with the new line added
Resulting in the new index file showing:
Code: Select all
// Configuration
require_once('config.php');
require_once('config2.php');


Then if another person makes a config3mod. The same process happens to the new index.php file.
a backup is made to "index.php_20100503_config3mod"

Resulting in the final index file showing:
Code: Select all
// Configuration
require_once('config.php');
require_once('config3.php');
require_once('config2.php');


Then uninstalls would simply replace the newly created file with the backed up version.
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18200
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: Conflicting OpenCart contributions

Postby Xsecrets » Mon May 03, 2010 6:01 pm

Qphoria wrote:Then uninstalls would simply replace the newly created file with the backed up version.

while that would be better than what we have now you would have to uninstall everything in the order you installed it, unless I'm missing something.
Xsecrets
 
Posts: 5042
Joined: Sat Oct 24, 2009 7:51 pm
Location: FL US

Re: Conflicting OpenCart contributions

Postby JNeuhoff » Mon May 03, 2010 6:46 pm

Also, the XML scripts with the change instructions would have to be created by the contributor, and he wouldn't even be aware of the fact that someone else might have done some changes to the same core-class, too.

So, I don't think Q's solution would work.
J.Neuhoff - MHC Web Design

OpenCart Override Engine (Version 5.3)
allowing addons to override and modify core methods, language files and templates (see also FAQ)
User avatar
JNeuhoff
 
Posts: 2113
Joined: Tue Dec 04, 2007 7:38 pm

Re: Conflicting OpenCart contributions

Postby Qphoria » Wed May 05, 2010 8:47 pm

Well i dunno. it works for SMF and I've never had a problem there. Actually in SMF they have an uninstall script rather than simply restoring the backup file. Then it wouldn't have the problem that xsecrets mentioned.
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18200
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: Conflicting OpenCart contributions

Postby i2Paq » Wed May 05, 2010 9:00 pm

Qphoria wrote:Well i dunno. it works for SMF and I've never had a problem there.


I had problems with it in SMF and sometimes had to manually build in some of the mods.
Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________
Our FREE search: Find your answer FAST!.

First Things First: Opencart Check List.
Documentation: Our Documentation section.
BUGs?: Known BUGS for All OC Versions.

Problemen met de BTW?: [How to] BTW + Verzend & betaalmethodes.
User avatar
i2Paq
Global Moderator
 
Posts: 9757
Joined: Mon Nov 09, 2009 11:00 am
Location: Winkel - The Netherlands

Re: Conflicting OpenCart contributions

Postby Qphoria » Wed May 05, 2010 9:09 pm

SHUT UP!
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18200
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria


Return to General Discussion

Who is online

Users browsing this forum: dmsims and 16 guests

Hosted by Arvixe Web Hosting