Skip to content

Commit

Permalink
Merge pull request #964 from nextcloud/fix/noid/context-node-rel-retu…
Browse files Browse the repository at this point in the history
…rntypes

fix(Contexts): explicitely state non-int types
  • Loading branch information
juliushaertl committed Apr 4, 2024
2 parents 87d494d + bc96f82 commit 7eaa637
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions lib/Db/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Context extends Entity implements JsonSerializable {

public function __construct() {
$this->addType('id', 'integer');
$this->addType('owner_type', 'integer');
}

public function jsonSerialize(): array {
Expand Down
20 changes: 10 additions & 10 deletions lib/Db/ContextMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ protected function formatResultRows(array $rows, ?string $userId) {
return $carry;
}
$carry[$item['share_id']] = [
'share_id' => $item['share_id'],
'share_id' => (int)$item['share_id'],
'receiver' => $item['receiver'],
'receiver_type' => $item['receiver_type'],
'display_mode_default' => $item['display_mode_default'],
'display_mode_default' => (int)$item['display_mode_default'],
];
if ($userId !== null) {
$carry[$item['share_id']]['display_mode'] = $item['display_mode'];
$carry[$item['share_id']]['display_mode'] = (int)$item['display_mode'];
}
return $carry;
}, []);
Expand All @@ -100,10 +100,10 @@ protected function formatResultRows(array $rows, ?string $userId) {
return $carry;
}
$carry[$item['node_rel_id']] = [
'id' => $item['node_rel_id'],
'node_id' => $item['node_id'],
'node_type' => $item['node_type'],
'permissions' => $item['permissions'],
'id' => (int)$item['node_rel_id'],
'node_id' => (int)$item['node_id'],
'node_type' => (int)$item['node_type'],
'permissions' => (int)$item['permissions'],
];
return $carry;
}, []);
Expand All @@ -116,12 +116,12 @@ protected function formatResultRows(array $rows, ?string $userId) {
if (!isset($carry[$item['page_id']])) {
$carry[$item['page_id']] = ['content' => []];
}
$carry[$item['page_id']]['id'] = $item['page_id'];
$carry[$item['page_id']]['id'] = (int)$item['page_id'];
$carry[$item['page_id']]['page_type'] = $item['page_type'];
if ($item['node_rel_id'] !== null) {
$carry[$item['page_id']]['content'][$item['content_id']] = [
'order' => $item['order'],
'node_rel_id' => $item['node_rel_id']
'order' => (int)$item['order'],
'node_rel_id' => (int)$item['node_rel_id']
];
}

Expand Down
4 changes: 4 additions & 0 deletions lib/Db/ContextNodeRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class ContextNodeRelation extends Entity implements \JsonSerializable {

public function __construct() {
$this->addType('id', 'integer');
$this->addType('context_id', 'integer');
$this->addType('node_id', 'integer');
$this->addType('node_type', 'integer');
$this->addType('permissions', 'integer');
}

public function jsonSerialize(): array {
Expand Down
3 changes: 3 additions & 0 deletions lib/Db/PageContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class PageContent extends Entity implements \JsonSerializable {

public function __construct() {
$this->addType('id', 'integer');
$this->addType('page_id', 'integer');
$this->addType('node_rel_id', 'integer');
$this->addType('order', 'integer');
}

public function jsonSerialize(): array {
Expand Down

0 comments on commit 7eaa637

Please sign in to comment.