From 1ca31167eae7d975c72d80b4a76ba6ac68936cc5 Mon Sep 17 00:00:00 2001 From: maxtor Date: Sat, 24 Aug 2019 18:33:17 +0300 Subject: [PATCH 01/10] Updated required phalcon version --- .gitignore | 2 ++ composer.json | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index dadd0895e..8afcdb038 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ tests/aerospike.suite.yml tests/unit.suite.5.yml tests/unit.suite.yml tests/unit5x.suite.yml + +.idea/ \ No newline at end of file diff --git a/composer.json b/composer.json index fd6040263..73578a21d 100644 --- a/composer.json +++ b/composer.json @@ -30,8 +30,8 @@ "email": "support@phalconphp.com" }, "require": { - "php": ">=5.5", - "ext-phalcon": "~3.3" + "php": ">=7.2", + "ext-phalcon": "~4" }, "require-dev": { "phpdocumentor/reflection-docblock": "2.0.4", From 397880a1661d591753d8a710d9a0c725c6461f44 Mon Sep 17 00:00:00 2001 From: maxtor Date: Sat, 24 Aug 2019 19:38:55 +0300 Subject: [PATCH 02/10] updated declaration for QueryBuilder methods --- Library/Phalcon/Mvc/Model/EagerLoading/QueryBuilder.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Library/Phalcon/Mvc/Model/EagerLoading/QueryBuilder.php b/Library/Phalcon/Mvc/Model/EagerLoading/QueryBuilder.php index 899040d39..a24556a5b 100644 --- a/Library/Phalcon/Mvc/Model/EagerLoading/QueryBuilder.php +++ b/Library/Phalcon/Mvc/Model/EagerLoading/QueryBuilder.php @@ -1,26 +1,27 @@ _conditions; From 7f6b80721c5cfbae96f26274137380bd09ce5f06 Mon Sep 17 00:00:00 2001 From: maxtor Date: Wed, 28 Aug 2019 16:47:23 +0300 Subject: [PATCH 03/10] fix Mailer Manager parent class --- Library/Phalcon/Mailer/Manager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Phalcon/Mailer/Manager.php b/Library/Phalcon/Mailer/Manager.php index fd8d55c06..68e7a0eb7 100644 --- a/Library/Phalcon/Mailer/Manager.php +++ b/Library/Phalcon/Mailer/Manager.php @@ -20,7 +20,7 @@ namespace Phalcon\Mailer; use Phalcon\Config; -use Phalcon\Mvc\User\Component; +use Phalcon\Plugin; use Phalcon\Mvc\View; /** @@ -37,7 +37,7 @@ * * @package Phalcon\Manager */ -class Manager extends Component +class Manager extends Plugin { /** * @var array From 00e8f816be1f2a037df0eabae4606d5dfdc4446f Mon Sep 17 00:00:00 2001 From: maxtor Date: Wed, 28 Aug 2019 17:01:09 +0300 Subject: [PATCH 04/10] add contentAlternative --- Library/Phalcon/Mailer/Message.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Library/Phalcon/Mailer/Message.php b/Library/Phalcon/Mailer/Message.php index f8a377df3..33c3da057 100644 --- a/Library/Phalcon/Mailer/Message.php +++ b/Library/Phalcon/Mailer/Message.php @@ -340,6 +340,21 @@ public function getContent() return $this->getMessage()->getBody(); } + /** + * Add optionally an alternative body + * + * @param string $content + * @param string $contentType optional + * @param string $charset optional + * + * @return $this + */ + public function contentAlternative($content, $contentType = null, $charset = null) + { + $this->getMessage()->addPart($content, $contentType, $charset); + return $this; + } + /** * Set the Content-type of this message. * From 94852391ee1896b4a8672b58a78b216dd834bedc Mon Sep 17 00:00:00 2001 From: maxtor Date: Wed, 28 Aug 2019 19:00:11 +0300 Subject: [PATCH 05/10] fix for pull request --- .gitignore | 4 +--- composer.json | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 8afcdb038..42ec4541e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,4 @@ codeception.yml tests/aerospike.suite.yml tests/unit.suite.5.yml tests/unit.suite.yml -tests/unit5x.suite.yml - -.idea/ \ No newline at end of file +tests/unit5x.suite.yml \ No newline at end of file diff --git a/composer.json b/composer.json index 73578a21d..b2ab1f63b 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ }, "require": { "php": ">=7.2", - "ext-phalcon": "~4" + "ext-phalcon": "~4.0.0-beta.2" }, "require-dev": { "phpdocumentor/reflection-docblock": "2.0.4", From ea814ea7623bb464f946481a71b96121d52f7282 Mon Sep 17 00:00:00 2001 From: maxtor Date: Tue, 3 Sep 2019 17:05:00 +0300 Subject: [PATCH 06/10] Phalcon\Logger\Adapter\Database for phalcon v4 --- Library/Phalcon/Logger/Adapter/Database.php | 139 ++++++++++---------- 1 file changed, 71 insertions(+), 68 deletions(-) diff --git a/Library/Phalcon/Logger/Adapter/Database.php b/Library/Phalcon/Logger/Adapter/Database.php index 1b946d367..2b1a9e43a 100644 --- a/Library/Phalcon/Logger/Adapter/Database.php +++ b/Library/Phalcon/Logger/Adapter/Database.php @@ -19,28 +19,45 @@ namespace Phalcon\Logger\Adapter; -use Phalcon\Db\Column; use Phalcon\Logger\Exception; +use Phalcon\Logger\Formatter\FormatterInterface; +use Phalcon\Logger\Item; +use Phalcon\Db\Adapter\AdapterInterface as DbAdapterInterface; use Phalcon\Logger\Formatter\Line as LineFormatter; -use Phalcon\Logger\Adapter as LoggerAdapter; -use Phalcon\Logger\AdapterInterface; -use Phalcon\Db\AdapterInterface as DbAdapterInterface; +use Phalcon\Db\Column; /** - * Database Logger + * Phalcon\Logger\Adapter\Database * * Adapter to store logs in a database table - * - * @package Phalcon\Logger\Adapter */ -class Database extends LoggerAdapter implements AdapterInterface +class Database extends AbstractAdapter { + /** + * Database connection + * + * @var DbAdapterInterface + */ + protected $db; + + /** + * Table name + * + * @var string + */ + protected $table = "log"; + /** * Name * @var string */ protected $name = 'phalcon'; + /** + * @var \Phalcon\Logger\Formatter\AbstractFormatter + */ + protected $_formatter; + /** * Adapter options * @var array @@ -48,18 +65,9 @@ class Database extends LoggerAdapter implements AdapterInterface protected $options = []; /** - * @var \Phalcon\Db\AdapterInterface + * Constructor. Accepts the name and some options */ - protected $db; - - /** - * Class constructor. - * - * @param string $name - * @param array $options - * @throws \Phalcon\Logger\Exception - */ - public function __construct($name = 'phalcon', array $options = []) + public function __construct(string $name = 'phalcon', array $options = []) { if (!isset($options['db'])) { throw new Exception("Parameter 'db' is required"); @@ -76,6 +84,7 @@ public function __construct($name = 'phalcon', array $options = []) } $this->db = $options['db']; + $this->table = $options['table']; if ($name) { $this->name = $name; @@ -87,64 +96,22 @@ public function __construct($name = 'phalcon', array $options = []) /** * Sets database connection * - * @param AdapterInterface $db + * @param DbAdapterInterface $db * @return $this */ - public function setDb(AdapterInterface $db) + public function setDb(DbAdapterInterface $db) { $this->db = $db; return $this; } - /** - * {@inheritdoc} - * - * @return \Phalcon\Logger\FormatterInterface - */ - public function getFormatter() - { - if (!is_object($this->_formatter)) { - $this->_formatter = new LineFormatter('%message%'); - } - - return $this->_formatter; - } - - /** - * Writes the log to the file itself - * - * @param string $message - * @param integer $type - * @param integer $time - * @param array $context - * @return bool - */ - public function logInternal($message, $type, $time, $context = []) - { - return $this->db->execute( - 'INSERT INTO ' . $this->options['table'] . ' VALUES (null, ?, ?, ?, ?)', - [ - $this->name, - $type, - $this->getFormatter()->format($message, $type, $time, $context), - $time, - ], - [ - Column::BIND_PARAM_STR, - Column::BIND_PARAM_INT, - Column::BIND_PARAM_STR, - Column::BIND_PARAM_INT, - ] - ); - } - /** * {@inheritdoc} * * @return boolean */ - public function close() + public function close(): bool { if ($this->db->isUnderTransaction()) { $this->db->commit(); @@ -160,7 +127,7 @@ public function close() * * @return $this */ - public function begin() + public function begin(): AdapterInterface { $this->db->begin(); @@ -172,7 +139,7 @@ public function begin() * * @return $this */ - public function commit() + public function commit(): AdapterInterface { $this->db->commit(); @@ -185,10 +152,46 @@ public function commit() * * @return $this */ - public function rollback() + public function rollback(): AdapterInterface { $this->db->rollback(); return $this; } -} + + /** + * {@inheritdoc} + * + * @return FormatterInterface + */ + public function getFormatter(): FormatterInterface + { + if (!is_object($this->_formatter)) { + $this->_formatter = new LineFormatter('%message%'); + } + + return $this->_formatter; + } + + /** + * Processes the message i.e. writes it to the file + */ + public function process(Item $item) + { + return $this->db->execute( + 'INSERT INTO ' . $this->table . ' VALUES (null, ?, ?, ?, ?)', + [ + $this->name, + $item->getType(), + $this->getFormatter()->format($item), + $item->getTime(), + ], + [ + Column::BIND_PARAM_STR, + Column::BIND_PARAM_INT, + Column::BIND_PARAM_STR, + Column::BIND_PARAM_INT, + ] + ); + } +} \ No newline at end of file From 294e9ce8c6fc6be7070907843776b1f2eee7691b Mon Sep 17 00:00:00 2001 From: Maksim Malikov Date: Sun, 5 Jan 2020 17:38:21 +0300 Subject: [PATCH 07/10] update for phalcon 4.0.0-RC.3 --- Library/Phalcon/Mailer/Manager.php | 4 ++-- composer.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Phalcon/Mailer/Manager.php b/Library/Phalcon/Mailer/Manager.php index 68e7a0eb7..8b075d56c 100644 --- a/Library/Phalcon/Mailer/Manager.php +++ b/Library/Phalcon/Mailer/Manager.php @@ -20,7 +20,7 @@ namespace Phalcon\Mailer; use Phalcon\Config; -use Phalcon\Plugin; +use Phalcon\DI\Injectable; use Phalcon\Mvc\View; /** @@ -37,7 +37,7 @@ * * @package Phalcon\Manager */ -class Manager extends Plugin +class Manager extends Injectable { /** * @var array diff --git a/composer.json b/composer.json index b2ab1f63b..7c9933b58 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ }, "require": { "php": ">=7.2", - "ext-phalcon": "~4.0.0-beta.2" + "ext-phalcon": "~4.0.0" }, "require-dev": { "phpdocumentor/reflection-docblock": "2.0.4", From 4c9556a1867e5d47402fb62e02c429843a3d0ae4 Mon Sep 17 00:00:00 2001 From: Maksim Malikov Date: Sun, 5 Jan 2020 18:13:36 +0300 Subject: [PATCH 08/10] update for phalcon 4.0.0-RC.3 add eventsManager in Mailer\Manager --- Library/Phalcon/Mailer/Manager.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Library/Phalcon/Mailer/Manager.php b/Library/Phalcon/Mailer/Manager.php index 8b075d56c..a61d4ace4 100644 --- a/Library/Phalcon/Mailer/Manager.php +++ b/Library/Phalcon/Mailer/Manager.php @@ -21,6 +21,8 @@ use Phalcon\Config; use Phalcon\DI\Injectable; +use Phalcon\Events\EventsAwareInterface; +use Phalcon\Events\ManagerInterface; use Phalcon\Mvc\View; /** @@ -37,7 +39,7 @@ * * @package Phalcon\Manager */ -class Manager extends Injectable +class Manager extends Injectable implements EventsAwareInterface { /** * @var array @@ -64,6 +66,8 @@ class Manager extends Injectable */ protected $viewEngines = null; + protected $eventsManager; + /** * Create a new MailerManager component using $config for configuring * @@ -74,6 +78,16 @@ public function __construct(array $config) $this->configure($config); } + public function getEventsManager(): ?ManagerInterface + { + return $this->eventsManager; + } + + public function setEventsManager(ManagerInterface $eventsManager) + { + $this->eventsManager = $eventsManager; + } + /** * Create a new Message instance. * From dd6a6aa096eecb7415a743a2ac91a3b724d5a617 Mon Sep 17 00:00:00 2001 From: Maksim Malikov Date: Sun, 5 Jan 2020 18:19:36 +0300 Subject: [PATCH 09/10] fix compatibility Mailer\Manager with EventsAwareInterface --- Library/Phalcon/Mailer/Manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Phalcon/Mailer/Manager.php b/Library/Phalcon/Mailer/Manager.php index a61d4ace4..0697efde3 100644 --- a/Library/Phalcon/Mailer/Manager.php +++ b/Library/Phalcon/Mailer/Manager.php @@ -83,7 +83,7 @@ public function getEventsManager(): ?ManagerInterface return $this->eventsManager; } - public function setEventsManager(ManagerInterface $eventsManager) + public function setEventsManager(ManagerInterface $eventsManager): void { $this->eventsManager = $eventsManager; } From 8780083a6ecb73fffa8bcc947aec5b76a826a057 Mon Sep 17 00:00:00 2001 From: Maksim Malikov Date: Wed, 8 Apr 2020 16:56:17 +0300 Subject: [PATCH 10/10] fix Library/Phalcon/Logger/Adapter/Database.php --- Library/Phalcon/Logger/Adapter/Database.php | 4 ++-- composer.json | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Library/Phalcon/Logger/Adapter/Database.php b/Library/Phalcon/Logger/Adapter/Database.php index 2b1a9e43a..2c784849c 100644 --- a/Library/Phalcon/Logger/Adapter/Database.php +++ b/Library/Phalcon/Logger/Adapter/Database.php @@ -176,9 +176,9 @@ public function getFormatter(): FormatterInterface /** * Processes the message i.e. writes it to the file */ - public function process(Item $item) + public function process(Item $item): void { - return $this->db->execute( + $this->db->execute( 'INSERT INTO ' . $this->table . ' VALUES (null, ?, ?, ?, ?)', [ $this->name, diff --git a/composer.json b/composer.json index 7c9933b58..4546cc03b 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,8 @@ "codeception/verify": "^0.3", "vlucas/phpdotenv": "^2.4", "phalcon/dd": "^1.1", - "doctrine/instantiator": "1.0.5" + "doctrine/instantiator": "1.0.5", + "phalcon/ide-stubs": "4.x-dev" }, "suggest": { "ext-aerospike": "*",