From 6fe5c781794042be79de944a709d9068fd6b2e6e Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Thu, 6 Jul 2017 19:51:15 +0700 Subject: [PATCH] Added config option 'php-censor.build.writer_buffer_size' for configuring BuildErrorWriter buffer_size property (Count of inserts in the one SQL query). --- docs/en/configuring.md | 3 ++- src/PHPCensor/Command/InstallCommand.php | 3 ++- src/PHPCensor/Store/BuildErrorWriter.php | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/en/configuring.md b/docs/en/configuring.md index 1dbc5767..2624867e 100644 --- a/docs/en/configuring.md +++ b/docs/en/configuring.md @@ -42,7 +42,8 @@ php-censor: commit: false # This option allow/deny to post comments to Github commit pull_request: false # This option allow/deny to post comments to Github Pull Request build: - remove_builds: true # This option allow/deny build cleaning + remove_builds: true # This option allow/deny build cleaning + writer_buffer_size: 500 # BuildErrorWriter buffer size (count of inserts in one SQL query) security: disable_auth: false # This option allows/deny you to disable authentication for PHP Censor default_user_id: 1 # Default user when authentication disabled diff --git a/src/PHPCensor/Command/InstallCommand.php b/src/PHPCensor/Command/InstallCommand.php index cfa1f509..8e8aa0d4 100644 --- a/src/PHPCensor/Command/InstallCommand.php +++ b/src/PHPCensor/Command/InstallCommand.php @@ -269,7 +269,8 @@ class InstallCommand extends Command ], ], 'build' => [ - 'remove_builds' => true, + 'remove_builds' => true, + 'writer_buffer_size' => 500, ], 'security' => [ 'disable_auth' => false, diff --git a/src/PHPCensor/Store/BuildErrorWriter.php b/src/PHPCensor/Store/BuildErrorWriter.php index faadbc8e..e0dc89de 100644 --- a/src/PHPCensor/Store/BuildErrorWriter.php +++ b/src/PHPCensor/Store/BuildErrorWriter.php @@ -2,6 +2,7 @@ namespace PHPCensor\Store; +use b8\Config; use b8\Database; /** @@ -19,7 +20,7 @@ class BuildErrorWriter * @var int * @see https://stackoverflow.com/questions/40361164/pdoexception-sqlstatehy000-general-error-7-number-of-parameters-must-be-bet */ - protected $buffer_size = 5000; + protected $buffer_size; /** * BuildErrorWriter constructor. @@ -28,7 +29,8 @@ class BuildErrorWriter */ public function __construct($build_id) { - $this->build_id = $build_id; + $this->buffer_size = (integer)Config::getInstance()->get('php-censor.build.writer_buffer_size', 500); + $this->build_id = $build_id; } /**