Code Duplication    Length = 14-16 lines in 2 locations

engine/classes/ElggEntity.php 2 locations

@@ 1334-1349 (lines=16) @@
1331
		$user_guid = elgg_get_logged_in_user_guid();
1332
1333
		// If given an owner, verify it can be loaded
1334
		if ($owner_guid) {
1335
			$owner = $this->getOwnerEntity();
1336
			if (!$owner) {
1337
				_elgg_services()->logger->error("User $user_guid tried to create a ($type, $subtype), but the given"
1338
					. " owner $owner_guid could not be loaded.");
1339
				return false;
1340
			}
1341
1342
			// If different owner than logged in, verify can write to container.
1343
1344
			if ($user_guid != $owner_guid && !$owner->canWriteToContainer(0, $type, $subtype)) {
1345
				_elgg_services()->logger->error("User $user_guid tried to create a ($type, $subtype) with owner"
1346
					. " $owner_guid, but the user wasn't permitted to write to the owner's container.");
1347
				return false;
1348
			}
1349
		}
1350
1351
		// If given a container, verify it can be loaded and that the current user can write to it
1352
		if ($container_guid) {
@@ 1352-1365 (lines=14) @@
1349
		}
1350
1351
		// If given a container, verify it can be loaded and that the current user can write to it
1352
		if ($container_guid) {
1353
			$container = $this->getContainerEntity();
1354
			if (!$container) {
1355
				_elgg_services()->logger->error("User $user_guid tried to create a ($type, $subtype), but the given"
1356
					. " container $container_guid could not be loaded.");
1357
				return false;
1358
			}
1359
1360
			if (!$container->canWriteToContainer(0, $type, $subtype)) {
1361
				_elgg_services()->logger->error("User $user_guid tried to create a ($type, $subtype), but was not"
1362
					. " permitted to write to container $container_guid.");
1363
				return false;
1364
			}
1365
		}
1366
1367
		// Create primary table row
1368
		$guid = _elgg_services()->entityTable->insertRow((object) [