| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace UserAccessManager\Setup\Update; |
| 6 |
|
| 7 |
use Exception; |
| 8 |
use UserAccessManager\Setup\Database\DatabaseUpdate; |
| 9 |
|
| 10 |
class DatabaseUpdate5 extends DatabaseUpdate |
| 11 |
{ |
| 12 |
public function getVersion(): string |
| 13 |
{ |
| 14 |
return '1.5.1'; |
| 15 |
} |
| 16 |
|
| 17 |
/** |
| 18 |
* @throws Exception |
| 19 |
*/ |
| 20 |
public function update(): bool |
| 21 |
{ |
| 22 |
$dbAccessGroupToObject = $this->database->getUserGroupToObjectTable(); |
| 23 |
$query = "SELECT object_id AS objectId, object_type AS objectType, group_id AS groupId |
| 24 |
FROM {$dbAccessGroupToObject} |
| 25 |
WHERE general_object_type = ''"; |
| 26 |
|
| 27 |
$dbObjects = (array) $this->database->getResults($query); |
| 28 |
$success = true; |
| 29 |
|
| 30 |
foreach ($dbObjects as $dbObject) { |
| 31 |
$update = $this->database->update( |
| 32 |
$dbAccessGroupToObject, |
| 33 |
['general_object_type' => $this->objectHandler->getGeneralObjectType($dbObject->objectType)], |
| 34 |
[ |
| 35 |
'object_id' => $dbObject->objectId, |
| 36 |
'group_id' => $dbObject->groupId, |
| 37 |
'object_type' => $dbObject->objectType |
| 38 |
] |
| 39 |
); |
| 40 |
$success = $success && ($update !== false); |
| 41 |
} |
| 42 |
|
| 43 |
return $success; |
| 44 |
} |
| 45 |
} |
| 46 |
|