aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/DB/Adapter.php20
-rw-r--r--lib/private/DB/AdapterOCI8.php2
-rw-r--r--lib/private/DB/AdapterPgSql.php2
-rw-r--r--lib/private/DB/Connection.php29
-rw-r--r--lib/private/Files/SetupManager.php3
-rw-r--r--lib/private/User/LazyUser.php4
-rw-r--r--lib/private/User/User.php13
-rw-r--r--lib/private/legacy/OC_Helper.php2
-rw-r--r--lib/private/legacy/OC_Util.php2
9 files changed, 30 insertions, 47 deletions
diff --git a/lib/private/DB/Adapter.php b/lib/private/DB/Adapter.php
index edd8c1bf023..8f1b8e6d75f 100644
--- a/lib/private/DB/Adapter.php
+++ b/lib/private/DB/Adapter.php
@@ -28,25 +28,11 @@ class Adapter {
/**
* @param string $table name
*
- * @return int id of last insert statement, 0 in case there was no INSERT before or it failed to get the ID
+ * @return int id of last insert statement
* @throws Exception
*/
- public function lastInsertId($table, bool $allowRetry = true): int {
- $return = $this->conn->realLastInsertId($table);
- if ($return === 0 && $allowRetry) {
- /**
- * During a reconnect we are losing the connection and when the
- * realLastInsertId call is the one triggering the reconnect, it
- * does not return the ID. But inside the reconnect, we were able
- * to save the last insert id, so calling it a second time is going
- * to be successful.
- * We can not return the result on the initial call, as we are already
- * way deeper in the stack performing the actual database query on
- * the doctrine driver.
- */
- return $this->lastInsertId($table, false);
- }
- return $return;
+ public function lastInsertId($table) {
+ return (int)$this->conn->realLastInsertId($table);
}
/**
diff --git a/lib/private/DB/AdapterOCI8.php b/lib/private/DB/AdapterOCI8.php
index f5ad9f7c934..0a509090bca 100644
--- a/lib/private/DB/AdapterOCI8.php
+++ b/lib/private/DB/AdapterOCI8.php
@@ -8,7 +8,7 @@
namespace OC\DB;
class AdapterOCI8 extends Adapter {
- public function lastInsertId($table, bool $allowRetry = true): int {
+ public function lastInsertId($table) {
if (is_null($table)) {
throw new \InvalidArgumentException('Oracle requires a table name to be passed into lastInsertId()');
}
diff --git a/lib/private/DB/AdapterPgSql.php b/lib/private/DB/AdapterPgSql.php
index b321fcf4715..db48c81c2c5 100644
--- a/lib/private/DB/AdapterPgSql.php
+++ b/lib/private/DB/AdapterPgSql.php
@@ -9,7 +9,7 @@ namespace OC\DB;
class AdapterPgSql extends Adapter {
- public function lastInsertId($table, bool $allowRetry = true): int {
+ public function lastInsertId($table) {
$result = $this->conn->executeQuery('SELECT lastval()');
$val = $result->fetchOne();
$result->free();
diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php
index 4ba2d2a341d..96dd578b2ef 100644
--- a/lib/private/DB/Connection.php
+++ b/lib/private/DB/Connection.php
@@ -92,8 +92,6 @@ class Connection extends PrimaryReadReplicaConnection {
protected ShardConnectionManager $shardConnectionManager;
protected AutoIncrementHandler $autoIncrementHandler;
protected bool $isShardingEnabled;
- protected bool $disableReconnect = false;
- protected int $lastInsertId = 0;
public const SHARD_PRESETS = [
'filecache' => [
@@ -512,9 +510,9 @@ class Connection extends PrimaryReadReplicaConnection {
* because the underlying database may not even support the notion of AUTO_INCREMENT/IDENTITY
* columns or sequences.
*
- * @param ?string $name Name of the sequence object from which the ID should be returned.
+ * @param string $seqName Name of the sequence object from which the ID should be returned.
*
- * @return int the last inserted ID, 0 in case there was no INSERT before or it failed to get the ID
+ * @return int the last inserted ID.
* @throws Exception
*/
public function lastInsertId($name = null): int {
@@ -528,13 +526,8 @@ class Connection extends PrimaryReadReplicaConnection {
* @internal
* @throws Exception
*/
- public function realLastInsertId($seqName = null): int {
- if ($this->lastInsertId !== 0) {
- $lastInsertId = $this->lastInsertId;
- $this->lastInsertId = 0;
- return $lastInsertId;
- }
- return (int)parent::lastInsertId($seqName);
+ public function realLastInsertId($seqName = null) {
+ return parent::lastInsertId($seqName);
}
/**
@@ -903,23 +896,11 @@ class Connection extends PrimaryReadReplicaConnection {
if (
!isset($this->lastConnectionCheck[$this->getConnectionName()]) ||
time() <= $this->lastConnectionCheck[$this->getConnectionName()] + 30 ||
- $this->isTransactionActive() ||
- $this->disableReconnect
+ $this->isTransactionActive()
) {
return;
}
- if ($this->getDatabaseProvider() === IDBConnection::PLATFORM_MYSQL) {
- /**
- * Before reconnecting we save the lastInsertId, so that if the reconnect
- * happens between the INSERT executeStatement() and the getLastInsertId call
- * we are able to return the correct result after all.
- */
- $this->disableReconnect = true;
- $this->lastInsertId = (int)parent::lastInsertId();
- $this->disableReconnect = false;
- }
-
try {
$this->_conn->query($this->getDriver()->getDatabasePlatform()->getDummySelectSQL());
$this->lastConnectionCheck[$this->getConnectionName()] = time();
diff --git a/lib/private/Files/SetupManager.php b/lib/private/Files/SetupManager.php
index 7f97187179e..4ab40b01f4a 100644
--- a/lib/private/Files/SetupManager.php
+++ b/lib/private/Files/SetupManager.php
@@ -23,7 +23,6 @@ use OC\Share\Share;
use OC\Share20\ShareDisableChecker;
use OC_App;
use OC_Hook;
-use OC_Util;
use OCA\Files_External\Config\ExternalMountPoint;
use OCA\Files_Sharing\External\Mount;
use OCA\Files_Sharing\ISharedMountPoint;
@@ -157,7 +156,7 @@ class SetupManager {
if ($mount instanceof HomeMountPoint) {
$user = $mount->getUser();
return new Quota(['storage' => $storage, 'quotaCallback' => function () use ($user) {
- return OC_Util::getUserQuota($user);
+ return $user->getQuotaBytes();
}, 'root' => 'files', 'include_external_storage' => $quotaIncludeExternal]);
}
diff --git a/lib/private/User/LazyUser.php b/lib/private/User/LazyUser.php
index 715265f6a39..501169019d4 100644
--- a/lib/private/User/LazyUser.php
+++ b/lib/private/User/LazyUser.php
@@ -160,6 +160,10 @@ class LazyUser implements IUser {
return $this->getUser()->getQuota();
}
+ public function getQuotaBytes(): int|float {
+ return $this->getUser()->getQuotaBytes();
+ }
+
public function setQuota($quota) {
$this->getUser()->setQuota($quota);
}
diff --git a/lib/private/User/User.php b/lib/private/User/User.php
index 8e01a15695c..88ed0d44387 100644
--- a/lib/private/User/User.php
+++ b/lib/private/User/User.php
@@ -558,6 +558,19 @@ class User implements IUser {
return $quota;
}
+ public function getQuotaBytes(): int|float {
+ $quota = $this->getQuota();
+ if ($quota === 'none') {
+ return \OCP\Files\FileInfo::SPACE_UNLIMITED;
+ }
+
+ $bytes = \OCP\Util::computerFileSize($quota);
+ if ($bytes === false) {
+ return \OCP\Files\FileInfo::SPACE_UNKNOWN;
+ }
+ return $bytes;
+ }
+
/**
* set the users' quota
*
diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php
index 87c820dcd53..4388f775623 100644
--- a/lib/private/legacy/OC_Helper.php
+++ b/lib/private/legacy/OC_Helper.php
@@ -272,7 +272,7 @@ class OC_Helper {
} else {
$user = \OC::$server->getUserSession()->getUser();
}
- $quota = OC_Util::getUserQuota($user);
+ $quota = $user?->getQuotaBytes() ?? \OCP\Files\FileInfo::SPACE_UNKNOWN;
if ($quota !== \OCP\Files\FileInfo::SPACE_UNLIMITED) {
// always get free space / total space from root + mount points
return self::getGlobalStorageInfo($quota, $user, $mount);
diff --git a/lib/private/legacy/OC_Util.php b/lib/private/legacy/OC_Util.php
index 9444da4f36d..87447af8adc 100644
--- a/lib/private/legacy/OC_Util.php
+++ b/lib/private/legacy/OC_Util.php
@@ -98,7 +98,7 @@ class OC_Util {
*
* @param IUser|null $user
* @return int|\OCP\Files\FileInfo::SPACE_UNLIMITED|false|float Quota bytes
- * @deprecated 9.0.0 - Use \OCP\IUser::getQuota
+ * @deprecated 9.0.0 - Use \OCP\IUser::getQuota or \OCP\IUser::getQuotaBytes
*/
public static function getUserQuota(?IUser $user) {
if (is_null($user)) {