https://github.com/vtsykun/better-oro-bundle
Performance improve & bugfix for oro-platform
https://github.com/vtsykun/better-oro-bundle
Last synced: 12 days ago
JSON representation
Performance improve & bugfix for oro-platform
- Host: GitHub
- URL: https://github.com/vtsykun/better-oro-bundle
- Owner: vtsykun
- Created: 2017-12-24T22:14:49.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-10T09:45:57.000Z (about 6 years ago)
- Last Synced: 2025-03-25T17:49:25.137Z (29 days ago)
- Language: PHP
- Size: 523 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Audit: Audit/AuditTokenStorage.php
Awesome Lists containing this project
README
# BetterOroBundle
This bundle provide bugfixes and new features for OroPlatform.
Table of Contents
-----------------
- [Job logger](#job-logger)
- [Change message priorities](#change-message-priorities)
- [Message send events](#message-send-events)
- [Dump not translated entities](#debug-entity-translations)
- [Command for generate Oro bundle](#generate-bundle)
- [Handle jobs exception](#handle-jobs-exception)
- [Improve cron cleanup](#improve-cron-cleanup)
- [Better log format](#better-log-format)
- [Disable container reset extension](#disable-container-reset-extension)
- [Calendar date duplicate](#calendar-date-duplicate)
- [Disable outgoing network requests by OroCRM Request Form](#disable-orocrm-request-form)
- [Fix order by timePeriod in DateGroupingFilter](#fix-order-by-the-time-period)
- [Manual cron run](#cron-run-in-ui)
- [Show datagrid exception if debug = true](./Datagrid/DataGridExtension.php#L27)
- [Dataaudit improvement](#dataaudit-improvement)## Configurable capabilities
```yml
okvpn_better_oro:
capabilities:
mq_disable_container_reset: true #Disable container reset extension for performance
mq_send_events: true #Dispatch sending events & overwrite message priority of queue processing
mq_log_format: true #User frendly format of MQ logs in console (in tty console)
cron_fix_cleanup: true #Fix cron definition load command
job_logs: true #Display job output and errors in UI
fix_calendar: true #Fix calendar days generator in ReportBunle
```### Job logger
The job logger provides the ability to display logs in the UI. Usage: inject logger `okvpn.jobs.logger` into your serviceExample:
```php
class SomeProcessor implements MessageProcessorInterface
{/** @var LoggerInterface */
private $logger;/** @var JobRunner */
private $jobRunner;public function __construct(LoggerInterface $logger, JobRunner $jobRunner)
{
$this->logger = $logger;
$this->jobRunner = $jobRunner;
}
/**
* {@inheritdoc}
*/
public function process(MessageInterface $message, SessionInterface $session)
{
$body = JSON::decode($message->getBody());$result = $this->jobRunner->runDelayed(
$body['jobId'],
function () use ($body) {
try {
$this->logger->info('This logs will display in UI on the given root jobs page.')
} catch (\Throwable $e) {
$this->logger->critical(
'An error occupies during job execute'
['e' => $e,] // the full stack trace & exception message will display on the job page.
);return false;
}
}
);
$this->logger->info('This log will not display, because there isn\'t active job');
return $result ? self::ACK : self::REJECT;
}
}```
#### Execute jobs in active transaction
The log persistence happen in a separate transaction from the process that executes it, so information available to end user
thru UI immediately when its created.### Change message priorities
You can change the predefined message priority. Example:
```yml
# Resources/config/oro/app.yml
okvpn_better_oro:
default_priorities:
oro.importexport.cli_import: 3 # topic_name OR cron_command OR process_definition (from worklfow bundle)
oro.importexport.pre_cli_import: 3
oro.importexport.pre_http_import: 3
oro.importexport.http_import: 3
oro.importexport.pre_export: 3
oro.importexport.export: 3
oro.importexport.post_export: 3
oro.importexport.send_import_notification: 1
```| Priority | Map |
|-----|:------:|
| 0 | VERY LOW |
| 1 | LOW |
| 2 | MEDIUM |
| 3 | HIGH |
| 4 | VERY HIGH |**By default 2**
### Message send events
```php
addPostQuery(new OptimiseDataauditIndexQuery());
}
}
```2) To remove old audit record you can use garbage collection cron command `oro:cron:dataaudit-garbage-collector`
To enable the cron command needs add to your configuration `Resources/oro/app.yml` or `config/config.yml`
Where: `keep_time` time in sec. action: `update`, `create`, `remove`.```
okvpn_better_oro:
dataaudit:
dataaudit_gc:
- { action: update, keep_time: 259200, entity_class: 'Okvpn\Bundle\AppBundle\Entity\Item' }```
3) Set default organization if not token in security context. When command runs from CLI and modify entity,
its changes will not display in grid. You can set default organization for this case.
To set default organization ID needs update configuration `Resources/oro/app.yml` or `config/config.yml````
okvpn_better_oro:
dataaudit:
default_organization: 1
```### Disable orocrm request form
Outgoing network requests to https://r.orocrm.com were noticed. Their reason - [php script](https://github.com/oroinc/platform/blob/2.6/src/Oro/Bundle/PlatformBundle/Form/UrlGenerator.php#L11) and
[js script](https://github.com/oroinc/platform/blob/2.6/src/Oro/Bundle/PlatformBundle/Resources/views/have_request.html.twig)
The give script sends information about OroPlatform to remote server, also load a strange js script.### Fix order by the time period
Order by the time period was broken by commit (OroPlatform 2.6.0): https://github.com/oroinc/platform/commit/5d9e5d1852aa82fb538710bfb0e4dcbc0b9b19b5
[](./Resources/docs/bug3.png)
### Cron run in UI
[](./Resources/docs/cron.png)
### Handle jobs exception
You can see all critical errors that occurred during execute job in UI.
[](./Resources/docs/jobs.png)### Better log format
[](./Resources/docs/logs.png)