diff --git a/lib/private/db/adapteroci8.php b/lib/private/db/adapteroci8.php
index 6e7857e6620d52eb77b716f5577dbd5a1957c639..76c265bc178beab4e32bb6b9fcf1f30e4dbb3b22 100644
--- a/lib/private/db/adapteroci8.php
+++ b/lib/private/db/adapteroci8.php
@@ -26,6 +26,9 @@ namespace OC\DB;
 
 class AdapterOCI8 extends Adapter {
 	public function lastInsertId($table) {
+		if (is_null($table)) {
+			throw new \InvalidArgumentException('Oracle requires a table name to be passed into lastInsertId()');
+		}
 		if ($table !== null) {
 			$suffix = '_SEQ';
 			$table = '"' . $table . $suffix . '"';
diff --git a/lib/private/db/connection.php b/lib/private/db/connection.php
index 1b86d3d383ac69e555180bffb13e62e7ffff56c2..85b1b7cd5ea07e7d95b691ed6a3f21b243f8a02b 100644
--- a/lib/private/db/connection.php
+++ b/lib/private/db/connection.php
@@ -214,8 +214,7 @@ class Connection extends \Doctrine\DBAL\Connection implements IDBConnection {
 	 * @param string $seqName Name of the sequence object from which the ID should be returned.
 	 * @return string A string representation of the last inserted ID.
 	 */
-	public function lastInsertId($seqName = null)
-	{
+	public function lastInsertId($seqName = null) {
 		if ($seqName) {
 			$seqName = $this->replaceTablePrefix($seqName);
 		}
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index d377708a2681bf4b0b785533d18521876ad1a308..6aac0d6264de1951a4ebfb15c9e3fa96cb26b89c 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -2332,22 +2332,7 @@ class Share extends Constants {
 
 		$id = false;
 		if ($result) {
-			$id =  \OC::$server->getDatabaseConnection()->lastInsertId();
-			// Fallback, if lastInterId() doesn't work we need to perform a select
-			// to get the ID (seems to happen sometimes on Oracle)
-			if (!$id) {
-				$getId = \OC_DB::prepare('
-					SELECT `id`
-					FROM`*PREFIX*share`
-					WHERE `uid_owner` = ? AND `item_target` = ? AND `item_source` = ? AND `stime` = ?
-					');
-				$r = $getId->execute(array($shareData['uidOwner'], $shareData['itemTarget'], $shareData['itemSource'], $shareData['shareTime']));
-				if ($r) {
-					$row = $r->fetchRow();
-					$id = $row['id'];
-				}
-			}
-
+			$id =  \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share');
 		}
 
 		return $id;
diff --git a/tests/lib/repair/cleantags.php b/tests/lib/repair/cleantags.php
index a511daa03d67a8275dc264670e3a4596d15c0721..896dd333cc2c46537168096d60d10967012beeca 100644
--- a/tests/lib/repair/cleantags.php
+++ b/tests/lib/repair/cleantags.php
@@ -165,20 +165,6 @@ class CleanTags extends \Test\TestCase {
 	 * @return int
 	 */
 	protected function getLastInsertID($tableName, $idName) {
-		$id = $this->connection->lastInsertId();
-		if ($id) {
-			return $id;
-		}
-
-		// FIXME !!!! ORACLE WORKAROUND DO NOT COPY
-		// FIXME INSTEAD HELP FIXING DOCTRINE
-		// FIXME https://github.com/owncloud/core/issues/13303
-		// FIXME ALSO FIX https://github.com/owncloud/core/commit/2dd85ec984c12d3be401518f22c90d2327bec07a
-		$qb = $this->connection->getQueryBuilder();
-		$result = $qb->select($qb->createFunction('MAX(`' . $idName . '`)'))
-			->from($tableName)
-			->execute();
-
-		return (int) $result->fetchColumn();
+		return $this->connection->lastInsertId("*PREFIX*$tableName");
 	}
 }
diff --git a/tests/lib/repair/oldgroupmembershipsharestest.php b/tests/lib/repair/oldgroupmembershipsharestest.php
index 74f68bd7899618c923ef9a7c74546d9174896670..272e1ef09c4125b09c5cb01e6cbc81575c2d25d7 100644
--- a/tests/lib/repair/oldgroupmembershipsharestest.php
+++ b/tests/lib/repair/oldgroupmembershipsharestest.php
@@ -72,7 +72,7 @@ class OldGroupMembershipSharesTest extends \Test\TestCase {
 			->orderBy('id', 'ASC')
 			->execute();
 		$rows = $result->fetchAll();
-		$this->assertSame([['id' => $parent], ['id' => $group2], ['id' => $user1], ['id' => $member], ['id' => $notAMember]], $rows);
+		$this->assertEquals([['id' => $parent], ['id' => $group2], ['id' => $user1], ['id' => $member], ['id' => $notAMember]], $rows);
 		$result->closeCursor();
 
 		$repair->run();
@@ -83,7 +83,7 @@ class OldGroupMembershipSharesTest extends \Test\TestCase {
 			->orderBy('id', 'ASC')
 			->execute();
 		$rows = $result->fetchAll();
-		$this->assertSame([['id' => $parent], ['id' => $group2], ['id' => $user1], ['id' => $member]], $rows);
+		$this->assertEquals([['id' => $parent], ['id' => $group2], ['id' => $user1], ['id' => $member]], $rows);
 		$result->closeCursor();
 	}
 
@@ -118,21 +118,6 @@ class OldGroupMembershipSharesTest extends \Test\TestCase {
 			->values($shareValues)
 			->execute();
 
-		return $this->getLastShareId();
-	}
-
-	/**
-	 * @return int
-	 */
-	protected function getLastShareId() {
-		// select because lastInsertId does not work with OCI
-		$query = $this->connection->getQueryBuilder();
-		$result = $query->select('id')
-			->from('share')
-			->orderBy('id', 'DESC')
-			->execute();
-		$row = $result->fetch();
-		$result->closeCursor();
-		return $row['id'];
+		return $this->connection->lastInsertId('*PREFIX*share');
 	}
 }
diff --git a/tests/lib/repair/repairinvalidsharestest.php b/tests/lib/repair/repairinvalidsharestest.php
index 005a2db234421793681432e97d511297e196a50f..e8dcaa4da97d7201f36c2977ce69ec4def3bdcaf 100644
--- a/tests/lib/repair/repairinvalidsharestest.php
+++ b/tests/lib/repair/repairinvalidsharestest.php
@@ -162,7 +162,7 @@ class RepairInvalidSharesTest extends TestCase {
 			->orderBy('id', 'ASC')
 			->execute();
 		$rows = $result->fetchAll();
-		$this->assertSame([['id' => $parent], ['id' => $validChild], ['id' => $invalidChild]], $rows);
+		$this->assertEquals([['id' => $parent], ['id' => $validChild], ['id' => $invalidChild]], $rows);
 		$result->closeCursor();
 
 		$this->repair->run();
@@ -173,7 +173,7 @@ class RepairInvalidSharesTest extends TestCase {
 			->orderBy('id', 'ASC')
 			->execute();
 		$rows = $result->fetchAll();
-		$this->assertSame([['id' => $parent], ['id' => $validChild]], $rows);
+		$this->assertEquals([['id' => $parent], ['id' => $validChild]], $rows);
 		$result->closeCursor();
 	}
 
@@ -181,15 +181,7 @@ class RepairInvalidSharesTest extends TestCase {
 	 * @return int
 	 */
 	protected function getLastShareId() {
-		// select because lastInsertId does not work with OCI
-		$query = $this->connection->getQueryBuilder();
-		$result = $query->select('id')
-			->from('share')
-			->orderBy('id', 'DESC')
-			->execute();
-		$row = $result->fetch();
-		$result->closeCursor();
-		return $row['id'];
+		return $this->connection->lastInsertId('*PREFIX*share');
 	}
 }