Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
remove safe as there is removed of thecodingmachine module
Signed-off-by: nabim777 <[email protected]>
  • Loading branch information
nabim777 committed Jun 7, 2024
commit a86283d74b8871d357dd8196bbbf21e43426e56b
6 changes: 3 additions & 3 deletions lib/Controller/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public function oauthRedirect(string $code = '', string $state = ''): RedirectRe
);

try {
$oauthJourneyStartingPageDecoded = \Safe\json_decode($oauthJourneyStartingPage);
$oauthJourneyStartingPageDecoded = json_decode($oauthJourneyStartingPage);

if ($oauthJourneyStartingPageDecoded->page === 'dashboard') {
$newUrl = $this->urlGenerator->linkToRoute('dashboard.dashboard.index');
Expand Down Expand Up @@ -438,12 +438,12 @@ public function oauthRedirect(string $code = '', string $state = ''): RedirectRe

$validCodeVerifier = false;
if (is_string($codeVerifier)) {
$validCodeVerifier = (\Safe\preg_match('/^[A-Za-z0-9\-._~]{43,128}$/', $codeVerifier) === 1);
$validCodeVerifier = (preg_match('/^[A-Za-z0-9\-._~]{43,128}$/', $codeVerifier) === 1);
}

$validClientSecret = false;
if (is_string($clientSecret)) {
$validClientSecret = (\Safe\preg_match('/^.{10,}$/', $clientSecret) === 1);
$validClientSecret = (preg_match('/^.{10,}$/', $clientSecret) === 1);
}

if ($clientID && $validClientSecret && $validCodeVerifier && $configState !== '' && $configState === $state) {
Expand Down
24 changes: 10 additions & 14 deletions lib/Service/OpenProjectAPIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
use OCP\Security\ISecureRandom;
use OCP\Server;
use Psr\Log\LoggerInterface;
use Safe\Exceptions\JsonException;

define('CACHE_TTL', 3600);

Expand Down Expand Up @@ -189,7 +188,7 @@ public function getNotifications(string $userId): array {

$params = [
'pageSize' => -1,
'filters' => \Safe\json_encode($filters)
'filters' => json_encode($filters)
];
$result = $this->request($userId, 'notifications', $params);
if (isset($result['error'])) {
Expand Down Expand Up @@ -222,7 +221,6 @@ public function getBaseUrl(): string {
* @param bool $onlyLinkableWorkPackages
* @return array<mixed>
* @throws \OCP\PreConditionNotMetException
* @throws \Safe\Exceptions\JsonException
*/
public function searchWorkPackage(
string $userId,
Expand Down Expand Up @@ -261,7 +259,6 @@ public function searchWorkPackage(
* @param bool $onlyLinkableWorkPackages
* @return array<mixed>
* @throws \OCP\PreConditionNotMetException
* @throws \Safe\Exceptions\JsonException
*/
private function searchRequest(string $userId, array $filters, bool $onlyLinkableWorkPackages = true): array {
$resultsById = [];
Expand All @@ -274,8 +271,8 @@ private function searchRequest(string $userId, array $filters, bool $onlyLinkabl
}

$params = [
'filters' => \Safe\json_encode($filters),
'sortBy' => \Safe\json_encode($sortBy),
'filters' => json_encode($filters),
'sortBy' => json_encode($sortBy),
];
$searchResult = $this->request($userId, 'work_packages', $params);

Expand Down Expand Up @@ -772,7 +769,7 @@ public function linkWorkPackageToFile(
]
];

$params['body'] = \Safe\json_encode($body);
$params['body'] = json_encode($body);
$result = $this->request(
$userId, 'work_packages/' . $values["workpackageId"] . '/file_links', $params, 'POST'
);
Expand Down Expand Up @@ -804,7 +801,6 @@ public function linkWorkPackageToFile(
/**
* @throws OpenprojectErrorException
* @throws PreConditionNotMetException
* @throws JsonException
* @throws Exception
* @return array<mixed>
*/
Expand All @@ -816,7 +812,7 @@ public function markAllNotificationsOfWorkPackageAsRead(
['operator' => '=', 'values' => [(string)$workpackageId]]
];
$params['body'] = '';
$fullUrl = 'notifications/read_ian?filters=' . urlencode(\Safe\json_encode($filters));
$fullUrl = 'notifications/read_ian?filters=' . urlencode(json_encode($filters));

$result = $this->request(
$userId, $fullUrl, $params, 'POST'
Expand Down Expand Up @@ -1358,7 +1354,7 @@ public function getAvailableOpenProjectProjects(string $userId): array {
['operator' => '&=', 'values' => ["file_links/manage", "work_packages/create"]]
];
$params = [
'filters' => \Safe\json_encode($filters)
'filters' => json_encode($filters)
];
$result = $this->request($userId, 'work_packages/available_projects', $params);
if (isset($result['error'])) {
Expand All @@ -1382,10 +1378,10 @@ public function getAvailableOpenProjectProjects(string $userId): array {
* @param array<mixed> $body
*
* @return array<string,mixed>
* @throws OpenprojectResponseException|PreConditionNotMetException|JsonException|OpenprojectErrorException
* @throws OpenprojectResponseException|PreConditionNotMetException|OpenprojectErrorException
*/
public function getOpenProjectWorkPackageForm(string $userId, string $projectId, array $body): array {
$params['body'] = \Safe\json_encode($body);
$params['body'] = json_encode($body);
$result = $this->request($userId, 'projects/'.$projectId.'/work_packages/form', $params, 'POST');
if (isset($result['error'])) {
throw new OpenprojectErrorException($result['error'], $result['statusCode']);
Expand Down Expand Up @@ -1430,10 +1426,10 @@ public function getAvailableAssigneesOfAProject(string $userId, string $projectI
* @param array<mixed> $body
*
* @return array<mixed>
* @throws OpenprojectResponseException|PreConditionNotMetException|JsonException|OpenprojectErrorException
* @throws OpenprojectResponseException|PreConditionNotMetException|OpenprojectErrorException
*/
public function createWorkPackage(string $userId, array $body): array {
$params['body'] = \Safe\json_encode($body);
$params['body'] = json_encode($body);
$result = $this->request($userId, 'work_packages', $params, 'POST');
if (isset($result['error'])) {
throw new OpenprojectErrorException($result['error'], $result['statusCode']);
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/Controller/DirectUploadControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public function testDirectUploadException(
):void {
$nodeMock = $this->getNodeMock('folder');
$tmpFileName = '/tmp/integration_openproject_unit_test';
\Safe\touch($tmpFileName);
touch($tmpFileName);
$nodeMock[0]->method('newFile')->will($this->throwException($exception));
$userFolderMock = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$userFolderMock->method('getById')->willReturn($nodeMock);
Expand All @@ -219,7 +219,7 @@ public function testNegativeFreeSpace(): void {
$fileMock->method('getId')->willReturn(123);
$nodeMock = $this->getNodeMock('folder');
$tmpFileName = '/tmp/integration_openproject_unit_test';
\Safe\touch($tmpFileName);
touch($tmpFileName);
$nodeMock[0]->method('getFreeSpace')->willReturn(-3);
$nodeMock[0]->method('newFile')->willReturn($fileMock);
$userFolderMock = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
Expand Down
6 changes: 3 additions & 3 deletions tests/lib/Service/OpenProjectAPIServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ public function testGetNotificationsRequest() {
$consumerRequest
->setMethod('GET')
->setPath($this->notificationsPath)
->setQuery("pageSize=-1&filters=" . \Safe\json_encode([[
->setQuery("pageSize=-1&filters=" . json_encode([[
'readIAN' =>
['operator' => '=', 'values' => ['f']]
]]))
Expand Down Expand Up @@ -1594,7 +1594,7 @@ public function testLinkWorkPackageToFileRequest(): void {
->method('request')
->with(
'user', 'work_packages/123/file_links',
['body' => \Safe\json_encode($this->validFileLinkRequestBody)]
['body' => json_encode($this->validFileLinkRequestBody)]
);
$values = $this->singleFileInformation;
$result = $service->linkWorkPackageToFile(
Expand Down Expand Up @@ -1852,7 +1852,7 @@ public function testLinkWorkPackageToMultipleFileRequest(): void {
->method('request')
->with(
'user', 'work_packages/123/file_links',
['body' => \Safe\json_encode($this->validFileLinkRequestBodyForMultipleFiles)]
['body' => json_encode($this->validFileLinkRequestBodyForMultipleFiles)]
);
$values = $this->multipleFileInformation;
$result = $service->linkWorkPackageToFile(
Expand Down