Using Drupal GPL code in a non-Drupal project

Events happening in the community are now at Drupal community events on www.drupal.org.
evillemez's picture

Is this kosher if the other product is also released under the GPL? It seems like it would be, but I'm wondering what people's thoughts are? Here's the concrete example:

As a hobby I've created a PHP framework which uses a few aspects of Drupal, but not others - for example, the same .htaccess file to provide clean-url support, and an object oriented version of Drupal 7's files.inc for managing files and providing stream wrapper support. Now, since that's internal use it shouldn't really matter according to the license. But what if this new system goes into production use, not being sold or distributed necessarily, just put in active use somewhere. If the code that was taken/modified from Drupal is documented, and the entire framework is released under the same license as Drupal (GPL v2 or higher), is there a problem with this?

Would this be considered a derivative work of Drupal, or would it be considered a work "based on" Drupal? Or, would neither apply since the two systems would be fundamentally incompatible?

According to the license, it seems like this wouldn't be a problem - but I'd like to know what the community thinks about it.

Also, does having the code in a publicly accessible repository, like github, count as distribution?

Comments

Yes and yes

Crell's picture

If you're using code from Drupal in this new project, then yes it would also need to be distributed under GPLv2+ if it is distributed. (Actually you could also use GPLv3+ at that point as well.) As long as you do that, however, what you describe is completely legal. Noting the parts that come from Drupal is also recommended. (I'm not certain off hand if it's strictly required, but it's polite if nothing else.)

If you are able to make improvements to the system, it's encouraged but not required that you also contribute those improvements to Drupal as well. Of course, if you're using vast swaths of Drupal then you're probably better off just using Drupal, but it doesn't sound like that's the case.

A public repository such as GitHub would count as distribution, since you're making it available to 3rd parties.

Thank you

evillemez's picture

Thanks so much for clarifications. Anything I adapt from Drupal I try and document well enough to find the original code.

I don't know if what I'm doing would be considered improvements, unfortunately. I'd like to contribute some stuff back (boy, I can't wait until Drupal development has moved to github completely), but a lot of what I have modified thus far fundamentally changes the way it has to be implemented, so it would just break everything else in Drupal.

By the way, I really enjoyed your presentations on the D7 db layer and object oriented programming at DrupalCon San Fran. They really helped, and I like that certain systems are beginning to take a more object oriented approach, I hope this trend continues and accelerates!

Not GitHub

Crell's picture

Drupal is not moving to GitHub. We're setting up our own Git repository server and workflow to replace our integrated CVS workflow. That said, yes, I'm looking forward to it, too. :-)

Thanks for the call-out. I don't expect Drupal to ever become fully OO; that would be a step backward. But there are certainly places that we could better leverage OO techniques.

OT -- "step backward" ?

Aveu's picture

I know this is off topic but why do you think going fully OO would be a step backward?

AOP

Crell's picture

There are things that PHP's OO syntax doesn't make easy that we still want to do, most notably things involving aspect-oriented programming. So far no one has figured out a good way to emulate that efficiently in OO code e as well as we can in procedural code (hooks). If someone can, though, I'm interested in hearing about it. (Just not in this thread.)

Hi Crell, I read you said,

r_honey's picture

Hi Crell, I read you said, "not in this thread", but here are my views in response to this:

"So far no one has figured out a good way to emulate that efficiently in OO code e as well as we can in procedural code (hooks). If someone can, though, I'm interested in hearing about it."

I think there's an easy way to accomplish this. Make each module implement a class with the same name as the module. Then the class needs to provide public methods for each hook it needs to implement. e.g.

class MyModule {
public function init() {
}

public function user() {
}
}

The Drupal framework itself will create an instance of the class for each module, and then can use PHP built-in function, method_exists (http://www.php.net/manual/en/function.method-exists.php), to check if a module implements a hook. If it does, call the method normally as a hook.

Now, there are other modules e.g. Views, that have their own requirements. Certainly I would not like to have Views code in the main MyModule.module file, as that would bloat the code.

The solution is also easy. As a module developer, I would provide 2 classes:

mymodule.module, and
mymodule_views.module

The first contains: class MyModule {}

and the second contains: class MyModule_Views {}

There's only 1 thing that needs to be considered in the above approach, how do I access methods of MyModule from another class, like we can today call methods of one module from another module.

This takes me to present 2 options:

1) The methods in the module class (i.e. hooks) should be static. I personally am not in favor of this appraoch, as this is not extensible.
2) The Drupal framework exposes the object for each module it has created, so I can get the object for each module class from Drupal framework, and use it to access oublich methods provided by that module. I am more inclined to this approach, as this allows me benefits of OO approach like inheritance, overriding etc.

Would be interesting to see, what you think...

--
I always think tomorrow will have more time than today.
And every today seems to pass-by faster than yesterday.
http://www.rahulsingla.com

What I think

Crell's picture

http://groups.drupal.org/node/20728

As I said, the Legal group is not the place to discuss OO architecture.

Legal

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: