Code Duplication    Length = 16-17 lines in 2 locations

code/api/CopyFactory.php 2 locations

@@ 503-519 (lines=17) @@
500
                    $newObjectParent->$relationalFieldForChildWithID = $newObjectChildObject->ID;
501
                    $newObjectParent->write();
502
                }
503
                if ($this->recordSession) {
504
                    if (!$newObjectChildObject) {
505
                        self::add_to_session("ERROR:  did not create object listed above", $copyFromChildObject, $newObjectChildObject);
506
                    } else {
507
                        self::add_to_session("CREATED object", $copyFromChildObject, $newObjectChildObject);
508
                    }
509
                    if ($newObjectParent->$relationalFieldForChildWithID != $newObjectChildObject->ID) {
510
                        self::add_to_session(
511
                            "ERROR: broken link ... '".$newObjectParent->$relationalFieldForChildWithID."' is not equal to '".$newObjectChildObject->ID."'",
512
                            $copyFromChildObject,
513
                            $newObjectChildObject
514
                        );
515
                    //hack fix
516
                    } else {
517
                        self::add_to_session("Saved with correct new parent field ($relationFieldForParentWithID) ID: ".$newObjectChildObject->$relationFieldForParentWithID, $copyFromChildObject, $newObjectChildObject);
518
                    }
519
                }
520
            }
521
        }
522
        return $this;
@@ 666-681 (lines=16) @@
663
                $newObjectChildObject->$relationFieldForParentWithID = $newObjectParent->ID;
664
                $newObjectChildObject->write();
665
            }
666
            if ($this->recordSession) {
667
                if (!$newObjectChildObject) {
668
                    self::add_to_session("ERROR: did not create object listed above", $copyFromChildObject, $newObjectChildObject);
669
                } else {
670
                    self::add_to_session("CREATED object", $copyFromChildObject, $newObjectChildObject);
671
                }
672
                if ($newObjectChildObject->$relationFieldForParentWithID != $newObjectParent->ID) {
673
                    self::add_to_session(
674
                        "
675
                        ERROR: broken link ...  '".$newObjectChildObject->$relationFieldForParentWithID."' is not equal to '".$newObjectParent->ID."'",
676
                        $copyFromChildObject,
677
                        $newObjectChildObject
678
                    );
679
                //hack fix
680
                } else {
681
                    self::add_to_session("Saved with correct new parent field ($relationFieldForParentWithID) ID: ".$newObjectChildObject->$relationFieldForParentWithID, $copyFromChildObject, $newObjectChildObject);
682
                }
683
            }
684
        }