@@ -19,8 +19,8 @@ |
||
| 19 | 19 | protected function configure() |
| 20 | 20 | { |
| 21 | 21 | $this->setName('about') |
| 22 | - ->setDescription('Short information about AuditApplication') |
|
| 23 | - ->setHelp('<info>audit about</info>'); |
|
| 22 | + ->setDescription('Short information about AuditApplication') |
|
| 23 | + ->setHelp('<info>audit about</info>'); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | //-------------------------------------------------------------------------------------------------------------------- |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | $this->io->write(<<<EOT |
| 35 | 35 | <info>AuditApplication - Database Auditing</info> |
| 36 | 36 | <comment>Creates audit tables and triggers to track data changes in databases.</comment> |
| 37 | -EOT |
|
| 37 | +eot |
|
| 38 | 38 | ); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -70,8 +70,8 @@ |
||
| 70 | 70 | if ($mandatory) |
| 71 | 71 | { |
| 72 | 72 | throw new RuntimeException("Setting '%s' not found in section '%s' configuration file.", |
| 73 | - $settingName, |
|
| 74 | - $sectionName); |
|
| 73 | + $settingName, |
|
| 74 | + $sectionName); |
|
| 75 | 75 | } |
| 76 | 76 | else |
| 77 | 77 | { |
@@ -28,8 +28,8 @@ |
||
| 28 | 28 | protected function configure() |
| 29 | 29 | { |
| 30 | 30 | $this->setName('config') |
| 31 | - ->setDescription('Create or edit config file') |
|
| 32 | - ->addArgument('config file', InputArgument::OPTIONAL, 'The audit configuration file', 'etc/audit.json'); |
|
| 31 | + ->setDescription('Create or edit config file') |
|
| 32 | + ->addArgument('config file', InputArgument::OPTIONAL, 'The audit configuration file', 'etc/audit.json'); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | //-------------------------------------------------------------------------------------------------------------------- |
@@ -117,7 +117,7 @@ |
||
| 117 | 117 | $auditColumns, |
| 118 | 118 | $skipVariable, |
| 119 | 119 | $additionSql); |
| 120 | - $sql = $helper->buildStatement(); |
|
| 120 | + $sql = $helper->buildStatement(); |
|
| 121 | 121 | |
| 122 | 122 | self::executeNone($sql); |
| 123 | 123 | } |
@@ -163,6 +163,7 @@ discard block |
||
| 163 | 163 | //-------------------------------------------------------------------------------------------------------------------- |
| 164 | 164 | /** |
| 165 | 165 | * {@inheritdoc} |
| 166 | + * @param string $query |
|
| 166 | 167 | */ |
| 167 | 168 | public static function executeNone($query) |
| 168 | 169 | { |
@@ -185,6 +186,7 @@ discard block |
||
| 185 | 186 | //-------------------------------------------------------------------------------------------------------------------- |
| 186 | 187 | /** |
| 187 | 188 | * {@inheritdoc} |
| 189 | + * @param string $query |
|
| 188 | 190 | */ |
| 189 | 191 | public static function executeRow1($query) |
| 190 | 192 | { |
@@ -196,6 +198,7 @@ discard block |
||
| 196 | 198 | //-------------------------------------------------------------------------------------------------------------------- |
| 197 | 199 | /** |
| 198 | 200 | * {@inheritdoc} |
| 201 | + * @param string $query |
|
| 199 | 202 | */ |
| 200 | 203 | public static function executeRows($query) |
| 201 | 204 | { |
@@ -83,14 +83,14 @@ discard block |
||
| 83 | 83 | $additionSql) |
| 84 | 84 | { |
| 85 | 85 | $helper = new CreateAuditTrigger($dataSchemaName, |
| 86 | - $auditSchemaName, |
|
| 87 | - $tableName, |
|
| 88 | - $triggerName, |
|
| 89 | - $triggerAction, |
|
| 90 | - $auditColumns, |
|
| 91 | - $tableColumns, |
|
| 92 | - $skipVariable, |
|
| 93 | - $additionSql); |
|
| 86 | + $auditSchemaName, |
|
| 87 | + $tableName, |
|
| 88 | + $triggerName, |
|
| 89 | + $triggerAction, |
|
| 90 | + $auditColumns, |
|
| 91 | + $tableColumns, |
|
| 92 | + $skipVariable, |
|
| 93 | + $additionSql); |
|
| 94 | 94 | $sql = $helper->buildStatement(); |
| 95 | 95 | |
| 96 | 96 | self::executeNone($sql); |
@@ -258,8 +258,8 @@ discard block |
||
| 258 | 258 | where TABLE_SCHEMA = %s |
| 259 | 259 | and TABLE_NAME = %s |
| 260 | 260 | order by ORDINAL_POSITION', |
| 261 | - parent::quoteString($schemaName), |
|
| 262 | - parent::quoteString($tableName)); |
|
| 261 | + parent::quoteString($schemaName), |
|
| 262 | + parent::quoteString($tableName)); |
|
| 263 | 263 | |
| 264 | 264 | return self::executeRows($sql); |
| 265 | 265 | } |
@@ -283,8 +283,8 @@ discard block |
||
| 283 | 283 | inner join information_schema.COLLATION_CHARACTER_SET_APPLICABILITY t2 on t2.COLLATION_NAME = t1.TABLE_COLLATION |
| 284 | 284 | WHERE t1.TABLE_SCHEMA = %s |
| 285 | 285 | AND t1.TABLE_NAME = %s', |
| 286 | - parent::quoteString($schemaName), |
|
| 287 | - parent::quoteString($tableName)); |
|
| 286 | + parent::quoteString($schemaName), |
|
| 287 | + parent::quoteString($tableName)); |
|
| 288 | 288 | |
| 289 | 289 | return self::executeRow1($sql); |
| 290 | 290 | } |
@@ -306,8 +306,8 @@ discard block |
||
| 306 | 306 | where TRIGGER_SCHEMA = %s |
| 307 | 307 | and EVENT_OBJECT_TABLE = %s |
| 308 | 308 | order by Trigger_Name', |
| 309 | - parent::quoteString($schemaName), |
|
| 310 | - parent::quoteString($tableName)); |
|
| 309 | + parent::quoteString($schemaName), |
|
| 310 | + parent::quoteString($tableName)); |
|
| 311 | 311 | |
| 312 | 312 | return self::executeRows($sql); |
| 313 | 313 | } |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | where TRIGGER_SCHEMA = %s |
| 350 | 350 | order by EVENT_OBJECT_TABLE |
| 351 | 351 | , TRIGGER_NAME', |
| 352 | - parent::quoteString($schemaName)); |
|
| 352 | + parent::quoteString($schemaName)); |
|
| 353 | 353 | |
| 354 | 354 | return self::executeRows($sql); |
| 355 | 355 | } |
@@ -108,8 +108,8 @@ discard block |
||
| 108 | 108 | public function createAuditTable() |
| 109 | 109 | { |
| 110 | 110 | $this->io->logInfo('Creating audit table <dbo>%s.%s<dbo>', |
| 111 | - $this->auditSchemaName, |
|
| 112 | - $this->configTable->getTableName()); |
|
| 111 | + $this->auditSchemaName, |
|
| 112 | + $this->configTable->getTableName()); |
|
| 113 | 113 | |
| 114 | 114 | // In the audit table all columns from the data table must be nullable. |
| 115 | 115 | $dataTableColumnsDatabase = clone($this->dataTableColumnsDatabase); |
@@ -117,9 +117,9 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | $columns = TableColumnsMetadata::combine($this->auditColumns, $dataTableColumnsDatabase); |
| 119 | 119 | AuditDataLayer::createAuditTable($this->configTable->getSchemaName(), |
| 120 | - $this->auditSchemaName, |
|
| 121 | - $this->configTable->getTableName(), |
|
| 122 | - $columns); |
|
| 120 | + $this->auditSchemaName, |
|
| 121 | + $this->configTable->getTableName(), |
|
| 122 | + $columns); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | //-------------------------------------------------------------------------------------------------------------------- |
@@ -242,14 +242,14 @@ discard block |
||
| 242 | 242 | $this->configTable->getTableName()); |
| 243 | 243 | |
| 244 | 244 | AuditDataLayer::createAuditTrigger($this->configTable->getSchemaName(), |
| 245 | - $this->auditSchemaName, |
|
| 246 | - $this->configTable->getTableName(), |
|
| 247 | - $triggerName, |
|
| 248 | - $action, |
|
| 249 | - $this->auditColumns, |
|
| 250 | - $this->dataTableColumnsDatabase, |
|
| 251 | - $skipVariable, |
|
| 252 | - $additionSql); |
|
| 245 | + $this->auditSchemaName, |
|
| 246 | + $this->configTable->getTableName(), |
|
| 247 | + $triggerName, |
|
| 248 | + $action, |
|
| 249 | + $this->auditColumns, |
|
| 250 | + $this->dataTableColumnsDatabase, |
|
| 251 | + $skipVariable, |
|
| 252 | + $additionSql); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | //-------------------------------------------------------------------------------------------------------------------- |
@@ -366,23 +366,23 @@ discard block |
||
| 366 | 366 | foreach ($newColumns->getColumns() as $column) |
| 367 | 367 | { |
| 368 | 368 | $this->io->logInfo('New column <dbo>%s.%s</dbo>', |
| 369 | - $this->configTable->getTableName(), |
|
| 370 | - $column->getProperty('column_name')); |
|
| 369 | + $this->configTable->getTableName(), |
|
| 370 | + $column->getProperty('column_name')); |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | foreach ($obsoleteColumns->getColumns() as $column) |
| 374 | 374 | { |
| 375 | 375 | $this->io->logInfo('Obsolete column <dbo>%s.%s</dbo>', |
| 376 | - $this->configTable->getTableName(), |
|
| 377 | - $column->getProperty('column_name')); |
|
| 376 | + $this->configTable->getTableName(), |
|
| 377 | + $column->getProperty('column_name')); |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | foreach ($alteredColumns->getColumns() as $column) |
| 381 | 381 | { |
| 382 | 382 | $this->io->logInfo('Type of <dbo>%s.%s</dbo> has been altered to <dbo>%s</dbo>', |
| 383 | - $this->configTable->getTableName(), |
|
| 384 | - $column->getProperty('column_name'), |
|
| 385 | - $column->getProperty('column_type')); |
|
| 383 | + $this->configTable->getTableName(), |
|
| 384 | + $column->getProperty('column_name'), |
|
| 385 | + $column->getProperty('column_type')); |
|
| 386 | 386 | } |
| 387 | 387 | } |
| 388 | 388 | |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | { |
| 161 | 161 | $this->io->writeln(sprintf('<info>Found new table %s</info>', $table['table_name'])); |
| 162 | 162 | $this->config['tables'][$table['table_name']] = ['audit' => false, |
| 163 | - 'alias' => null, |
|
| 164 | - 'skip' => null]; |
|
| 163 | + 'alias' => null, |
|
| 164 | + 'skip' => null]; |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | } |
@@ -225,15 +225,15 @@ discard block |
||
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | $configTable = new TableMetadata($table['table_name'], |
| 228 | - $this->config['database']['data_schema'], |
|
| 229 | - $tableColumns); |
|
| 228 | + $this->config['database']['data_schema'], |
|
| 229 | + $tableColumns); |
|
| 230 | 230 | |
| 231 | 231 | $currentTable = new AuditTable($this->io, |
| 232 | - $configTable, |
|
| 233 | - $this->config['database']['audit_schema'], |
|
| 234 | - $this->auditColumnsMetadata, |
|
| 235 | - $this->config['tables'][$table['table_name']]['alias'], |
|
| 236 | - $this->config['tables'][$table['table_name']]['skip']); |
|
| 232 | + $configTable, |
|
| 233 | + $this->config['database']['audit_schema'], |
|
| 234 | + $this->auditColumnsMetadata, |
|
| 235 | + $this->config['tables'][$table['table_name']]['alias'], |
|
| 236 | + $this->config['tables'][$table['table_name']]['skip']); |
|
| 237 | 237 | |
| 238 | 238 | // Ensure an audit table exists. |
| 239 | 239 | if (StaticDataLayer::searchInRowSet('table_name', $table['table_name'], $this->auditSchemaTables)===null) |
@@ -257,15 +257,15 @@ discard block |
||
| 257 | 257 | else |
| 258 | 258 | { |
| 259 | 259 | $configTable = new TableMetadata($table['table_name'], |
| 260 | - $this->config['database']['data_schema'], |
|
| 261 | - []); |
|
| 260 | + $this->config['database']['data_schema'], |
|
| 261 | + []); |
|
| 262 | 262 | |
| 263 | 263 | $currentTable = new AuditTable($this->io, |
| 264 | - $configTable, |
|
| 265 | - $this->config['database']['audit_schema'], |
|
| 266 | - $this->auditColumnsMetadata, |
|
| 267 | - '', |
|
| 268 | - ''); |
|
| 264 | + $configTable, |
|
| 265 | + $this->config['database']['audit_schema'], |
|
| 266 | + $this->auditColumnsMetadata, |
|
| 267 | + '', |
|
| 268 | + ''); |
|
| 269 | 269 | |
| 270 | 270 | $currentTable->dropAuditTriggers($this->config['database']['data_schema'], $table['table_name']); |
| 271 | 271 | } |
@@ -21,10 +21,10 @@ discard block |
||
| 21 | 21 | protected function configure() |
| 22 | 22 | { |
| 23 | 23 | $this->setName('drop-triggers') |
| 24 | - ->setDescription('Drops all triggers') |
|
| 25 | - ->setHelp('Drops all triggers (including triggers not created by audit) from all tables (including tables '. |
|
| 26 | - 'excluded for auditing) in the data schema.') |
|
| 27 | - ->addArgument('config file', InputArgument::REQUIRED, 'The audit configuration file'); |
|
| 24 | + ->setDescription('Drops all triggers') |
|
| 25 | + ->setHelp('Drops all triggers (including triggers not created by audit) from all tables (including tables '. |
|
| 26 | + 'excluded for auditing) in the data schema.') |
|
| 27 | + ->addArgument('config file', InputArgument::REQUIRED, 'The audit configuration file'); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | //-------------------------------------------------------------------------------------------------------------------- |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | foreach ($triggers as $trigger) |
| 61 | 61 | { |
| 62 | 62 | $this->io->logInfo('Dropping trigger <dbo>%s</dbo> from table <dbo>%s</dbo>', |
| 63 | - $trigger['trigger_name'], |
|
| 64 | - $trigger['table_name']); |
|
| 63 | + $trigger['trigger_name'], |
|
| 64 | + $trigger['table_name']); |
|
| 65 | 65 | |
| 66 | 66 | AuditDataLayer::dropTrigger($data_schema, $trigger['trigger_name']); |
| 67 | 67 | } |
@@ -197,8 +197,7 @@ |
||
| 197 | 197 | && $audit_character_set_name==$config_character_set_name |
| 198 | 198 | && $audit_collation_name==$config_collation_name |
| 199 | 199 | && $audit_collation_name==$data_collation_name |
| 200 | - ) |
|
| 201 | - { |
|
| 200 | + ) { |
|
| 202 | 201 | return true; |
| 203 | 202 | } |
| 204 | 203 | } |
@@ -31,9 +31,9 @@ |
||
| 31 | 31 | protected function configure() |
| 32 | 32 | { |
| 33 | 33 | $this->setName('alter-audit-table') |
| 34 | - ->setDescription('Creates alter SQL statements for audit tables') |
|
| 35 | - ->addArgument('config file', InputArgument::REQUIRED, 'The audit configuration file') |
|
| 36 | - ->addArgument('sql file', InputArgument::REQUIRED, 'The destination file for the SQL statements'); |
|
| 34 | + ->setDescription('Creates alter SQL statements for audit tables') |
|
| 35 | + ->addArgument('config file', InputArgument::REQUIRED, 'The audit configuration file') |
|
| 36 | + ->addArgument('sql file', InputArgument::REQUIRED, 'The destination file for the SQL statements'); |
|
| 37 | 37 | |
| 38 | 38 | $this->setHelp(<<<EOL |
| 39 | 39 | Generates alter table SQL statements for aligning the audit tables with the |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | No SQL statements will be generated for missing or obsolete columns in the |
| 50 | 50 | audit tables. Use the command 'audit' for creating missing columns in audit |
| 51 | 51 | tables. |
| 52 | -EOL |
|
| 52 | +eol |
|
| 53 | 53 | ); |
| 54 | 54 | } |
| 55 | 55 | |