ADded transactions for multiple get handlers

This commit is contained in:
Lukas Metzger 2018-04-02 13:24:24 +02:00
parent 25382d0de3
commit dcc0989d6d
4 changed files with 16 additions and 0 deletions

View file

@ -37,6 +37,8 @@ class Credentials
*/ */
public function getCredentials(\Utils\PagingInfo &$pi, int $recordId) : array public function getCredentials(\Utils\PagingInfo &$pi, int $recordId) : array
{ {
$this->db->beginTransaction();
//Count elements //Count elements
if ($pi->pageSize === null) { if ($pi->pageSize === null) {
$pi->totalPages = 1; $pi->totalPages = 1;
@ -62,6 +64,8 @@ class Credentials
$data = $query->fetchAll(); $data = $query->fetchAll();
$this->db->commit();
return array_map(function ($item) { return array_map(function ($item) {
$item['id'] = intval($item['id']); $item['id'] = intval($item['id']);
return $item; return $item;

View file

@ -38,6 +38,8 @@ class Domains
*/ */
public function getDomains(\Utils\PagingInfo &$pi, int $userId, ? string $query, ? string $sorting, ? string $type) : array public function getDomains(\Utils\PagingInfo &$pi, int $userId, ? string $query, ? string $sorting, ? string $type) : array
{ {
$this->db->beginTransaction();
$ac = new \Operations\AccessControl($this->c); $ac = new \Operations\AccessControl($this->c);
$userIsAdmin = $ac->isAdmin($userId); $userIsAdmin = $ac->isAdmin($userId);
@ -99,6 +101,8 @@ class Domains
$data = $query->fetchAll(); $data = $query->fetchAll();
$this->db->commit();
return array_map(function ($item) { return array_map(function ($item) {
if ($item['type'] != 'SLAVE') { if ($item['type'] != 'SLAVE') {
unset($item['master']); unset($item['master']);

View file

@ -35,6 +35,8 @@ class Permissions
*/ */
public function getPermissions(\Utils\PagingInfo &$pi, int $userId) : array public function getPermissions(\Utils\PagingInfo &$pi, int $userId) : array
{ {
$this->db->beginTransaction();
//Count elements //Count elements
if ($pi->pageSize === null) { if ($pi->pageSize === null) {
$pi->totalPages = 1; $pi->totalPages = 1;
@ -63,6 +65,8 @@ class Permissions
$data = $query->fetchAll(); $data = $query->fetchAll();
$this->db->commit();
return $data; return $data;
} }

View file

@ -49,6 +49,8 @@ class Records
? string $queryContent, ? string $queryContent,
? string $sort ? string $sort
) : array { ) : array {
$this->db->beginTransaction();
$ac = new \Operations\AccessControl($this->c); $ac = new \Operations\AccessControl($this->c);
$userIsAdmin = $ac->isAdmin($userId); $userIsAdmin = $ac->isAdmin($userId);
@ -119,6 +121,8 @@ class Records
$data = $query->fetchAll(); $data = $query->fetchAll();
$this->db->commit();
return array_map(function ($item) { return array_map(function ($item) {
$item['id'] = intval($item['id']); $item['id'] = intval($item['id']);
$item['priority'] = intval($item['priority']); $item['priority'] = intval($item['priority']);