@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | // TODO: Not the elegant way. Improvement neccessary |
| 125 | 125 | foreach ($polls as $poll) { |
| 126 | 126 | $combinedPoll = (object) array_merge( |
| 127 | - (array) json_decode(json_encode($poll)), (array) json_decode(json_encode($this->acl->setPollId($poll->getId())))); |
|
| 127 | + (array) json_decode(json_encode($poll)), (array) json_decode(json_encode($this->acl->setPollId($poll->getId())))); |
|
| 128 | 128 | if ($combinedPoll->allowView) { |
| 129 | 129 | $pollList[] = $combinedPoll; |
| 130 | 130 | } |
@@ -243,8 +243,8 @@ discard block |
||
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | if (!$this->poll->getDeleted()) { |
| 246 | - $this->logger->alert('user ' . $this->userId . ' trying to permanently delete active poll'); |
|
| 247 | - return new DataResponse(['message' => 'Permanent deletion of active poll.'], Http::STATUS_CONFLICT); |
|
| 246 | + $this->logger->alert('user ' . $this->userId . ' trying to permanently delete active poll'); |
|
| 247 | + return new DataResponse(['message' => 'Permanent deletion of active poll.'], Http::STATUS_CONFLICT); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | $this->pollMapper->delete($this->poll); |
@@ -42,15 +42,15 @@ discard block |
||
| 42 | 42 | /** @var IConfig */ |
| 43 | 43 | protected $config; |
| 44 | 44 | |
| 45 | - /** @var array */ |
|
| 46 | - protected $childTables = [ |
|
| 47 | - 'polls_comments', |
|
| 48 | - 'polls_log', |
|
| 49 | - 'polls_notif', |
|
| 50 | - 'polls_options', |
|
| 51 | - 'polls_share', |
|
| 52 | - 'polls_votes', |
|
| 53 | - ]; |
|
| 45 | + /** @var array */ |
|
| 46 | + protected $childTables = [ |
|
| 47 | + 'polls_comments', |
|
| 48 | + 'polls_log', |
|
| 49 | + 'polls_notif', |
|
| 50 | + 'polls_options', |
|
| 51 | + 'polls_share', |
|
| 52 | + 'polls_votes', |
|
| 53 | + ]; |
|
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * @param IDBConnection $connection |
@@ -62,37 +62,37 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * @param IOutput $output |
|
| 67 | - * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 68 | - * @param array $options |
|
| 69 | - * @return null |
|
| 70 | - * @since 13.0.0 |
|
| 71 | - */ |
|
| 72 | - public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { |
|
| 73 | - // delete all orphaned entries by selecting all rows |
|
| 74 | - // those poll_ids are not present in the polls table |
|
| 75 | - // |
|
| 76 | - // we have to use a raw query, because NOT EXISTS is not |
|
| 77 | - // part of doctrine's expression builder |
|
| 78 | - // |
|
| 79 | - // get table prefix, as we are running a raw query |
|
| 80 | - $prefix = $this->config->getSystemValue('dbtableprefix', 'oc_'); |
|
| 81 | - // check for orphaned entries in all tables referencing |
|
| 82 | - // the main polls table |
|
| 83 | - foreach($this->childTables as $tbl) { |
|
| 84 | - $child = "$prefix$tbl"; |
|
| 85 | - $query = "DELETE |
|
| 65 | + /** |
|
| 66 | + * @param IOutput $output |
|
| 67 | + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 68 | + * @param array $options |
|
| 69 | + * @return null |
|
| 70 | + * @since 13.0.0 |
|
| 71 | + */ |
|
| 72 | + public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { |
|
| 73 | + // delete all orphaned entries by selecting all rows |
|
| 74 | + // those poll_ids are not present in the polls table |
|
| 75 | + // |
|
| 76 | + // we have to use a raw query, because NOT EXISTS is not |
|
| 77 | + // part of doctrine's expression builder |
|
| 78 | + // |
|
| 79 | + // get table prefix, as we are running a raw query |
|
| 80 | + $prefix = $this->config->getSystemValue('dbtableprefix', 'oc_'); |
|
| 81 | + // check for orphaned entries in all tables referencing |
|
| 82 | + // the main polls table |
|
| 83 | + foreach($this->childTables as $tbl) { |
|
| 84 | + $child = "$prefix$tbl"; |
|
| 85 | + $query = "DELETE |
|
| 86 | 86 | FROM $child |
| 87 | 87 | WHERE NOT EXISTS ( |
| 88 | 88 | SELECT NULL |
| 89 | 89 | FROM {$prefix}polls_polls polls |
| 90 | 90 | WHERE polls.id = {$child}.poll_id |
| 91 | 91 | )"; |
| 92 | - $stmt = $this->connection->prepare($query); |
|
| 93 | - $stmt->execute(); |
|
| 94 | - } |
|
| 95 | - } |
|
| 92 | + $stmt = $this->connection->prepare($query); |
|
| 93 | + $stmt->execute(); |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | 98 | * @param IOutput $output |
@@ -102,16 +102,16 @@ discard block |
||
| 102 | 102 | * @since 13.0.0 |
| 103 | 103 | */ |
| 104 | 104 | public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
| 105 | - // add an on delete fk contraint to all tables referencing the main polls table |
|
| 105 | + // add an on delete fk contraint to all tables referencing the main polls table |
|
| 106 | 106 | /** @var ISchemaWrapper $schema */ |
| 107 | 107 | $schema = $schemaClosure(); |
| 108 | 108 | |
| 109 | - $eventTable = $schema->getTable('polls_polls'); |
|
| 110 | - foreach($this->childTables as $tbl) { |
|
| 111 | - $table = $schema->getTable($tbl); |
|
| 109 | + $eventTable = $schema->getTable('polls_polls'); |
|
| 110 | + foreach($this->childTables as $tbl) { |
|
| 111 | + $table = $schema->getTable($tbl); |
|
| 112 | 112 | |
| 113 | - $table->addForeignKeyConstraint($eventTable, ['poll_id'], ['id'], ['onDelete' => 'CASCADE']); |
|
| 114 | - } |
|
| 113 | + $table->addForeignKeyConstraint($eventTable, ['poll_id'], ['id'], ['onDelete' => 'CASCADE']); |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | 116 | return $schema; |
| 117 | 117 | } |