9

I answered a question on SO with code that came mostly from php.net. It was not immediately clear to me exactly what license, if any, applies to the example code on php.net. I can't claim ownership of it. How is this licensed?

6
  • A possibly more 'interesting' version is someone asking about a question where the code is not MIT or CC compatible. For example, a segment of code from openJdk AbstractList (GPL) - or any situation where you don't have the right to relicense the software under a more lax license.
    – user213963
    Jan 14, 2016 at 20:53
  • I think you might have hit on the issue I anticipated but I did not have the experience to communicate.
    – TecBrat
    Jan 14, 2016 at 21:00
  • I might have posted this on the wrong meta, but I think it applies across sites, so maybe it's better here after all.
    – TecBrat
    Jan 15, 2016 at 2:05
  • 1
    Given that I wrote this bit on Programmers.SE which has three lines of code from a GPL'ed project demonstrating issues with hashCode(), here is just fine.
    – user213963
    Jan 15, 2016 at 2:07
  • 1
    This is not a new problem. The exact same problem exists with the current license.
    – Pablo
    Jan 15, 2016 at 9:39
  • @Pablo Yes. As I said in my answer.
    – kjbartel
    Jan 15, 2016 at 9:43

3 Answers 3

8

As described by Machavity, the php.net manual has its license. As of this writing, that appears to be a CC with attribution 3.0 license. CC to CC license typically isn't all that much of a problem.

A more interesting situation would be one where someone is asking about a bit of code. Lets say... AbstractList form the openjdk. This code is covered under the GPL license.

Say a person is asking about the internal Itr class to it and how the checkForComodification works.

It really boils down to two options.

One option is that the question provides a link to the code and doesn't include it. This would be very much like linking to a JSFiddle as the entirety of the question on SO - frowned upon. The relevant MSO post is Should a question that is meaningless without viewing an external link be closed? where ChrisF says:

You could also leave a comment explaining that questions (like answers) should really stand on their own merits and only have external links for references etc.

If the code is too long to post in the question then that's another sign of a bad question. The OP should really be able to narrow the problem down to a few lines of code. If they're not at that stage yet then Stack Overflow isn't the place they should be posting.

Though its not that the code is too long.

The other option would be to include the bit of relevant code. I'm looking at a dozen lines right here. Currently, I would argue that the incorporation of the code in the question would be covered by fair use. And... we've now entered the murky world of IANAL.

The question and the answers are talking about the code. It isn't granting the use of the code under any particular license - it isn't even intended to be used as code.

However, once someone says "all the code on the site is under MIT" now that code is code... and you probably can't include it because you can't relicense the GPL code as MIT code.

Stepping through some code for gcc, or openJdk in an post shouldn't try to make that code licensed under MIT. The unfortunate effect of trying to provide a license for the code in a question would be that any code that is in the question must be MIT (and SE waiver) compatible - or a link only. And that will be detrimental to the quality of questions and answers across the entirety of the SE network where code that may not be able to be relicensed in a way to be included is a necessary part of a post.

6
  • 2
    GPL is also not compatible with CC-BY-SA. So this problem already exists if people use the code in an answer as code. (Note: CC-BY-SA 4.0 is compatible with GPL 3 from CC-BY-SA 4.0 to GPL 3 but not the other way around and SE uses CC-BY-SA 3.0 anyway which has no compatible non-CC licenses).
    – kjbartel
    Jan 15, 2016 at 9:03
  • @kjbartel no it isn't. For that matter, anything that doesn't have a license on it is also incompatible with pretty much everything. However, when one is using the material as an explanation and not attempting to say "this is code" in a way that isn't intended to be used as code or diminish the value of the copyrighted material one can make an argument for fair use. I am concerned that the fair use argument would disappear in its entirety if the material was to be licensed as code rather than as knowledge.
    – user213963
    Jan 15, 2016 at 14:05
  • 1
    @kjbartel: This should be possible with user-generated content on SE right now: CC BY-SA 3.0 → CC BY-SA 4.0 → GPLv3. But only for adaptations.
    – unor
    Jan 15, 2016 at 15:56
  • @unor I would love to see someone write a bit of code for an algorithm that is patented and place it under CC-BY-SA and watch it slip into a GPLv3 project that has the patent waiver and see what chaos ensues. Documenting a patented algorithm and explaining it in a CC document doesn't constitute a violation of the patent. And material incorporated with fair use for documentation and explanation in CC material that is under a GPL incompatible license doesn't mean that that can slide into the GPL software via this process either. I wouldn't trust that route at all.
    – user213963
    Jan 16, 2016 at 1:27
  • ... I realize that some path exists, I just don't believe that it would necessarily stand up well when documentation tries to become code when there are so many ways that one can document things.
    – user213963
    Jan 16, 2016 at 1:29
  • @MichaelT, the patent terms are always just between those who publish code under GPL and those who use it. They have no bearing on those who publish code under another license that allows incorporation in GPL projects (whether BY-SA or MIT) or those whose code is not involved at all. In particular, having code under MIT license would not change that issue in any way.
    – otus
    Jan 17, 2016 at 14:07
3

In your case it most likely doesn't apply. You used and linked code from the PHP manual which is under its own license which states

  1. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:

Relevant subsection

to Distribute and Publicly Perform Adaptations.

In other words, you took what was in the manual and adapted it for your answer. Since it wasn't a direct copy, you could (in theory) claim it as your own original work (as long as you attribute the original). Disclaimer I am not a lawyer so take that with a grain of salt.

The MIT debate is over someone taking the code you provided and using it, and then your claiming some form of copyright over it. All Stack overflow is trying to do is clarify the rights you, as a receiver of that code, have under the law.

3
  • I am far from fluent on the intricacies of various licenses. Perhaps a hypothetical situation in which there would be a conflict would be a situation where the code in question, from this hypothetical other site, is already unsuitably licensed for inclusion here. Is that your understanding of this issue?
    – TecBrat
    Jan 14, 2016 at 20:40
  • My understanding is that you quoted from something licensed under CC 3.0. Your quoting it means your quote falls under that license. If you quoted something that was under a stricter copyright, you would be bound by that copyright as well. BUT, then the issue of Fair Use would have to apply in some fashion, especially if you linked back to the source material
    – Machavity
    Jan 14, 2016 at 20:44
  • If it's an original work, the terms of the PHP documentation license are irrelevant. If it's not an original work, then you need to provide proper attribution (a link does not qualify), which the author did not.
    – Jeremy
    Jan 14, 2016 at 20:47
2

I asked a similar question earlier on meta.SO.

For both the current CC-BY-SA and the proposed MIT license, my understanding is (IANAL) that you may take code licensed under an incompatible license (such as GPL) and post it to an SE site if you are commenting on or teaching others about how the code works. This would usually fall under fair use (but would vary from country to country).

Somebody else though would not be allowed to then take that code in the question or answer and use it solely under the current CC-BY-SA or the proposed MIT license. Presenting the code on SE may be fair use but the use of that code in another program is not. Thus it would be violating the original license which the copyright holder applied to the code.

If you are not the copyright holder then you cannot apply a new license unless the license specifically allows you to do so.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .