Skip to content

Commit

Permalink
fix(occ): incorrect type of field in ExAppOccCommand (#278)
Browse files Browse the repository at this point in the history
Should fix incorrect type handling by different DBMS during ExApp occ
command registration.

Signed-off-by: Andrey Borysenko <[email protected]>
Signed-off-by: Alexander Piskun <[email protected]>
  • Loading branch information
andrey18106 authored Apr 23, 2024
1 parent 8bd2e68 commit 3b06bd7
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 25 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,11 @@ jobs:

nc-py-api-oci:
runs-on: ubuntu-22.04
name: NC_Py_API • stable28 • 8.2 • Oracle
name: NC_Py_API • ${{ matrix.server-version }} • 8.2 • Oracle
strategy:
fail-fast: false
matrix:
server-version: [ 'stable28', 'stable29' ]

services:
oracle:
Expand Down Expand Up @@ -300,13 +304,13 @@ jobs:
with:
submodules: true
repository: nextcloud/server
ref: stable28
ref: ${{ matrix.server-version }}

- name: Checkout Notifications
uses: actions/checkout@v3
with:
repository: nextcloud/notifications
ref: stable28
ref: ${{ matrix.server-version }}
path: apps/notifications

- name: Checkout AppAPI
Expand Down Expand Up @@ -376,7 +380,7 @@ jobs:
if: always()
uses: actions/upload-artifact@v3
with:
name: oci_nc_py_api_stable28_8.2_nextcloud.log
name: oci_nc_py_api_${{ matrix.server-version }}_8.2_nextcloud.log
path: data/nextcloud.log
if-no-files-found: warn

Expand Down
4 changes: 2 additions & 2 deletions docs/tech_details/api/occ_command.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Params
{
"name": "appid:unique:command:name",
"description": "Description of the command",
"hidden": "true/false",
"hidden": "1/0",
"arguments": [
{
"name": "argument_name",
Expand Down Expand Up @@ -66,7 +66,7 @@ Lets assume we have a command `ping` that takes an argument `test_arg` and has a
{
"name": "my_app_id:ping",
"description": "Test ping command",
"hidden": "false",
"hidden": 0,
"arguments": [
{
"name": "test_arg",
Expand Down
4 changes: 2 additions & 2 deletions lib/Controller/OccCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class OccCommandController extends OCSController {

public function __construct(
IRequest $request,
private readonly ExAppOccService $service,
private readonly ExAppOccService $service
) {
parent::__construct(Application::APP_ID, $request);

Expand All @@ -33,7 +33,7 @@ public function registerCommand(
string $name,
string $description,
string $execute_handler,
bool $hidden = false,
int $hidden = 0,
array $arguments = [],
array $options = [],
array $usages = [],
Expand Down
8 changes: 5 additions & 3 deletions lib/Db/Console/ExAppOccCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
* @method string getAppid()
* @method string getName()
* @method string getDescription()
* @method bool getHidden()
* @method int getHidden()
* @method array getArguments()
* @method array getOptions()
* @method array getUsages()
* @method string getExecuteHandler()
* @method void setAppid(string $appid)
* @method void setName(string $name)
* @method void setDescription(string $description)
* @method void setHidden(bool $hidden)
* @method void setHidden(int $hidden)
* @method void setArguments(array $arguments)
* @method void setOptions(array $options)
* @method void setUsages(array $usages)
Expand All @@ -46,7 +46,7 @@ public function __construct(array $params = []) {
$this->addType('appid', 'string');
$this->addType('name', 'string');
$this->addType('description', 'string');
$this->addType('hidden', 'bool');
$this->addType('hidden', 'int');
$this->addType('arguments', 'json');
$this->addType('options', 'json');
$this->addType('usages', 'json');
Expand All @@ -63,6 +63,8 @@ public function __construct(array $params = []) {
}
if (isset($params['description'])) {
$this->setDescription($params['description']);
} else {
$this->setDescription('');
}
if (isset($params['hidden'])) {
$this->setHidden($params['hidden']);
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/Console/ExAppOccCommandMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function findAllEnabled(): array {
$qb = $this->db->getQueryBuilder();
$result = $qb->select('exs.*')
->from($this->tableName, 'exs')
->innerJoin('exs', 'ex_apps', 'exa', 'exa.appid = exs.appid')
->innerJoin('exs', 'ex_apps', 'exa', $qb->expr()->eq('exa.appid', 'exs.appid'))
->where(
$qb->expr()->eq('exa.enabled', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT))
)
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/ExAppEventsListenerMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function findAllEnabled(): array {
$qb = $this->db->getQueryBuilder();
$result = $qb->select('exs.*')
->from($this->tableName, 'exs')
->innerJoin('exs', 'ex_apps', 'exa', 'exa.appid = exs.appid')
->innerJoin('exs', 'ex_apps', 'exa', $qb->expr()->eq('exa.appid', 'exs.appid'))
->where(
$qb->expr()->eq('exa.enabled', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT))
)
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/SpeechToText/SpeechToTextProviderMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function findAllEnabled(): array {
$qb = $this->db->getQueryBuilder();
$result = $qb->select('exs.*')
->from($this->tableName, 'exs')
->innerJoin('exs', 'ex_apps', 'exa', 'exa.appid = exs.appid')
->innerJoin('exs', 'ex_apps', 'exa', $qb->expr()->eq('exa.appid', 'exs.appid'))
->where(
$qb->expr()->eq('exa.enabled', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT))
)
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/TextProcessing/TextProcessingProviderMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function findAllEnabled(): array {
$qb = $this->db->getQueryBuilder();
$result = $qb->select('exs.*')
->from($this->tableName, 'exs')
->innerJoin('exs', 'ex_apps', 'exa', 'exa.appid = exs.appid')
->innerJoin('exs', 'ex_apps', 'exa', $qb->expr()->eq('exa.appid', 'exs.appid'))
->where(
$qb->expr()->eq('exa.enabled', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT))
)->executeQuery();
Expand Down
2 changes: 2 additions & 0 deletions lib/Db/Translation/TranslationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public function __construct(array $params = []) {
}
if (isset($params['action_detect_lang'])) {
$this->setActionDetectLang($params['action_detect_lang']);
} else {
$this->setActionDetectLang('');
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Db/Translation/TranslationProviderMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function findAllEnabled(): array {
$qb = $this->db->getQueryBuilder();
$result = $qb->select('exs.*')
->from($this->tableName, 'exs')
->innerJoin('exs', 'ex_apps', 'exa', 'exa.appid = exs.appid')
->innerJoin('exs', 'ex_apps', 'exa', $qb->expr()->eq('exa.appid', 'exs.appid'))
->where(
$qb->expr()->eq('exa.enabled', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT))
)
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/UI/FilesActionsMenuMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function findAllEnabled(): array {
$qb = $this->db->getQueryBuilder();
$result = $qb->select('exs.*')
->from($this->tableName, 'exs')
->innerJoin('exs', 'ex_apps', 'exa', 'exa.appid = exs.appid')
->innerJoin('exs', 'ex_apps', 'exa', $qb->expr()->eq('exa.appid', 'exs.appid'))
->where(
$qb->expr()->eq('exa.enabled', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT))
)
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/UI/SettingsFormMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function findAllEnabled(): array {
$qb = $this->db->getQueryBuilder();
$result = $qb->select('exs.*')
->from($this->tableName, 'exs')
->innerJoin('exs', 'ex_apps', 'exa', 'exa.appid = exs.appid')
->innerJoin('exs', 'ex_apps', 'exa', $qb->expr()->eq('exa.appid', 'exs.appid'))
->where(
$qb->expr()->eq('exa.enabled', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT))
)
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/UI/TopMenuMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function findAllEnabled(): array {
$qb = $this->db->getQueryBuilder();
$result = $qb->select('exs.*')
->from($this->tableName, 'exs')
->innerJoin('exs', 'ex_apps', 'exa', 'exa.appid = exs.appid')
->innerJoin('exs', 'ex_apps', 'exa', $qb->expr()->eq('exa.appid', 'exs.appid'))
->where(
$qb->expr()->eq('exa.enabled', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT))
)
Expand Down
4 changes: 1 addition & 3 deletions lib/Fetcher/ExAppArchiveFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ public function downloadInfoXml(array $exAppAppstoreData, string &$extractedDir)

// Validate signature of downloaded archive
$certificate = openssl_get_publickey($exAppAppstoreData['certificate']);
$verified = (bool) openssl_verify(file_get_contents($tempFile), base64_decode($releaseSignature), $certificate, OPENSSL_ALGO_SHA512);

if (!$verified) {
if (openssl_verify(file_get_contents($tempFile), base64_decode($releaseSignature), $certificate, OPENSSL_ALGO_SHA512) !== 1) {
return null;
}

Expand Down
4 changes: 3 additions & 1 deletion lib/Migration/Version2205Date20240411124836.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
// Symfony\Component\Console\Command\Command->setName()
$table->addColumn('name', Types::STRING, [
'notnull' => true,
'length' => 128,
'length' => 64,
]);
// Symfony\Component\Console\Command\Command->setDescription()
$table->addColumn('description', Types::STRING, [
Expand All @@ -46,6 +46,8 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
// Symfony\Component\Console\Command\Command->setHidden()
$table->addColumn('hidden', Types::SMALLINT, [
'notnull' => true,
'default' => 0,
'length' => 1,
]);
// Symfony\Component\Console\Command\Command->addArgument()
$table->addColumn('arguments', Types::JSON, [
Expand Down
4 changes: 2 additions & 2 deletions lib/Service/ExAppOccService.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function registerCommand(
string $appId,
string $name,
string $description,
bool $hidden,
int $hidden,
array $arguments,
array $options,
array $usages,
Expand Down Expand Up @@ -124,7 +124,7 @@ public function __construct(
protected function configure() {
$this->setName($this->occCommand->getName());
$this->setDescription($this->occCommand->getDescription());
$this->setHidden($this->occCommand->getHidden());
$this->setHidden(filter_var($this->occCommand->getHidden(), FILTER_VALIDATE_BOOLEAN));
foreach ($this->occCommand->getArguments() as $argument) {
$this->addArgument(
$argument['name'],
Expand Down

0 comments on commit 3b06bd7

Please sign in to comment.