Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/Service/MiscService.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ public function asyncAndLeaveClientOutOfThis($result = '') {
ob_start();
echo(json_encode($result));
$size = ob_get_length();
header('Content-Length: ' . $size);
if ($size !== false) {
header('Content-Length: ' . $size);
}
ob_end_flush();
flush();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/ShareWrapperService.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ private function generateSharedWithByPathCacheKey(
$pathHash = \md5($path);
return $federatedUser->getSingleId() . '#'
. $pathHash . '#'
. $forChildren . '#'
. (int)$forChildren . '#'
. $probeSum;
}

Expand Down
4 changes: 3 additions & 1 deletion lib/Tools/Traits/TAsync.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public function async(string $result = ''): void {
echo($result);

$size = ob_get_length();
header('Content-Length: ' . $size);
if ($size !== false) {
header('Content-Length: ' . $size);
}
ob_end_flush();
flush();
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Tools/Traits/TNCLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ trait TNCLogger {
public static $INFO = 1;
public static $DEBUG = 0;


/**
* @param Throwable $t
* @param array $serializable
Expand Down Expand Up @@ -172,7 +171,8 @@ public function log(int $level, string $message, bool $trace = false, array $ser
* @return LoggerInterface
*/
public function logger(): LoggerInterface {
if (isset($this->logger)) {
/** @psalm-suppress UndefinedThisPropertyFetch Ugly but works */
if (isset($this->logger) && $this->logger instanceof LoggerInterface) {
return $this->logger;
} else {
return Server::get(LoggerInterface::class);
Expand Down
25 changes: 10 additions & 15 deletions lib/Tools/Traits/TNCRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
trait TNCRequest {
use TNCLogger;


/**
* @param int $size
*/
Expand Down Expand Up @@ -86,6 +85,7 @@ public function doRequest(NCRequest $request, bool $exceptionOnIssue = true): vo
* @return IClientService
*/
public function clientService(): IClientService {
/** @psalm-suppress UndefinedThisPropertyFetch Ugly but works */
if (isset($this->clientService) && $this->clientService instanceof IClientService) {
return $this->clientService;
} else {
Expand Down Expand Up @@ -140,19 +140,14 @@ private function generationClientOptions(NCRequest $request) {
*/
private function useClient(NCRequest $request): IResponse {
$client = $request->getClient();
switch ($request->getType()) {
case Request::TYPE_POST:
return $client->post($request->getCompleteUrl(), $request->getClientOptions());
case Request::TYPE_PUT:
return $client->put($request->getCompleteUrl(), $request->getClientOptions());
case Request::TYPE_DELETE:
return $client->delete($request->getCompleteUrl(), $request->getClientOptions());
case Request::TYPE_GET:
return $client->get(
$request->getCompleteUrl() . $request->getQueryString(), $request->getClientOptions()
);
default:
throw new Exception('unknown request type ' . json_encode($request));
}
return match ($request->getType()) {
Request::TYPE_POST => $client->post($request->getCompleteUrl(), $request->getClientOptions()),
Request::TYPE_PUT => $client->put($request->getCompleteUrl(), $request->getClientOptions()),
Request::TYPE_DELETE => $client->delete($request->getCompleteUrl(), $request->getClientOptions()),
Request::TYPE_GET => $client->get(
$request->getCompleteUrl() . $request->getQueryString(), $request->getClientOptions()
),
default => throw new Exception('unknown request type ' . json_encode($request)),
};
}
}
2 changes: 1 addition & 1 deletion lib/Tools/Traits/TStringTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function humanReadable(int $bytes): string {
$s = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
$e = floor(log($bytes, 1024));

return round($bytes / pow(1024, $e), 2) . ' ' . $s[$e];
return (string)round((float)$bytes / pow(1024, $e), 2) . ' ' . $s[$e];
}


Expand Down
2 changes: 1 addition & 1 deletion tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="6.5.0@38fc8444edf0cebc9205296ee6e30e906ade783b">
<files psalm-version="6.14.3@d0b040a91f280f071c1abcb1b77ce3822058725a">
<file src="lib/Activity/ProviderParser.php">
<TypeDoesNotContainType>
<code><![CDATA[str_starts_with($sK, '_')]]></code>
Expand Down
13 changes: 13 additions & 0 deletions tests/stubs/oc_db_querybuilder_querybuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@
use OCP\IDBConnection;
use Psr\Log\LoggerInterface;

enum ConflictResolutionMode {
/**
* Wait for the row to be unlocked.
*/
case Ordinary;
/**
* Skip the row if it is locked.
*/
case SkipLocked;
}

class QueryBuilder implements IQueryBuilder {
/** @var string */
protected $lastInsertedTable;
Expand Down Expand Up @@ -981,4 +992,6 @@ public function runAcrossAllShards(): self
{
}


public function forUpdate(ConflictResolutionMode $conflictResolutionMode = ConflictResolutionMode::Ordinary): self {}
}
Loading