okvpn/better-oro-bundle

针对 oro-platform 的性能提升和错误修复

安装: 8

依赖: 0

建议者: 0

安全性: 0

星标: 5

关注者: 2

分支: 1

开放问题: 0

类型:symfony-bundle

3.1.3 2019-03-10 09:43 UTC

This package is auto-updated.

Last update: 2024-09-10 21:31:00 UTC


README

此包提供 OroPlatform 的错误修复和新功能。

目录

可配置功能

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 

作业记录器

作业记录器提供在 UI 中显示日志的能力。用法:将日志注入到您的服务中 okvpn.jobs.logger

示例

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;
    }
}

在活动事务中执行作业

日志持久化发生在执行它的过程之外的单独事务中,因此信息可以通过 UI 立即提供给最终用户。

更改消息优先级

您可以根据需要更改预定义的消息优先级。例如

# 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

默认为 2

消息发送事件

<?php

namespace Okvpn\Bundle\BetterOroBundle\Event;

final class SendEvents
{
    /**
     * Dispatch before send a message to the producer.
     * Used for modify properties, headers, body or decline sending to producer
     */
    const BEFORE_SEND = 'message_queue.before_send';

    /**
     * Dispatch after send message to producer.
     */
    const AFTER_SEND = 'message_queue.after_send';
}

生成包

命令 oro:generate:bundle 帮助您根据 Oro 应用程序的特定情况生成新包

  • 创建文件 Resources/config/oro/bundles.yml
  • 创建迁移存根
  • 不更新内核、主配置和主要路由 app/*

调试实体翻译。

命令 okvpn:entity-translations:dump 用于调试和查找实体的未翻译标签

转储实体的未翻译标签

php app/console okvpn:entity-translations:dump "Okvpn\Bundle\AkumaBundle\Entity\Akuma" --skip-translated
okvpn:
    akuma:
        akuma:
            entity_label: ''
            entity_plural_label: ''
            created_at:
                label: ''
            file_name:
                label: ''
            id:
                label: ''
            time:
                label: ''
            type:
                label: ''

转储给定包的所有实体的未翻译标签

php app/console okvpn:entity-translations:dump "OkvpnAkumaBundle" --skip-translated
okvpn:
    akuma:
       ...

日历日期重复

存在 crontab 命令 oro:cron:calendar:date 用于向日历表添加新天。此表通常用于按天构建报告、创建按天分组的 dql 查询等。但是,此命令工作不正确:每次 crontab 触发时,表中都会出现重复项。此包通过防止在 oro_calendar_date 表中记录重复来修复此问题。

改进 crontab 清理

当用户运行命令 oro:cron:definitions:load 以加载 crontab 定义时,所有 crontab 触发器都将从数据库中删除。此行为已更改,以允许使用 CronBundle 的功能而不使用 crontab 命令,即创建不基于命令的触发器。

禁用容器重置扩展

处理消息后重置容器对性能和内存泄漏有很大影响。此功能已被此包禁用。

数据审计改进

  1. 删除了未使用的索引。索引大小是表大小的 3 倍。同时,许多索引未使用且相互重叠。要删除未使用的索引,您可以使用查询。
<?php

namespace App\Bundle\AppBundle\Migrations\Schema\v1_0;

use Doctrine\DBAL\Schema\Schema;
use Okvpn\Bundle\BetterOroBundle\Migration\OptimiseDataauditIndexQuery;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;

class AppBundleMigration implements Migration
{
    /**
     * @inheritDoc
     */
    public function up(Schema $schema, QueryBag $queries)
    {
        $queries->addPostQuery(new OptimiseDataauditIndexQuery());
    }
}
  1. 要删除旧审计记录,您可以使用垃圾收集 crontab 命令 oro:cron:dataaudit-garbage-collector。要启用此 crontab 命令,需要在您的配置中添加 Resources/oro/app.ymlconfig/config.yml。位置:keep_time 时间(秒)。操作:updatecreateremove
okvpn_better_oro:
    dataaudit:
        dataaudit_gc:
            - { action: update, keep_time: 259200, entity_class: 'Okvpn\Bundle\AppBundle\Entity\Item' }

  1. 如果安全上下文中没有令牌,则设置默认组织。当命令从 CLI 运行并修改实体时,其更改将不会显示在网格中。您可以为此情况设置默认组织。要设置默认组织 ID,需要更新配置 Resources/oro/app.ymlconfig/config.yml
okvpn_better_oro:
    dataaudit:
        default_organization: 1

禁用 orocrm 请求表单

注意到了向 https://r.orocrm.com 发送的出站网络请求。其原因是 PHP 脚本JavaScript 脚本。该脚本向远程服务器发送有关OroPlatform的信息,还加载了一个奇怪的JavaScript脚本。

按时间范围修复排序

按时间范围排序被提交(OroPlatform 2.6.0)破坏: https://github.com/oroinc/platform/commit/5d9e5d1852aa82fb538710bfb0e4dcbc0b9b19b5

Bug 3

UI 中运行Cron

CRON

处理作业异常

您可以在UI中看到执行作业过程中发生的所有关键错误。 Logs

更好的日志格式

Logs