Licensing of code snippets posted in threads?

Matthew S

Adherent
Joined
Jun 27, 2015
Messages
306
On forums like TAZ, and on app developer sites, such as Xenforo etc, occasionally code snippets get posted in discussions to help other users achieve something. Can these be considered as in the public domain, or is there some other license involved? I'm mindful of the possibility that the poster may not have the authority to post that code and subsequently cause it to become "Free". How should I/we treat code snippets like this if wanting to include it in distributed code?
 

Snog

Developer
Joined
Sep 9, 2012
Messages
225
If it's a true snippet where the entire function is not shown, you're probably OK.

If it's a complete function that's proprietary to an add-on (you'll know it is by looking at it), then think twice about including it.

With that said, in general there are things that can only be done in a limited number of ways so some duplication of code happens between all programs. It's unavoidable.

Because of the limited number of ways to do things, the general test for copyright infringement (which is what you seem concerned about) is intent. Was the intent there to defraud the original developer?
 

pierce

Habitué
Joined
Apr 10, 2016
Messages
1,165
From the moment it is created it is copyrighted.

It doesn't become "free".

As such it must be discarded, licensed or attributed.

However assuming that your on a support site and you are trying to code something and somebody helps you, that "help" is assumed to be free. Unless they code the whole thing for you then that is back to the original copyright issue.

Theres a lot of jokes about programming is the copy and paste of stack overflow.

ai.imgur.com_SZPjHwz.jpg
 

Snog

Developer
Joined
Sep 9, 2012
Messages
225
What pierce said is both true and false at the same time. ;)

For instance, a simple foreach loop that might be a snippet somewhere like this is not able to be copyrighted because there's only one way to do a foreach loop in PHP.
Code:
foreach($x as $y)
{
   // SOME CODE HERE
}

Now, the 'SOME CODE HERE' MAY be able to be copyrighted depending on what it does.

As an example of a full foreach loop that can not be copyrighted would be the case of extracting the user name from a list of users in XenForo (or I'll bet any other forum software) because there's only one way to do it using a foreach loop...
Code:
foreach($users as $user)
{
   $usernamelist[] = $user['username'];
}

The entire copyright system for programs is subject to intent, what the program does and how it does it. The source code is only able to be copyrighted to the extent of any unique items in the code and how it arrives at the end result for what the program does. For instance my Application Forms add-on works differently than other forms add-ons. It is very possible there are similar sections of code simply because there are a limited number of ways to do things in PHP. I hope that doesn't make things muddier than they already might be. :)
 
Last edited:

pierce

Habitué
Joined
Apr 10, 2016
Messages
1,165
Well somebody patented the wheel in Australia and google was fighting the courts about API's against oracle and had to dumb it right down, BT tried to collect licences for a "A href" link so I wouldn't say foreach is exempt from that.

But for smart people that are reasonable I would say that ownership of code would be something that achieves something.

$random_numbers = array();
$random_numbers = getRandomLottoNumbers(6);

the function getRandomLottoNumbers has a certain amount of code required that could be uniquely programmed by many developers to achieve the same result.

If you go asking about iso9600 standards (or whatever one it is) that is a whole can of worms.
 
Top