Merge branch '3.5' into 3.6

This commit is contained in:
Daniel Hensby 2018-04-18 13:14:07 +01:00
commit 8359f3dc97
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E
3 changed files with 32 additions and 10 deletions

View File

@ -8,27 +8,27 @@
[![Dependency Status](https://www.versioneye.com/php/silverstripe:framework/badge.svg)](https://www.versioneye.com/php/silverstripe:framework)
[![Reference Status](https://www.versioneye.com/php/silverstripe:framework/reference_badge.svg?style=flat)](https://www.versioneye.com/php/silverstripe:framework/references)
PHP5 framework forming the base for the SilverStripe CMS ([http://silverstripe.org](http://silverstripe.org)).
Requires a [`silverstripe-installer`](http://github.com/silverstripe/silverstripe-installer) base project. Typically used alongside the [`cms`](http://github.com/silverstripe/silverstripe-cms) module.
PHP5 framework forming the base for the SilverStripe CMS ([https://silverstripe.org](https://silverstripe.org)).
Requires a [`silverstripe-installer`](https://github.com/silverstripe/silverstripe-installer) base project. Typically used alongside the [`cms`](https://github.com/silverstripe/silverstripe-cms) module.
## Installation ##
See [installation on different platforms](http://doc.silverstripe.org/framework/en/installation/),
and [installation from source](http://doc.silverstripe.org/framework/en/installation/from-source).
See [installation on different platforms](https://doc.silverstripe.org/framework/en/installation/),
and [installation from source](https://doc.silverstripe.org/framework/en/installation/from-source).
## Bugtracker ##
Bugs are tracked on [github.com](https://github.com/silverstripe/silverstripe-framework/issues).
Please read our [issue reporting guidelines](http://doc.silverstripe.org/framework/en/misc/contributing/issues).
Please read our [issue reporting guidelines](https://doc.silverstripe.org/framework/en/misc/contributing/issues).
## Development and Contribution ##
If you would like to make changes to the SilverStripe core codebase, we have an extensive [guide to contributing code](http://doc.silverstripe.org/framework/en/misc/contributing/code).
If you would like to make changes to the SilverStripe core codebase, we have an extensive [guide to contributing code](https://docs.silverstripe.org/en/contributing/code/).
## Links ##
* [Server Requirements](http://doc.silverstripe.org/framework/en/installation/server-requirements)
* [Changelogs](http://doc.silverstripe.org/framework/en/changelogs/)
* [Server Requirements](https://doc.silverstripe.org/framework/en/installation/server-requirements)
* [Changelogs](https://doc.silverstripe.org/framework/en/changelogs/)
* [Bugtracker: Framework](https://github.com/silverstripe/silverstripe-framework/issues)
* [Bugtracker: CMS](https://github.com/silverstripe/silverstripe-cms/issues)
* [Bugtracker: Installer](https://github.com/silverstripe/silverstripe-installer/issues)

View File

@ -586,7 +586,20 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
private function duplicateRelations($sourceObject, $destinationObject, $name) {
$relations = $sourceObject->$name();
if ($relations) {
if ($relations instanceOf RelationList) { //many-to-something relation
if ($relations instanceOf ManyManyList) { //many-to-many relation
$extraFieldNames = $relations->getExtraFields();
if ($relations->Count() > 0) { //with more than one thing it is related to
foreach($relations as $relation) {
// Merge extra fields
$extraFields = array();
foreach ($extraFieldNames as $fieldName => $fieldType) {
$extraFields[$fieldName] = $relation->getField($fieldName);
}
$destinationObject->$name()->add($relation, $extraFields);
}
}
} else if ($relations instanceOf RelationList) { //many-to-something relation
if ($relations->Count() > 0) { //with more than one thing it is related to
foreach($relations as $relation) {
$destinationObject->$name()->add($relation);

View File

@ -77,7 +77,7 @@ class DataObjectDuplicationTest extends SapphireTest {
//create relations
$one->twos()->add($two);
$one->threes()->add($three);
$one->threes()->add($three, array('TestExtra'=>'three'));
$one = DataObject::get_by_id("DataObjectDuplicateTestClass1", $one->ID);
$two = DataObject::get_by_id("DataObjectDuplicateTestClass2", $two->ID);
@ -115,6 +115,9 @@ class DataObjectDuplicationTest extends SapphireTest {
"Match between relation of copy and the original");
$this->assertEquals($one->ID, $threeCopy->ones()->First()->ID,
"Match between relation of copy and the original");
$this->assertEquals('three', $oneCopy->threes()->First()->TestExtra,
"Match between extra field of copy and the original");
}
}
@ -133,6 +136,12 @@ class DataObjectDuplicateTestClass1 extends DataObject implements TestOnly {
private static $many_many = array(
'threes' => 'DataObjectDuplicateTestClass3'
);
private static $many_many_extraFields = array(
'threes' => array(
'TestExtra' => 'Varchar'
)
);
}
class DataObjectDuplicateTestClass2 extends DataObject implements TestOnly {